@measured/puck 0.18.2-canary.daff71e → 0.18.2-canary.fc7fda2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +268 -279
- package/dist/index.d.mts +45 -3
- package/dist/index.d.ts +45 -3
- package/dist/index.js +1304 -1416
- package/dist/index.mjs +1502 -1616
- package/dist/{resolve-all-data-DtHY0CRO.d.mts → resolve-all-data-DzJEE28m.d.mts} +3 -3
- package/dist/{resolve-all-data-DtHY0CRO.d.ts → resolve-all-data-DzJEE28m.d.ts} +3 -3
- package/dist/rsc.d.mts +4 -4
- package/dist/rsc.d.ts +4 -4
- package/dist/rsc.js +5 -3
- package/dist/rsc.mjs +5 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -169,12 +169,14 @@ __export(core_exports, {
|
|
169
169
|
Button: () => Button,
|
170
170
|
Drawer: () => Drawer,
|
171
171
|
DropZone: () => DropZone,
|
172
|
+
DropZoneProvider: () => DropZoneProvider,
|
172
173
|
FieldLabel: () => FieldLabel,
|
173
174
|
Group: () => Group,
|
174
175
|
IconButton: () => IconButton,
|
175
176
|
Label: () => Label,
|
176
177
|
Puck: () => Puck,
|
177
178
|
Render: () => Render,
|
179
|
+
dropZoneContext: () => dropZoneContext,
|
178
180
|
migrate: () => migrate,
|
179
181
|
overrideKeys: () => overrideKeys,
|
180
182
|
resolveAllData: () => resolveAllData,
|
@@ -260,7 +262,7 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
260
262
|
|
261
263
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
262
264
|
init_react_import();
|
263
|
-
var styles_module_default = { "ActionBar": "
|
265
|
+
var styles_module_default = { "ActionBar": "_ActionBar_194sn_1", "ActionBar-label": "_ActionBar-label_194sn_18", "ActionBar-action": "_ActionBar-action_194sn_30", "ActionBar-group": "_ActionBar-group_194sn_38" };
|
264
266
|
|
265
267
|
// components/ActionBar/index.tsx
|
266
268
|
var import_jsx_runtime = require("react/jsx-runtime");
|
@@ -306,10 +308,10 @@ init_react_import();
|
|
306
308
|
|
307
309
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
308
310
|
init_react_import();
|
309
|
-
var styles_module_default2 = { "InputWrapper": "
|
311
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
|
310
312
|
|
311
313
|
// components/AutoField/index.tsx
|
312
|
-
var
|
314
|
+
var import_react20 = require("react");
|
313
315
|
|
314
316
|
// components/AutoField/fields/index.tsx
|
315
317
|
init_react_import();
|
@@ -319,7 +321,7 @@ init_react_import();
|
|
319
321
|
|
320
322
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/fields/ArrayField/styles.module.css#css-module
|
321
323
|
init_react_import();
|
322
|
-
var styles_module_default3 = { "ArrayField": "
|
324
|
+
var styles_module_default3 = { "ArrayField": "_ArrayField_1jcbq_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_1jcbq_13", "ArrayField-addButton": "_ArrayField-addButton_1jcbq_18", "ArrayField--hasItems": "_ArrayField--hasItems_1jcbq_33", "ArrayFieldItem": "_ArrayFieldItem_1jcbq_63", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_1jcbq_71", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_1jcbq_81", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_1jcbq_97", "ArrayField--addDisabled": "_ArrayField--addDisabled_1jcbq_128", "ArrayFieldItem-body": "_ArrayFieldItem-body_1jcbq_164", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_1jcbq_173", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_1jcbq_181", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_1jcbq_187" };
|
323
325
|
|
324
326
|
// ../../node_modules/lucide-react/dist/esm/lucide-react.js
|
325
327
|
init_react_import();
|
@@ -769,7 +771,7 @@ var IconButton = ({
|
|
769
771
|
};
|
770
772
|
|
771
773
|
// components/AutoField/fields/ArrayField/index.tsx
|
772
|
-
var
|
774
|
+
var import_react12 = require("react");
|
773
775
|
|
774
776
|
// components/DragIcon/index.tsx
|
775
777
|
init_react_import();
|
@@ -1277,8 +1279,8 @@ function useAppContext() {
|
|
1277
1279
|
|
1278
1280
|
// components/Sortable/index.tsx
|
1279
1281
|
init_react_import();
|
1280
|
-
var
|
1281
|
-
var
|
1282
|
+
var import_react9 = require("@dnd-kit/react");
|
1283
|
+
var import_react10 = require("react");
|
1282
1284
|
|
1283
1285
|
// lib/dnd/dnd-kit/safe.ts
|
1284
1286
|
init_react_import();
|
@@ -1306,826 +1308,172 @@ function useSortableSafe(input) {
|
|
1306
1308
|
return (0, import_sortable.useSortable)(input);
|
1307
1309
|
}
|
1308
1310
|
|
1309
|
-
//
|
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
|
1311
|
+
// components/Sortable/index.tsx
|
1312
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
1313
|
+
var SortableProvider = ({
|
1314
|
+
children,
|
1315
|
+
onMove
|
1316
|
+
}) => {
|
1317
|
+
const [move, setMove] = (0, import_react10.useState)({ source: -1, target: -1 });
|
1318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
1319
|
+
import_react9.DragDropProvider,
|
1320
|
+
{
|
1321
|
+
onDragOver: (event) => {
|
1322
|
+
const { operation } = event;
|
1323
|
+
if (operation.source && operation.target) {
|
1324
|
+
const newMove = {
|
1325
|
+
source: operation.source.data.index,
|
1326
|
+
target: operation.target.data.index
|
1327
|
+
};
|
1328
|
+
if (newMove.source !== newMove.target) {
|
1329
|
+
setMove({
|
1330
|
+
source: operation.source.data.index,
|
1331
|
+
target: operation.target.data.index
|
1332
|
+
});
|
1381
1333
|
}
|
1382
|
-
},
|
1383
|
-
{
|
1384
|
-
// Cancel activation if there is a competing Drag and Drop interaction
|
1385
|
-
type: "dragstart",
|
1386
|
-
listener: this.handleDragStart
|
1387
1334
|
}
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
|
1396
|
-
return;
|
1335
|
+
},
|
1336
|
+
onDragEnd: () => {
|
1337
|
+
if (move.source !== -1 && move.target !== -1) {
|
1338
|
+
onMove(move);
|
1339
|
+
}
|
1340
|
+
},
|
1341
|
+
children
|
1397
1342
|
}
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1343
|
+
);
|
1344
|
+
};
|
1345
|
+
var Sortable = ({
|
1346
|
+
id,
|
1347
|
+
index,
|
1348
|
+
disabled,
|
1349
|
+
children,
|
1350
|
+
type = "item"
|
1351
|
+
}) => {
|
1352
|
+
const { ref: sortableRef, status } = useSortableSafe({
|
1353
|
+
id,
|
1354
|
+
type,
|
1355
|
+
index,
|
1356
|
+
disabled,
|
1357
|
+
data: { index }
|
1358
|
+
});
|
1359
|
+
return children({ status, ref: sortableRef });
|
1360
|
+
};
|
1361
|
+
|
1362
|
+
// components/AutoField/context.tsx
|
1363
|
+
init_react_import();
|
1364
|
+
var import_react11 = require("react");
|
1365
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
1366
|
+
var NestedFieldContext = (0, import_react11.createContext)({});
|
1367
|
+
var useNestedFieldContext = () => {
|
1368
|
+
const context = (0, import_react11.useContext)(NestedFieldContext);
|
1369
|
+
return __spreadProps(__spreadValues({}, context), {
|
1370
|
+
readOnlyFields: context.readOnlyFields || {}
|
1371
|
+
});
|
1372
|
+
};
|
1373
|
+
var NestedFieldProvider = ({
|
1374
|
+
children,
|
1375
|
+
name,
|
1376
|
+
subName,
|
1377
|
+
wildcardName = name,
|
1378
|
+
readOnlyFields
|
1379
|
+
}) => {
|
1380
|
+
const subPath = `${name}.${subName}`;
|
1381
|
+
const wildcardSubPath = `${wildcardName}.${subName}`;
|
1382
|
+
const subReadOnlyFields = (0, import_react11.useMemo)(
|
1383
|
+
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
1384
|
+
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
1385
|
+
if (isLocal) {
|
1386
|
+
const subPathPattern = new RegExp(
|
1387
|
+
`^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
|
1415
1388
|
);
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1389
|
+
const localName = readOnlyKey.replace(subPathPattern, "");
|
1390
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1391
|
+
[localName]: readOnlyFields[readOnlyKey]
|
1419
1392
|
});
|
1420
1393
|
}
|
1394
|
+
return acc;
|
1395
|
+
}, {}),
|
1396
|
+
[name, subName, wildcardName, readOnlyFields]
|
1397
|
+
);
|
1398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
1399
|
+
NestedFieldContext.Provider,
|
1400
|
+
{
|
1401
|
+
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
1402
|
+
children
|
1421
1403
|
}
|
1422
|
-
|
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));
|
1404
|
+
);
|
1405
|
+
};
|
1406
|
+
|
1407
|
+
// components/AutoField/fields/ArrayField/index.tsx
|
1408
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
1409
|
+
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
1410
|
+
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
1411
|
+
var ArrayField = ({
|
1412
|
+
field,
|
1413
|
+
onChange,
|
1414
|
+
value: _value,
|
1415
|
+
name,
|
1416
|
+
label,
|
1417
|
+
readOnly,
|
1418
|
+
id,
|
1419
|
+
Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadValues({}, props))
|
1420
|
+
}) => {
|
1421
|
+
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
1422
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
1423
|
+
const value = _value;
|
1424
|
+
const arrayState = state.ui.arrayState[id] || {
|
1425
|
+
items: Array.from(value || []).map((item, idx) => {
|
1426
|
+
return {
|
1427
|
+
_originalIndex: idx,
|
1428
|
+
_arrayId: `${id}-${idx}`
|
1429
|
+
};
|
1430
|
+
}),
|
1431
|
+
openId: ""
|
1432
|
+
};
|
1433
|
+
const [localState, setLocalState] = (0, import_react12.useState)({ arrayState, value });
|
1434
|
+
(0, import_react12.useEffect)(() => {
|
1435
|
+
setLocalState({ arrayState, value });
|
1436
|
+
}, [value, state.ui.arrayState[id]]);
|
1437
|
+
const mapArrayStateToUi = (0, import_react12.useCallback)(
|
1438
|
+
(partialArrayState) => {
|
1439
|
+
return {
|
1440
|
+
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
1441
|
+
[id]: __spreadValues(__spreadValues({}, arrayState), partialArrayState)
|
1442
|
+
})
|
1443
|
+
};
|
1444
|
+
},
|
1445
|
+
[arrayState]
|
1446
|
+
);
|
1447
|
+
const getHighestIndex = (0, import_react12.useCallback)(() => {
|
1448
|
+
return arrayState.items.reduce(
|
1449
|
+
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
1450
|
+
-1
|
1451
|
+
);
|
1452
|
+
}, [arrayState]);
|
1453
|
+
const regenerateArrayState = (0, import_react12.useCallback)(
|
1454
|
+
(value2) => {
|
1455
|
+
let highestIndex = getHighestIndex();
|
1456
|
+
const newItems = Array.from(value2 || []).map((item, idx) => {
|
1457
|
+
var _a;
|
1458
|
+
const arrayStateItem = arrayState.items[idx];
|
1459
|
+
const newItem = {
|
1460
|
+
_originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : highestIndex + 1,
|
1461
|
+
_arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex + 1}`
|
1462
|
+
};
|
1463
|
+
if (newItem._originalIndex > highestIndex) {
|
1464
|
+
highestIndex = newItem._originalIndex;
|
1465
|
+
}
|
1466
|
+
return newItem;
|
1467
|
+
});
|
1468
|
+
return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
|
1469
|
+
},
|
1470
|
+
[arrayState]
|
1471
|
+
);
|
1472
|
+
(0, import_react12.useEffect)(() => {
|
1473
|
+
if (arrayState.items.length > 0) {
|
1474
|
+
setUi(mapArrayStateToUi(arrayState));
|
2126
1475
|
}
|
2127
1476
|
}, []);
|
2128
|
-
const [isDragging, setIsDragging] = (0, import_react13.useState)(false);
|
2129
1477
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
2130
1478
|
if (field.type !== "array" || !field.arrayFields) {
|
2131
1479
|
return null;
|
@@ -2141,8 +1489,6 @@ var ArrayField = ({
|
|
2141
1489
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2142
1490
|
SortableProvider,
|
2143
1491
|
{
|
2144
|
-
onDragStart: () => setIsDragging(true),
|
2145
|
-
onDragEnd: () => setIsDragging(false),
|
2146
1492
|
onMove: (move) => {
|
2147
1493
|
const newValue = reorder(value, move.source, move.target);
|
2148
1494
|
const newArrayStateItems = reorder(
|
@@ -2173,7 +1519,7 @@ var ArrayField = ({
|
|
2173
1519
|
e.preventDefault();
|
2174
1520
|
},
|
2175
1521
|
children: [
|
2176
|
-
|
1522
|
+
localState.arrayState.items.map((item, i) => {
|
2177
1523
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2178
1524
|
const data = Array.from(localState.value || [])[i] || {};
|
2179
1525
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
@@ -2196,7 +1542,6 @@ var ArrayField = ({
|
|
2196
1542
|
"div",
|
2197
1543
|
{
|
2198
1544
|
onClick: (e) => {
|
2199
|
-
if (isDragging) return;
|
2200
1545
|
e.preventDefault();
|
2201
1546
|
e.stopPropagation();
|
2202
1547
|
if (arrayState.openId === _arrayId) {
|
@@ -2226,11 +1571,7 @@ var ArrayField = ({
|
|
2226
1571
|
onClick: (e) => {
|
2227
1572
|
e.stopPropagation();
|
2228
1573
|
const existingValue = [...value || []];
|
2229
|
-
existingValue.splice(
|
2230
|
-
i,
|
2231
|
-
0,
|
2232
|
-
existingValue[i]
|
2233
|
-
);
|
1574
|
+
existingValue.splice(i, 0, existingValue[i]);
|
2234
1575
|
onChange(
|
2235
1576
|
existingValue,
|
2236
1577
|
mapArrayStateToUi(
|
@@ -2272,72 +1613,62 @@ var ArrayField = ({
|
|
2272
1613
|
]
|
2273
1614
|
}
|
2274
1615
|
),
|
2275
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2276
|
-
|
2277
|
-
{
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
1616
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
1617
|
+
const subField = field.arrayFields[subName];
|
1618
|
+
const indexName = `${name}[${i}]`;
|
1619
|
+
const subPath = `${indexName}.${subName}`;
|
1620
|
+
const localIndexName = `${localName}[${i}]`;
|
1621
|
+
const localWildcardName = `${localName}[*]`;
|
1622
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
1623
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
1624
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
1625
|
+
const label2 = subField.label || subName;
|
1626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1627
|
+
NestedFieldProvider,
|
1628
|
+
{
|
1629
|
+
name: localIndexName,
|
1630
|
+
wildcardName: localWildcardName,
|
1631
|
+
subName,
|
1632
|
+
readOnlyFields,
|
1633
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1634
|
+
AutoFieldPrivate,
|
2294
1635
|
{
|
2295
|
-
name:
|
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
|
-
) })
|
1636
|
+
name: subPath,
|
1637
|
+
label: label2,
|
1638
|
+
id: `${_arrayId}_${subName}`,
|
1639
|
+
readOnly: subReadOnly,
|
1640
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
1641
|
+
label: label2
|
1642
|
+
// May be used by custom fields
|
1643
|
+
}),
|
1644
|
+
value: data[subName],
|
1645
|
+
onChange: (val, ui) => {
|
1646
|
+
onChange(
|
1647
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
1648
|
+
[subName]: val
|
1649
|
+
})),
|
1650
|
+
ui
|
1651
|
+
);
|
1652
|
+
}
|
1653
|
+
}
|
1654
|
+
)
|
1655
|
+
},
|
1656
|
+
subPath
|
1657
|
+
);
|
1658
|
+
}) }) })
|
2327
1659
|
]
|
2328
1660
|
}
|
2329
1661
|
)
|
2330
1662
|
},
|
2331
1663
|
_arrayId
|
2332
1664
|
);
|
2333
|
-
})
|
1665
|
+
}),
|
2334
1666
|
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2335
1667
|
"button",
|
2336
1668
|
{
|
2337
1669
|
type: "button",
|
2338
1670
|
className: getClassName5("addButton"),
|
2339
1671
|
onClick: () => {
|
2340
|
-
if (isDragging) return;
|
2341
1672
|
const existingValue = value || [];
|
2342
1673
|
const newValue = [
|
2343
1674
|
...existingValue,
|
@@ -2418,19 +1749,19 @@ var DefaultField = ({
|
|
2418
1749
|
|
2419
1750
|
// components/AutoField/fields/ExternalField/index.tsx
|
2420
1751
|
init_react_import();
|
2421
|
-
var
|
1752
|
+
var import_react16 = require("react");
|
2422
1753
|
|
2423
1754
|
// components/ExternalInput/index.tsx
|
2424
1755
|
init_react_import();
|
2425
|
-
var
|
1756
|
+
var import_react15 = require("react");
|
2426
1757
|
|
2427
1758
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
2428
1759
|
init_react_import();
|
2429
|
-
var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-
|
1760
|
+
var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_8wgzm_1", "ExternalInput-button": "_ExternalInput-button_8wgzm_5", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_8wgzm_24", "ExternalInput--readOnly": "_ExternalInput--readOnly_8wgzm_31", "ExternalInput-detachButton": "_ExternalInput-detachButton_8wgzm_35", "ExternalInput": "_ExternalInput_8wgzm_1", "ExternalInputModal": "_ExternalInputModal_8wgzm_79", "ExternalInputModal-grid": "_ExternalInputModal-grid_8wgzm_89", "ExternalInputModal--filtersToggled": "_ExternalInputModal--filtersToggled_8wgzm_100", "ExternalInputModal-filters": "_ExternalInputModal-filters_8wgzm_105", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_8wgzm_124", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_8wgzm_133", "ExternalInputModal-table": "_ExternalInputModal-table_8wgzm_133", "ExternalInputModal-thead": "_ExternalInputModal-thead_8wgzm_149", "ExternalInputModal-th": "_ExternalInputModal-th_8wgzm_149", "ExternalInputModal-td": "_ExternalInputModal-td_8wgzm_164", "ExternalInputModal-tr": "_ExternalInputModal-tr_8wgzm_169", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_8wgzm_176", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_8wgzm_202", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_8wgzm_206", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_8wgzm_223", "ExternalInputModal-searchForm": "_ExternalInputModal-searchForm_8wgzm_227", "ExternalInputModal-search": "_ExternalInputModal-search_8wgzm_227", "ExternalInputModal-searchIcon": "_ExternalInputModal-searchIcon_8wgzm_264", "ExternalInputModal-searchIconText": "_ExternalInputModal-searchIconText_8wgzm_289", "ExternalInputModal-searchInput": "_ExternalInputModal-searchInput_8wgzm_299", "ExternalInputModal-searchActions": "_ExternalInputModal-searchActions_8wgzm_313", "ExternalInputModal-searchActionIcon": "_ExternalInputModal-searchActionIcon_8wgzm_326", "ExternalInputModal-footerContainer": "_ExternalInputModal-footerContainer_8wgzm_330", "ExternalInputModal-footer": "_ExternalInputModal-footer_8wgzm_330" };
|
2430
1761
|
|
2431
1762
|
// components/Modal/index.tsx
|
2432
1763
|
init_react_import();
|
2433
|
-
var
|
1764
|
+
var import_react13 = require("react");
|
2434
1765
|
|
2435
1766
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
2436
1767
|
init_react_import();
|
@@ -2445,8 +1776,8 @@ var Modal = ({
|
|
2445
1776
|
onClose,
|
2446
1777
|
isOpen
|
2447
1778
|
}) => {
|
2448
|
-
const [rootEl, setRootEl] = (0,
|
2449
|
-
(0,
|
1779
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
1780
|
+
(0, import_react13.useEffect)(() => {
|
2450
1781
|
setRootEl(document.getElementById("puck-portal-root"));
|
2451
1782
|
}, []);
|
2452
1783
|
if (!rootEl) {
|
@@ -2493,11 +1824,11 @@ init_react_import();
|
|
2493
1824
|
|
2494
1825
|
// components/Button/Button.tsx
|
2495
1826
|
init_react_import();
|
2496
|
-
var
|
1827
|
+
var import_react14 = require("react");
|
2497
1828
|
|
2498
1829
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
2499
1830
|
init_react_import();
|
2500
|
-
var Button_module_default = { "Button": "
|
1831
|
+
var Button_module_default = { "Button": "_Button_1t64k_1", "Button--medium": "_Button--medium_1t64k_29", "Button--large": "_Button--large_1t64k_37", "Button-icon": "_Button-icon_1t64k_44", "Button--primary": "_Button--primary_1t64k_48", "Button--secondary": "_Button--secondary_1t64k_67", "Button--flush": "_Button--flush_1t64k_84", "Button--disabled": "_Button--disabled_1t64k_88", "Button--fullWidth": "_Button--fullWidth_1t64k_95", "Button-spinner": "_Button-spinner_1t64k_100" };
|
2501
1832
|
|
2502
1833
|
// lib/filter-data-attrs.ts
|
2503
1834
|
init_react_import();
|
@@ -2543,8 +1874,8 @@ var Button = (_a) => {
|
|
2543
1874
|
"size",
|
2544
1875
|
"loading"
|
2545
1876
|
]);
|
2546
|
-
const [loading, setLoading] = (0,
|
2547
|
-
(0,
|
1877
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
1878
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
2548
1879
|
const ElementType = href ? "a" : type ? "button" : "span";
|
2549
1880
|
const dataAttrs = filterDataAttrs(props);
|
2550
1881
|
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
@@ -2599,28 +1930,28 @@ var ExternalInput = ({
|
|
2599
1930
|
mapRow = (val) => val,
|
2600
1931
|
filterFields
|
2601
1932
|
} = field || {};
|
2602
|
-
const [data, setData] = (0,
|
2603
|
-
const [isOpen, setOpen] = (0,
|
2604
|
-
const [isLoading, setIsLoading] = (0,
|
1933
|
+
const [data, setData] = (0, import_react15.useState)([]);
|
1934
|
+
const [isOpen, setOpen] = (0, import_react15.useState)(false);
|
1935
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
|
2605
1936
|
const hasFilterFields = !!filterFields;
|
2606
|
-
const [filters, setFilters] = (0,
|
2607
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
2608
|
-
const mappedData = (0,
|
1937
|
+
const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
|
1938
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
|
1939
|
+
const mappedData = (0, import_react15.useMemo)(() => {
|
2609
1940
|
return data.map(mapRow);
|
2610
1941
|
}, [data]);
|
2611
|
-
const keys = (0,
|
1942
|
+
const keys = (0, import_react15.useMemo)(() => {
|
2612
1943
|
const validKeys = /* @__PURE__ */ new Set();
|
2613
1944
|
for (const item of mappedData) {
|
2614
1945
|
for (const key of Object.keys(item)) {
|
2615
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
1946
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
|
2616
1947
|
validKeys.add(key);
|
2617
1948
|
}
|
2618
1949
|
}
|
2619
1950
|
}
|
2620
1951
|
return Array.from(validKeys);
|
2621
1952
|
}, [mappedData]);
|
2622
|
-
const [searchQuery, setSearchQuery] = (0,
|
2623
|
-
const search = (0,
|
1953
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
1954
|
+
const search = (0, import_react15.useCallback)(
|
2624
1955
|
(query, filters2) => __async(void 0, null, function* () {
|
2625
1956
|
setIsLoading(true);
|
2626
1957
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -2633,7 +1964,7 @@ var ExternalInput = ({
|
|
2633
1964
|
}),
|
2634
1965
|
[id, field]
|
2635
1966
|
);
|
2636
|
-
const Footer = (0,
|
1967
|
+
const Footer = (0, import_react15.useCallback)(
|
2637
1968
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
2638
1969
|
props.items.length,
|
2639
1970
|
" result",
|
@@ -2641,7 +1972,7 @@ var ExternalInput = ({
|
|
2641
1972
|
] }),
|
2642
1973
|
[field.renderFooter]
|
2643
1974
|
);
|
2644
|
-
(0,
|
1975
|
+
(0, import_react15.useEffect)(() => {
|
2645
1976
|
search(searchQuery, filters);
|
2646
1977
|
}, []);
|
2647
1978
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
@@ -2734,26 +2065,18 @@ var ExternalInput = ({
|
|
2734
2065
|
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
2735
2066
|
const filterField = filterFields[fieldName];
|
2736
2067
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2737
|
-
|
2068
|
+
AutoFieldPrivate,
|
2738
2069
|
{
|
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
|
-
)
|
2070
|
+
field: filterField,
|
2071
|
+
name: fieldName,
|
2072
|
+
id: `external_field_${fieldName}_filter`,
|
2073
|
+
label: filterField.label || fieldName,
|
2074
|
+
value: filters[fieldName],
|
2075
|
+
onChange: (value2) => {
|
2076
|
+
const newFilters = __spreadProps(__spreadValues({}, filters), { [fieldName]: value2 });
|
2077
|
+
setFilters(newFilters);
|
2078
|
+
search(searchQuery, newFilters);
|
2079
|
+
}
|
2757
2080
|
},
|
2758
2081
|
fieldName
|
2759
2082
|
);
|
@@ -2812,7 +2135,7 @@ var ExternalField = ({
|
|
2812
2135
|
var _a, _b, _c;
|
2813
2136
|
const validField = field;
|
2814
2137
|
const deprecatedField = field;
|
2815
|
-
(0,
|
2138
|
+
(0, import_react16.useEffect)(() => {
|
2816
2139
|
if (deprecatedField.adaptor) {
|
2817
2140
|
console.error(
|
2818
2141
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
@@ -2847,7 +2170,7 @@ var ExternalField = ({
|
|
2847
2170
|
|
2848
2171
|
// components/AutoField/fields/RadioField/index.tsx
|
2849
2172
|
init_react_import();
|
2850
|
-
var
|
2173
|
+
var import_react17 = require("react");
|
2851
2174
|
|
2852
2175
|
// lib/safe-json-parse.ts
|
2853
2176
|
init_react_import();
|
@@ -2873,7 +2196,7 @@ var RadioField = ({
|
|
2873
2196
|
label,
|
2874
2197
|
Label: Label2
|
2875
2198
|
}) => {
|
2876
|
-
const flatOptions = (0,
|
2199
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2877
2200
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2878
2201
|
[field]
|
2879
2202
|
);
|
@@ -2923,7 +2246,7 @@ var RadioField = ({
|
|
2923
2246
|
|
2924
2247
|
// components/AutoField/fields/SelectField/index.tsx
|
2925
2248
|
init_react_import();
|
2926
|
-
var
|
2249
|
+
var import_react18 = require("react");
|
2927
2250
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2928
2251
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2929
2252
|
var SelectField = ({
|
@@ -2936,7 +2259,7 @@ var SelectField = ({
|
|
2936
2259
|
readOnly,
|
2937
2260
|
id
|
2938
2261
|
}) => {
|
2939
|
-
const flatOptions = (0,
|
2262
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2940
2263
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2941
2264
|
[field]
|
2942
2265
|
);
|
@@ -3088,7 +2411,7 @@ var ObjectField = ({
|
|
3088
2411
|
|
3089
2412
|
// lib/use-safe-id.ts
|
3090
2413
|
init_react_import();
|
3091
|
-
var
|
2414
|
+
var import_react19 = __toESM(require("react"));
|
3092
2415
|
|
3093
2416
|
// lib/generate-id.ts
|
3094
2417
|
init_react_import();
|
@@ -3097,10 +2420,10 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
3097
2420
|
|
3098
2421
|
// lib/use-safe-id.ts
|
3099
2422
|
var useSafeId = () => {
|
3100
|
-
if (typeof
|
3101
|
-
return
|
2423
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
2424
|
+
return import_react19.default.useId();
|
3102
2425
|
}
|
3103
|
-
const [id] = (0,
|
2426
|
+
const [id] = (0, import_react19.useState)(generateId());
|
3104
2427
|
return id;
|
3105
2428
|
};
|
3106
2429
|
|
@@ -3134,7 +2457,7 @@ var FieldLabelInternal = ({
|
|
3134
2457
|
readOnly
|
3135
2458
|
}) => {
|
3136
2459
|
const { overrides } = useAppContext();
|
3137
|
-
const Wrapper = (0,
|
2460
|
+
const Wrapper = (0, import_react20.useMemo)(
|
3138
2461
|
() => overrides.fieldLabel || FieldLabel,
|
3139
2462
|
[overrides]
|
3140
2463
|
);
|
@@ -3156,7 +2479,7 @@ var FieldLabelInternal = ({
|
|
3156
2479
|
function AutoFieldInternal(props) {
|
3157
2480
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
3158
2481
|
const { dispatch, overrides, selectedItem } = useAppContext();
|
3159
|
-
const nestedFieldContext = (0,
|
2482
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
3160
2483
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
3161
2484
|
const field = props.field;
|
3162
2485
|
const label = field.label;
|
@@ -3188,9 +2511,9 @@ function AutoFieldInternal(props) {
|
|
3188
2511
|
Label: Label2,
|
3189
2512
|
id: resolvedId
|
3190
2513
|
});
|
3191
|
-
const onFocus = (0,
|
2514
|
+
const onFocus = (0, import_react20.useCallback)(
|
3192
2515
|
(e) => {
|
3193
|
-
if (mergedProps.name &&
|
2516
|
+
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
3194
2517
|
e.stopPropagation();
|
3195
2518
|
dispatch({
|
3196
2519
|
type: "setUi",
|
@@ -3202,7 +2525,7 @@ function AutoFieldInternal(props) {
|
|
3202
2525
|
},
|
3203
2526
|
[mergedProps.name]
|
3204
2527
|
);
|
3205
|
-
const onBlur = (0,
|
2528
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
3206
2529
|
if ("name" in e.target) {
|
3207
2530
|
dispatch({
|
3208
2531
|
type: "setUi",
|
@@ -3246,7 +2569,7 @@ function AutoFieldInternal(props) {
|
|
3246
2569
|
function AutoFieldPrivate(props) {
|
3247
2570
|
const { state } = useAppContext();
|
3248
2571
|
const { value, onChange } = props;
|
3249
|
-
const [localValue, setLocalValue] = (0,
|
2572
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
3250
2573
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
3251
2574
|
(val, ui) => {
|
3252
2575
|
onChange(val, ui);
|
@@ -3254,11 +2577,11 @@ function AutoFieldPrivate(props) {
|
|
3254
2577
|
50,
|
3255
2578
|
{ leading: true }
|
3256
2579
|
);
|
3257
|
-
const onChangeLocal = (0,
|
2580
|
+
const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
|
3258
2581
|
setLocalValue(val);
|
3259
2582
|
onChangeDb(val, ui);
|
3260
2583
|
}, []);
|
3261
|
-
(0,
|
2584
|
+
(0, import_react20.useEffect)(() => {
|
3262
2585
|
if (state.ui.field.focus !== props.name) {
|
3263
2586
|
setLocalValue(value);
|
3264
2587
|
}
|
@@ -3270,7 +2593,7 @@ function AutoFieldPrivate(props) {
|
|
3270
2593
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
3271
2594
|
}
|
3272
2595
|
function AutoField(props) {
|
3273
|
-
const DefaultLabel = (0,
|
2596
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
3274
2597
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
3275
2598
|
"div",
|
3276
2599
|
__spreadProps(__spreadValues({}, labelProps), {
|
@@ -3282,36 +2605,371 @@ function AutoField(props) {
|
|
3282
2605
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
3283
2606
|
}
|
3284
2607
|
|
3285
|
-
// components/Drawer/index.tsx
|
3286
|
-
init_react_import();
|
2608
|
+
// components/Drawer/index.tsx
|
2609
|
+
init_react_import();
|
2610
|
+
|
2611
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
2612
|
+
init_react_import();
|
2613
|
+
var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
|
2614
|
+
|
2615
|
+
// components/Drawer/index.tsx
|
2616
|
+
var import_react32 = require("react");
|
2617
|
+
|
2618
|
+
// components/DragDropContext/index.tsx
|
2619
|
+
init_react_import();
|
2620
|
+
var import_react30 = require("@dnd-kit/react");
|
2621
|
+
var import_react31 = require("react");
|
2622
|
+
var import_dom = require("@dnd-kit/dom");
|
2623
|
+
|
2624
|
+
// components/DropZone/index.tsx
|
2625
|
+
init_react_import();
|
2626
|
+
var import_react29 = require("react");
|
2627
|
+
|
2628
|
+
// components/DraggableComponent/index.tsx
|
2629
|
+
init_react_import();
|
2630
|
+
var import_react23 = require("react");
|
2631
|
+
|
2632
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2633
|
+
init_react_import();
|
2634
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
|
2635
|
+
|
2636
|
+
// components/DraggableComponent/index.tsx
|
2637
|
+
var import_react_dom2 = require("react-dom");
|
2638
|
+
|
2639
|
+
// lib/dnd/collision/dynamic/index.ts
|
2640
|
+
init_react_import();
|
2641
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
2642
|
+
|
2643
|
+
// lib/dnd/collision/directional/index.ts
|
2644
|
+
init_react_import();
|
2645
|
+
var import_abstract = require("@dnd-kit/abstract");
|
2646
|
+
|
2647
|
+
// lib/dnd/collision/collision-debug.ts
|
2648
|
+
init_react_import();
|
2649
|
+
var DEBUG = false;
|
2650
|
+
var debugElements = {};
|
2651
|
+
var timeout;
|
2652
|
+
var collisionDebug = (a, b, id, color, label) => {
|
2653
|
+
if (!DEBUG) return;
|
2654
|
+
const debugId = `${id}-debug`;
|
2655
|
+
clearTimeout(timeout);
|
2656
|
+
timeout = setTimeout(() => {
|
2657
|
+
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
2658
|
+
svg.remove();
|
2659
|
+
delete debugElements[id2];
|
2660
|
+
});
|
2661
|
+
}, 1e3);
|
2662
|
+
requestAnimationFrame(() => {
|
2663
|
+
var _a, _b;
|
2664
|
+
const existingEl = debugElements[debugId];
|
2665
|
+
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
2666
|
+
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
2667
|
+
if (!existingEl) {
|
2668
|
+
const svgNs = "http://www.w3.org/2000/svg";
|
2669
|
+
const svg = document.createElementNS(svgNs, "svg");
|
2670
|
+
line = document.createElementNS(svgNs, "line");
|
2671
|
+
text = document.createElementNS(svgNs, "text");
|
2672
|
+
svg.setAttribute("id", debugId);
|
2673
|
+
svg.setAttribute(
|
2674
|
+
"style",
|
2675
|
+
"position: fixed; height: 100%; width: 100%; pointer-events: none;"
|
2676
|
+
);
|
2677
|
+
svg.appendChild(line);
|
2678
|
+
svg.appendChild(text);
|
2679
|
+
text.setAttribute("fill", `black`);
|
2680
|
+
document.body.appendChild(svg);
|
2681
|
+
debugElements[debugId] = { svg, line, text };
|
2682
|
+
}
|
2683
|
+
line.setAttribute("x1", a.x.toString());
|
2684
|
+
line.setAttribute("x2", b.x.toString());
|
2685
|
+
line.setAttribute("y1", a.y.toString());
|
2686
|
+
line.setAttribute("y2", b.y.toString());
|
2687
|
+
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
2688
|
+
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
2689
|
+
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
2690
|
+
if (label) {
|
2691
|
+
text.innerHTML = label;
|
2692
|
+
}
|
2693
|
+
});
|
2694
|
+
};
|
2695
|
+
|
2696
|
+
// lib/dnd/collision/directional/index.ts
|
2697
|
+
var distanceChange = "increasing";
|
2698
|
+
var directionalCollision = (input, previous) => {
|
2699
|
+
var _a;
|
2700
|
+
const { dragOperation, droppable } = input;
|
2701
|
+
const { shape: dropShape } = droppable;
|
2702
|
+
const { position } = dragOperation;
|
2703
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
2704
|
+
if (!dragShape || !dropShape) return null;
|
2705
|
+
const dropCenter = dropShape.center;
|
2706
|
+
const distanceToPrevious = Math.sqrt(
|
2707
|
+
Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
|
2708
|
+
);
|
2709
|
+
const distanceToCurrent = Math.sqrt(
|
2710
|
+
Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
|
2711
|
+
);
|
2712
|
+
distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
|
2713
|
+
collisionDebug(
|
2714
|
+
dragShape.center,
|
2715
|
+
dropCenter,
|
2716
|
+
droppable.id.toString(),
|
2717
|
+
"rebeccapurple"
|
2718
|
+
);
|
2719
|
+
if (distanceChange === "decreasing") {
|
2720
|
+
return {
|
2721
|
+
id: droppable.id,
|
2722
|
+
value: 1,
|
2723
|
+
type: import_abstract.CollisionType.Collision
|
2724
|
+
};
|
2725
|
+
}
|
2726
|
+
return null;
|
2727
|
+
};
|
3287
2728
|
|
3288
|
-
//
|
2729
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
3289
2730
|
init_react_import();
|
3290
|
-
var
|
3291
|
-
|
3292
|
-
|
3293
|
-
|
2731
|
+
var getDirection = (dragAxis, delta) => {
|
2732
|
+
if (dragAxis === "dynamic") {
|
2733
|
+
if (Math.abs(delta.y) > Math.abs(delta.x)) {
|
2734
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2735
|
+
} else {
|
2736
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
2737
|
+
}
|
2738
|
+
} else if (dragAxis === "x") {
|
2739
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
2740
|
+
}
|
2741
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2742
|
+
};
|
3294
2743
|
|
3295
|
-
//
|
2744
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
3296
2745
|
init_react_import();
|
3297
|
-
var
|
3298
|
-
|
3299
|
-
|
2746
|
+
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2747
|
+
const dragRect = dragShape.boundingRectangle;
|
2748
|
+
const dropCenter = dropShape.center;
|
2749
|
+
if (direction === "down") {
|
2750
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
2751
|
+
return dragRect.bottom >= dropCenter.y + offset2;
|
2752
|
+
} else if (direction === "up") {
|
2753
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
2754
|
+
return dragRect.top < dropCenter.y - offset2;
|
2755
|
+
} else if (direction === "left") {
|
2756
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
|
2757
|
+
return dropCenter.x - offset2 >= dragRect.left;
|
2758
|
+
}
|
2759
|
+
const offset = offsetMultiplier * dropShape.boundingRectangle.width;
|
2760
|
+
return dragRect.right - offset >= dropCenter.x;
|
2761
|
+
};
|
3300
2762
|
|
3301
|
-
//
|
2763
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
3302
2764
|
init_react_import();
|
3303
|
-
var
|
2765
|
+
var import_geometry = require("@dnd-kit/geometry");
|
2766
|
+
var INTERVAL_SENSITIVITY = 10;
|
2767
|
+
var intervalCache = {
|
2768
|
+
current: { x: 0, y: 0 },
|
2769
|
+
delta: { x: 0, y: 0 },
|
2770
|
+
previous: { x: 0, y: 0 },
|
2771
|
+
direction: null
|
2772
|
+
};
|
2773
|
+
var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
2774
|
+
intervalCache.current = point;
|
2775
|
+
intervalCache.delta = {
|
2776
|
+
x: point.x - intervalCache.previous.x,
|
2777
|
+
y: point.y - intervalCache.previous.y
|
2778
|
+
};
|
2779
|
+
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
2780
|
+
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
2781
|
+
intervalCache.previous = import_geometry.Point.from(point);
|
2782
|
+
}
|
2783
|
+
return intervalCache;
|
2784
|
+
};
|
3304
2785
|
|
3305
|
-
//
|
2786
|
+
// ../../node_modules/@dnd-kit/collision/dist/index.js
|
3306
2787
|
init_react_import();
|
3307
|
-
var
|
2788
|
+
var import_abstract2 = require("@dnd-kit/abstract");
|
2789
|
+
var import_geometry2 = require("@dnd-kit/geometry");
|
2790
|
+
var import_abstract3 = require("@dnd-kit/abstract");
|
2791
|
+
var import_geometry3 = require("@dnd-kit/geometry");
|
2792
|
+
var import_abstract4 = require("@dnd-kit/abstract");
|
2793
|
+
var import_geometry4 = require("@dnd-kit/geometry");
|
2794
|
+
var import_abstract5 = require("@dnd-kit/abstract");
|
2795
|
+
var import_geometry5 = require("@dnd-kit/geometry");
|
2796
|
+
var import_abstract6 = require("@dnd-kit/abstract");
|
2797
|
+
var import_geometry6 = require("@dnd-kit/geometry");
|
2798
|
+
var import_abstract7 = require("@dnd-kit/abstract");
|
2799
|
+
var import_geometry7 = require("@dnd-kit/geometry");
|
2800
|
+
var pointerIntersection = ({
|
2801
|
+
dragOperation,
|
2802
|
+
droppable
|
2803
|
+
}) => {
|
2804
|
+
const pointerCoordinates = dragOperation.position.current;
|
2805
|
+
if (!pointerCoordinates) {
|
2806
|
+
return null;
|
2807
|
+
}
|
2808
|
+
const { id } = droppable;
|
2809
|
+
if (!droppable.shape) {
|
2810
|
+
return null;
|
2811
|
+
}
|
2812
|
+
if (droppable.shape.containsPoint(pointerCoordinates)) {
|
2813
|
+
const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
|
2814
|
+
return {
|
2815
|
+
id,
|
2816
|
+
value: 1 / distance,
|
2817
|
+
type: import_abstract2.CollisionType.PointerIntersection,
|
2818
|
+
priority: import_abstract2.CollisionPriority.High
|
2819
|
+
};
|
2820
|
+
}
|
2821
|
+
return null;
|
2822
|
+
};
|
2823
|
+
var closestCorners = (input) => {
|
2824
|
+
const { dragOperation, droppable } = input;
|
2825
|
+
const { shape, position } = dragOperation;
|
2826
|
+
if (!droppable.shape) {
|
2827
|
+
return null;
|
2828
|
+
}
|
2829
|
+
const { left, top, right, bottom } = droppable.shape.boundingRectangle;
|
2830
|
+
const corners = [
|
2831
|
+
{
|
2832
|
+
x: left,
|
2833
|
+
y: top
|
2834
|
+
},
|
2835
|
+
{
|
2836
|
+
x: right,
|
2837
|
+
y: top
|
2838
|
+
},
|
2839
|
+
{
|
2840
|
+
x: left,
|
2841
|
+
y: bottom
|
2842
|
+
},
|
2843
|
+
{
|
2844
|
+
x: right,
|
2845
|
+
y: bottom
|
2846
|
+
}
|
2847
|
+
];
|
2848
|
+
const distance = corners.reduce(
|
2849
|
+
(acc, corner) => {
|
2850
|
+
var _a;
|
2851
|
+
return acc + import_geometry4.Point.distance(
|
2852
|
+
import_geometry4.Point.from(corner),
|
2853
|
+
(_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
|
2854
|
+
);
|
2855
|
+
},
|
2856
|
+
0
|
2857
|
+
);
|
2858
|
+
const value = distance / 4;
|
2859
|
+
return {
|
2860
|
+
id: droppable.id,
|
2861
|
+
value: 1 / value,
|
2862
|
+
type: import_abstract4.CollisionType.Collision,
|
2863
|
+
priority: import_abstract4.CollisionPriority.Normal
|
2864
|
+
};
|
2865
|
+
};
|
3308
2866
|
|
3309
|
-
//
|
2867
|
+
// lib/dnd/collision/dynamic/store.ts
|
3310
2868
|
init_react_import();
|
3311
|
-
var
|
2869
|
+
var import_vanilla = require("zustand/vanilla");
|
2870
|
+
var collisionStore = (0, import_vanilla.createStore)(() => ({
|
2871
|
+
fallbackEnabled: false
|
2872
|
+
}));
|
3312
2873
|
|
3313
|
-
//
|
3314
|
-
var
|
2874
|
+
// lib/dnd/collision/dynamic/index.ts
|
2875
|
+
var flushNext = "";
|
2876
|
+
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2877
|
+
var _a, _b, _c, _d, _e;
|
2878
|
+
const { dragOperation, droppable } = input;
|
2879
|
+
const { position } = dragOperation;
|
2880
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
2881
|
+
const { shape: dropShape } = droppable;
|
2882
|
+
if (!dragShape || !dropShape) {
|
2883
|
+
return null;
|
2884
|
+
}
|
2885
|
+
const { center: dragCenter } = dragShape;
|
2886
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2887
|
+
const interval = trackMovementInterval(position.current, dragAxis);
|
2888
|
+
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2889
|
+
direction: interval.direction
|
2890
|
+
});
|
2891
|
+
const collisionMap = dragOperation.data.collisionMap || {};
|
2892
|
+
dragOperation.data.collisionMap = collisionMap;
|
2893
|
+
collisionMap[droppable.id] = {
|
2894
|
+
direction: interval.direction
|
2895
|
+
};
|
2896
|
+
const { center: dropCenter } = dropShape;
|
2897
|
+
const overMidpoint = getMidpointImpact(
|
2898
|
+
dragShape,
|
2899
|
+
dropShape,
|
2900
|
+
interval.direction,
|
2901
|
+
midpointOffset
|
2902
|
+
);
|
2903
|
+
if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
|
2904
|
+
const collision = directionalCollision(input, interval.previous);
|
2905
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
2906
|
+
if (collision) {
|
2907
|
+
return __spreadProps(__spreadValues({}, collision), {
|
2908
|
+
priority: import_abstract8.CollisionPriority.Highest
|
2909
|
+
});
|
2910
|
+
}
|
2911
|
+
}
|
2912
|
+
const intersectionArea = dragShape.intersectionArea(dropShape);
|
2913
|
+
const intersectionRatio = intersectionArea / dropShape.area;
|
2914
|
+
if (intersectionArea && overMidpoint) {
|
2915
|
+
collisionDebug(
|
2916
|
+
dragCenter,
|
2917
|
+
dropCenter,
|
2918
|
+
droppable.id.toString(),
|
2919
|
+
"green",
|
2920
|
+
interval.direction
|
2921
|
+
);
|
2922
|
+
const collision = {
|
2923
|
+
id: droppable.id,
|
2924
|
+
value: intersectionRatio,
|
2925
|
+
priority: import_abstract8.CollisionPriority.High,
|
2926
|
+
type: import_abstract8.CollisionType.Collision
|
2927
|
+
};
|
2928
|
+
const shouldFlushId = flushNext === droppable.id;
|
2929
|
+
flushNext = "";
|
2930
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2931
|
+
}
|
2932
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2933
|
+
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2934
|
+
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2935
|
+
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
2936
|
+
const fallbackCollision = closestCorners(input);
|
2937
|
+
if (fallbackCollision) {
|
2938
|
+
const direction = getDirection(dragAxis, {
|
2939
|
+
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
2940
|
+
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
2941
|
+
});
|
2942
|
+
collisionMap[droppable.id] = {
|
2943
|
+
direction
|
2944
|
+
};
|
2945
|
+
if (intersectionArea) {
|
2946
|
+
collisionDebug(
|
2947
|
+
dragCenter,
|
2948
|
+
dropCenter,
|
2949
|
+
droppable.id.toString(),
|
2950
|
+
"red",
|
2951
|
+
direction || ""
|
2952
|
+
);
|
2953
|
+
flushNext = droppable.id;
|
2954
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2955
|
+
priority: import_abstract8.CollisionPriority.Low
|
2956
|
+
});
|
2957
|
+
}
|
2958
|
+
collisionDebug(
|
2959
|
+
dragCenter,
|
2960
|
+
dropCenter,
|
2961
|
+
droppable.id.toString(),
|
2962
|
+
"orange",
|
2963
|
+
direction || ""
|
2964
|
+
);
|
2965
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract8.CollisionPriority.Lowest });
|
2966
|
+
}
|
2967
|
+
}
|
2968
|
+
}
|
2969
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
2970
|
+
delete collisionMap[droppable.id];
|
2971
|
+
return null;
|
2972
|
+
};
|
3315
2973
|
|
3316
2974
|
// lib/get-deep-scroll-position.ts
|
3317
2975
|
init_react_import();
|
@@ -3334,11 +2992,11 @@ function getDeepScrollPosition(element) {
|
|
3334
2992
|
|
3335
2993
|
// components/DropZone/context.tsx
|
3336
2994
|
init_react_import();
|
3337
|
-
var
|
2995
|
+
var import_react21 = require("react");
|
3338
2996
|
var import_zustand = require("zustand");
|
3339
2997
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
3340
|
-
var dropZoneContext = (0,
|
3341
|
-
var ZoneStoreContext = (0,
|
2998
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2999
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
3342
3000
|
(0, import_zustand.createStore)(() => ({
|
3343
3001
|
zoneDepthIndex: {},
|
3344
3002
|
nextZoneDepthIndex: {},
|
@@ -3358,19 +3016,19 @@ var DropZoneProvider = ({
|
|
3358
3016
|
children,
|
3359
3017
|
value
|
3360
3018
|
}) => {
|
3361
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
3362
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
3019
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3020
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3363
3021
|
{}
|
3364
3022
|
);
|
3365
|
-
const [activeZones, setActiveZones] = (0,
|
3023
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3366
3024
|
const { dispatch } = useAppContext();
|
3367
|
-
const registerZoneArea = (0,
|
3025
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
3368
3026
|
(area) => {
|
3369
3027
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3370
3028
|
},
|
3371
3029
|
[setAreasWithZones]
|
3372
3030
|
);
|
3373
|
-
const registerZone = (0,
|
3031
|
+
const registerZone = (0, import_react21.useCallback)(
|
3374
3032
|
(zoneCompound) => {
|
3375
3033
|
if (!dispatch) {
|
3376
3034
|
return;
|
@@ -3383,7 +3041,7 @@ var DropZoneProvider = ({
|
|
3383
3041
|
},
|
3384
3042
|
[setActiveZones, dispatch]
|
3385
3043
|
);
|
3386
|
-
const unregisterZone = (0,
|
3044
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
3387
3045
|
(zoneCompound) => {
|
3388
3046
|
if (!dispatch) {
|
3389
3047
|
return;
|
@@ -3398,7 +3056,7 @@ var DropZoneProvider = ({
|
|
3398
3056
|
},
|
3399
3057
|
[setActiveZones, dispatch]
|
3400
3058
|
);
|
3401
|
-
const memoValue = (0,
|
3059
|
+
const memoValue = (0, import_react21.useMemo)(
|
3402
3060
|
() => __spreadValues({
|
3403
3061
|
hoveringComponent,
|
3404
3062
|
setHoveringComponent,
|
@@ -3415,11 +3073,11 @@ var DropZoneProvider = ({
|
|
3415
3073
|
|
3416
3074
|
// lib/use-context-store.ts
|
3417
3075
|
init_react_import();
|
3418
|
-
var
|
3076
|
+
var import_react22 = require("react");
|
3419
3077
|
var import_zustand2 = require("zustand");
|
3420
3078
|
var import_shallow = require("zustand/react/shallow");
|
3421
3079
|
function useContextStore(context, selector) {
|
3422
|
-
const store = (0,
|
3080
|
+
const store = (0, import_react22.useContext)(context);
|
3423
3081
|
if (!store) {
|
3424
3082
|
throw new Error("useContextStore must be used inside context");
|
3425
3083
|
}
|
@@ -3478,9 +3136,9 @@ var DraggableComponent = ({
|
|
3478
3136
|
iframe,
|
3479
3137
|
state
|
3480
3138
|
} = useAppContext();
|
3481
|
-
const ctx = (0,
|
3482
|
-
const [localZones, setLocalZones] = (0,
|
3483
|
-
const registerLocalZone = (0,
|
3139
|
+
const ctx = (0, import_react23.useContext)(dropZoneContext);
|
3140
|
+
const [localZones, setLocalZones] = (0, import_react23.useState)({});
|
3141
|
+
const registerLocalZone = (0, import_react23.useCallback)(
|
3484
3142
|
(zoneCompound2, active) => {
|
3485
3143
|
var _a;
|
3486
3144
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -3490,7 +3148,7 @@ var DraggableComponent = ({
|
|
3490
3148
|
},
|
3491
3149
|
[setLocalZones]
|
3492
3150
|
);
|
3493
|
-
const unregisterLocalZone = (0,
|
3151
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
3494
3152
|
(zoneCompound2) => {
|
3495
3153
|
var _a;
|
3496
3154
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -3504,8 +3162,8 @@ var DraggableComponent = ({
|
|
3504
3162
|
);
|
3505
3163
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
3506
3164
|
const { path = [] } = ctx || {};
|
3507
|
-
const [canDrag, setCanDrag] = (0,
|
3508
|
-
(0,
|
3165
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3166
|
+
(0, import_react23.useEffect)(() => {
|
3509
3167
|
var _a;
|
3510
3168
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
3511
3169
|
if (item) {
|
@@ -3521,7 +3179,7 @@ var DraggableComponent = ({
|
|
3521
3179
|
);
|
3522
3180
|
const canCollide = canDrag || userIsDragging;
|
3523
3181
|
const disabled = !isEnabled || !canCollide;
|
3524
|
-
const [dragAxis, setDragAxis] = (0,
|
3182
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
3525
3183
|
const { ref: sortableRef, status } = useSortableSafe({
|
3526
3184
|
id,
|
3527
3185
|
index,
|
@@ -3547,8 +3205,8 @@ var DraggableComponent = ({
|
|
3547
3205
|
}
|
3548
3206
|
});
|
3549
3207
|
const thisIsDragging = status === "dragging";
|
3550
|
-
const ref = (0,
|
3551
|
-
const refSetter = (0,
|
3208
|
+
const ref = (0, import_react23.useRef)(null);
|
3209
|
+
const refSetter = (0, import_react23.useCallback)(
|
3552
3210
|
(el) => {
|
3553
3211
|
sortableRef(el);
|
3554
3212
|
if (el) {
|
@@ -3557,14 +3215,14 @@ var DraggableComponent = ({
|
|
3557
3215
|
},
|
3558
3216
|
[sortableRef]
|
3559
3217
|
);
|
3560
|
-
const [portalEl, setPortalEl] = (0,
|
3561
|
-
(0,
|
3218
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3219
|
+
(0, import_react23.useEffect)(() => {
|
3562
3220
|
var _a, _b, _c;
|
3563
3221
|
setPortalEl(
|
3564
3222
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
3565
3223
|
);
|
3566
3224
|
}, [iframe.enabled, ref.current]);
|
3567
|
-
const getStyle = (0,
|
3225
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3568
3226
|
var _a, _b, _c;
|
3569
3227
|
if (!ref.current) return;
|
3570
3228
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3584,11 +3242,11 @@ var DraggableComponent = ({
|
|
3584
3242
|
};
|
3585
3243
|
return style2;
|
3586
3244
|
}, [ref.current]);
|
3587
|
-
const [style, setStyle] = (0,
|
3588
|
-
const sync = (0,
|
3245
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3246
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3589
3247
|
setStyle(getStyle());
|
3590
3248
|
}, [ref.current, iframe]);
|
3591
|
-
(0,
|
3249
|
+
(0, import_react23.useEffect)(() => {
|
3592
3250
|
if (ref.current && !userIsDragging) {
|
3593
3251
|
const observer = new ResizeObserver(sync);
|
3594
3252
|
observer.observe(ref.current);
|
@@ -3597,7 +3255,7 @@ var DraggableComponent = ({
|
|
3597
3255
|
};
|
3598
3256
|
}
|
3599
3257
|
}, [ref.current, userIsDragging]);
|
3600
|
-
(0,
|
3258
|
+
(0, import_react23.useEffect)(() => {
|
3601
3259
|
ctx == null ? void 0 : ctx.registerPath(
|
3602
3260
|
id,
|
3603
3261
|
{
|
@@ -3611,14 +3269,14 @@ var DraggableComponent = ({
|
|
3611
3269
|
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3612
3270
|
};
|
3613
3271
|
}, [id, zoneCompound, index, componentType]);
|
3614
|
-
const CustomActionBar = (0,
|
3272
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3615
3273
|
() => overrides.actionBar || DefaultActionBar,
|
3616
3274
|
[overrides.actionBar]
|
3617
3275
|
);
|
3618
3276
|
const permissions = getPermissions({
|
3619
3277
|
item: selectedItem
|
3620
3278
|
});
|
3621
|
-
const onClick = (0,
|
3279
|
+
const onClick = (0, import_react23.useCallback)(
|
3622
3280
|
(e) => {
|
3623
3281
|
e.stopPropagation();
|
3624
3282
|
dispatch({
|
@@ -3630,7 +3288,7 @@ var DraggableComponent = ({
|
|
3630
3288
|
},
|
3631
3289
|
[index, zoneCompound, id]
|
3632
3290
|
);
|
3633
|
-
const onSelectParent = (0,
|
3291
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3634
3292
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3635
3293
|
return;
|
3636
3294
|
}
|
@@ -3648,23 +3306,23 @@ var DraggableComponent = ({
|
|
3648
3306
|
}
|
3649
3307
|
});
|
3650
3308
|
}, [ctx, path]);
|
3651
|
-
const onDuplicate = (0,
|
3309
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3652
3310
|
dispatch({
|
3653
3311
|
type: "duplicate",
|
3654
3312
|
sourceIndex: index,
|
3655
3313
|
sourceZone: zoneCompound
|
3656
3314
|
});
|
3657
3315
|
}, [index, zoneCompound]);
|
3658
|
-
const onDelete = (0,
|
3316
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3659
3317
|
dispatch({
|
3660
3318
|
type: "remove",
|
3661
3319
|
index,
|
3662
3320
|
zone: zoneCompound
|
3663
3321
|
});
|
3664
3322
|
}, [index, zoneCompound]);
|
3665
|
-
const [hover, setHover] = (0,
|
3323
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3666
3324
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3667
|
-
(0,
|
3325
|
+
(0, import_react23.useEffect)(() => {
|
3668
3326
|
if (!ref.current) {
|
3669
3327
|
return;
|
3670
3328
|
}
|
@@ -3714,7 +3372,7 @@ var DraggableComponent = ({
|
|
3714
3372
|
thisIsDragging,
|
3715
3373
|
inDroppableZone
|
3716
3374
|
]);
|
3717
|
-
(0,
|
3375
|
+
(0, import_react23.useEffect)(() => {
|
3718
3376
|
if (ref.current && disabled) {
|
3719
3377
|
ref.current.setAttribute("data-puck-disabled", "");
|
3720
3378
|
return () => {
|
@@ -3723,8 +3381,8 @@ var DraggableComponent = ({
|
|
3723
3381
|
};
|
3724
3382
|
}
|
3725
3383
|
}, [disabled, ref]);
|
3726
|
-
const [isVisible, setIsVisible] = (0,
|
3727
|
-
(0,
|
3384
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3385
|
+
(0, import_react23.useEffect)(() => {
|
3728
3386
|
sync();
|
3729
3387
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3730
3388
|
setIsVisible(true);
|
@@ -3732,7 +3390,7 @@ var DraggableComponent = ({
|
|
3732
3390
|
setIsVisible(false);
|
3733
3391
|
}
|
3734
3392
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3735
|
-
const syncActionsPosition = (0,
|
3393
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3736
3394
|
(el) => {
|
3737
3395
|
if (el) {
|
3738
3396
|
const view = el.ownerDocument.defaultView;
|
@@ -3749,7 +3407,7 @@ var DraggableComponent = ({
|
|
3749
3407
|
},
|
3750
3408
|
[zoomConfig]
|
3751
3409
|
);
|
3752
|
-
(0,
|
3410
|
+
(0, import_react23.useEffect)(() => {
|
3753
3411
|
if (userDragAxis) {
|
3754
3412
|
setDragAxis(userDragAxis);
|
3755
3413
|
return;
|
@@ -3843,14 +3501,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
3843
3501
|
|
3844
3502
|
// components/DropZone/lib/use-min-empty-height.ts
|
3845
3503
|
init_react_import();
|
3846
|
-
var
|
3504
|
+
var import_react24 = require("react");
|
3847
3505
|
var useMinEmptyHeight = ({
|
3848
3506
|
zoneCompound,
|
3849
3507
|
userMinEmptyHeight,
|
3850
3508
|
ref
|
3851
3509
|
}) => {
|
3852
|
-
const [prevHeight, setPrevHeight] = (0,
|
3853
|
-
const [isAnimating, setIsAnimating] = (0,
|
3510
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3511
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3854
3512
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3855
3513
|
var _a, _b;
|
3856
3514
|
return {
|
@@ -3858,7 +3516,7 @@ var useMinEmptyHeight = ({
|
|
3858
3516
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3859
3517
|
};
|
3860
3518
|
});
|
3861
|
-
(0,
|
3519
|
+
(0, import_react24.useEffect)(() => {
|
3862
3520
|
if (draggedItem && ref.current) {
|
3863
3521
|
if (isZone) {
|
3864
3522
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3892,15 +3550,15 @@ function assignRefs(refs, node) {
|
|
3892
3550
|
|
3893
3551
|
// components/DropZone/lib/use-content-with-preview.ts
|
3894
3552
|
init_react_import();
|
3895
|
-
var
|
3553
|
+
var import_react27 = require("react");
|
3896
3554
|
|
3897
3555
|
// lib/dnd/use-rendered-callback.ts
|
3898
3556
|
init_react_import();
|
3899
|
-
var
|
3900
|
-
var
|
3557
|
+
var import_react25 = require("@dnd-kit/react");
|
3558
|
+
var import_react26 = require("react");
|
3901
3559
|
function useRenderedCallback(callback, deps) {
|
3902
|
-
const manager = (0,
|
3903
|
-
return (0,
|
3560
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3561
|
+
return (0, import_react26.useCallback)(
|
3904
3562
|
(...args) => __async(this, null, function* () {
|
3905
3563
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
3906
3564
|
return callback(...args);
|
@@ -3935,8 +3593,8 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3935
3593
|
ui: { isDragging }
|
3936
3594
|
}
|
3937
3595
|
} = useAppContext();
|
3938
|
-
const [contentWithPreview, setContentWithPreview] = (0,
|
3939
|
-
const [localPreview, setLocalPreview] = (0,
|
3596
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3597
|
+
const [localPreview, setLocalPreview] = (0, import_react27.useState)(
|
3940
3598
|
preview
|
3941
3599
|
);
|
3942
3600
|
const updateContent = useRenderedCallback(
|
@@ -3977,7 +3635,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3977
3635
|
},
|
3978
3636
|
[draggedItemId, previewExists]
|
3979
3637
|
);
|
3980
|
-
(0,
|
3638
|
+
(0, import_react27.useEffect)(() => {
|
3981
3639
|
updateContent(content, preview, isDragging);
|
3982
3640
|
}, [content, preview, isDragging]);
|
3983
3641
|
return [contentWithPreview, localPreview];
|
@@ -3985,16 +3643,16 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3985
3643
|
|
3986
3644
|
// components/DropZone/lib/use-drag-axis.ts
|
3987
3645
|
init_react_import();
|
3988
|
-
var
|
3646
|
+
var import_react28 = require("react");
|
3989
3647
|
var GRID_DRAG_AXIS = "dynamic";
|
3990
3648
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3991
3649
|
var DEFAULT_DRAG_AXIS = "y";
|
3992
3650
|
var useDragAxis = (ref, collisionAxis) => {
|
3993
3651
|
const { status } = useAppContext();
|
3994
|
-
const [dragAxis, setDragAxis] = (0,
|
3652
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3995
3653
|
collisionAxis || DEFAULT_DRAG_AXIS
|
3996
3654
|
);
|
3997
|
-
const calculateDragAxis = (0,
|
3655
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3998
3656
|
if (ref.current) {
|
3999
3657
|
const computedStyle = window.getComputedStyle(ref.current);
|
4000
3658
|
if (computedStyle.display === "grid") {
|
@@ -4006,7 +3664,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4006
3664
|
}
|
4007
3665
|
}
|
4008
3666
|
}, [ref.current]);
|
4009
|
-
(0,
|
3667
|
+
(0, import_react28.useEffect)(() => {
|
4010
3668
|
const onViewportChange = () => {
|
4011
3669
|
calculateDragAxis();
|
4012
3670
|
};
|
@@ -4015,7 +3673,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4015
3673
|
window.removeEventListener("viewportchange", onViewportChange);
|
4016
3674
|
};
|
4017
3675
|
}, []);
|
4018
|
-
(0,
|
3676
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
4019
3677
|
return [dragAxis, calculateDragAxis];
|
4020
3678
|
};
|
4021
3679
|
|
@@ -4025,7 +3683,7 @@ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_de
|
|
4025
3683
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
4026
3684
|
var RENDER_DEBUG = false;
|
4027
3685
|
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
4028
|
-
var DropZoneEdit = (0,
|
3686
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
4029
3687
|
function DropZoneEditInternal({
|
4030
3688
|
zone,
|
4031
3689
|
allow,
|
@@ -4036,7 +3694,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4036
3694
|
collisionAxis
|
4037
3695
|
}, userRef) {
|
4038
3696
|
const appContext2 = useAppContext();
|
4039
|
-
const ctx = (0,
|
3697
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4040
3698
|
const {
|
4041
3699
|
// These all need setting via context
|
4042
3700
|
data,
|
@@ -4072,12 +3730,12 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4072
3730
|
};
|
4073
3731
|
});
|
4074
3732
|
const { itemSelector } = appContext2.state.ui;
|
4075
|
-
(0,
|
3733
|
+
(0, import_react29.useEffect)(() => {
|
4076
3734
|
if (areaId && registerZoneArea) {
|
4077
3735
|
registerZoneArea(areaId);
|
4078
3736
|
}
|
4079
3737
|
}, [areaId]);
|
4080
|
-
(0,
|
3738
|
+
(0, import_react29.useEffect)(() => {
|
4081
3739
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4082
3740
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4083
3741
|
}
|
@@ -4087,14 +3745,14 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4087
3745
|
}
|
4088
3746
|
};
|
4089
3747
|
}, []);
|
4090
|
-
const content = (0,
|
3748
|
+
const content = (0, import_react29.useMemo)(() => {
|
4091
3749
|
if (areaId && zone !== rootDroppableId) {
|
4092
3750
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
4093
3751
|
}
|
4094
3752
|
return data.content || [];
|
4095
3753
|
}, [data, zoneCompound]);
|
4096
|
-
const ref = (0,
|
4097
|
-
const acceptsTarget = (0,
|
3754
|
+
const ref = (0, import_react29.useRef)(null);
|
3755
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
4098
3756
|
(componentType) => {
|
4099
3757
|
if (!componentType) {
|
4100
3758
|
return true;
|
@@ -4116,7 +3774,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4116
3774
|
},
|
4117
3775
|
[allow, disallow]
|
4118
3776
|
);
|
4119
|
-
(0,
|
3777
|
+
(0, import_react29.useEffect)(() => {
|
4120
3778
|
if (registerLocalZone) {
|
4121
3779
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
4122
3780
|
}
|
@@ -4251,13 +3909,13 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4251
3909
|
}
|
4252
3910
|
);
|
4253
3911
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
4254
|
-
var DropZoneRender = (0,
|
3912
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
4255
3913
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
4256
|
-
const ctx = (0,
|
3914
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4257
3915
|
const { data, areaId = "root", config } = ctx || {};
|
4258
3916
|
let zoneCompound = rootDroppableId;
|
4259
3917
|
let content = (data == null ? void 0 : data.content) || [];
|
4260
|
-
(0,
|
3918
|
+
(0, import_react29.useEffect)(() => {
|
4261
3919
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4262
3920
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4263
3921
|
}
|
@@ -4303,10 +3961,9 @@ var DropZoneRender = (0, import_react30.forwardRef)(
|
|
4303
3961
|
}) });
|
4304
3962
|
}
|
4305
3963
|
);
|
4306
|
-
var
|
4307
|
-
var DropZone = (0, import_react30.forwardRef)(
|
3964
|
+
var DropZone = (0, import_react29.forwardRef)(
|
4308
3965
|
function DropZone2(props, ref) {
|
4309
|
-
const ctx = (0,
|
3966
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4310
3967
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
4311
3968
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
4312
3969
|
}
|
@@ -4328,8 +3985,8 @@ var getZoneId = (zoneCompound) => {
|
|
4328
3985
|
|
4329
3986
|
// lib/dnd/NestedDroppablePlugin.ts
|
4330
3987
|
init_react_import();
|
4331
|
-
var
|
4332
|
-
var
|
3988
|
+
var import_abstract9 = require("@dnd-kit/abstract");
|
3989
|
+
var import_state = require("@dnd-kit/state");
|
4333
3990
|
|
4334
3991
|
// lib/throttle.ts
|
4335
3992
|
init_react_import();
|
@@ -4410,25 +4067,6 @@ var GlobalPosition = class {
|
|
4410
4067
|
}
|
4411
4068
|
};
|
4412
4069
|
|
4413
|
-
// lib/bubble-pointer-event.ts
|
4414
|
-
init_react_import();
|
4415
|
-
var BaseEvent = typeof PointerEvent !== "undefined" ? PointerEvent : Event;
|
4416
|
-
var BubbledPointerEvent = class extends BaseEvent {
|
4417
|
-
constructor(type, data) {
|
4418
|
-
super(type, data);
|
4419
|
-
this._originalTarget = null;
|
4420
|
-
this.originalTarget = data.originalTarget;
|
4421
|
-
}
|
4422
|
-
// Necessary for Firefox
|
4423
|
-
set originalTarget(target) {
|
4424
|
-
this._originalTarget = target;
|
4425
|
-
}
|
4426
|
-
// Necessary for Firefox
|
4427
|
-
get originalTarget() {
|
4428
|
-
return this._originalTarget;
|
4429
|
-
}
|
4430
|
-
};
|
4431
|
-
|
4432
4070
|
// lib/dnd/NestedDroppablePlugin.ts
|
4433
4071
|
var depthSort = (candidates) => {
|
4434
4072
|
return candidates.sort((a, b) => {
|
@@ -4545,15 +4183,15 @@ var findDeepestCandidate = (position, manager) => {
|
|
4545
4183
|
area: null
|
4546
4184
|
};
|
4547
4185
|
};
|
4548
|
-
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends
|
4186
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4549
4187
|
constructor(manager, options) {
|
4550
4188
|
super(manager);
|
4551
4189
|
if (typeof window === "undefined") {
|
4552
4190
|
return;
|
4553
4191
|
}
|
4554
|
-
const cleanupEffect = (0,
|
4192
|
+
const cleanupEffect = (0, import_state.effects)(() => {
|
4555
4193
|
const handleMove = (event) => {
|
4556
|
-
const target = event
|
4194
|
+
const target = event.originalTarget || event.target;
|
4557
4195
|
const position = new GlobalPosition(target, {
|
4558
4196
|
x: event.clientX,
|
4559
4197
|
y: event.clientY
|
@@ -4776,237 +4414,491 @@ function reduceData(data, action, config) {
|
|
4776
4414
|
})
|
4777
4415
|
});
|
4778
4416
|
}
|
4779
|
-
if (action.type === "reorder") {
|
4780
|
-
return reorderAction(data, action);
|
4417
|
+
if (action.type === "reorder") {
|
4418
|
+
return reorderAction(data, action);
|
4419
|
+
}
|
4420
|
+
if (action.type === "move") {
|
4421
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
4422
|
+
return data;
|
4423
|
+
}
|
4424
|
+
const newData = setupZone(
|
4425
|
+
setupZone(data, action.sourceZone),
|
4426
|
+
action.destinationZone
|
4427
|
+
);
|
4428
|
+
const item = getItem(
|
4429
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
4430
|
+
newData
|
4431
|
+
);
|
4432
|
+
if (action.sourceZone === action.destinationZone) {
|
4433
|
+
return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
|
4434
|
+
}
|
4435
|
+
if (action.sourceZone === rootDroppableId) {
|
4436
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4437
|
+
content: remove(newData.content, action.sourceIndex),
|
4438
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4439
|
+
[action.destinationZone]: insert(
|
4440
|
+
newData.zones[action.destinationZone],
|
4441
|
+
action.destinationIndex,
|
4442
|
+
item
|
4443
|
+
)
|
4444
|
+
})
|
4445
|
+
});
|
4446
|
+
}
|
4447
|
+
if (action.destinationZone === rootDroppableId) {
|
4448
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4449
|
+
content: insert(newData.content, action.destinationIndex, item),
|
4450
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4451
|
+
[action.sourceZone]: remove(
|
4452
|
+
newData.zones[action.sourceZone],
|
4453
|
+
action.sourceIndex
|
4454
|
+
)
|
4455
|
+
})
|
4456
|
+
});
|
4457
|
+
}
|
4458
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4459
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4460
|
+
[action.sourceZone]: remove(
|
4461
|
+
newData.zones[action.sourceZone],
|
4462
|
+
action.sourceIndex
|
4463
|
+
),
|
4464
|
+
[action.destinationZone]: insert(
|
4465
|
+
newData.zones[action.destinationZone],
|
4466
|
+
action.destinationIndex,
|
4467
|
+
item
|
4468
|
+
)
|
4469
|
+
})
|
4470
|
+
});
|
4471
|
+
}
|
4472
|
+
if (action.type === "replace") {
|
4473
|
+
return replaceAction(data, action);
|
4474
|
+
}
|
4475
|
+
if (action.type === "remove") {
|
4476
|
+
const item = getItem({ index: action.index, zone: action.zone }, data);
|
4477
|
+
const dataWithRelatedRemoved = setupZone(
|
4478
|
+
removeRelatedZones(item, data),
|
4479
|
+
action.zone
|
4480
|
+
);
|
4481
|
+
if (action.zone === rootDroppableId) {
|
4482
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
4483
|
+
content: remove(data.content, action.index)
|
4484
|
+
});
|
4485
|
+
}
|
4486
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
4487
|
+
zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
|
4488
|
+
[action.zone]: remove(
|
4489
|
+
dataWithRelatedRemoved.zones[action.zone],
|
4490
|
+
action.index
|
4491
|
+
)
|
4492
|
+
})
|
4493
|
+
});
|
4494
|
+
}
|
4495
|
+
if (action.type === "registerZone") {
|
4496
|
+
if (zoneCache[action.zone]) {
|
4497
|
+
return __spreadProps(__spreadValues({}, data), {
|
4498
|
+
zones: __spreadProps(__spreadValues({}, data.zones), {
|
4499
|
+
[action.zone]: zoneCache[action.zone]
|
4500
|
+
})
|
4501
|
+
});
|
4502
|
+
}
|
4503
|
+
return setupZone(data, action.zone);
|
4504
|
+
}
|
4505
|
+
if (action.type === "unregisterZone") {
|
4506
|
+
const _zones = __spreadValues({}, data.zones || {});
|
4507
|
+
if (_zones[action.zone]) {
|
4508
|
+
zoneCache[action.zone] = _zones[action.zone];
|
4509
|
+
delete _zones[action.zone];
|
4510
|
+
}
|
4511
|
+
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
4512
|
+
}
|
4513
|
+
if (action.type === "setData") {
|
4514
|
+
if (typeof action.data === "object") {
|
4515
|
+
return __spreadValues(__spreadValues({}, data), action.data);
|
4516
|
+
}
|
4517
|
+
return __spreadValues(__spreadValues({}, data), action.data(data));
|
4518
|
+
}
|
4519
|
+
return data;
|
4520
|
+
}
|
4521
|
+
|
4522
|
+
// reducer/state.ts
|
4523
|
+
init_react_import();
|
4524
|
+
var reduceUi = (ui, action) => {
|
4525
|
+
if (action.type === "setUi") {
|
4526
|
+
if (typeof action.ui === "object") {
|
4527
|
+
return __spreadValues(__spreadValues({}, ui), action.ui);
|
4528
|
+
}
|
4529
|
+
return __spreadValues(__spreadValues({}, ui), action.ui(ui));
|
4530
|
+
}
|
4531
|
+
if (action.type === "duplicate") {
|
4532
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4533
|
+
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4534
|
+
});
|
4535
|
+
}
|
4536
|
+
if (action.type === "remove") {
|
4537
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4538
|
+
itemSelector: null
|
4539
|
+
});
|
4540
|
+
}
|
4541
|
+
return ui;
|
4542
|
+
};
|
4543
|
+
|
4544
|
+
// reducer/actions.tsx
|
4545
|
+
init_react_import();
|
4546
|
+
|
4547
|
+
// reducer/index.ts
|
4548
|
+
function storeInterceptor(reducer, record, onAction) {
|
4549
|
+
return (state, action) => {
|
4550
|
+
const newAppState = reducer(state, action);
|
4551
|
+
const isValidType = ![
|
4552
|
+
"registerZone",
|
4553
|
+
"unregisterZone",
|
4554
|
+
"setData",
|
4555
|
+
"setUi",
|
4556
|
+
"set"
|
4557
|
+
].includes(action.type);
|
4558
|
+
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
4559
|
+
if (record) record(newAppState);
|
4560
|
+
}
|
4561
|
+
onAction == null ? void 0 : onAction(action, newAppState, state);
|
4562
|
+
return newAppState;
|
4563
|
+
};
|
4564
|
+
}
|
4565
|
+
var setAction = (state, action) => {
|
4566
|
+
if (typeof action.state === "object") {
|
4567
|
+
return __spreadValues(__spreadValues({}, state), action.state);
|
4568
|
+
}
|
4569
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
4570
|
+
};
|
4571
|
+
function createReducer({
|
4572
|
+
config,
|
4573
|
+
record,
|
4574
|
+
onAction
|
4575
|
+
}) {
|
4576
|
+
return storeInterceptor(
|
4577
|
+
(state, action) => {
|
4578
|
+
const data = reduceData(state.data, action, config);
|
4579
|
+
const ui = reduceUi(state.ui, action);
|
4580
|
+
if (action.type === "set") {
|
4581
|
+
return setAction(state, action);
|
4582
|
+
}
|
4583
|
+
return { data, ui };
|
4584
|
+
},
|
4585
|
+
record,
|
4586
|
+
onAction
|
4587
|
+
);
|
4588
|
+
}
|
4589
|
+
|
4590
|
+
// lib/insert-component.ts
|
4591
|
+
var insertComponent = (componentType, zone, index, {
|
4592
|
+
config,
|
4593
|
+
dispatch,
|
4594
|
+
resolveData,
|
4595
|
+
state
|
4596
|
+
}) => {
|
4597
|
+
const id = generateId(componentType);
|
4598
|
+
const insertActionData = {
|
4599
|
+
type: "insert",
|
4600
|
+
componentType,
|
4601
|
+
destinationIndex: index,
|
4602
|
+
destinationZone: zone,
|
4603
|
+
id
|
4604
|
+
};
|
4605
|
+
const insertedData = insertAction(state.data, insertActionData, config);
|
4606
|
+
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
4607
|
+
// Dispatch insert rather set, as user's may rely on this via onAction
|
4608
|
+
// We must always record history here so the insert is added to user history
|
4609
|
+
// If the user has defined a resolveData method, they will end up with 2 history
|
4610
|
+
// entries on insert - one for the initial insert, and one when the data resolves
|
4611
|
+
recordHistory: true
|
4612
|
+
}));
|
4613
|
+
const itemSelector = {
|
4614
|
+
index,
|
4615
|
+
zone
|
4616
|
+
};
|
4617
|
+
dispatch({ type: "setUi", ui: { itemSelector } });
|
4618
|
+
resolveData({
|
4619
|
+
data: insertedData,
|
4620
|
+
ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
|
4621
|
+
});
|
4622
|
+
};
|
4623
|
+
|
4624
|
+
// components/DragDropContext/index.tsx
|
4625
|
+
var import_use_debounce2 = require("use-debounce");
|
4626
|
+
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
4627
|
+
|
4628
|
+
// lib/dnd/PointerSensor.ts
|
4629
|
+
init_react_import();
|
4630
|
+
var import_state3 = require("@dnd-kit/state");
|
4631
|
+
var import_abstract10 = require("@dnd-kit/abstract");
|
4632
|
+
var import_geometry8 = require("@dnd-kit/geometry");
|
4633
|
+
var import_utilities = require("@dnd-kit/dom/utilities");
|
4634
|
+
var _clearTimeout;
|
4635
|
+
var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
|
4636
|
+
constructor(manager, options) {
|
4637
|
+
super(manager);
|
4638
|
+
this.manager = manager;
|
4639
|
+
this.options = options;
|
4640
|
+
this.listeners = new import_utilities.Listeners();
|
4641
|
+
this.cleanup = /* @__PURE__ */ new Set();
|
4642
|
+
this.source = void 0;
|
4643
|
+
__privateAdd(this, _clearTimeout);
|
4644
|
+
this.handleCancel = this.handleCancel.bind(this);
|
4645
|
+
this.handlePointerUp = this.handlePointerUp.bind(this);
|
4646
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
4647
|
+
(0, import_state3.effect)(() => {
|
4648
|
+
const unbindGlobal = this.bindGlobal(options != null ? options : {});
|
4649
|
+
return () => {
|
4650
|
+
unbindGlobal();
|
4651
|
+
};
|
4652
|
+
});
|
4653
|
+
}
|
4654
|
+
bind(source, options = this.options) {
|
4655
|
+
const unbind = (0, import_state3.effect)(() => {
|
4656
|
+
var _a;
|
4657
|
+
const target = (_a = source.handle) != null ? _a : source.element;
|
4658
|
+
const listener = (event) => {
|
4659
|
+
if ((0, import_utilities.isPointerEvent)(event)) {
|
4660
|
+
this.handlePointerDown(event, source, options);
|
4661
|
+
}
|
4662
|
+
};
|
4663
|
+
if (target) {
|
4664
|
+
patchWindow(target.ownerDocument.defaultView);
|
4665
|
+
target.addEventListener("pointerdown", listener);
|
4666
|
+
return () => {
|
4667
|
+
target.removeEventListener("pointerdown", listener);
|
4668
|
+
};
|
4669
|
+
}
|
4670
|
+
});
|
4671
|
+
return unbind;
|
4781
4672
|
}
|
4782
|
-
|
4783
|
-
|
4784
|
-
|
4673
|
+
bindGlobal(options) {
|
4674
|
+
const documents = /* @__PURE__ */ new Set();
|
4675
|
+
for (const draggable of this.manager.registry.draggables.value) {
|
4676
|
+
if (draggable.element) {
|
4677
|
+
documents.add((0, import_utilities.getDocument)(draggable.element));
|
4678
|
+
}
|
4785
4679
|
}
|
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" }));
|
4680
|
+
for (const droppable of this.manager.registry.droppables.value) {
|
4681
|
+
if (droppable.element) {
|
4682
|
+
documents.add((0, import_utilities.getDocument)(droppable.element));
|
4683
|
+
}
|
4796
4684
|
}
|
4797
|
-
|
4798
|
-
|
4799
|
-
|
4800
|
-
|
4801
|
-
|
4802
|
-
|
4803
|
-
|
4804
|
-
|
4805
|
-
|
4806
|
-
|
4807
|
-
|
4685
|
+
const unbindFns = Array.from(documents).map(
|
4686
|
+
(doc) => this.listeners.bind(doc, [
|
4687
|
+
{
|
4688
|
+
type: "pointermove",
|
4689
|
+
listener: (event) => this.handlePointerMove(event, doc, options)
|
4690
|
+
},
|
4691
|
+
{
|
4692
|
+
type: "pointerup",
|
4693
|
+
listener: this.handlePointerUp,
|
4694
|
+
options: {
|
4695
|
+
capture: true
|
4696
|
+
}
|
4697
|
+
},
|
4698
|
+
{
|
4699
|
+
// Cancel activation if there is a competing Drag and Drop interaction
|
4700
|
+
type: "dragstart",
|
4701
|
+
listener: this.handleDragStart
|
4702
|
+
}
|
4703
|
+
])
|
4704
|
+
);
|
4705
|
+
return () => {
|
4706
|
+
unbindFns.forEach((unbind) => unbind());
|
4707
|
+
};
|
4708
|
+
}
|
4709
|
+
handlePointerDown(event, source, options = {}) {
|
4710
|
+
if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
|
4711
|
+
return;
|
4808
4712
|
}
|
4809
|
-
|
4810
|
-
|
4811
|
-
|
4812
|
-
|
4813
|
-
|
4814
|
-
|
4815
|
-
|
4816
|
-
|
4817
|
-
|
4818
|
-
|
4713
|
+
const offset = (0, import_utilities.getFrameTransform)(source.element);
|
4714
|
+
this.initialCoordinates = {
|
4715
|
+
x: event.clientX * offset.scaleX + offset.x,
|
4716
|
+
y: event.clientY * offset.scaleY + offset.y
|
4717
|
+
};
|
4718
|
+
this.source = source;
|
4719
|
+
const { activationConstraints } = options;
|
4720
|
+
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
4721
|
+
event.stopImmediatePropagation();
|
4722
|
+
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
4723
|
+
this.handleStart(source, event);
|
4724
|
+
} else {
|
4725
|
+
const { delay } = constraints;
|
4726
|
+
if (delay) {
|
4727
|
+
const timeout3 = setTimeout(
|
4728
|
+
() => this.handleStart(source, event),
|
4729
|
+
delay.value
|
4730
|
+
);
|
4731
|
+
__privateSet(this, _clearTimeout, () => {
|
4732
|
+
clearTimeout(timeout3);
|
4733
|
+
__privateSet(this, _clearTimeout, void 0);
|
4734
|
+
});
|
4735
|
+
}
|
4819
4736
|
}
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
|
4824
|
-
|
4825
|
-
|
4826
|
-
|
4827
|
-
newData.zones[action.destinationZone],
|
4828
|
-
action.destinationIndex,
|
4829
|
-
item
|
4830
|
-
)
|
4831
|
-
})
|
4832
|
-
});
|
4737
|
+
const cleanup = () => {
|
4738
|
+
var _a;
|
4739
|
+
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
4740
|
+
this.initialCoordinates = void 0;
|
4741
|
+
this.source = void 0;
|
4742
|
+
};
|
4743
|
+
this.cleanup.add(cleanup);
|
4833
4744
|
}
|
4834
|
-
|
4835
|
-
|
4745
|
+
handlePointerMove(event, doc, options) {
|
4746
|
+
if (!this.source) {
|
4747
|
+
return;
|
4748
|
+
}
|
4749
|
+
const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
|
4750
|
+
if (doc !== ownerDocument) {
|
4751
|
+
return;
|
4752
|
+
}
|
4753
|
+
const coordinates = {
|
4754
|
+
x: event.clientX,
|
4755
|
+
y: event.clientY
|
4756
|
+
};
|
4757
|
+
const offset = (0, import_utilities.getFrameTransform)(this.source.element);
|
4758
|
+
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
4759
|
+
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
4760
|
+
if (this.manager.dragOperation.status.dragging) {
|
4761
|
+
event.preventDefault();
|
4762
|
+
event.stopPropagation();
|
4763
|
+
this.manager.actions.move({ to: coordinates });
|
4764
|
+
return;
|
4765
|
+
}
|
4766
|
+
if (!this.initialCoordinates) {
|
4767
|
+
return;
|
4768
|
+
}
|
4769
|
+
const delta = {
|
4770
|
+
x: coordinates.x - this.initialCoordinates.x,
|
4771
|
+
y: coordinates.y - this.initialCoordinates.y
|
4772
|
+
};
|
4773
|
+
const { activationConstraints } = options;
|
4774
|
+
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
|
4775
|
+
const { distance, delay } = constraints != null ? constraints : {};
|
4776
|
+
if (distance) {
|
4777
|
+
if (distance.tolerance != null && (0, import_geometry8.exceedsDistance)(delta, distance.tolerance)) {
|
4778
|
+
return this.handleCancel();
|
4779
|
+
}
|
4780
|
+
if ((0, import_geometry8.exceedsDistance)(delta, distance.value)) {
|
4781
|
+
return this.handleStart(this.source, event);
|
4782
|
+
}
|
4783
|
+
}
|
4784
|
+
if (delay) {
|
4785
|
+
if ((0, import_geometry8.exceedsDistance)(delta, delay.tolerance)) {
|
4786
|
+
return this.handleCancel();
|
4787
|
+
}
|
4788
|
+
}
|
4836
4789
|
}
|
4837
|
-
|
4838
|
-
|
4839
|
-
|
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
|
-
});
|
4790
|
+
handlePointerUp(event) {
|
4791
|
+
if (!this.source) {
|
4792
|
+
return;
|
4847
4793
|
}
|
4848
|
-
|
4849
|
-
|
4850
|
-
|
4851
|
-
|
4852
|
-
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4794
|
+
event.preventDefault();
|
4795
|
+
event.stopPropagation();
|
4796
|
+
const { status } = this.manager.dragOperation;
|
4797
|
+
if (!status.idle) {
|
4798
|
+
const canceled = !status.initialized;
|
4799
|
+
this.manager.actions.stop({ canceled });
|
4800
|
+
}
|
4801
|
+
this.cleanup.forEach((cleanup) => cleanup());
|
4802
|
+
this.cleanup.clear();
|
4856
4803
|
}
|
4857
|
-
|
4858
|
-
if (
|
4859
|
-
|
4860
|
-
|
4861
|
-
[action.zone]: zoneCache[action.zone]
|
4862
|
-
})
|
4863
|
-
});
|
4804
|
+
handleKeyDown(event) {
|
4805
|
+
if (event.key === "Escape") {
|
4806
|
+
event.preventDefault();
|
4807
|
+
this.handleCancel();
|
4864
4808
|
}
|
4865
|
-
return setupZone(data, action.zone);
|
4866
4809
|
}
|
4867
|
-
|
4868
|
-
|
4869
|
-
|
4870
|
-
|
4871
|
-
|
4810
|
+
handleStart(source, event) {
|
4811
|
+
var _a;
|
4812
|
+
const { manager, initialCoordinates } = this;
|
4813
|
+
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
4814
|
+
if (!initialCoordinates || manager.dragOperation.status.initialized) {
|
4815
|
+
return;
|
4816
|
+
}
|
4817
|
+
if (event.defaultPrevented) {
|
4818
|
+
return;
|
4872
4819
|
}
|
4873
|
-
|
4820
|
+
event.preventDefault();
|
4821
|
+
(0, import_state3.batch)(() => {
|
4822
|
+
manager.actions.setDragSource(source.id);
|
4823
|
+
manager.actions.start({ coordinates: initialCoordinates, event });
|
4824
|
+
});
|
4825
|
+
const ownerDocument = (0, import_utilities.getDocument)(event.target);
|
4826
|
+
const unbind = this.listeners.bind(ownerDocument, [
|
4827
|
+
{
|
4828
|
+
// Prevent scrolling on touch devices
|
4829
|
+
type: "touchmove",
|
4830
|
+
listener: preventDefault,
|
4831
|
+
options: {
|
4832
|
+
passive: false
|
4833
|
+
}
|
4834
|
+
},
|
4835
|
+
{
|
4836
|
+
// Prevent click events
|
4837
|
+
type: "click",
|
4838
|
+
listener: preventDefault
|
4839
|
+
},
|
4840
|
+
{
|
4841
|
+
type: "keydown",
|
4842
|
+
listener: this.handleKeyDown
|
4843
|
+
}
|
4844
|
+
]);
|
4845
|
+
ownerDocument.body.setPointerCapture(event.pointerId);
|
4846
|
+
this.cleanup.add(unbind);
|
4874
4847
|
}
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4848
|
+
handleDragStart(event) {
|
4849
|
+
const { target } = event;
|
4850
|
+
if (!(0, import_utilities.isElement)(target)) {
|
4851
|
+
return;
|
4878
4852
|
}
|
4879
|
-
|
4880
|
-
|
4881
|
-
|
4882
|
-
}
|
4883
|
-
|
4884
|
-
// reducer/state.ts
|
4885
|
-
init_react_import();
|
4886
|
-
var reduceUi = (ui, action) => {
|
4887
|
-
if (action.type === "setUi") {
|
4888
|
-
if (typeof action.ui === "object") {
|
4889
|
-
return __spreadValues(__spreadValues({}, ui), action.ui);
|
4853
|
+
const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
|
4854
|
+
if (isNativeDraggable) {
|
4855
|
+
this.handleCancel();
|
4856
|
+
} else {
|
4857
|
+
preventDefault(event);
|
4890
4858
|
}
|
4891
|
-
return __spreadValues(__spreadValues({}, ui), action.ui(ui));
|
4892
4859
|
}
|
4893
|
-
|
4894
|
-
|
4895
|
-
|
4896
|
-
|
4860
|
+
handleCancel() {
|
4861
|
+
const { dragOperation } = this.manager;
|
4862
|
+
if (dragOperation.status.initialized) {
|
4863
|
+
this.manager.actions.stop({ canceled: true });
|
4864
|
+
}
|
4865
|
+
this.cleanup.forEach((cleanup) => cleanup());
|
4866
|
+
this.cleanup.clear();
|
4897
4867
|
}
|
4898
|
-
|
4899
|
-
|
4900
|
-
itemSelector: null
|
4901
|
-
});
|
4868
|
+
destroy() {
|
4869
|
+
this.listeners.clear();
|
4902
4870
|
}
|
4903
|
-
return ui;
|
4904
4871
|
};
|
4905
|
-
|
4906
|
-
|
4907
|
-
|
4908
|
-
|
4909
|
-
|
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);
|
4922
|
-
}
|
4923
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
4924
|
-
return newAppState;
|
4925
|
-
};
|
4872
|
+
_clearTimeout = new WeakMap();
|
4873
|
+
_PointerSensor.configure = (0, import_abstract10.configurator)(_PointerSensor);
|
4874
|
+
var PointerSensor = _PointerSensor;
|
4875
|
+
function preventDefault(event) {
|
4876
|
+
event.preventDefault();
|
4926
4877
|
}
|
4927
|
-
|
4928
|
-
if (typeof action.state === "object") {
|
4929
|
-
return __spreadValues(__spreadValues({}, state), action.state);
|
4930
|
-
}
|
4931
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
4932
|
-
};
|
4933
|
-
function createReducer({
|
4934
|
-
config,
|
4935
|
-
record,
|
4936
|
-
onAction
|
4937
|
-
}) {
|
4938
|
-
return storeInterceptor(
|
4939
|
-
(state, action) => {
|
4940
|
-
const data = reduceData(state.data, action, config);
|
4941
|
-
const ui = reduceUi(state.ui, action);
|
4942
|
-
if (action.type === "set") {
|
4943
|
-
return setAction(state, action);
|
4944
|
-
}
|
4945
|
-
return { data, ui };
|
4946
|
-
},
|
4947
|
-
record,
|
4948
|
-
onAction
|
4949
|
-
);
|
4878
|
+
function noop() {
|
4950
4879
|
}
|
4951
|
-
|
4952
|
-
|
4953
|
-
|
4954
|
-
|
4955
|
-
dispatch,
|
4956
|
-
resolveData,
|
4957
|
-
state
|
4958
|
-
}) => {
|
4959
|
-
const id = generateId(componentType);
|
4960
|
-
const insertActionData = {
|
4961
|
-
type: "insert",
|
4962
|
-
componentType,
|
4963
|
-
destinationIndex: index,
|
4964
|
-
destinationZone: zone,
|
4965
|
-
id
|
4966
|
-
};
|
4967
|
-
const insertedData = insertAction(state.data, insertActionData, config);
|
4968
|
-
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
4969
|
-
// Dispatch insert rather set, as user's may rely on this via onAction
|
4970
|
-
// We must always record history here so the insert is added to user history
|
4971
|
-
// If the user has defined a resolveData method, they will end up with 2 history
|
4972
|
-
// entries on insert - one for the initial insert, and one when the data resolves
|
4973
|
-
recordHistory: true
|
4974
|
-
}));
|
4975
|
-
const itemSelector = {
|
4976
|
-
index,
|
4977
|
-
zone
|
4978
|
-
};
|
4979
|
-
dispatch({ type: "setUi", ui: { itemSelector } });
|
4980
|
-
resolveData({
|
4981
|
-
data: insertedData,
|
4982
|
-
ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
|
4983
|
-
});
|
4984
|
-
};
|
4985
|
-
|
4986
|
-
// components/DragDropContext/index.tsx
|
4987
|
-
var import_use_debounce2 = require("use-debounce");
|
4988
|
-
var import_zustand3 = require("zustand");
|
4989
|
-
|
4990
|
-
// lib/get-deep-dir.ts
|
4991
|
-
init_react_import();
|
4992
|
-
function getDeepDir(el) {
|
4993
|
-
function findDir(node) {
|
4994
|
-
if (!node) return "ltr";
|
4995
|
-
const d = node.getAttribute("dir");
|
4996
|
-
return d || findDir(node.parentElement);
|
4880
|
+
var windows = /* @__PURE__ */ new WeakSet();
|
4881
|
+
function patchWindow(window2) {
|
4882
|
+
if (!window2 || windows.has(window2)) {
|
4883
|
+
return;
|
4997
4884
|
}
|
4998
|
-
|
4885
|
+
window2.addEventListener("touchmove", noop, {
|
4886
|
+
capture: false,
|
4887
|
+
passive: false
|
4888
|
+
});
|
4889
|
+
windows.add(window2);
|
4999
4890
|
}
|
5000
4891
|
|
5001
4892
|
// components/DragDropContext/index.tsx
|
4893
|
+
var import_zustand3 = require("zustand");
|
5002
4894
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5003
4895
|
var DEBUG3 = false;
|
5004
|
-
var dragListenerContext = (0,
|
4896
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
5005
4897
|
dragListeners: {}
|
5006
4898
|
});
|
5007
4899
|
function useDragListener(type, fn, deps = []) {
|
5008
|
-
const { setDragListeners } = (0,
|
5009
|
-
(0,
|
4900
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
4901
|
+
(0, import_react31.useEffect)(() => {
|
5010
4902
|
if (setDragListeners) {
|
5011
4903
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5012
4904
|
[type]: [...old[type] || [], fn]
|
@@ -5016,8 +4908,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5016
4908
|
}
|
5017
4909
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5018
4910
|
var useTempDisableFallback = (timeout3) => {
|
5019
|
-
const lastFallbackDisable = (0,
|
5020
|
-
return (0,
|
4911
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
4912
|
+
return (0, import_react31.useCallback)((manager) => {
|
5021
4913
|
collisionStore.setState({ fallbackEnabled: false });
|
5022
4914
|
const fallbackId = generateId();
|
5023
4915
|
lastFallbackDisable.current = fallbackId;
|
@@ -5034,11 +4926,11 @@ var DragDropContextClient = ({
|
|
5034
4926
|
disableAutoScroll
|
5035
4927
|
}) => {
|
5036
4928
|
const { state, config, dispatch, resolveData } = useAppContext();
|
5037
|
-
const id = (0,
|
4929
|
+
const id = (0, import_react31.useId)();
|
5038
4930
|
const { data } = state;
|
5039
|
-
const debouncedParamsRef = (0,
|
4931
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
5040
4932
|
const tempDisableFallback = useTempDisableFallback(100);
|
5041
|
-
const [zoneStore] = (0,
|
4933
|
+
const [zoneStore] = (0, import_react31.useState)(
|
5042
4934
|
() => (0, import_zustand3.createStore)(() => ({
|
5043
4935
|
zoneDepthIndex: {},
|
5044
4936
|
nextZoneDepthIndex: {},
|
@@ -5048,7 +4940,7 @@ var DragDropContextClient = ({
|
|
5048
4940
|
previewIndex: {}
|
5049
4941
|
}))
|
5050
4942
|
);
|
5051
|
-
const getChanged2 = (0,
|
4943
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
5052
4944
|
(params, id2) => {
|
5053
4945
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5054
4946
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5069,7 +4961,7 @@ var DragDropContextClient = ({
|
|
5069
4961
|
},
|
5070
4962
|
[zoneStore]
|
5071
4963
|
);
|
5072
|
-
const setDeepestAndCollide = (0,
|
4964
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
5073
4965
|
(params, manager) => {
|
5074
4966
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5075
4967
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5093,7 +4985,7 @@ var DragDropContextClient = ({
|
|
5093
4985
|
setDeepestDb.cancel();
|
5094
4986
|
debouncedParamsRef.current = null;
|
5095
4987
|
};
|
5096
|
-
(0,
|
4988
|
+
(0, import_react31.useEffect)(() => {
|
5097
4989
|
if (DEBUG3) {
|
5098
4990
|
zoneStore.subscribe(
|
5099
4991
|
(s) => {
|
@@ -5107,7 +4999,7 @@ var DragDropContextClient = ({
|
|
5107
4999
|
);
|
5108
5000
|
}
|
5109
5001
|
}, []);
|
5110
|
-
const [plugins] = (0,
|
5002
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
5111
5003
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5112
5004
|
createNestedDroppablePlugin(
|
5113
5005
|
{
|
@@ -5154,11 +5046,29 @@ var DragDropContextClient = ({
|
|
5154
5046
|
id
|
5155
5047
|
)
|
5156
5048
|
]);
|
5157
|
-
const sensors =
|
5158
|
-
|
5159
|
-
|
5160
|
-
|
5161
|
-
|
5049
|
+
const [sensors] = (0, import_react31.useState)(() => [
|
5050
|
+
PointerSensor.configure({
|
5051
|
+
activationConstraints(event, source) {
|
5052
|
+
var _a;
|
5053
|
+
const { pointerType, target } = event;
|
5054
|
+
if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
5055
|
+
return void 0;
|
5056
|
+
}
|
5057
|
+
const delay = { value: 200, tolerance: 10 };
|
5058
|
+
if (pointerType === "touch") {
|
5059
|
+
return { delay };
|
5060
|
+
}
|
5061
|
+
return {
|
5062
|
+
delay,
|
5063
|
+
distance: { value: 5 }
|
5064
|
+
};
|
5065
|
+
}
|
5066
|
+
})
|
5067
|
+
]);
|
5068
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
5069
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
5070
|
+
const dragMode = (0, import_react31.useRef)(null);
|
5071
|
+
const registerPath = (0, import_react31.useCallback)(
|
5162
5072
|
(id2, selector, label) => {
|
5163
5073
|
const [area] = getZoneId(selector.zone);
|
5164
5074
|
setPathData((latestPathData = {}) => {
|
@@ -5176,7 +5086,7 @@ var DragDropContextClient = ({
|
|
5176
5086
|
},
|
5177
5087
|
[data, setPathData]
|
5178
5088
|
);
|
5179
|
-
const unregisterPath = (0,
|
5089
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5180
5090
|
(id2) => {
|
5181
5091
|
setPathData((latestPathData = {}) => {
|
5182
5092
|
const newPathData = __spreadValues({}, latestPathData);
|
@@ -5186,7 +5096,7 @@ var DragDropContextClient = ({
|
|
5186
5096
|
},
|
5187
5097
|
[data, setPathData]
|
5188
5098
|
);
|
5189
|
-
const initialSelector = (0,
|
5099
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5190
5100
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5191
5101
|
dragListenerContext.Provider,
|
5192
5102
|
{
|
@@ -5195,7 +5105,7 @@ var DragDropContextClient = ({
|
|
5195
5105
|
setDragListeners
|
5196
5106
|
},
|
5197
5107
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5198
|
-
|
5108
|
+
import_react30.DragDropProvider,
|
5199
5109
|
{
|
5200
5110
|
plugins,
|
5201
5111
|
sensors,
|
@@ -5217,13 +5127,6 @@ var DragDropContextClient = ({
|
|
5217
5127
|
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
5218
5128
|
fn(event, manager);
|
5219
5129
|
});
|
5220
|
-
dispatch({
|
5221
|
-
type: "setUi",
|
5222
|
-
ui: {
|
5223
|
-
itemSelector: null,
|
5224
|
-
isDragging: false
|
5225
|
-
}
|
5226
|
-
});
|
5227
5130
|
return;
|
5228
5131
|
}
|
5229
5132
|
if (thisPreview) {
|
@@ -5281,8 +5184,7 @@ var DragDropContextClient = ({
|
|
5281
5184
|
targetZone = targetData.zone;
|
5282
5185
|
targetIndex = targetData.index;
|
5283
5186
|
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";
|
5187
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
5286
5188
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
5287
5189
|
targetIndex = targetIndex - 1;
|
5288
5190
|
}
|
@@ -5424,7 +5326,7 @@ var DrawerItemInner = ({
|
|
5424
5326
|
dragRef,
|
5425
5327
|
isDragDisabled
|
5426
5328
|
}) => {
|
5427
|
-
const CustomInner = (0,
|
5329
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5428
5330
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5429
5331
|
[children]
|
5430
5332
|
);
|
@@ -5478,7 +5380,7 @@ var DrawerItem = ({
|
|
5478
5380
|
isDragDisabled
|
5479
5381
|
}) => {
|
5480
5382
|
const resolvedId = id || name;
|
5481
|
-
const [dynamicId, setDynamicId] = (0,
|
5383
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5482
5384
|
if (typeof index !== "undefined") {
|
5483
5385
|
console.error(
|
5484
5386
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5517,7 +5419,7 @@ var Drawer = ({
|
|
5517
5419
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5518
5420
|
);
|
5519
5421
|
}
|
5520
|
-
const id = (0,
|
5422
|
+
const id = (0, import_react32.useId)();
|
5521
5423
|
const { ref } = useDroppableSafe({
|
5522
5424
|
id,
|
5523
5425
|
type: "void",
|
@@ -5539,18 +5441,18 @@ Drawer.Item = DrawerItem;
|
|
5539
5441
|
|
5540
5442
|
// components/Puck/index.tsx
|
5541
5443
|
init_react_import();
|
5542
|
-
var
|
5444
|
+
var import_react50 = require("react");
|
5543
5445
|
|
5544
5446
|
// components/SidebarSection/index.tsx
|
5545
5447
|
init_react_import();
|
5546
5448
|
|
5547
5449
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
5548
5450
|
init_react_import();
|
5549
|
-
var styles_module_default13 = { "SidebarSection": "
|
5451
|
+
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
5452
|
|
5551
5453
|
// lib/use-breadcrumbs.ts
|
5552
5454
|
init_react_import();
|
5553
|
-
var
|
5455
|
+
var import_react33 = require("react");
|
5554
5456
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5555
5457
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5556
5458
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5600,8 +5502,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5600
5502
|
state: { data },
|
5601
5503
|
selectedItem
|
5602
5504
|
} = useAppContext();
|
5603
|
-
const dzContext = (0,
|
5604
|
-
return (0,
|
5505
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5506
|
+
return (0, import_react33.useMemo)(() => {
|
5605
5507
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5606
5508
|
selectedItem,
|
5607
5509
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5725,7 +5627,7 @@ function MenuBar({
|
|
5725
5627
|
|
5726
5628
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5727
5629
|
init_react_import();
|
5728
|
-
var styles_module_default15 = { "Puck": "
|
5630
|
+
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
5631
|
|
5730
5632
|
// components/Puck/components/Fields/index.tsx
|
5731
5633
|
init_react_import();
|
@@ -5735,15 +5637,15 @@ init_react_import();
|
|
5735
5637
|
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
5638
|
|
5737
5639
|
// components/Puck/components/Fields/index.tsx
|
5738
|
-
var
|
5640
|
+
var import_react37 = require("react");
|
5739
5641
|
|
5740
5642
|
// lib/use-resolved-fields.ts
|
5741
5643
|
init_react_import();
|
5742
|
-
var
|
5644
|
+
var import_react36 = require("react");
|
5743
5645
|
|
5744
5646
|
// lib/use-parent.ts
|
5745
5647
|
init_react_import();
|
5746
|
-
var
|
5648
|
+
var import_react34 = require("react");
|
5747
5649
|
var getParent = (itemSelector, pathData, data) => {
|
5748
5650
|
var _a;
|
5749
5651
|
if (!itemSelector) return null;
|
@@ -5755,8 +5657,8 @@ var getParent = (itemSelector, pathData, data) => {
|
|
5755
5657
|
};
|
5756
5658
|
var useGetParent = () => {
|
5757
5659
|
const { state } = useAppContext();
|
5758
|
-
const { pathData } = (0,
|
5759
|
-
return (0,
|
5660
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5661
|
+
return (0, import_react34.useCallback)(
|
5760
5662
|
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5761
5663
|
[state.ui.itemSelector, pathData, state.data]
|
5762
5664
|
);
|
@@ -5767,10 +5669,10 @@ var useParent = () => {
|
|
5767
5669
|
|
5768
5670
|
// lib/use-on-value-change.ts
|
5769
5671
|
init_react_import();
|
5770
|
-
var
|
5672
|
+
var import_react35 = require("react");
|
5771
5673
|
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5772
|
-
const tracked = (0,
|
5773
|
-
(0,
|
5674
|
+
const tracked = (0, import_react35.useRef)(value);
|
5675
|
+
(0, import_react35.useEffect)(() => {
|
5774
5676
|
const oldValue = tracked.current;
|
5775
5677
|
if (!compare(value, oldValue)) {
|
5776
5678
|
tracked.current = value;
|
@@ -5787,37 +5689,28 @@ var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0
|
|
5787
5689
|
var defaultPageFields = {
|
5788
5690
|
title: { type: "text" }
|
5789
5691
|
};
|
5790
|
-
var useResolvedFields = ({
|
5791
|
-
_skipValueCheck,
|
5792
|
-
_skipIdCheck
|
5793
|
-
} = {}) => {
|
5692
|
+
var useResolvedFields = () => {
|
5794
5693
|
var _a, _b;
|
5795
5694
|
const { selectedItem, state, config } = useAppContext();
|
5796
5695
|
const parent = useParent();
|
5797
5696
|
const { data } = state;
|
5798
5697
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5799
5698
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5800
|
-
const defaultFields = (0,
|
5699
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5801
5700
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5802
5701
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5803
5702
|
);
|
5804
5703
|
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);
|
5704
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5705
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
|
5706
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5707
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5812
5708
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5813
|
-
const componentData =
|
5814
|
-
() => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
|
5815
|
-
[selectedItem, rootProps, data.root.readOnly]
|
5816
|
-
);
|
5709
|
+
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5817
5710
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5818
5711
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5819
5712
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5820
|
-
const resolveFields = (0,
|
5713
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5821
5714
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5822
5715
|
var _a2;
|
5823
5716
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5855,31 +5748,21 @@ var useResolvedFields = ({
|
|
5855
5748
|
}),
|
5856
5749
|
[data, config, componentData, selectedItem, state, parent]
|
5857
5750
|
);
|
5858
|
-
const triggerResolver = (0,
|
5751
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5859
5752
|
var _a2, _b2;
|
5860
5753
|
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5861
5754
|
if (hasResolver) {
|
5862
5755
|
setFieldsLoading(true);
|
5863
5756
|
resolveFields(defaultFields).then((fields) => {
|
5864
|
-
setResolvedFields({
|
5865
|
-
fields: fields || {},
|
5866
|
-
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5867
|
-
});
|
5757
|
+
setResolvedFields(fields || {});
|
5868
5758
|
lastFields.current = fields;
|
5869
5759
|
setFieldsLoading(false);
|
5870
5760
|
});
|
5871
5761
|
return;
|
5872
5762
|
}
|
5873
5763
|
}
|
5874
|
-
setResolvedFields(
|
5875
|
-
}, [
|
5876
|
-
defaultFields,
|
5877
|
-
state.ui.itemSelector,
|
5878
|
-
selectedItem,
|
5879
|
-
hasResolver,
|
5880
|
-
parent,
|
5881
|
-
resolveFields
|
5882
|
-
]);
|
5764
|
+
setResolvedFields(defaultFields);
|
5765
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5883
5766
|
useOnValueChange(
|
5884
5767
|
state.ui.itemSelector,
|
5885
5768
|
() => {
|
@@ -5890,18 +5773,14 @@ var useResolvedFields = ({
|
|
5890
5773
|
useOnValueChange(
|
5891
5774
|
{ data, parent, itemSelector: state.ui.itemSelector },
|
5892
5775
|
() => {
|
5893
|
-
if (_skipValueCheck) return;
|
5894
5776
|
triggerResolver();
|
5895
5777
|
},
|
5896
5778
|
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5897
5779
|
);
|
5898
|
-
(0,
|
5780
|
+
(0, import_react36.useEffect)(() => {
|
5899
5781
|
triggerResolver();
|
5900
5782
|
}, []);
|
5901
|
-
|
5902
|
-
return [defaultFields, fieldsLoading];
|
5903
|
-
}
|
5904
|
-
return [resolvedFields.fields, fieldsLoading];
|
5783
|
+
return [resolvedFields, fieldsLoading];
|
5905
5784
|
};
|
5906
5785
|
|
5907
5786
|
// components/Puck/components/Fields/index.tsx
|
@@ -5930,7 +5809,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
5930
5809
|
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
5810
|
const isLoading = fieldsResolving || componentResolving;
|
5932
5811
|
const rootProps = data.root.props || data.root;
|
5933
|
-
const Wrapper = (0,
|
5812
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5934
5813
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5935
5814
|
"form",
|
5936
5815
|
{
|
@@ -6051,14 +5930,14 @@ init_react_import();
|
|
6051
5930
|
|
6052
5931
|
// lib/use-component-list.tsx
|
6053
5932
|
init_react_import();
|
6054
|
-
var
|
5933
|
+
var import_react38 = require("react");
|
6055
5934
|
|
6056
5935
|
// components/ComponentList/index.tsx
|
6057
5936
|
init_react_import();
|
6058
5937
|
|
6059
5938
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
6060
5939
|
init_react_import();
|
6061
|
-
var styles_module_default17 = { "ComponentList": "
|
5940
|
+
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
5941
|
|
6063
5942
|
// components/ComponentList/index.tsx
|
6064
5943
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
@@ -6118,8 +5997,8 @@ ComponentList.Item = ComponentListItem;
|
|
6118
5997
|
// lib/use-component-list.tsx
|
6119
5998
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6120
5999
|
var useComponentList = (config, ui) => {
|
6121
|
-
const [componentList, setComponentList] = (0,
|
6122
|
-
(0,
|
6000
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
6001
|
+
(0, import_react38.useEffect)(() => {
|
6123
6002
|
var _a, _b, _c;
|
6124
6003
|
if (Object.keys(ui.componentList).length > 0) {
|
6125
6004
|
const matchedComponents = [];
|
@@ -6188,22 +6067,22 @@ var useComponentList = (config, ui) => {
|
|
6188
6067
|
};
|
6189
6068
|
|
6190
6069
|
// components/Puck/components/Components/index.tsx
|
6191
|
-
var
|
6070
|
+
var import_react39 = require("react");
|
6192
6071
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6193
6072
|
var Components = () => {
|
6194
6073
|
const { config, state, overrides } = useAppContext();
|
6195
6074
|
const componentList = useComponentList(config, state.ui);
|
6196
|
-
const Wrapper = (0,
|
6075
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6197
6076
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6198
6077
|
};
|
6199
6078
|
|
6200
6079
|
// components/Puck/components/Preview/index.tsx
|
6201
6080
|
init_react_import();
|
6202
|
-
var
|
6081
|
+
var import_react41 = require("react");
|
6203
6082
|
|
6204
6083
|
// components/AutoFrame/index.tsx
|
6205
6084
|
init_react_import();
|
6206
|
-
var
|
6085
|
+
var import_react40 = require("react");
|
6207
6086
|
var import_object_hash = __toESM(require("object-hash"));
|
6208
6087
|
var import_react_dom3 = require("react-dom");
|
6209
6088
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6249,7 +6128,7 @@ var CopyHostStyles = ({
|
|
6249
6128
|
onStylesLoaded = () => null
|
6250
6129
|
}) => {
|
6251
6130
|
const { document: doc, window: win } = useFrame();
|
6252
|
-
(0,
|
6131
|
+
(0, import_react40.useEffect)(() => {
|
6253
6132
|
if (!win || !doc) {
|
6254
6133
|
return () => {
|
6255
6134
|
};
|
@@ -6408,8 +6287,8 @@ var CopyHostStyles = ({
|
|
6408
6287
|
}, []);
|
6409
6288
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6410
6289
|
};
|
6411
|
-
var autoFrameContext = (0,
|
6412
|
-
var useFrame = () => (0,
|
6290
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6291
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6413
6292
|
function AutoFrame(_a) {
|
6414
6293
|
var _b = _a, {
|
6415
6294
|
children,
|
@@ -6426,10 +6305,10 @@ function AutoFrame(_a) {
|
|
6426
6305
|
"onStylesLoaded",
|
6427
6306
|
"frameRef"
|
6428
6307
|
]);
|
6429
|
-
const [loaded, setLoaded] = (0,
|
6430
|
-
const [ctx, setCtx] = (0,
|
6431
|
-
const [mountTarget, setMountTarget] = (0,
|
6432
|
-
(0,
|
6308
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6309
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6310
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6311
|
+
(0, import_react40.useEffect)(() => {
|
6433
6312
|
var _a2;
|
6434
6313
|
if (frameRef.current) {
|
6435
6314
|
setCtx({
|
@@ -6491,14 +6370,13 @@ function Render({
|
|
6491
6370
|
config.root.render,
|
6492
6371
|
__spreadProps(__spreadValues({}, rootProps), {
|
6493
6372
|
puck: {
|
6494
|
-
renderDropZone:
|
6495
|
-
isEditing: false
|
6496
|
-
dragRef: null
|
6373
|
+
renderDropZone: DropZone,
|
6374
|
+
isEditing: false
|
6497
6375
|
},
|
6498
6376
|
title,
|
6499
6377
|
editMode: false,
|
6500
6378
|
id: "puck-root",
|
6501
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6379
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6502
6380
|
})
|
6503
6381
|
)
|
6504
6382
|
}
|
@@ -6514,7 +6392,7 @@ function Render({
|
|
6514
6392
|
depth: 0,
|
6515
6393
|
path: []
|
6516
6394
|
},
|
6517
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6395
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6518
6396
|
}
|
6519
6397
|
);
|
6520
6398
|
}
|
@@ -6524,12 +6402,25 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6524
6402
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6525
6403
|
var useBubbleIframeEvents = (ref) => {
|
6526
6404
|
const { status } = useAppContext();
|
6527
|
-
(0,
|
6405
|
+
(0, import_react41.useEffect)(() => {
|
6528
6406
|
var _a;
|
6529
6407
|
if (ref.current && status === "READY") {
|
6530
6408
|
const iframe = ref.current;
|
6409
|
+
class BubbledPointerEventClass extends PointerEvent {
|
6410
|
+
constructor(type, data) {
|
6411
|
+
super(type, data);
|
6412
|
+
this._originalTarget = null;
|
6413
|
+
this.originalTarget = data.originalTarget;
|
6414
|
+
}
|
6415
|
+
set originalTarget(target) {
|
6416
|
+
this._originalTarget = target;
|
6417
|
+
}
|
6418
|
+
get originalTarget() {
|
6419
|
+
return this._originalTarget;
|
6420
|
+
}
|
6421
|
+
}
|
6531
6422
|
const handlePointerMove = (event) => {
|
6532
|
-
const evt = new
|
6423
|
+
const evt = new BubbledPointerEventClass("pointermove", __spreadProps(__spreadValues({}, event), {
|
6533
6424
|
bubbles: true,
|
6534
6425
|
cancelable: false,
|
6535
6426
|
clientX: event.clientX,
|
@@ -6557,7 +6448,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6557
6448
|
};
|
6558
6449
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6559
6450
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6560
|
-
const Page = (0,
|
6451
|
+
const Page = (0, import_react41.useCallback)(
|
6561
6452
|
(pageProps) => {
|
6562
6453
|
var _a, _b;
|
6563
6454
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6566,20 +6457,20 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6566
6457
|
},
|
6567
6458
|
[config.root]
|
6568
6459
|
);
|
6569
|
-
const Frame = (0,
|
6460
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6570
6461
|
const rootProps = state.data.root.props || state.data.root;
|
6571
|
-
const ref = (0,
|
6462
|
+
const ref = (0, import_react41.useRef)(null);
|
6572
6463
|
useBubbleIframeEvents(ref);
|
6573
6464
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6574
6465
|
Page,
|
6575
6466
|
__spreadProps(__spreadValues({}, rootProps), {
|
6576
6467
|
puck: {
|
6577
|
-
renderDropZone:
|
6468
|
+
renderDropZone: DropZone,
|
6578
6469
|
isEditing: true,
|
6579
6470
|
dragRef: null
|
6580
6471
|
},
|
6581
6472
|
editMode: true,
|
6582
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6473
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
6583
6474
|
})
|
6584
6475
|
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
|
6585
6476
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
@@ -6651,7 +6542,7 @@ init_react_import();
|
|
6651
6542
|
|
6652
6543
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
6653
6544
|
init_react_import();
|
6654
|
-
var styles_module_default19 = { "LayerTree": "
|
6545
|
+
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
6546
|
|
6656
6547
|
// lib/scroll-into-view.ts
|
6657
6548
|
init_react_import();
|
@@ -6665,7 +6556,7 @@ var scrollIntoView = (el) => {
|
|
6665
6556
|
};
|
6666
6557
|
|
6667
6558
|
// components/LayerTree/index.tsx
|
6668
|
-
var
|
6559
|
+
var import_react42 = require("react");
|
6669
6560
|
|
6670
6561
|
// lib/is-child-of-zone.ts
|
6671
6562
|
init_react_import();
|
@@ -6711,7 +6602,7 @@ var LayerTree = ({
|
|
6711
6602
|
label
|
6712
6603
|
}) => {
|
6713
6604
|
const zones = data.zones || {};
|
6714
|
-
const ctx = (0,
|
6605
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6715
6606
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6716
6607
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6717
6608
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6818,13 +6709,13 @@ var LayerTree = ({
|
|
6818
6709
|
};
|
6819
6710
|
|
6820
6711
|
// components/Puck/components/Outline/index.tsx
|
6821
|
-
var
|
6712
|
+
var import_react43 = require("react");
|
6822
6713
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6823
6714
|
var Outline = () => {
|
6824
6715
|
const { dispatch, state, overrides, config } = useAppContext();
|
6825
6716
|
const { data, ui } = state;
|
6826
6717
|
const { itemSelector } = ui;
|
6827
|
-
const setItemSelector = (0,
|
6718
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6828
6719
|
(newItemSelector) => {
|
6829
6720
|
dispatch({
|
6830
6721
|
type: "setUi",
|
@@ -6833,7 +6724,7 @@ var Outline = () => {
|
|
6833
6724
|
},
|
6834
6725
|
[]
|
6835
6726
|
);
|
6836
|
-
const Wrapper = (0,
|
6727
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6837
6728
|
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
6729
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6839
6730
|
LayerTree,
|
@@ -6947,19 +6838,19 @@ function usePuckHistory({
|
|
6947
6838
|
|
6948
6839
|
// lib/use-history-store.ts
|
6949
6840
|
init_react_import();
|
6950
|
-
var
|
6841
|
+
var import_react44 = require("react");
|
6951
6842
|
var import_use_debounce3 = require("use-debounce");
|
6952
6843
|
var EMPTY_HISTORY_INDEX = 0;
|
6953
6844
|
function useHistoryStore(initialHistory) {
|
6954
6845
|
var _a, _b;
|
6955
|
-
const [histories, setHistories] = (0,
|
6846
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6956
6847
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6957
6848
|
);
|
6958
6849
|
const updateHistories = (histories2) => {
|
6959
6850
|
setHistories(histories2);
|
6960
6851
|
setIndex(histories2.length - 1);
|
6961
6852
|
};
|
6962
|
-
const [index, setIndex] = (0,
|
6853
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6963
6854
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6964
6855
|
);
|
6965
6856
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -7119,15 +7010,15 @@ var getBox = function getBox2(el) {
|
|
7119
7010
|
};
|
7120
7011
|
|
7121
7012
|
// components/Puck/components/Canvas/index.tsx
|
7122
|
-
var
|
7013
|
+
var import_react46 = require("react");
|
7123
7014
|
|
7124
7015
|
// components/ViewportControls/index.tsx
|
7125
7016
|
init_react_import();
|
7126
|
-
var
|
7017
|
+
var import_react45 = require("react");
|
7127
7018
|
|
7128
7019
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7129
7020
|
init_react_import();
|
7130
|
-
var styles_module_default20 = { "ViewportControls": "
|
7021
|
+
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
7022
|
|
7132
7023
|
// components/ViewportControls/index.tsx
|
7133
7024
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
@@ -7146,8 +7037,8 @@ var ViewportButton = ({
|
|
7146
7037
|
onClick
|
7147
7038
|
}) => {
|
7148
7039
|
const { state } = useAppContext();
|
7149
|
-
const [isActive, setIsActive] = (0,
|
7150
|
-
(0,
|
7040
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7041
|
+
(0, import_react45.useEffect)(() => {
|
7151
7042
|
setIsActive(width === state.ui.viewports.current.width);
|
7152
7043
|
}, [width, state.ui.viewports.current.width]);
|
7153
7044
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -7183,7 +7074,7 @@ var ViewportControls = ({
|
|
7183
7074
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7184
7075
|
(option) => option.value === autoZoom
|
7185
7076
|
);
|
7186
|
-
const zoomOptions = (0,
|
7077
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
7187
7078
|
() => [
|
7188
7079
|
...defaultZoomOptions,
|
7189
7080
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7306,17 +7197,17 @@ var Canvas = () => {
|
|
7306
7197
|
const { status, iframe } = useAppContext();
|
7307
7198
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7308
7199
|
const { ui } = state;
|
7309
|
-
const frameRef = (0,
|
7310
|
-
const [showTransition, setShowTransition] = (0,
|
7311
|
-
const defaultRender = (0,
|
7200
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7201
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7202
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7312
7203
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7313
7204
|
return PuckDefault;
|
7314
7205
|
}, []);
|
7315
|
-
const CustomPreview = (0,
|
7206
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7316
7207
|
() => overrides.preview || defaultRender,
|
7317
7208
|
[overrides]
|
7318
7209
|
);
|
7319
|
-
const getFrameDimensions = (0,
|
7210
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7320
7211
|
if (frameRef.current) {
|
7321
7212
|
const frame = frameRef.current;
|
7322
7213
|
const box = getBox(frame);
|
@@ -7324,7 +7215,7 @@ var Canvas = () => {
|
|
7324
7215
|
}
|
7325
7216
|
return { width: 0, height: 0 };
|
7326
7217
|
}, [frameRef]);
|
7327
|
-
const resetAutoZoom = (0,
|
7218
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7328
7219
|
(ui2 = state.ui) => {
|
7329
7220
|
if (frameRef.current) {
|
7330
7221
|
setZoomConfig(
|
@@ -7334,11 +7225,11 @@ var Canvas = () => {
|
|
7334
7225
|
},
|
7335
7226
|
[frameRef, zoomConfig, state.ui]
|
7336
7227
|
);
|
7337
|
-
(0,
|
7228
|
+
(0, import_react46.useEffect)(() => {
|
7338
7229
|
setShowTransition(false);
|
7339
7230
|
resetAutoZoom();
|
7340
7231
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7341
|
-
(0,
|
7232
|
+
(0, import_react46.useEffect)(() => {
|
7342
7233
|
const { height: frameHeight } = getFrameDimensions();
|
7343
7234
|
if (ui.viewports.current.height === "auto") {
|
7344
7235
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7346,13 +7237,13 @@ var Canvas = () => {
|
|
7346
7237
|
}));
|
7347
7238
|
}
|
7348
7239
|
}, [zoomConfig.zoom]);
|
7349
|
-
(0,
|
7240
|
+
(0, import_react46.useEffect)(() => {
|
7350
7241
|
if (ZOOM_ON_CHANGE) {
|
7351
7242
|
setShowTransition(true);
|
7352
7243
|
resetAutoZoom(ui);
|
7353
7244
|
}
|
7354
7245
|
}, [ui.viewports.current.width]);
|
7355
|
-
(0,
|
7246
|
+
(0, import_react46.useEffect)(() => {
|
7356
7247
|
const cb = () => {
|
7357
7248
|
setShowTransition(false);
|
7358
7249
|
resetAutoZoom();
|
@@ -7362,8 +7253,8 @@ var Canvas = () => {
|
|
7362
7253
|
window.removeEventListener("resize", cb);
|
7363
7254
|
};
|
7364
7255
|
}, []);
|
7365
|
-
const [showLoader, setShowLoader] = (0,
|
7366
|
-
(0,
|
7256
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7257
|
+
(0, import_react46.useEffect)(() => {
|
7367
7258
|
setTimeout(() => {
|
7368
7259
|
setShowLoader(true);
|
7369
7260
|
}, 500);
|
@@ -7441,7 +7332,7 @@ var Canvas = () => {
|
|
7441
7332
|
|
7442
7333
|
// lib/use-loaded-overrides.ts
|
7443
7334
|
init_react_import();
|
7444
|
-
var
|
7335
|
+
var import_react47 = require("react");
|
7445
7336
|
|
7446
7337
|
// lib/load-overrides.ts
|
7447
7338
|
init_react_import();
|
@@ -7480,7 +7371,7 @@ var useLoadedOverrides = ({
|
|
7480
7371
|
overrides,
|
7481
7372
|
plugins
|
7482
7373
|
}) => {
|
7483
|
-
return (0,
|
7374
|
+
return (0, import_react47.useMemo)(() => {
|
7484
7375
|
return loadOverrides({ overrides, plugins });
|
7485
7376
|
}, [plugins, overrides]);
|
7486
7377
|
};
|
@@ -7492,14 +7383,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7492
7383
|
|
7493
7384
|
// lib/use-inject-css.ts
|
7494
7385
|
init_react_import();
|
7495
|
-
var
|
7386
|
+
var import_react48 = require("react");
|
7496
7387
|
var styles = ``;
|
7497
7388
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7498
|
-
const [el, setEl] = (0,
|
7499
|
-
(0,
|
7389
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7390
|
+
(0, import_react48.useEffect)(() => {
|
7500
7391
|
setEl(document.createElement("style"));
|
7501
7392
|
}, []);
|
7502
|
-
(0,
|
7393
|
+
(0, import_react48.useEffect)(() => {
|
7503
7394
|
var _a;
|
7504
7395
|
if (!el || typeof window === "undefined") {
|
7505
7396
|
return;
|
@@ -7519,10 +7410,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7519
7410
|
|
7520
7411
|
// lib/use-preview-mode-hotkeys.ts
|
7521
7412
|
init_react_import();
|
7522
|
-
var
|
7413
|
+
var import_react49 = require("react");
|
7523
7414
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7524
7415
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7525
|
-
const toggleInteractive = (0,
|
7416
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7526
7417
|
dispatch({
|
7527
7418
|
type: "setUi",
|
7528
7419
|
ui: (ui) => ({
|
@@ -7542,11 +7433,6 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
|
7542
7433
|
preventDefault: true,
|
7543
7434
|
document: resolvedFrame
|
7544
7435
|
});
|
7545
|
-
(0, import_react_hotkeys_hook2.useHotkeys)("ctrl+i", toggleInteractive, { preventDefault: true });
|
7546
|
-
(0, import_react_hotkeys_hook2.useHotkeys)("ctrl+i", toggleInteractiveIframe, {
|
7547
|
-
preventDefault: true,
|
7548
|
-
document: resolvedFrame
|
7549
|
-
});
|
7550
7436
|
};
|
7551
7437
|
|
7552
7438
|
// components/Puck/index.tsx
|
@@ -7579,7 +7465,7 @@ function Puck({
|
|
7579
7465
|
waitForStyles: true
|
7580
7466
|
}, _iframe);
|
7581
7467
|
useInjectGlobalCss(iframe.enabled);
|
7582
|
-
const [generatedAppState] = (0,
|
7468
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7583
7469
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7584
7470
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7585
7471
|
let clientUiState = {};
|
@@ -7651,14 +7537,14 @@ function Puck({
|
|
7651
7537
|
histories,
|
7652
7538
|
index: initialHistoryIndex
|
7653
7539
|
});
|
7654
|
-
const [reducer] = (0,
|
7540
|
+
const [reducer] = (0, import_react50.useState)(
|
7655
7541
|
() => createReducer({
|
7656
7542
|
config,
|
7657
7543
|
record: historyStore.record,
|
7658
7544
|
onAction
|
7659
7545
|
})
|
7660
7546
|
);
|
7661
|
-
const [appState, dispatch] = (0,
|
7547
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7662
7548
|
reducer,
|
7663
7549
|
flushZones(initialAppState)
|
7664
7550
|
);
|
@@ -7669,14 +7555,14 @@ function Puck({
|
|
7669
7555
|
historyStore,
|
7670
7556
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7671
7557
|
});
|
7672
|
-
const [menuOpen, setMenuOpen] = (0,
|
7558
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7673
7559
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7674
7560
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7675
|
-
(0,
|
7561
|
+
(0, import_react50.useEffect)(() => {
|
7676
7562
|
if (onChange) onChange(data);
|
7677
7563
|
}, [data]);
|
7678
7564
|
const rootProps = data.root.props || data.root;
|
7679
|
-
const toggleSidebars = (0,
|
7565
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7680
7566
|
(sidebar) => {
|
7681
7567
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7682
7568
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7690,7 +7576,7 @@ function Puck({
|
|
7690
7576
|
},
|
7691
7577
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7692
7578
|
);
|
7693
|
-
(0,
|
7579
|
+
(0, import_react50.useEffect)(() => {
|
7694
7580
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7695
7581
|
dispatch({
|
7696
7582
|
type: "setUi",
|
@@ -7713,7 +7599,7 @@ function Puck({
|
|
7713
7599
|
window.removeEventListener("resize", handleResize);
|
7714
7600
|
};
|
7715
7601
|
}, []);
|
7716
|
-
const defaultHeaderRender = (0,
|
7602
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7717
7603
|
if (renderHeader) {
|
7718
7604
|
console.warn(
|
7719
7605
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7727,7 +7613,7 @@ function Puck({
|
|
7727
7613
|
}
|
7728
7614
|
return DefaultOverride;
|
7729
7615
|
}, [renderHeader]);
|
7730
|
-
const defaultHeaderActionsRender = (0,
|
7616
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7731
7617
|
if (renderHeaderActions) {
|
7732
7618
|
console.warn(
|
7733
7619
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7744,20 +7630,20 @@ function Puck({
|
|
7744
7630
|
overrides,
|
7745
7631
|
plugins
|
7746
7632
|
});
|
7747
|
-
const CustomPuck = (0,
|
7633
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7748
7634
|
() => loadedOverrides.puck || DefaultOverride,
|
7749
7635
|
[loadedOverrides]
|
7750
7636
|
);
|
7751
|
-
const CustomHeader = (0,
|
7637
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7752
7638
|
() => loadedOverrides.header || defaultHeaderRender,
|
7753
7639
|
[loadedOverrides]
|
7754
7640
|
);
|
7755
|
-
const CustomHeaderActions = (0,
|
7641
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7756
7642
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7757
7643
|
[loadedOverrides]
|
7758
7644
|
);
|
7759
|
-
const [mounted, setMounted] = (0,
|
7760
|
-
(0,
|
7645
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7646
|
+
(0, import_react50.useEffect)(() => {
|
7761
7647
|
setMounted(true);
|
7762
7648
|
}, []);
|
7763
7649
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
@@ -8062,12 +7948,14 @@ var usePuck = () => {
|
|
8062
7948
|
Button,
|
8063
7949
|
Drawer,
|
8064
7950
|
DropZone,
|
7951
|
+
DropZoneProvider,
|
8065
7952
|
FieldLabel,
|
8066
7953
|
Group,
|
8067
7954
|
IconButton,
|
8068
7955
|
Label,
|
8069
7956
|
Puck,
|
8070
7957
|
Render,
|
7958
|
+
dropZoneContext,
|
8071
7959
|
migrate,
|
8072
7960
|
overrideKeys,
|
8073
7961
|
resolveAllData,
|