@measured/puck 0.18.2-canary.5db6f4d → 0.18.2-canary.73bb338
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 +279 -268
- package/dist/index.d.mts +3 -45
- package/dist/index.d.ts +3 -45
- package/dist/index.js +1825 -1718
- package/dist/index.mjs +2637 -2528
- package/dist/{resolve-all-data-DzJEE28m.d.mts → resolve-all-data-DtHY0CRO.d.mts} +3 -3
- package/dist/{resolve-all-data-DzJEE28m.d.ts → resolve-all-data-DtHY0CRO.d.ts} +3 -3
- package/dist/rsc.d.mts +4 -4
- package/dist/rsc.d.ts +4 -4
- package/dist/rsc.js +3 -5
- package/dist/rsc.mjs +3 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -169,14 +169,12 @@ __export(core_exports, {
|
|
169
169
|
Button: () => Button,
|
170
170
|
Drawer: () => Drawer,
|
171
171
|
DropZone: () => DropZone,
|
172
|
-
DropZoneProvider: () => DropZoneProvider,
|
173
172
|
FieldLabel: () => FieldLabel,
|
174
173
|
Group: () => Group,
|
175
174
|
IconButton: () => IconButton,
|
176
175
|
Label: () => Label,
|
177
176
|
Puck: () => Puck,
|
178
177
|
Render: () => Render,
|
179
|
-
dropZoneContext: () => dropZoneContext,
|
180
178
|
migrate: () => migrate,
|
181
179
|
overrideKeys: () => overrideKeys,
|
182
180
|
resolveAllData: () => resolveAllData,
|
@@ -262,7 +260,7 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
262
260
|
|
263
261
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
264
262
|
init_react_import();
|
265
|
-
var styles_module_default = { "ActionBar": "
|
263
|
+
var styles_module_default = { "ActionBar": "_ActionBar_rvadt_1", "ActionBar-label": "_ActionBar-label_rvadt_18", "ActionBar-action": "_ActionBar-action_rvadt_30", "ActionBar-group": "_ActionBar-group_rvadt_38" };
|
266
264
|
|
267
265
|
// components/ActionBar/index.tsx
|
268
266
|
var import_jsx_runtime = require("react/jsx-runtime");
|
@@ -308,10 +306,10 @@ init_react_import();
|
|
308
306
|
|
309
307
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
310
308
|
init_react_import();
|
311
|
-
var styles_module_default2 = { "InputWrapper": "
|
309
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_g5w3n_1", "Input-label": "_Input-label_g5w3n_5", "Input-labelIcon": "_Input-labelIcon_g5w3n_14", "Input-disabledIcon": "_Input-disabledIcon_g5w3n_21", "Input-input": "_Input-input_g5w3n_26", "Input": "_Input_g5w3n_1", "Input--readOnly": "_Input--readOnly_g5w3n_74", "Input-radioGroupItems": "_Input-radioGroupItems_g5w3n_85", "Input-radio": "_Input-radio_g5w3n_85", "Input-radioInner": "_Input-radioInner_g5w3n_102", "Input-radioInput": "_Input-radioInput_g5w3n_147" };
|
312
310
|
|
313
311
|
// components/AutoField/index.tsx
|
314
|
-
var
|
312
|
+
var import_react21 = require("react");
|
315
313
|
|
316
314
|
// components/AutoField/fields/index.tsx
|
317
315
|
init_react_import();
|
@@ -321,7 +319,7 @@ init_react_import();
|
|
321
319
|
|
322
320
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/fields/ArrayField/styles.module.css#css-module
|
323
321
|
init_react_import();
|
324
|
-
var styles_module_default3 = { "ArrayField": "
|
322
|
+
var styles_module_default3 = { "ArrayField": "_ArrayField_14u8o_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_14u8o_13", "ArrayField-addButton": "_ArrayField-addButton_14u8o_18", "ArrayField--hasItems": "_ArrayField--hasItems_14u8o_33", "ArrayField-inner": "_ArrayField-inner_14u8o_59", "ArrayFieldItem": "_ArrayFieldItem_14u8o_67", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_14u8o_78", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_14u8o_82", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_14u8o_97", "ArrayField--addDisabled": "_ArrayField--addDisabled_14u8o_127", "ArrayFieldItem-body": "_ArrayFieldItem-body_14u8o_166", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_14u8o_175", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_14u8o_183", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_14u8o_189" };
|
325
323
|
|
326
324
|
// ../../node_modules/lucide-react/dist/esm/lucide-react.js
|
327
325
|
init_react_import();
|
@@ -771,7 +769,7 @@ var IconButton = ({
|
|
771
769
|
};
|
772
770
|
|
773
771
|
// components/AutoField/fields/ArrayField/index.tsx
|
774
|
-
var
|
772
|
+
var import_react13 = require("react");
|
775
773
|
|
776
774
|
// components/DragIcon/index.tsx
|
777
775
|
init_react_import();
|
@@ -1279,8 +1277,8 @@ function useAppContext() {
|
|
1279
1277
|
|
1280
1278
|
// components/Sortable/index.tsx
|
1281
1279
|
init_react_import();
|
1282
|
-
var
|
1283
|
-
var
|
1280
|
+
var import_react10 = require("@dnd-kit/react");
|
1281
|
+
var import_react11 = require("react");
|
1284
1282
|
|
1285
1283
|
// lib/dnd/dnd-kit/safe.ts
|
1286
1284
|
init_react_import();
|
@@ -1308,187 +1306,843 @@ function useSortableSafe(input) {
|
|
1308
1306
|
return (0, import_sortable.useSortable)(input);
|
1309
1307
|
}
|
1310
1308
|
|
1311
|
-
//
|
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
|
-
});
|
1333
|
-
}
|
1334
|
-
}
|
1335
|
-
},
|
1336
|
-
onDragEnd: () => {
|
1337
|
-
if (move.source !== -1 && move.target !== -1) {
|
1338
|
-
onMove(move);
|
1339
|
-
}
|
1340
|
-
},
|
1341
|
-
children
|
1342
|
-
}
|
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
|
1309
|
+
// lib/dnd/use-sensors.ts
|
1363
1310
|
init_react_import();
|
1364
|
-
var
|
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, "\\*")
|
1388
|
-
);
|
1389
|
-
const localName = readOnlyKey.replace(subPathPattern, "");
|
1390
|
-
return __spreadProps(__spreadValues({}, acc), {
|
1391
|
-
[localName]: readOnlyFields[readOnlyKey]
|
1392
|
-
});
|
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
|
1403
|
-
}
|
1404
|
-
);
|
1405
|
-
};
|
1311
|
+
var import_react9 = require("react");
|
1406
1312
|
|
1407
|
-
//
|
1408
|
-
|
1409
|
-
var
|
1410
|
-
var
|
1411
|
-
var
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1313
|
+
// lib/dnd/PointerSensor.ts
|
1314
|
+
init_react_import();
|
1315
|
+
var import_state = require("@dnd-kit/state");
|
1316
|
+
var import_abstract = require("@dnd-kit/abstract");
|
1317
|
+
var import_geometry = require("@dnd-kit/geometry");
|
1318
|
+
var import_utilities = require("@dnd-kit/dom/utilities");
|
1319
|
+
var _clearTimeout;
|
1320
|
+
var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
|
1321
|
+
constructor(manager, options) {
|
1322
|
+
super(manager);
|
1323
|
+
this.manager = manager;
|
1324
|
+
this.options = options;
|
1325
|
+
this.listeners = new import_utilities.Listeners();
|
1326
|
+
this.cleanup = /* @__PURE__ */ new Set();
|
1327
|
+
this.source = void 0;
|
1328
|
+
__privateAdd(this, _clearTimeout);
|
1329
|
+
this.handleCancel = this.handleCancel.bind(this);
|
1330
|
+
this.handlePointerUp = this.handlePointerUp.bind(this);
|
1331
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
1332
|
+
(0, import_state.effect)(() => {
|
1333
|
+
const unbindGlobal = this.bindGlobal(options != null ? options : {});
|
1334
|
+
return () => {
|
1335
|
+
unbindGlobal();
|
1429
1336
|
};
|
1430
|
-
})
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
1441
|
-
[id]: __spreadValues(__spreadValues({}, arrayState), partialArrayState)
|
1442
|
-
})
|
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
|
+
}
|
1443
1347
|
};
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
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}`
|
1348
|
+
if (target) {
|
1349
|
+
patchWindow(target.ownerDocument.defaultView);
|
1350
|
+
target.addEventListener("pointerdown", listener);
|
1351
|
+
return () => {
|
1352
|
+
target.removeEventListener("pointerdown", listener);
|
1462
1353
|
};
|
1463
|
-
|
1464
|
-
|
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
|
1381
|
+
}
|
1382
|
+
},
|
1383
|
+
{
|
1384
|
+
// Cancel activation if there is a competing Drag and Drop interaction
|
1385
|
+
type: "dragstart",
|
1386
|
+
listener: this.handleDragStart
|
1465
1387
|
}
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
(
|
1473
|
-
if (
|
1474
|
-
|
1388
|
+
])
|
1389
|
+
);
|
1390
|
+
return () => {
|
1391
|
+
unbindFns.forEach((unbind) => unbind());
|
1392
|
+
};
|
1393
|
+
}
|
1394
|
+
handlePointerDown(event, source, options = {}) {
|
1395
|
+
if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
|
1396
|
+
return;
|
1475
1397
|
}
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1398
|
+
const offset = (0, import_utilities.getFrameTransform)(source.element);
|
1399
|
+
this.initialCoordinates = {
|
1400
|
+
x: event.clientX * offset.scaleX + offset.x,
|
1401
|
+
y: event.clientY * offset.scaleY + offset.y
|
1402
|
+
};
|
1403
|
+
this.source = source;
|
1404
|
+
const { activationConstraints } = options;
|
1405
|
+
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
1406
|
+
event.stopImmediatePropagation();
|
1407
|
+
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
1408
|
+
this.handleStart(source, event);
|
1409
|
+
} else {
|
1410
|
+
const { delay } = constraints;
|
1411
|
+
if (delay) {
|
1412
|
+
const timeout3 = setTimeout(
|
1413
|
+
() => this.handleStart(source, event),
|
1414
|
+
delay.value
|
1415
|
+
);
|
1416
|
+
__privateSet(this, _clearTimeout, () => {
|
1417
|
+
clearTimeout(timeout3);
|
1418
|
+
__privateSet(this, _clearTimeout, void 0);
|
1419
|
+
});
|
1420
|
+
}
|
1421
|
+
}
|
1422
|
+
const cleanup = () => {
|
1423
|
+
var _a;
|
1424
|
+
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
1425
|
+
this.initialCoordinates = void 0;
|
1426
|
+
this.source = void 0;
|
1427
|
+
};
|
1428
|
+
this.cleanup.add(cleanup);
|
1480
1429
|
}
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1430
|
+
handlePointerMove(event, doc, options) {
|
1431
|
+
if (!this.source) {
|
1432
|
+
return;
|
1433
|
+
}
|
1434
|
+
const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
|
1435
|
+
if (doc !== ownerDocument) {
|
1436
|
+
return;
|
1437
|
+
}
|
1438
|
+
const coordinates = {
|
1439
|
+
x: event.clientX,
|
1440
|
+
y: event.clientY
|
1441
|
+
};
|
1442
|
+
const offset = (0, import_utilities.getFrameTransform)(this.source.element);
|
1443
|
+
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
1444
|
+
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
1445
|
+
if (this.manager.dragOperation.status.dragging) {
|
1446
|
+
event.preventDefault();
|
1447
|
+
event.stopPropagation();
|
1448
|
+
this.manager.actions.move({ to: coordinates });
|
1449
|
+
return;
|
1450
|
+
}
|
1451
|
+
if (!this.initialCoordinates) {
|
1452
|
+
return;
|
1453
|
+
}
|
1454
|
+
const delta = {
|
1455
|
+
x: coordinates.x - this.initialCoordinates.x,
|
1456
|
+
y: coordinates.y - this.initialCoordinates.y
|
1457
|
+
};
|
1458
|
+
const { activationConstraints } = options;
|
1459
|
+
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
|
1460
|
+
const { distance, delay } = constraints != null ? constraints : {};
|
1461
|
+
if (distance) {
|
1462
|
+
if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
|
1463
|
+
return this.handleCancel();
|
1464
|
+
}
|
1465
|
+
if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
|
1466
|
+
return this.handleStart(this.source, event);
|
1467
|
+
}
|
1468
|
+
}
|
1469
|
+
if (delay) {
|
1470
|
+
if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
|
1471
|
+
return this.handleCancel();
|
1472
|
+
}
|
1473
|
+
}
|
1474
|
+
}
|
1475
|
+
handlePointerUp(event) {
|
1476
|
+
if (!this.source) {
|
1477
|
+
return;
|
1478
|
+
}
|
1479
|
+
event.preventDefault();
|
1480
|
+
event.stopPropagation();
|
1481
|
+
const { status } = this.manager.dragOperation;
|
1482
|
+
if (!status.idle) {
|
1483
|
+
const canceled = !status.initialized;
|
1484
|
+
this.manager.actions.stop({ canceled });
|
1485
|
+
}
|
1486
|
+
this.cleanup.forEach((cleanup) => cleanup());
|
1487
|
+
this.cleanup.clear();
|
1488
|
+
}
|
1489
|
+
handleKeyDown(event) {
|
1490
|
+
if (event.key === "Escape") {
|
1491
|
+
event.preventDefault();
|
1492
|
+
this.handleCancel();
|
1493
|
+
}
|
1494
|
+
}
|
1495
|
+
handleStart(source, event) {
|
1496
|
+
var _a;
|
1497
|
+
const { manager, initialCoordinates } = this;
|
1498
|
+
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
1499
|
+
if (!initialCoordinates || manager.dragOperation.status.initialized) {
|
1500
|
+
return;
|
1501
|
+
}
|
1502
|
+
if (event.defaultPrevented) {
|
1503
|
+
return;
|
1504
|
+
}
|
1505
|
+
event.preventDefault();
|
1506
|
+
(0, import_state.batch)(() => {
|
1507
|
+
manager.actions.setDragSource(source.id);
|
1508
|
+
manager.actions.start({ coordinates: initialCoordinates, event });
|
1509
|
+
});
|
1510
|
+
const ownerDocument = (0, import_utilities.getDocument)(event.target);
|
1511
|
+
const unbind = this.listeners.bind(ownerDocument, [
|
1512
|
+
{
|
1513
|
+
// Prevent scrolling on touch devices
|
1514
|
+
type: "touchmove",
|
1515
|
+
listener: preventDefault,
|
1516
|
+
options: {
|
1517
|
+
passive: false
|
1518
|
+
}
|
1519
|
+
},
|
1520
|
+
{
|
1521
|
+
// Prevent click events
|
1522
|
+
type: "click",
|
1523
|
+
listener: preventDefault
|
1524
|
+
},
|
1525
|
+
{
|
1526
|
+
type: "keydown",
|
1527
|
+
listener: this.handleKeyDown
|
1528
|
+
}
|
1529
|
+
]);
|
1530
|
+
ownerDocument.body.setPointerCapture(event.pointerId);
|
1531
|
+
this.cleanup.add(unbind);
|
1532
|
+
}
|
1533
|
+
handleDragStart(event) {
|
1534
|
+
const { target } = event;
|
1535
|
+
if (!(0, import_utilities.isElement)(target)) {
|
1536
|
+
return;
|
1537
|
+
}
|
1538
|
+
const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
|
1539
|
+
if (isNativeDraggable) {
|
1540
|
+
this.handleCancel();
|
1541
|
+
} else {
|
1542
|
+
preventDefault(event);
|
1543
|
+
}
|
1544
|
+
}
|
1545
|
+
handleCancel() {
|
1546
|
+
const { dragOperation } = this.manager;
|
1547
|
+
if (dragOperation.status.initialized) {
|
1548
|
+
this.manager.actions.stop({ canceled: true });
|
1549
|
+
}
|
1550
|
+
this.cleanup.forEach((cleanup) => cleanup());
|
1551
|
+
this.cleanup.clear();
|
1552
|
+
}
|
1553
|
+
destroy() {
|
1554
|
+
this.listeners.clear();
|
1555
|
+
}
|
1556
|
+
};
|
1557
|
+
_clearTimeout = new WeakMap();
|
1558
|
+
_PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
|
1559
|
+
var PointerSensor = _PointerSensor;
|
1560
|
+
function preventDefault(event) {
|
1561
|
+
event.preventDefault();
|
1562
|
+
}
|
1563
|
+
function noop() {
|
1564
|
+
}
|
1565
|
+
var windows = /* @__PURE__ */ new WeakSet();
|
1566
|
+
function patchWindow(window2) {
|
1567
|
+
if (!window2 || windows.has(window2)) {
|
1568
|
+
return;
|
1569
|
+
}
|
1570
|
+
window2.addEventListener("touchmove", noop, {
|
1571
|
+
capture: false,
|
1572
|
+
passive: false
|
1573
|
+
});
|
1574
|
+
windows.add(window2);
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
// lib/dnd/use-sensors.ts
|
1578
|
+
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
1579
|
+
var useSensors = () => {
|
1580
|
+
const [sensors] = (0, import_react9.useState)(() => [
|
1581
|
+
PointerSensor.configure({
|
1582
|
+
activationConstraints(event, source) {
|
1583
|
+
var _a;
|
1584
|
+
const { pointerType, target } = event;
|
1585
|
+
if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
1586
|
+
return void 0;
|
1587
|
+
}
|
1588
|
+
const delay = { value: 200, tolerance: 10 };
|
1589
|
+
if (pointerType === "touch") {
|
1590
|
+
return { delay };
|
1591
|
+
}
|
1592
|
+
return {
|
1593
|
+
delay,
|
1594
|
+
distance: { value: 5 }
|
1595
|
+
};
|
1596
|
+
}
|
1597
|
+
})
|
1598
|
+
]);
|
1599
|
+
return sensors;
|
1600
|
+
};
|
1601
|
+
|
1602
|
+
// lib/dnd/collision/dynamic/index.ts
|
1603
|
+
init_react_import();
|
1604
|
+
var import_abstract9 = require("@dnd-kit/abstract");
|
1605
|
+
|
1606
|
+
// lib/dnd/collision/directional/index.ts
|
1607
|
+
init_react_import();
|
1608
|
+
var import_abstract2 = require("@dnd-kit/abstract");
|
1609
|
+
|
1610
|
+
// lib/dnd/collision/collision-debug.ts
|
1611
|
+
init_react_import();
|
1612
|
+
var DEBUG = false;
|
1613
|
+
var debugElements = {};
|
1614
|
+
var timeout;
|
1615
|
+
var collisionDebug = (a, b, id, color, label) => {
|
1616
|
+
if (!DEBUG) return;
|
1617
|
+
const debugId = `${id}-debug`;
|
1618
|
+
clearTimeout(timeout);
|
1619
|
+
timeout = setTimeout(() => {
|
1620
|
+
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
1621
|
+
svg.remove();
|
1622
|
+
delete debugElements[id2];
|
1623
|
+
});
|
1624
|
+
}, 1e3);
|
1625
|
+
requestAnimationFrame(() => {
|
1626
|
+
var _a, _b;
|
1627
|
+
const existingEl = debugElements[debugId];
|
1628
|
+
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
1629
|
+
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
1630
|
+
if (!existingEl) {
|
1631
|
+
const svgNs = "http://www.w3.org/2000/svg";
|
1632
|
+
const svg = document.createElementNS(svgNs, "svg");
|
1633
|
+
line = document.createElementNS(svgNs, "line");
|
1634
|
+
text = document.createElementNS(svgNs, "text");
|
1635
|
+
svg.setAttribute("id", debugId);
|
1636
|
+
svg.setAttribute(
|
1637
|
+
"style",
|
1638
|
+
"position: fixed; height: 100%; width: 100%; pointer-events: none;"
|
1639
|
+
);
|
1640
|
+
svg.appendChild(line);
|
1641
|
+
svg.appendChild(text);
|
1642
|
+
text.setAttribute("fill", `black`);
|
1643
|
+
document.body.appendChild(svg);
|
1644
|
+
debugElements[debugId] = { svg, line, text };
|
1645
|
+
}
|
1646
|
+
line.setAttribute("x1", a.x.toString());
|
1647
|
+
line.setAttribute("x2", b.x.toString());
|
1648
|
+
line.setAttribute("y1", a.y.toString());
|
1649
|
+
line.setAttribute("y2", b.y.toString());
|
1650
|
+
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
1651
|
+
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
1652
|
+
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
1653
|
+
if (label) {
|
1654
|
+
text.innerHTML = label;
|
1655
|
+
}
|
1656
|
+
});
|
1657
|
+
};
|
1658
|
+
|
1659
|
+
// lib/dnd/collision/directional/index.ts
|
1660
|
+
var distanceChange = "increasing";
|
1661
|
+
var directionalCollision = (input, previous) => {
|
1662
|
+
var _a;
|
1663
|
+
const { dragOperation, droppable } = input;
|
1664
|
+
const { shape: dropShape } = droppable;
|
1665
|
+
const { position } = dragOperation;
|
1666
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
1667
|
+
if (!dragShape || !dropShape) return null;
|
1668
|
+
const dropCenter = dropShape.center;
|
1669
|
+
const distanceToPrevious = Math.sqrt(
|
1670
|
+
Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
|
1671
|
+
);
|
1672
|
+
const distanceToCurrent = Math.sqrt(
|
1673
|
+
Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
|
1674
|
+
);
|
1675
|
+
distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
|
1676
|
+
collisionDebug(
|
1677
|
+
dragShape.center,
|
1678
|
+
dropCenter,
|
1679
|
+
droppable.id.toString(),
|
1680
|
+
"rebeccapurple"
|
1681
|
+
);
|
1682
|
+
if (distanceChange === "decreasing") {
|
1683
|
+
return {
|
1684
|
+
id: droppable.id,
|
1685
|
+
value: 1,
|
1686
|
+
type: import_abstract2.CollisionType.Collision
|
1687
|
+
};
|
1688
|
+
}
|
1689
|
+
return null;
|
1690
|
+
};
|
1691
|
+
|
1692
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
1693
|
+
init_react_import();
|
1694
|
+
var getDirection = (dragAxis, delta) => {
|
1695
|
+
if (dragAxis === "dynamic") {
|
1696
|
+
if (Math.abs(delta.y) > Math.abs(delta.x)) {
|
1697
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
1698
|
+
} else {
|
1699
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
1700
|
+
}
|
1701
|
+
} else if (dragAxis === "x") {
|
1702
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
1703
|
+
}
|
1704
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
1705
|
+
};
|
1706
|
+
|
1707
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
1708
|
+
init_react_import();
|
1709
|
+
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
1710
|
+
const dragRect = dragShape.boundingRectangle;
|
1711
|
+
const dropCenter = dropShape.center;
|
1712
|
+
if (direction === "down") {
|
1713
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
1714
|
+
return dragRect.bottom >= dropCenter.y + offset2;
|
1715
|
+
} else if (direction === "up") {
|
1716
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
1717
|
+
return dragRect.top < dropCenter.y - offset2;
|
1718
|
+
} else if (direction === "left") {
|
1719
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
|
1720
|
+
return dropCenter.x - offset2 >= dragRect.left;
|
1721
|
+
}
|
1722
|
+
const offset = offsetMultiplier * dropShape.boundingRectangle.width;
|
1723
|
+
return dragRect.right - offset >= dropCenter.x;
|
1724
|
+
};
|
1725
|
+
|
1726
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
1727
|
+
init_react_import();
|
1728
|
+
var import_geometry2 = require("@dnd-kit/geometry");
|
1729
|
+
var INTERVAL_SENSITIVITY = 10;
|
1730
|
+
var intervalCache = {
|
1731
|
+
current: { x: 0, y: 0 },
|
1732
|
+
delta: { x: 0, y: 0 },
|
1733
|
+
previous: { x: 0, y: 0 },
|
1734
|
+
direction: null
|
1735
|
+
};
|
1736
|
+
var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
1737
|
+
intervalCache.current = point;
|
1738
|
+
intervalCache.delta = {
|
1739
|
+
x: point.x - intervalCache.previous.x,
|
1740
|
+
y: point.y - intervalCache.previous.y
|
1741
|
+
};
|
1742
|
+
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
1743
|
+
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
1744
|
+
intervalCache.previous = import_geometry2.Point.from(point);
|
1745
|
+
}
|
1746
|
+
return intervalCache;
|
1747
|
+
};
|
1748
|
+
|
1749
|
+
// ../../node_modules/@dnd-kit/collision/dist/index.js
|
1750
|
+
init_react_import();
|
1751
|
+
var import_abstract3 = require("@dnd-kit/abstract");
|
1752
|
+
var import_geometry3 = require("@dnd-kit/geometry");
|
1753
|
+
var import_abstract4 = require("@dnd-kit/abstract");
|
1754
|
+
var import_geometry4 = require("@dnd-kit/geometry");
|
1755
|
+
var import_abstract5 = require("@dnd-kit/abstract");
|
1756
|
+
var import_geometry5 = require("@dnd-kit/geometry");
|
1757
|
+
var import_abstract6 = require("@dnd-kit/abstract");
|
1758
|
+
var import_geometry6 = require("@dnd-kit/geometry");
|
1759
|
+
var import_abstract7 = require("@dnd-kit/abstract");
|
1760
|
+
var import_geometry7 = require("@dnd-kit/geometry");
|
1761
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
1762
|
+
var import_geometry8 = require("@dnd-kit/geometry");
|
1763
|
+
var pointerIntersection = ({
|
1764
|
+
dragOperation,
|
1765
|
+
droppable
|
1766
|
+
}) => {
|
1767
|
+
const pointerCoordinates = dragOperation.position.current;
|
1768
|
+
if (!pointerCoordinates) {
|
1769
|
+
return null;
|
1770
|
+
}
|
1771
|
+
const { id } = droppable;
|
1772
|
+
if (!droppable.shape) {
|
1773
|
+
return null;
|
1774
|
+
}
|
1775
|
+
if (droppable.shape.containsPoint(pointerCoordinates)) {
|
1776
|
+
const distance = import_geometry3.Point.distance(droppable.shape.center, pointerCoordinates);
|
1777
|
+
return {
|
1778
|
+
id,
|
1779
|
+
value: 1 / distance,
|
1780
|
+
type: import_abstract3.CollisionType.PointerIntersection,
|
1781
|
+
priority: import_abstract3.CollisionPriority.High
|
1782
|
+
};
|
1783
|
+
}
|
1784
|
+
return null;
|
1785
|
+
};
|
1786
|
+
var closestCorners = (input) => {
|
1787
|
+
const { dragOperation, droppable } = input;
|
1788
|
+
const { shape, position } = dragOperation;
|
1789
|
+
if (!droppable.shape) {
|
1790
|
+
return null;
|
1791
|
+
}
|
1792
|
+
const { left, top, right, bottom } = droppable.shape.boundingRectangle;
|
1793
|
+
const corners = [
|
1794
|
+
{
|
1795
|
+
x: left,
|
1796
|
+
y: top
|
1797
|
+
},
|
1798
|
+
{
|
1799
|
+
x: right,
|
1800
|
+
y: top
|
1801
|
+
},
|
1802
|
+
{
|
1803
|
+
x: left,
|
1804
|
+
y: bottom
|
1805
|
+
},
|
1806
|
+
{
|
1807
|
+
x: right,
|
1808
|
+
y: bottom
|
1809
|
+
}
|
1810
|
+
];
|
1811
|
+
const distance = corners.reduce(
|
1812
|
+
(acc, corner) => {
|
1813
|
+
var _a;
|
1814
|
+
return acc + import_geometry5.Point.distance(
|
1815
|
+
import_geometry5.Point.from(corner),
|
1816
|
+
(_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
|
1817
|
+
);
|
1818
|
+
},
|
1819
|
+
0
|
1820
|
+
);
|
1821
|
+
const value = distance / 4;
|
1822
|
+
return {
|
1823
|
+
id: droppable.id,
|
1824
|
+
value: 1 / value,
|
1825
|
+
type: import_abstract5.CollisionType.Collision,
|
1826
|
+
priority: import_abstract5.CollisionPriority.Normal
|
1827
|
+
};
|
1828
|
+
};
|
1829
|
+
|
1830
|
+
// lib/dnd/collision/dynamic/store.ts
|
1831
|
+
init_react_import();
|
1832
|
+
var import_vanilla = require("zustand/vanilla");
|
1833
|
+
var collisionStore = (0, import_vanilla.createStore)(() => ({
|
1834
|
+
fallbackEnabled: false
|
1835
|
+
}));
|
1836
|
+
|
1837
|
+
// lib/dnd/collision/dynamic/index.ts
|
1838
|
+
var flushNext = "";
|
1839
|
+
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
1840
|
+
var _a, _b, _c, _d, _e;
|
1841
|
+
const { dragOperation, droppable } = input;
|
1842
|
+
const { position } = dragOperation;
|
1843
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
1844
|
+
const { shape: dropShape } = droppable;
|
1845
|
+
if (!dragShape || !dropShape) {
|
1846
|
+
return null;
|
1847
|
+
}
|
1848
|
+
const { center: dragCenter } = dragShape;
|
1849
|
+
const { fallbackEnabled } = collisionStore.getState();
|
1850
|
+
const interval = trackMovementInterval(position.current, dragAxis);
|
1851
|
+
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
1852
|
+
direction: interval.direction
|
1853
|
+
});
|
1854
|
+
const collisionMap = dragOperation.data.collisionMap || {};
|
1855
|
+
dragOperation.data.collisionMap = collisionMap;
|
1856
|
+
collisionMap[droppable.id] = {
|
1857
|
+
direction: interval.direction
|
1858
|
+
};
|
1859
|
+
const { center: dropCenter } = dropShape;
|
1860
|
+
const overMidpoint = getMidpointImpact(
|
1861
|
+
dragShape,
|
1862
|
+
dropShape,
|
1863
|
+
interval.direction,
|
1864
|
+
midpointOffset
|
1865
|
+
);
|
1866
|
+
if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
|
1867
|
+
const collision = directionalCollision(input, interval.previous);
|
1868
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
1869
|
+
if (collision) {
|
1870
|
+
return __spreadProps(__spreadValues({}, collision), {
|
1871
|
+
priority: import_abstract9.CollisionPriority.Highest
|
1872
|
+
});
|
1873
|
+
}
|
1874
|
+
}
|
1875
|
+
const intersectionArea = dragShape.intersectionArea(dropShape);
|
1876
|
+
const intersectionRatio = intersectionArea / dropShape.area;
|
1877
|
+
if (intersectionArea && overMidpoint) {
|
1878
|
+
collisionDebug(
|
1879
|
+
dragCenter,
|
1880
|
+
dropCenter,
|
1881
|
+
droppable.id.toString(),
|
1882
|
+
"green",
|
1883
|
+
interval.direction
|
1884
|
+
);
|
1885
|
+
const collision = {
|
1886
|
+
id: droppable.id,
|
1887
|
+
value: intersectionRatio,
|
1888
|
+
priority: import_abstract9.CollisionPriority.High,
|
1889
|
+
type: import_abstract9.CollisionType.Collision
|
1890
|
+
};
|
1891
|
+
const shouldFlushId = flushNext === droppable.id;
|
1892
|
+
flushNext = "";
|
1893
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
1894
|
+
}
|
1895
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
1896
|
+
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
1897
|
+
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
1898
|
+
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
1899
|
+
const fallbackCollision = closestCorners(input);
|
1900
|
+
if (fallbackCollision) {
|
1901
|
+
const direction = getDirection(dragAxis, {
|
1902
|
+
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
1903
|
+
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
1904
|
+
});
|
1905
|
+
collisionMap[droppable.id] = {
|
1906
|
+
direction
|
1907
|
+
};
|
1908
|
+
if (intersectionArea) {
|
1909
|
+
collisionDebug(
|
1910
|
+
dragCenter,
|
1911
|
+
dropCenter,
|
1912
|
+
droppable.id.toString(),
|
1913
|
+
"red",
|
1914
|
+
direction || ""
|
1915
|
+
);
|
1916
|
+
flushNext = droppable.id;
|
1917
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
1918
|
+
priority: import_abstract9.CollisionPriority.Low
|
1919
|
+
});
|
1920
|
+
}
|
1921
|
+
collisionDebug(
|
1922
|
+
dragCenter,
|
1923
|
+
dropCenter,
|
1924
|
+
droppable.id.toString(),
|
1925
|
+
"orange",
|
1926
|
+
direction || ""
|
1927
|
+
);
|
1928
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract9.CollisionPriority.Lowest });
|
1929
|
+
}
|
1930
|
+
}
|
1931
|
+
}
|
1932
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
1933
|
+
delete collisionMap[droppable.id];
|
1934
|
+
return null;
|
1935
|
+
};
|
1936
|
+
|
1937
|
+
// components/Sortable/index.tsx
|
1938
|
+
var import_modifiers = require("@dnd-kit/dom/modifiers");
|
1939
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
1940
|
+
var SortableProvider = ({
|
1941
|
+
children,
|
1942
|
+
onDragStart,
|
1943
|
+
onDragEnd,
|
1944
|
+
onMove
|
1945
|
+
}) => {
|
1946
|
+
const [move, setMove] = (0, import_react11.useState)({ source: -1, target: -1 });
|
1947
|
+
const sensors = useSensors();
|
1948
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
1949
|
+
import_react10.DragDropProvider,
|
1950
|
+
{
|
1951
|
+
sensors,
|
1952
|
+
modifiers: [
|
1953
|
+
import_modifiers.RestrictToElement.configure({
|
1954
|
+
element() {
|
1955
|
+
return document.querySelector("[data-dnd-container]");
|
1956
|
+
}
|
1957
|
+
})
|
1958
|
+
],
|
1959
|
+
onDragStart,
|
1960
|
+
onDragOver: (event, manager) => {
|
1961
|
+
var _a, _b;
|
1962
|
+
const { operation } = event;
|
1963
|
+
const { source, target } = operation;
|
1964
|
+
if (!source || !target) return;
|
1965
|
+
let sourceIndex = source.data.index;
|
1966
|
+
let targetIndex = target.data.index;
|
1967
|
+
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
|
1968
|
+
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
1969
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
|
1970
|
+
if (targetIndex >= sourceIndex) {
|
1971
|
+
targetIndex = targetIndex - 1;
|
1972
|
+
}
|
1973
|
+
if (collisionPosition === "after") {
|
1974
|
+
targetIndex = targetIndex + 1;
|
1975
|
+
}
|
1976
|
+
setMove({
|
1977
|
+
source: sourceIndex,
|
1978
|
+
target: targetIndex
|
1979
|
+
});
|
1980
|
+
}
|
1981
|
+
},
|
1982
|
+
onDragEnd: () => {
|
1983
|
+
setTimeout(() => {
|
1984
|
+
if (move.source !== -1 && move.target !== -1) {
|
1985
|
+
onMove(move);
|
1986
|
+
}
|
1987
|
+
onDragEnd();
|
1988
|
+
}, 250);
|
1989
|
+
setMove({ source: -1, target: -1 });
|
1990
|
+
},
|
1991
|
+
children
|
1992
|
+
}
|
1993
|
+
);
|
1994
|
+
};
|
1995
|
+
var Sortable = ({
|
1996
|
+
id,
|
1997
|
+
index,
|
1998
|
+
disabled,
|
1999
|
+
children,
|
2000
|
+
type = "item"
|
2001
|
+
}) => {
|
2002
|
+
const { ref: sortableRef, status } = useSortableSafe({
|
2003
|
+
id,
|
2004
|
+
type,
|
2005
|
+
index,
|
2006
|
+
disabled,
|
2007
|
+
data: { index },
|
2008
|
+
collisionDetector: createDynamicCollisionDetector("y")
|
2009
|
+
});
|
2010
|
+
return children({ status, ref: sortableRef });
|
2011
|
+
};
|
2012
|
+
|
2013
|
+
// components/AutoField/context.tsx
|
2014
|
+
init_react_import();
|
2015
|
+
var import_react12 = require("react");
|
2016
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
2017
|
+
var NestedFieldContext = (0, import_react12.createContext)({});
|
2018
|
+
var useNestedFieldContext = () => {
|
2019
|
+
const context = (0, import_react12.useContext)(NestedFieldContext);
|
2020
|
+
return __spreadProps(__spreadValues({}, context), {
|
2021
|
+
readOnlyFields: context.readOnlyFields || {}
|
2022
|
+
});
|
2023
|
+
};
|
2024
|
+
var NestedFieldProvider = ({
|
2025
|
+
children,
|
2026
|
+
name,
|
2027
|
+
subName,
|
2028
|
+
wildcardName = name,
|
2029
|
+
readOnlyFields
|
2030
|
+
}) => {
|
2031
|
+
const subPath = `${name}.${subName}`;
|
2032
|
+
const wildcardSubPath = `${wildcardName}.${subName}`;
|
2033
|
+
const subReadOnlyFields = (0, import_react12.useMemo)(
|
2034
|
+
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
2035
|
+
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
2036
|
+
if (isLocal) {
|
2037
|
+
const subPathPattern = new RegExp(
|
2038
|
+
`^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
|
2039
|
+
);
|
2040
|
+
const localName = readOnlyKey.replace(subPathPattern, "");
|
2041
|
+
return __spreadProps(__spreadValues({}, acc), {
|
2042
|
+
[localName]: readOnlyFields[readOnlyKey]
|
2043
|
+
});
|
2044
|
+
}
|
2045
|
+
return acc;
|
2046
|
+
}, {}),
|
2047
|
+
[name, subName, wildcardName, readOnlyFields]
|
2048
|
+
);
|
2049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
2050
|
+
NestedFieldContext.Provider,
|
2051
|
+
{
|
2052
|
+
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
2053
|
+
children
|
2054
|
+
}
|
2055
|
+
);
|
2056
|
+
};
|
2057
|
+
|
2058
|
+
// components/AutoField/fields/ArrayField/index.tsx
|
2059
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
2060
|
+
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
2061
|
+
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
2062
|
+
var ArrayField = ({
|
2063
|
+
field,
|
2064
|
+
onChange,
|
2065
|
+
value: _value,
|
2066
|
+
name,
|
2067
|
+
label,
|
2068
|
+
readOnly,
|
2069
|
+
id,
|
2070
|
+
Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadValues({}, props))
|
2071
|
+
}) => {
|
2072
|
+
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
2073
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2074
|
+
const value = _value;
|
2075
|
+
const arrayState = state.ui.arrayState[id] || {
|
2076
|
+
items: Array.from(value || []).map((item, idx) => {
|
2077
|
+
return {
|
2078
|
+
_originalIndex: idx,
|
2079
|
+
_arrayId: `${id}-${idx}`
|
2080
|
+
};
|
2081
|
+
}),
|
2082
|
+
openId: ""
|
2083
|
+
};
|
2084
|
+
const [localState, setLocalState] = (0, import_react13.useState)({ arrayState, value });
|
2085
|
+
(0, import_react13.useEffect)(() => {
|
2086
|
+
setLocalState({ arrayState, value });
|
2087
|
+
}, [value, state.ui.arrayState[id]]);
|
2088
|
+
const mapArrayStateToUi = (0, import_react13.useCallback)(
|
2089
|
+
(partialArrayState) => {
|
2090
|
+
return {
|
2091
|
+
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
2092
|
+
[id]: __spreadValues(__spreadValues({}, arrayState), partialArrayState)
|
2093
|
+
})
|
2094
|
+
};
|
2095
|
+
},
|
2096
|
+
[arrayState]
|
2097
|
+
);
|
2098
|
+
const getHighestIndex = (0, import_react13.useCallback)(() => {
|
2099
|
+
return arrayState.items.reduce(
|
2100
|
+
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
2101
|
+
-1
|
2102
|
+
);
|
2103
|
+
}, [arrayState]);
|
2104
|
+
const regenerateArrayState = (0, import_react13.useCallback)(
|
2105
|
+
(value2) => {
|
2106
|
+
let highestIndex = getHighestIndex();
|
2107
|
+
const newItems = Array.from(value2 || []).map((item, idx) => {
|
2108
|
+
var _a;
|
2109
|
+
const arrayStateItem = arrayState.items[idx];
|
2110
|
+
const newItem = {
|
2111
|
+
_originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : highestIndex + 1,
|
2112
|
+
_arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex + 1}`
|
2113
|
+
};
|
2114
|
+
if (newItem._originalIndex > highestIndex) {
|
2115
|
+
highestIndex = newItem._originalIndex;
|
2116
|
+
}
|
2117
|
+
return newItem;
|
2118
|
+
});
|
2119
|
+
return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
|
2120
|
+
},
|
2121
|
+
[arrayState]
|
2122
|
+
);
|
2123
|
+
(0, import_react13.useEffect)(() => {
|
2124
|
+
if (arrayState.items.length > 0) {
|
2125
|
+
setUi(mapArrayStateToUi(arrayState));
|
2126
|
+
}
|
2127
|
+
}, []);
|
2128
|
+
const [isDragging, setIsDragging] = (0, import_react13.useState)(false);
|
2129
|
+
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
2130
|
+
if (field.type !== "array" || !field.arrayFields) {
|
2131
|
+
return null;
|
2132
|
+
}
|
2133
|
+
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
2134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2135
|
+
Label2,
|
2136
|
+
{
|
2137
|
+
label: label || name,
|
1486
2138
|
icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(List, { size: 16 }),
|
1487
2139
|
el: "div",
|
1488
2140
|
readOnly,
|
1489
2141
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1490
2142
|
SortableProvider,
|
1491
2143
|
{
|
2144
|
+
onDragStart: () => setIsDragging(true),
|
2145
|
+
onDragEnd: () => setIsDragging(false),
|
1492
2146
|
onMove: (move) => {
|
1493
2147
|
const newValue = reorder(value, move.source, move.target);
|
1494
2148
|
const newArrayStateItems = reorder(
|
@@ -1519,7 +2173,7 @@ var ArrayField = ({
|
|
1519
2173
|
e.preventDefault();
|
1520
2174
|
},
|
1521
2175
|
children: [
|
1522
|
-
localState.arrayState.items.map((item, i) => {
|
2176
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
1523
2177
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
1524
2178
|
const data = Array.from(localState.value || [])[i] || {};
|
1525
2179
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
@@ -1542,6 +2196,7 @@ var ArrayField = ({
|
|
1542
2196
|
"div",
|
1543
2197
|
{
|
1544
2198
|
onClick: (e) => {
|
2199
|
+
if (isDragging) return;
|
1545
2200
|
e.preventDefault();
|
1546
2201
|
e.stopPropagation();
|
1547
2202
|
if (arrayState.openId === _arrayId) {
|
@@ -1571,7 +2226,11 @@ var ArrayField = ({
|
|
1571
2226
|
onClick: (e) => {
|
1572
2227
|
e.stopPropagation();
|
1573
2228
|
const existingValue = [...value || []];
|
1574
|
-
existingValue.splice(
|
2229
|
+
existingValue.splice(
|
2230
|
+
i,
|
2231
|
+
0,
|
2232
|
+
existingValue[i]
|
2233
|
+
);
|
1575
2234
|
onChange(
|
1576
2235
|
existingValue,
|
1577
2236
|
mapArrayStateToUi(
|
@@ -1613,62 +2272,72 @@ var ArrayField = ({
|
|
1613
2272
|
]
|
1614
2273
|
}
|
1615
2274
|
),
|
1616
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
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,
|
1635
|
-
{
|
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
|
-
)
|
2275
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2276
|
+
"fieldset",
|
2277
|
+
{
|
2278
|
+
className: getClassNameItem("fieldset"),
|
2279
|
+
onPointerDownCapture: (e) => {
|
2280
|
+
e.stopPropagation();
|
1655
2281
|
},
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
2282
|
+
children: Object.keys(field.arrayFields).map((subName) => {
|
2283
|
+
const subField = field.arrayFields[subName];
|
2284
|
+
const indexName = `${name}[${i}]`;
|
2285
|
+
const subPath = `${indexName}.${subName}`;
|
2286
|
+
const localIndexName = `${localName}[${i}]`;
|
2287
|
+
const localWildcardName = `${localName}[*]`;
|
2288
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
2289
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2290
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2291
|
+
const label2 = subField.label || subName;
|
2292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2293
|
+
NestedFieldProvider,
|
2294
|
+
{
|
2295
|
+
name: localIndexName,
|
2296
|
+
wildcardName: localWildcardName,
|
2297
|
+
subName,
|
2298
|
+
readOnlyFields,
|
2299
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2300
|
+
AutoFieldPrivate,
|
2301
|
+
{
|
2302
|
+
name: subPath,
|
2303
|
+
label: label2,
|
2304
|
+
id: `${_arrayId}_${subName}`,
|
2305
|
+
readOnly: subReadOnly,
|
2306
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2307
|
+
label: label2
|
2308
|
+
// May be used by custom fields
|
2309
|
+
}),
|
2310
|
+
value: data[subName],
|
2311
|
+
onChange: (val, ui) => {
|
2312
|
+
onChange(
|
2313
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2314
|
+
[subName]: val
|
2315
|
+
})),
|
2316
|
+
ui
|
2317
|
+
);
|
2318
|
+
}
|
2319
|
+
}
|
2320
|
+
)
|
2321
|
+
},
|
2322
|
+
subPath
|
2323
|
+
);
|
2324
|
+
})
|
2325
|
+
}
|
2326
|
+
) })
|
1659
2327
|
]
|
1660
2328
|
}
|
1661
2329
|
)
|
1662
2330
|
},
|
1663
2331
|
_arrayId
|
1664
2332
|
);
|
1665
|
-
}),
|
2333
|
+
}) }),
|
1666
2334
|
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1667
2335
|
"button",
|
1668
2336
|
{
|
1669
2337
|
type: "button",
|
1670
2338
|
className: getClassName5("addButton"),
|
1671
2339
|
onClick: () => {
|
2340
|
+
if (isDragging) return;
|
1672
2341
|
const existingValue = value || [];
|
1673
2342
|
const newValue = [
|
1674
2343
|
...existingValue,
|
@@ -1749,19 +2418,19 @@ var DefaultField = ({
|
|
1749
2418
|
|
1750
2419
|
// components/AutoField/fields/ExternalField/index.tsx
|
1751
2420
|
init_react_import();
|
1752
|
-
var
|
2421
|
+
var import_react17 = require("react");
|
1753
2422
|
|
1754
2423
|
// components/ExternalInput/index.tsx
|
1755
2424
|
init_react_import();
|
1756
|
-
var
|
2425
|
+
var import_react16 = require("react");
|
1757
2426
|
|
1758
2427
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
1759
2428
|
init_react_import();
|
1760
|
-
var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-
|
2429
|
+
var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_91ls0_1", "ExternalInput-button": "_ExternalInput-button_91ls0_5", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_91ls0_24", "ExternalInput--readOnly": "_ExternalInput--readOnly_91ls0_31", "ExternalInput-detachButton": "_ExternalInput-detachButton_91ls0_35", "ExternalInput": "_ExternalInput_91ls0_1", "ExternalInputModal": "_ExternalInputModal_91ls0_79", "ExternalInputModal-grid": "_ExternalInputModal-grid_91ls0_89", "ExternalInputModal--filtersToggled": "_ExternalInputModal--filtersToggled_91ls0_100", "ExternalInputModal-filters": "_ExternalInputModal-filters_91ls0_105", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_91ls0_124", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_91ls0_133", "ExternalInputModal-table": "_ExternalInputModal-table_91ls0_133", "ExternalInputModal-thead": "_ExternalInputModal-thead_91ls0_149", "ExternalInputModal-th": "_ExternalInputModal-th_91ls0_149", "ExternalInputModal-td": "_ExternalInputModal-td_91ls0_164", "ExternalInputModal-tr": "_ExternalInputModal-tr_91ls0_169", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_91ls0_176", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_91ls0_202", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_91ls0_206", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_91ls0_223", "ExternalInputModal-searchForm": "_ExternalInputModal-searchForm_91ls0_227", "ExternalInputModal-search": "_ExternalInputModal-search_91ls0_227", "ExternalInputModal-searchIcon": "_ExternalInputModal-searchIcon_91ls0_264", "ExternalInputModal-searchIconText": "_ExternalInputModal-searchIconText_91ls0_289", "ExternalInputModal-searchInput": "_ExternalInputModal-searchInput_91ls0_299", "ExternalInputModal-searchActions": "_ExternalInputModal-searchActions_91ls0_313", "ExternalInputModal-searchActionIcon": "_ExternalInputModal-searchActionIcon_91ls0_326", "ExternalInputModal-footerContainer": "_ExternalInputModal-footerContainer_91ls0_330", "ExternalInputModal-footer": "_ExternalInputModal-footer_91ls0_330", "ExternalInputModal-field": "_ExternalInputModal-field_91ls0_343" };
|
1761
2430
|
|
1762
2431
|
// components/Modal/index.tsx
|
1763
2432
|
init_react_import();
|
1764
|
-
var
|
2433
|
+
var import_react14 = require("react");
|
1765
2434
|
|
1766
2435
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
1767
2436
|
init_react_import();
|
@@ -1776,8 +2445,8 @@ var Modal = ({
|
|
1776
2445
|
onClose,
|
1777
2446
|
isOpen
|
1778
2447
|
}) => {
|
1779
|
-
const [rootEl, setRootEl] = (0,
|
1780
|
-
(0,
|
2448
|
+
const [rootEl, setRootEl] = (0, import_react14.useState)(null);
|
2449
|
+
(0, import_react14.useEffect)(() => {
|
1781
2450
|
setRootEl(document.getElementById("puck-portal-root"));
|
1782
2451
|
}, []);
|
1783
2452
|
if (!rootEl) {
|
@@ -1824,11 +2493,11 @@ init_react_import();
|
|
1824
2493
|
|
1825
2494
|
// components/Button/Button.tsx
|
1826
2495
|
init_react_import();
|
1827
|
-
var
|
2496
|
+
var import_react15 = require("react");
|
1828
2497
|
|
1829
2498
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
1830
2499
|
init_react_import();
|
1831
|
-
var Button_module_default = { "Button": "
|
2500
|
+
var Button_module_default = { "Button": "_Button_10byl_1", "Button--medium": "_Button--medium_10byl_29", "Button--large": "_Button--large_10byl_37", "Button-icon": "_Button-icon_10byl_44", "Button--primary": "_Button--primary_10byl_48", "Button--secondary": "_Button--secondary_10byl_67", "Button--flush": "_Button--flush_10byl_84", "Button--disabled": "_Button--disabled_10byl_88", "Button--fullWidth": "_Button--fullWidth_10byl_95", "Button-spinner": "_Button-spinner_10byl_100" };
|
1832
2501
|
|
1833
2502
|
// lib/filter-data-attrs.ts
|
1834
2503
|
init_react_import();
|
@@ -1874,8 +2543,8 @@ var Button = (_a) => {
|
|
1874
2543
|
"size",
|
1875
2544
|
"loading"
|
1876
2545
|
]);
|
1877
|
-
const [loading, setLoading] = (0,
|
1878
|
-
(0,
|
2546
|
+
const [loading, setLoading] = (0, import_react15.useState)(loadingProp);
|
2547
|
+
(0, import_react15.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
1879
2548
|
const ElementType = href ? "a" : type ? "button" : "span";
|
1880
2549
|
const dataAttrs = filterDataAttrs(props);
|
1881
2550
|
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
@@ -1930,28 +2599,28 @@ var ExternalInput = ({
|
|
1930
2599
|
mapRow = (val) => val,
|
1931
2600
|
filterFields
|
1932
2601
|
} = field || {};
|
1933
|
-
const [data, setData] = (0,
|
1934
|
-
const [isOpen, setOpen] = (0,
|
1935
|
-
const [isLoading, setIsLoading] = (0,
|
2602
|
+
const [data, setData] = (0, import_react16.useState)([]);
|
2603
|
+
const [isOpen, setOpen] = (0, import_react16.useState)(false);
|
2604
|
+
const [isLoading, setIsLoading] = (0, import_react16.useState)(true);
|
1936
2605
|
const hasFilterFields = !!filterFields;
|
1937
|
-
const [filters, setFilters] = (0,
|
1938
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
1939
|
-
const mappedData = (0,
|
2606
|
+
const [filters, setFilters] = (0, import_react16.useState)(field.initialFilters || {});
|
2607
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react16.useState)(hasFilterFields);
|
2608
|
+
const mappedData = (0, import_react16.useMemo)(() => {
|
1940
2609
|
return data.map(mapRow);
|
1941
2610
|
}, [data]);
|
1942
|
-
const keys = (0,
|
2611
|
+
const keys = (0, import_react16.useMemo)(() => {
|
1943
2612
|
const validKeys = /* @__PURE__ */ new Set();
|
1944
2613
|
for (const item of mappedData) {
|
1945
2614
|
for (const key of Object.keys(item)) {
|
1946
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
2615
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react16.isValidElement)(item[key])) {
|
1947
2616
|
validKeys.add(key);
|
1948
2617
|
}
|
1949
2618
|
}
|
1950
2619
|
}
|
1951
2620
|
return Array.from(validKeys);
|
1952
2621
|
}, [mappedData]);
|
1953
|
-
const [searchQuery, setSearchQuery] = (0,
|
1954
|
-
const search = (0,
|
2622
|
+
const [searchQuery, setSearchQuery] = (0, import_react16.useState)(field.initialQuery || "");
|
2623
|
+
const search = (0, import_react16.useCallback)(
|
1955
2624
|
(query, filters2) => __async(void 0, null, function* () {
|
1956
2625
|
setIsLoading(true);
|
1957
2626
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -1964,7 +2633,7 @@ var ExternalInput = ({
|
|
1964
2633
|
}),
|
1965
2634
|
[id, field]
|
1966
2635
|
);
|
1967
|
-
const Footer = (0,
|
2636
|
+
const Footer = (0, import_react16.useCallback)(
|
1968
2637
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
1969
2638
|
props.items.length,
|
1970
2639
|
" result",
|
@@ -1972,7 +2641,7 @@ var ExternalInput = ({
|
|
1972
2641
|
] }),
|
1973
2642
|
[field.renderFooter]
|
1974
2643
|
);
|
1975
|
-
(0,
|
2644
|
+
(0, import_react16.useEffect)(() => {
|
1976
2645
|
search(searchQuery, filters);
|
1977
2646
|
}, []);
|
1978
2647
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
@@ -2065,18 +2734,26 @@ var ExternalInput = ({
|
|
2065
2734
|
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
2066
2735
|
const filterField = filterFields[fieldName];
|
2067
2736
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2068
|
-
|
2737
|
+
"div",
|
2069
2738
|
{
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2739
|
+
className: getClassNameModal("field"),
|
2740
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2741
|
+
AutoFieldPrivate,
|
2742
|
+
{
|
2743
|
+
field: filterField,
|
2744
|
+
name: fieldName,
|
2745
|
+
id: `external_field_${fieldName}_filter`,
|
2746
|
+
label: filterField.label || fieldName,
|
2747
|
+
value: filters[fieldName],
|
2748
|
+
onChange: (value2) => {
|
2749
|
+
const newFilters = __spreadProps(__spreadValues({}, filters), {
|
2750
|
+
[fieldName]: value2
|
2751
|
+
});
|
2752
|
+
setFilters(newFilters);
|
2753
|
+
search(searchQuery, newFilters);
|
2754
|
+
}
|
2755
|
+
}
|
2756
|
+
)
|
2080
2757
|
},
|
2081
2758
|
fieldName
|
2082
2759
|
);
|
@@ -2135,7 +2812,7 @@ var ExternalField = ({
|
|
2135
2812
|
var _a, _b, _c;
|
2136
2813
|
const validField = field;
|
2137
2814
|
const deprecatedField = field;
|
2138
|
-
(0,
|
2815
|
+
(0, import_react17.useEffect)(() => {
|
2139
2816
|
if (deprecatedField.adaptor) {
|
2140
2817
|
console.error(
|
2141
2818
|
"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."
|
@@ -2170,7 +2847,7 @@ var ExternalField = ({
|
|
2170
2847
|
|
2171
2848
|
// components/AutoField/fields/RadioField/index.tsx
|
2172
2849
|
init_react_import();
|
2173
|
-
var
|
2850
|
+
var import_react18 = require("react");
|
2174
2851
|
|
2175
2852
|
// lib/safe-json-parse.ts
|
2176
2853
|
init_react_import();
|
@@ -2196,7 +2873,7 @@ var RadioField = ({
|
|
2196
2873
|
label,
|
2197
2874
|
Label: Label2
|
2198
2875
|
}) => {
|
2199
|
-
const flatOptions = (0,
|
2876
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2200
2877
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2201
2878
|
[field]
|
2202
2879
|
);
|
@@ -2246,7 +2923,7 @@ var RadioField = ({
|
|
2246
2923
|
|
2247
2924
|
// components/AutoField/fields/SelectField/index.tsx
|
2248
2925
|
init_react_import();
|
2249
|
-
var
|
2926
|
+
var import_react19 = require("react");
|
2250
2927
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2251
2928
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2252
2929
|
var SelectField = ({
|
@@ -2259,7 +2936,7 @@ var SelectField = ({
|
|
2259
2936
|
readOnly,
|
2260
2937
|
id
|
2261
2938
|
}) => {
|
2262
|
-
const flatOptions = (0,
|
2939
|
+
const flatOptions = (0, import_react19.useMemo)(
|
2263
2940
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2264
2941
|
[field]
|
2265
2942
|
);
|
@@ -2411,7 +3088,7 @@ var ObjectField = ({
|
|
2411
3088
|
|
2412
3089
|
// lib/use-safe-id.ts
|
2413
3090
|
init_react_import();
|
2414
|
-
var
|
3091
|
+
var import_react20 = __toESM(require("react"));
|
2415
3092
|
|
2416
3093
|
// lib/generate-id.ts
|
2417
3094
|
init_react_import();
|
@@ -2420,10 +3097,10 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
2420
3097
|
|
2421
3098
|
// lib/use-safe-id.ts
|
2422
3099
|
var useSafeId = () => {
|
2423
|
-
if (typeof
|
2424
|
-
return
|
3100
|
+
if (typeof import_react20.default.useId !== "undefined") {
|
3101
|
+
return import_react20.default.useId();
|
2425
3102
|
}
|
2426
|
-
const [id] = (0,
|
3103
|
+
const [id] = (0, import_react20.useState)(generateId());
|
2427
3104
|
return id;
|
2428
3105
|
};
|
2429
3106
|
|
@@ -2457,7 +3134,7 @@ var FieldLabelInternal = ({
|
|
2457
3134
|
readOnly
|
2458
3135
|
}) => {
|
2459
3136
|
const { overrides } = useAppContext();
|
2460
|
-
const Wrapper = (0,
|
3137
|
+
const Wrapper = (0, import_react21.useMemo)(
|
2461
3138
|
() => overrides.fieldLabel || FieldLabel,
|
2462
3139
|
[overrides]
|
2463
3140
|
);
|
@@ -2479,7 +3156,7 @@ var FieldLabelInternal = ({
|
|
2479
3156
|
function AutoFieldInternal(props) {
|
2480
3157
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2481
3158
|
const { dispatch, overrides, selectedItem } = useAppContext();
|
2482
|
-
const nestedFieldContext = (0,
|
3159
|
+
const nestedFieldContext = (0, import_react21.useContext)(NestedFieldContext);
|
2483
3160
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2484
3161
|
const field = props.field;
|
2485
3162
|
const label = field.label;
|
@@ -2511,9 +3188,9 @@ function AutoFieldInternal(props) {
|
|
2511
3188
|
Label: Label2,
|
2512
3189
|
id: resolvedId
|
2513
3190
|
});
|
2514
|
-
const onFocus = (0,
|
3191
|
+
const onFocus = (0, import_react21.useCallback)(
|
2515
3192
|
(e) => {
|
2516
|
-
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
3193
|
+
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
2517
3194
|
e.stopPropagation();
|
2518
3195
|
dispatch({
|
2519
3196
|
type: "setUi",
|
@@ -2525,7 +3202,7 @@ function AutoFieldInternal(props) {
|
|
2525
3202
|
},
|
2526
3203
|
[mergedProps.name]
|
2527
3204
|
);
|
2528
|
-
const onBlur = (0,
|
3205
|
+
const onBlur = (0, import_react21.useCallback)((e) => {
|
2529
3206
|
if ("name" in e.target) {
|
2530
3207
|
dispatch({
|
2531
3208
|
type: "setUi",
|
@@ -2569,7 +3246,7 @@ function AutoFieldInternal(props) {
|
|
2569
3246
|
function AutoFieldPrivate(props) {
|
2570
3247
|
const { state } = useAppContext();
|
2571
3248
|
const { value, onChange } = props;
|
2572
|
-
const [localValue, setLocalValue] = (0,
|
3249
|
+
const [localValue, setLocalValue] = (0, import_react21.useState)(value);
|
2573
3250
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
2574
3251
|
(val, ui) => {
|
2575
3252
|
onChange(val, ui);
|
@@ -2577,11 +3254,11 @@ function AutoFieldPrivate(props) {
|
|
2577
3254
|
50,
|
2578
3255
|
{ leading: true }
|
2579
3256
|
);
|
2580
|
-
const onChangeLocal = (0,
|
3257
|
+
const onChangeLocal = (0, import_react21.useCallback)((val, ui) => {
|
2581
3258
|
setLocalValue(val);
|
2582
3259
|
onChangeDb(val, ui);
|
2583
3260
|
}, []);
|
2584
|
-
(0,
|
3261
|
+
(0, import_react21.useEffect)(() => {
|
2585
3262
|
if (state.ui.field.focus !== props.name) {
|
2586
3263
|
setLocalValue(value);
|
2587
3264
|
}
|
@@ -2593,7 +3270,7 @@ function AutoFieldPrivate(props) {
|
|
2593
3270
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2594
3271
|
}
|
2595
3272
|
function AutoField(props) {
|
2596
|
-
const DefaultLabel = (0,
|
3273
|
+
const DefaultLabel = (0, import_react21.useMemo)(() => {
|
2597
3274
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2598
3275
|
"div",
|
2599
3276
|
__spreadProps(__spreadValues({}, labelProps), {
|
@@ -2603,373 +3280,38 @@ function AutoField(props) {
|
|
2603
3280
|
return DefaultLabel2;
|
2604
3281
|
}, [props.readOnly]);
|
2605
3282
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2606
|
-
}
|
2607
|
-
|
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
|
-
};
|
3283
|
+
}
|
2728
3284
|
|
2729
|
-
//
|
3285
|
+
// components/Drawer/index.tsx
|
2730
3286
|
init_react_import();
|
2731
|
-
var getDirection = (dragAxis, delta) => {
|
2732
|
-
if (dragAxis === "dynamic") {
|
2733
|
-
if (Math.abs(delta.y) > Math.abs(delta.x)) {
|
2734
|
-
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2735
|
-
} else {
|
2736
|
-
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
2737
|
-
}
|
2738
|
-
} else if (dragAxis === "x") {
|
2739
|
-
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
2740
|
-
}
|
2741
|
-
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2742
|
-
};
|
2743
3287
|
|
2744
|
-
//
|
3288
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
2745
3289
|
init_react_import();
|
2746
|
-
var
|
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
|
-
};
|
3290
|
+
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" };
|
2762
3291
|
|
2763
|
-
//
|
3292
|
+
// components/Drawer/index.tsx
|
3293
|
+
var import_react33 = require("react");
|
3294
|
+
|
3295
|
+
// components/DragDropContext/index.tsx
|
2764
3296
|
init_react_import();
|
2765
|
-
var
|
2766
|
-
var
|
2767
|
-
var
|
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
|
-
};
|
3297
|
+
var import_react31 = require("@dnd-kit/react");
|
3298
|
+
var import_react32 = require("react");
|
3299
|
+
var import_dom = require("@dnd-kit/dom");
|
2785
3300
|
|
2786
|
-
//
|
3301
|
+
// components/DropZone/index.tsx
|
2787
3302
|
init_react_import();
|
2788
|
-
var
|
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
|
-
};
|
3303
|
+
var import_react30 = require("react");
|
2866
3304
|
|
2867
|
-
//
|
3305
|
+
// components/DraggableComponent/index.tsx
|
2868
3306
|
init_react_import();
|
2869
|
-
var
|
2870
|
-
var collisionStore = (0, import_vanilla.createStore)(() => ({
|
2871
|
-
fallbackEnabled: false
|
2872
|
-
}));
|
3307
|
+
var import_react24 = require("react");
|
2873
3308
|
|
2874
|
-
//
|
2875
|
-
|
2876
|
-
var
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
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
|
-
};
|
3309
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
3310
|
+
init_react_import();
|
3311
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
|
3312
|
+
|
3313
|
+
// components/DraggableComponent/index.tsx
|
3314
|
+
var import_react_dom2 = require("react-dom");
|
2973
3315
|
|
2974
3316
|
// lib/get-deep-scroll-position.ts
|
2975
3317
|
init_react_import();
|
@@ -2992,11 +3334,11 @@ function getDeepScrollPosition(element) {
|
|
2992
3334
|
|
2993
3335
|
// components/DropZone/context.tsx
|
2994
3336
|
init_react_import();
|
2995
|
-
var
|
3337
|
+
var import_react22 = require("react");
|
2996
3338
|
var import_zustand = require("zustand");
|
2997
3339
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2998
|
-
var dropZoneContext = (0,
|
2999
|
-
var ZoneStoreContext = (0,
|
3340
|
+
var dropZoneContext = (0, import_react22.createContext)(null);
|
3341
|
+
var ZoneStoreContext = (0, import_react22.createContext)(
|
3000
3342
|
(0, import_zustand.createStore)(() => ({
|
3001
3343
|
zoneDepthIndex: {},
|
3002
3344
|
nextZoneDepthIndex: {},
|
@@ -3016,19 +3358,19 @@ var DropZoneProvider = ({
|
|
3016
3358
|
children,
|
3017
3359
|
value
|
3018
3360
|
}) => {
|
3019
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
3020
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
3361
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react22.useState)();
|
3362
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react22.useState)(
|
3021
3363
|
{}
|
3022
3364
|
);
|
3023
|
-
const [activeZones, setActiveZones] = (0,
|
3365
|
+
const [activeZones, setActiveZones] = (0, import_react22.useState)({});
|
3024
3366
|
const { dispatch } = useAppContext();
|
3025
|
-
const registerZoneArea = (0,
|
3367
|
+
const registerZoneArea = (0, import_react22.useCallback)(
|
3026
3368
|
(area) => {
|
3027
3369
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3028
3370
|
},
|
3029
3371
|
[setAreasWithZones]
|
3030
3372
|
);
|
3031
|
-
const registerZone = (0,
|
3373
|
+
const registerZone = (0, import_react22.useCallback)(
|
3032
3374
|
(zoneCompound) => {
|
3033
3375
|
if (!dispatch) {
|
3034
3376
|
return;
|
@@ -3041,7 +3383,7 @@ var DropZoneProvider = ({
|
|
3041
3383
|
},
|
3042
3384
|
[setActiveZones, dispatch]
|
3043
3385
|
);
|
3044
|
-
const unregisterZone = (0,
|
3386
|
+
const unregisterZone = (0, import_react22.useCallback)(
|
3045
3387
|
(zoneCompound) => {
|
3046
3388
|
if (!dispatch) {
|
3047
3389
|
return;
|
@@ -3056,7 +3398,7 @@ var DropZoneProvider = ({
|
|
3056
3398
|
},
|
3057
3399
|
[setActiveZones, dispatch]
|
3058
3400
|
);
|
3059
|
-
const memoValue = (0,
|
3401
|
+
const memoValue = (0, import_react22.useMemo)(
|
3060
3402
|
() => __spreadValues({
|
3061
3403
|
hoveringComponent,
|
3062
3404
|
setHoveringComponent,
|
@@ -3073,11 +3415,11 @@ var DropZoneProvider = ({
|
|
3073
3415
|
|
3074
3416
|
// lib/use-context-store.ts
|
3075
3417
|
init_react_import();
|
3076
|
-
var
|
3418
|
+
var import_react23 = require("react");
|
3077
3419
|
var import_zustand2 = require("zustand");
|
3078
3420
|
var import_shallow = require("zustand/react/shallow");
|
3079
3421
|
function useContextStore(context, selector) {
|
3080
|
-
const store = (0,
|
3422
|
+
const store = (0, import_react23.useContext)(context);
|
3081
3423
|
if (!store) {
|
3082
3424
|
throw new Error("useContextStore must be used inside context");
|
3083
3425
|
}
|
@@ -3136,9 +3478,9 @@ var DraggableComponent = ({
|
|
3136
3478
|
iframe,
|
3137
3479
|
state
|
3138
3480
|
} = useAppContext();
|
3139
|
-
const ctx = (0,
|
3140
|
-
const [localZones, setLocalZones] = (0,
|
3141
|
-
const registerLocalZone = (0,
|
3481
|
+
const ctx = (0, import_react24.useContext)(dropZoneContext);
|
3482
|
+
const [localZones, setLocalZones] = (0, import_react24.useState)({});
|
3483
|
+
const registerLocalZone = (0, import_react24.useCallback)(
|
3142
3484
|
(zoneCompound2, active) => {
|
3143
3485
|
var _a;
|
3144
3486
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -3148,7 +3490,7 @@ var DraggableComponent = ({
|
|
3148
3490
|
},
|
3149
3491
|
[setLocalZones]
|
3150
3492
|
);
|
3151
|
-
const unregisterLocalZone = (0,
|
3493
|
+
const unregisterLocalZone = (0, import_react24.useCallback)(
|
3152
3494
|
(zoneCompound2) => {
|
3153
3495
|
var _a;
|
3154
3496
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -3162,8 +3504,8 @@ var DraggableComponent = ({
|
|
3162
3504
|
);
|
3163
3505
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
3164
3506
|
const { path = [] } = ctx || {};
|
3165
|
-
const [canDrag, setCanDrag] = (0,
|
3166
|
-
(0,
|
3507
|
+
const [canDrag, setCanDrag] = (0, import_react24.useState)(false);
|
3508
|
+
(0, import_react24.useEffect)(() => {
|
3167
3509
|
var _a;
|
3168
3510
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
3169
3511
|
if (item) {
|
@@ -3179,7 +3521,7 @@ var DraggableComponent = ({
|
|
3179
3521
|
);
|
3180
3522
|
const canCollide = canDrag || userIsDragging;
|
3181
3523
|
const disabled = !isEnabled || !canCollide;
|
3182
|
-
const [dragAxis, setDragAxis] = (0,
|
3524
|
+
const [dragAxis, setDragAxis] = (0, import_react24.useState)(userDragAxis || autoDragAxis);
|
3183
3525
|
const { ref: sortableRef, status } = useSortableSafe({
|
3184
3526
|
id,
|
3185
3527
|
index,
|
@@ -3205,8 +3547,8 @@ var DraggableComponent = ({
|
|
3205
3547
|
}
|
3206
3548
|
});
|
3207
3549
|
const thisIsDragging = status === "dragging";
|
3208
|
-
const ref = (0,
|
3209
|
-
const refSetter = (0,
|
3550
|
+
const ref = (0, import_react24.useRef)(null);
|
3551
|
+
const refSetter = (0, import_react24.useCallback)(
|
3210
3552
|
(el) => {
|
3211
3553
|
sortableRef(el);
|
3212
3554
|
if (el) {
|
@@ -3215,14 +3557,14 @@ var DraggableComponent = ({
|
|
3215
3557
|
},
|
3216
3558
|
[sortableRef]
|
3217
3559
|
);
|
3218
|
-
const [portalEl, setPortalEl] = (0,
|
3219
|
-
(0,
|
3560
|
+
const [portalEl, setPortalEl] = (0, import_react24.useState)();
|
3561
|
+
(0, import_react24.useEffect)(() => {
|
3220
3562
|
var _a, _b, _c;
|
3221
3563
|
setPortalEl(
|
3222
3564
|
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
|
3223
3565
|
);
|
3224
3566
|
}, [iframe.enabled, ref.current]);
|
3225
|
-
const getStyle = (0,
|
3567
|
+
const getStyle = (0, import_react24.useCallback)(() => {
|
3226
3568
|
var _a, _b, _c;
|
3227
3569
|
if (!ref.current) return;
|
3228
3570
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3242,11 +3584,11 @@ var DraggableComponent = ({
|
|
3242
3584
|
};
|
3243
3585
|
return style2;
|
3244
3586
|
}, [ref.current]);
|
3245
|
-
const [style, setStyle] = (0,
|
3246
|
-
const sync = (0,
|
3587
|
+
const [style, setStyle] = (0, import_react24.useState)();
|
3588
|
+
const sync = (0, import_react24.useCallback)(() => {
|
3247
3589
|
setStyle(getStyle());
|
3248
3590
|
}, [ref.current, iframe]);
|
3249
|
-
(0,
|
3591
|
+
(0, import_react24.useEffect)(() => {
|
3250
3592
|
if (ref.current && !userIsDragging) {
|
3251
3593
|
const observer = new ResizeObserver(sync);
|
3252
3594
|
observer.observe(ref.current);
|
@@ -3255,7 +3597,7 @@ var DraggableComponent = ({
|
|
3255
3597
|
};
|
3256
3598
|
}
|
3257
3599
|
}, [ref.current, userIsDragging]);
|
3258
|
-
(0,
|
3600
|
+
(0, import_react24.useEffect)(() => {
|
3259
3601
|
ctx == null ? void 0 : ctx.registerPath(
|
3260
3602
|
id,
|
3261
3603
|
{
|
@@ -3269,14 +3611,14 @@ var DraggableComponent = ({
|
|
3269
3611
|
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3270
3612
|
};
|
3271
3613
|
}, [id, zoneCompound, index, componentType]);
|
3272
|
-
const CustomActionBar = (0,
|
3614
|
+
const CustomActionBar = (0, import_react24.useMemo)(
|
3273
3615
|
() => overrides.actionBar || DefaultActionBar,
|
3274
3616
|
[overrides.actionBar]
|
3275
3617
|
);
|
3276
3618
|
const permissions = getPermissions({
|
3277
3619
|
item: selectedItem
|
3278
3620
|
});
|
3279
|
-
const onClick = (0,
|
3621
|
+
const onClick = (0, import_react24.useCallback)(
|
3280
3622
|
(e) => {
|
3281
3623
|
e.stopPropagation();
|
3282
3624
|
dispatch({
|
@@ -3288,7 +3630,7 @@ var DraggableComponent = ({
|
|
3288
3630
|
},
|
3289
3631
|
[index, zoneCompound, id]
|
3290
3632
|
);
|
3291
|
-
const onSelectParent = (0,
|
3633
|
+
const onSelectParent = (0, import_react24.useCallback)(() => {
|
3292
3634
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3293
3635
|
return;
|
3294
3636
|
}
|
@@ -3306,23 +3648,23 @@ var DraggableComponent = ({
|
|
3306
3648
|
}
|
3307
3649
|
});
|
3308
3650
|
}, [ctx, path]);
|
3309
|
-
const onDuplicate = (0,
|
3651
|
+
const onDuplicate = (0, import_react24.useCallback)(() => {
|
3310
3652
|
dispatch({
|
3311
3653
|
type: "duplicate",
|
3312
3654
|
sourceIndex: index,
|
3313
3655
|
sourceZone: zoneCompound
|
3314
3656
|
});
|
3315
3657
|
}, [index, zoneCompound]);
|
3316
|
-
const onDelete = (0,
|
3658
|
+
const onDelete = (0, import_react24.useCallback)(() => {
|
3317
3659
|
dispatch({
|
3318
3660
|
type: "remove",
|
3319
3661
|
index,
|
3320
3662
|
zone: zoneCompound
|
3321
3663
|
});
|
3322
3664
|
}, [index, zoneCompound]);
|
3323
|
-
const [hover, setHover] = (0,
|
3665
|
+
const [hover, setHover] = (0, import_react24.useState)(false);
|
3324
3666
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3325
|
-
(0,
|
3667
|
+
(0, import_react24.useEffect)(() => {
|
3326
3668
|
if (!ref.current) {
|
3327
3669
|
return;
|
3328
3670
|
}
|
@@ -3372,7 +3714,7 @@ var DraggableComponent = ({
|
|
3372
3714
|
thisIsDragging,
|
3373
3715
|
inDroppableZone
|
3374
3716
|
]);
|
3375
|
-
(0,
|
3717
|
+
(0, import_react24.useEffect)(() => {
|
3376
3718
|
if (ref.current && disabled) {
|
3377
3719
|
ref.current.setAttribute("data-puck-disabled", "");
|
3378
3720
|
return () => {
|
@@ -3381,8 +3723,8 @@ var DraggableComponent = ({
|
|
3381
3723
|
};
|
3382
3724
|
}
|
3383
3725
|
}, [disabled, ref]);
|
3384
|
-
const [isVisible, setIsVisible] = (0,
|
3385
|
-
(0,
|
3726
|
+
const [isVisible, setIsVisible] = (0, import_react24.useState)(false);
|
3727
|
+
(0, import_react24.useEffect)(() => {
|
3386
3728
|
sync();
|
3387
3729
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3388
3730
|
setIsVisible(true);
|
@@ -3390,7 +3732,7 @@ var DraggableComponent = ({
|
|
3390
3732
|
setIsVisible(false);
|
3391
3733
|
}
|
3392
3734
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3393
|
-
const syncActionsPosition = (0,
|
3735
|
+
const syncActionsPosition = (0, import_react24.useCallback)(
|
3394
3736
|
(el) => {
|
3395
3737
|
if (el) {
|
3396
3738
|
const view = el.ownerDocument.defaultView;
|
@@ -3407,7 +3749,7 @@ var DraggableComponent = ({
|
|
3407
3749
|
},
|
3408
3750
|
[zoomConfig]
|
3409
3751
|
);
|
3410
|
-
(0,
|
3752
|
+
(0, import_react24.useEffect)(() => {
|
3411
3753
|
if (userDragAxis) {
|
3412
3754
|
setDragAxis(userDragAxis);
|
3413
3755
|
return;
|
@@ -3501,14 +3843,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
3501
3843
|
|
3502
3844
|
// components/DropZone/lib/use-min-empty-height.ts
|
3503
3845
|
init_react_import();
|
3504
|
-
var
|
3846
|
+
var import_react25 = require("react");
|
3505
3847
|
var useMinEmptyHeight = ({
|
3506
3848
|
zoneCompound,
|
3507
3849
|
userMinEmptyHeight,
|
3508
3850
|
ref
|
3509
3851
|
}) => {
|
3510
|
-
const [prevHeight, setPrevHeight] = (0,
|
3511
|
-
const [isAnimating, setIsAnimating] = (0,
|
3852
|
+
const [prevHeight, setPrevHeight] = (0, import_react25.useState)(0);
|
3853
|
+
const [isAnimating, setIsAnimating] = (0, import_react25.useState)(false);
|
3512
3854
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3513
3855
|
var _a, _b;
|
3514
3856
|
return {
|
@@ -3516,7 +3858,7 @@ var useMinEmptyHeight = ({
|
|
3516
3858
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3517
3859
|
};
|
3518
3860
|
});
|
3519
|
-
(0,
|
3861
|
+
(0, import_react25.useEffect)(() => {
|
3520
3862
|
if (draggedItem && ref.current) {
|
3521
3863
|
if (isZone) {
|
3522
3864
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3550,15 +3892,15 @@ function assignRefs(refs, node) {
|
|
3550
3892
|
|
3551
3893
|
// components/DropZone/lib/use-content-with-preview.ts
|
3552
3894
|
init_react_import();
|
3553
|
-
var
|
3895
|
+
var import_react28 = require("react");
|
3554
3896
|
|
3555
3897
|
// lib/dnd/use-rendered-callback.ts
|
3556
3898
|
init_react_import();
|
3557
|
-
var
|
3558
|
-
var
|
3899
|
+
var import_react26 = require("@dnd-kit/react");
|
3900
|
+
var import_react27 = require("react");
|
3559
3901
|
function useRenderedCallback(callback, deps) {
|
3560
|
-
const manager = (0,
|
3561
|
-
return (0,
|
3902
|
+
const manager = (0, import_react26.useDragDropManager)();
|
3903
|
+
return (0, import_react27.useCallback)(
|
3562
3904
|
(...args) => __async(this, null, function* () {
|
3563
3905
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
3564
3906
|
return callback(...args);
|
@@ -3593,8 +3935,8 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3593
3935
|
ui: { isDragging }
|
3594
3936
|
}
|
3595
3937
|
} = useAppContext();
|
3596
|
-
const [contentWithPreview, setContentWithPreview] = (0,
|
3597
|
-
const [localPreview, setLocalPreview] = (0,
|
3938
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react28.useState)(content);
|
3939
|
+
const [localPreview, setLocalPreview] = (0, import_react28.useState)(
|
3598
3940
|
preview
|
3599
3941
|
);
|
3600
3942
|
const updateContent = useRenderedCallback(
|
@@ -3635,7 +3977,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3635
3977
|
},
|
3636
3978
|
[draggedItemId, previewExists]
|
3637
3979
|
);
|
3638
|
-
(0,
|
3980
|
+
(0, import_react28.useEffect)(() => {
|
3639
3981
|
updateContent(content, preview, isDragging);
|
3640
3982
|
}, [content, preview, isDragging]);
|
3641
3983
|
return [contentWithPreview, localPreview];
|
@@ -3643,16 +3985,16 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3643
3985
|
|
3644
3986
|
// components/DropZone/lib/use-drag-axis.ts
|
3645
3987
|
init_react_import();
|
3646
|
-
var
|
3988
|
+
var import_react29 = require("react");
|
3647
3989
|
var GRID_DRAG_AXIS = "dynamic";
|
3648
3990
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3649
3991
|
var DEFAULT_DRAG_AXIS = "y";
|
3650
3992
|
var useDragAxis = (ref, collisionAxis) => {
|
3651
3993
|
const { status } = useAppContext();
|
3652
|
-
const [dragAxis, setDragAxis] = (0,
|
3994
|
+
const [dragAxis, setDragAxis] = (0, import_react29.useState)(
|
3653
3995
|
collisionAxis || DEFAULT_DRAG_AXIS
|
3654
3996
|
);
|
3655
|
-
const calculateDragAxis = (0,
|
3997
|
+
const calculateDragAxis = (0, import_react29.useCallback)(() => {
|
3656
3998
|
if (ref.current) {
|
3657
3999
|
const computedStyle = window.getComputedStyle(ref.current);
|
3658
4000
|
if (computedStyle.display === "grid") {
|
@@ -3664,7 +4006,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
3664
4006
|
}
|
3665
4007
|
}
|
3666
4008
|
}, [ref.current]);
|
3667
|
-
(0,
|
4009
|
+
(0, import_react29.useEffect)(() => {
|
3668
4010
|
const onViewportChange = () => {
|
3669
4011
|
calculateDragAxis();
|
3670
4012
|
};
|
@@ -3673,7 +4015,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
3673
4015
|
window.removeEventListener("viewportchange", onViewportChange);
|
3674
4016
|
};
|
3675
4017
|
}, []);
|
3676
|
-
(0,
|
4018
|
+
(0, import_react29.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
3677
4019
|
return [dragAxis, calculateDragAxis];
|
3678
4020
|
};
|
3679
4021
|
|
@@ -3683,7 +4025,7 @@ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_de
|
|
3683
4025
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3684
4026
|
var RENDER_DEBUG = false;
|
3685
4027
|
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
3686
|
-
var DropZoneEdit = (0,
|
4028
|
+
var DropZoneEdit = (0, import_react30.forwardRef)(
|
3687
4029
|
function DropZoneEditInternal({
|
3688
4030
|
zone,
|
3689
4031
|
allow,
|
@@ -3694,7 +4036,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3694
4036
|
collisionAxis
|
3695
4037
|
}, userRef) {
|
3696
4038
|
const appContext2 = useAppContext();
|
3697
|
-
const ctx = (0,
|
4039
|
+
const ctx = (0, import_react30.useContext)(dropZoneContext);
|
3698
4040
|
const {
|
3699
4041
|
// These all need setting via context
|
3700
4042
|
data,
|
@@ -3730,12 +4072,12 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3730
4072
|
};
|
3731
4073
|
});
|
3732
4074
|
const { itemSelector } = appContext2.state.ui;
|
3733
|
-
(0,
|
4075
|
+
(0, import_react30.useEffect)(() => {
|
3734
4076
|
if (areaId && registerZoneArea) {
|
3735
4077
|
registerZoneArea(areaId);
|
3736
4078
|
}
|
3737
4079
|
}, [areaId]);
|
3738
|
-
(0,
|
4080
|
+
(0, import_react30.useEffect)(() => {
|
3739
4081
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3740
4082
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3741
4083
|
}
|
@@ -3745,14 +4087,14 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3745
4087
|
}
|
3746
4088
|
};
|
3747
4089
|
}, []);
|
3748
|
-
const content = (0,
|
4090
|
+
const content = (0, import_react30.useMemo)(() => {
|
3749
4091
|
if (areaId && zone !== rootDroppableId) {
|
3750
4092
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3751
4093
|
}
|
3752
4094
|
return data.content || [];
|
3753
4095
|
}, [data, zoneCompound]);
|
3754
|
-
const ref = (0,
|
3755
|
-
const acceptsTarget = (0,
|
4096
|
+
const ref = (0, import_react30.useRef)(null);
|
4097
|
+
const acceptsTarget = (0, import_react30.useCallback)(
|
3756
4098
|
(componentType) => {
|
3757
4099
|
if (!componentType) {
|
3758
4100
|
return true;
|
@@ -3774,7 +4116,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3774
4116
|
},
|
3775
4117
|
[allow, disallow]
|
3776
4118
|
);
|
3777
|
-
(0,
|
4119
|
+
(0, import_react30.useEffect)(() => {
|
3778
4120
|
if (registerLocalZone) {
|
3779
4121
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3780
4122
|
}
|
@@ -3909,13 +4251,13 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3909
4251
|
}
|
3910
4252
|
);
|
3911
4253
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
3912
|
-
var DropZoneRender = (0,
|
4254
|
+
var DropZoneRender = (0, import_react30.forwardRef)(
|
3913
4255
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3914
|
-
const ctx = (0,
|
4256
|
+
const ctx = (0, import_react30.useContext)(dropZoneContext);
|
3915
4257
|
const { data, areaId = "root", config } = ctx || {};
|
3916
4258
|
let zoneCompound = rootDroppableId;
|
3917
4259
|
let content = (data == null ? void 0 : data.content) || [];
|
3918
|
-
(0,
|
4260
|
+
(0, import_react30.useEffect)(() => {
|
3919
4261
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3920
4262
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3921
4263
|
}
|
@@ -3961,944 +4303,710 @@ var DropZoneRender = (0, import_react29.forwardRef)(
|
|
3961
4303
|
}) });
|
3962
4304
|
}
|
3963
4305
|
);
|
3964
|
-
var
|
4306
|
+
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
|
4307
|
+
var DropZone = (0, import_react30.forwardRef)(
|
3965
4308
|
function DropZone2(props, ref) {
|
3966
|
-
const ctx = (0,
|
4309
|
+
const ctx = (0, import_react30.useContext)(dropZoneContext);
|
3967
4310
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3968
4311
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3969
|
-
}
|
3970
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3971
|
-
}
|
3972
|
-
);
|
3973
|
-
|
3974
|
-
// lib/get-zone-id.ts
|
3975
|
-
init_react_import();
|
3976
|
-
var getZoneId = (zoneCompound) => {
|
3977
|
-
if (!zoneCompound) {
|
3978
|
-
return [];
|
3979
|
-
}
|
3980
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
3981
|
-
return zoneCompound.split(":");
|
3982
|
-
}
|
3983
|
-
return [rootDroppableId, zoneCompound];
|
3984
|
-
};
|
3985
|
-
|
3986
|
-
// lib/dnd/NestedDroppablePlugin.ts
|
3987
|
-
init_react_import();
|
3988
|
-
var import_abstract9 = require("@dnd-kit/abstract");
|
3989
|
-
var import_state = require("@dnd-kit/state");
|
3990
|
-
|
3991
|
-
// lib/throttle.ts
|
3992
|
-
init_react_import();
|
3993
|
-
function timeout2(callback, duration) {
|
3994
|
-
const id = setTimeout(callback, duration);
|
3995
|
-
return () => clearTimeout(id);
|
3996
|
-
}
|
3997
|
-
function throttle(func, limit) {
|
3998
|
-
const time = () => performance.now();
|
3999
|
-
let cancel;
|
4000
|
-
let lastRan = 0;
|
4001
|
-
return function(...args) {
|
4002
|
-
const now = time();
|
4003
|
-
const context = this;
|
4004
|
-
if (now - lastRan >= limit) {
|
4005
|
-
func.apply(context, args);
|
4006
|
-
lastRan = now;
|
4007
|
-
} else {
|
4008
|
-
cancel == null ? void 0 : cancel();
|
4009
|
-
cancel = timeout2(() => {
|
4010
|
-
func.apply(context, args);
|
4011
|
-
lastRan = time();
|
4012
|
-
}, limit - (now - lastRan));
|
4013
|
-
}
|
4014
|
-
};
|
4015
|
-
}
|
4016
|
-
|
4017
|
-
// lib/get-frame.ts
|
4018
|
-
init_react_import();
|
4019
|
-
var getFrame = () => {
|
4020
|
-
if (typeof window === "undefined") return;
|
4021
|
-
let frameEl = document.querySelector("#preview-frame");
|
4022
|
-
if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
|
4023
|
-
return frameEl.contentDocument || document;
|
4024
|
-
}
|
4025
|
-
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
4026
|
-
};
|
4027
|
-
|
4028
|
-
// lib/global-position.ts
|
4029
|
-
init_react_import();
|
4030
|
-
var GlobalPosition = class {
|
4031
|
-
constructor(target, original) {
|
4032
|
-
this.scaleFactor = 1;
|
4033
|
-
this.frameEl = null;
|
4034
|
-
this.frameRect = null;
|
4035
|
-
var _a;
|
4036
|
-
this.target = target;
|
4037
|
-
this.original = original;
|
4038
|
-
this.frameEl = document.querySelector("iframe");
|
4039
|
-
if (this.frameEl) {
|
4040
|
-
this.frameRect = this.frameEl.getBoundingClientRect();
|
4041
|
-
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4042
|
-
}
|
4043
|
-
}
|
4044
|
-
get x() {
|
4045
|
-
return this.original.x;
|
4046
|
-
}
|
4047
|
-
get y() {
|
4048
|
-
return this.original.y;
|
4049
|
-
}
|
4050
|
-
get global() {
|
4051
|
-
if (document !== this.target.ownerDocument && this.frameRect) {
|
4052
|
-
return {
|
4053
|
-
x: this.x * this.scaleFactor + this.frameRect.left,
|
4054
|
-
y: this.y * this.scaleFactor + this.frameRect.top
|
4055
|
-
};
|
4056
|
-
}
|
4057
|
-
return this.original;
|
4058
|
-
}
|
4059
|
-
get frame() {
|
4060
|
-
if (document === this.target.ownerDocument && this.frameRect) {
|
4061
|
-
return {
|
4062
|
-
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
4063
|
-
y: (this.y - this.frameRect.top) / this.scaleFactor
|
4064
|
-
};
|
4065
|
-
}
|
4066
|
-
return this.original;
|
4067
|
-
}
|
4068
|
-
};
|
4069
|
-
|
4070
|
-
// lib/dnd/NestedDroppablePlugin.ts
|
4071
|
-
var depthSort = (candidates) => {
|
4072
|
-
return candidates.sort((a, b) => {
|
4073
|
-
const aData = a.data;
|
4074
|
-
const bData = b.data;
|
4075
|
-
if (aData.depth > bData.depth) {
|
4076
|
-
return 1;
|
4077
|
-
}
|
4078
|
-
if (bData.depth > aData.depth) {
|
4079
|
-
return -1;
|
4080
|
-
}
|
4081
|
-
return 0;
|
4082
|
-
});
|
4083
|
-
};
|
4084
|
-
var getZoneId2 = (candidate) => {
|
4085
|
-
let id = candidate == null ? void 0 : candidate.id;
|
4086
|
-
if (!candidate) return null;
|
4087
|
-
if (candidate.type === "component") {
|
4088
|
-
const data = candidate.data;
|
4089
|
-
if (data.containsActiveZone) {
|
4090
|
-
id = null;
|
4091
|
-
} else {
|
4092
|
-
id = data.zone;
|
4093
|
-
}
|
4094
|
-
} else if (candidate.type === "void") {
|
4095
|
-
return "void";
|
4096
|
-
}
|
4097
|
-
return id;
|
4098
|
-
};
|
4099
|
-
var getPointerCollisions = (position, manager) => {
|
4100
|
-
const candidates = [];
|
4101
|
-
let elements = position.target.ownerDocument.elementsFromPoint(
|
4102
|
-
position.x,
|
4103
|
-
position.y
|
4104
|
-
);
|
4105
|
-
const previewFrame = elements.find(
|
4106
|
-
(el) => el.getAttribute("data-puck-preview")
|
4107
|
-
);
|
4108
|
-
const drawer = elements.find((el) => el.getAttribute("data-puck-drawer"));
|
4109
|
-
if (drawer) {
|
4110
|
-
elements = [drawer];
|
4111
|
-
}
|
4112
|
-
if (previewFrame) {
|
4113
|
-
const frame = getFrame();
|
4114
|
-
if (frame) {
|
4115
|
-
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
4116
|
-
}
|
4117
|
-
}
|
4118
|
-
if (elements) {
|
4119
|
-
for (let i = 0; i < elements.length; i++) {
|
4120
|
-
const element = elements[i];
|
4121
|
-
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
4122
|
-
if (dropzoneId) {
|
4123
|
-
const droppable = manager.registry.droppables.get(dropzoneId);
|
4124
|
-
if (droppable) {
|
4125
|
-
candidates.push(droppable);
|
4126
|
-
}
|
4127
|
-
}
|
4128
|
-
const id = element.getAttribute("data-puck-dnd");
|
4129
|
-
if (id) {
|
4130
|
-
const droppable = manager.registry.droppables.get(id);
|
4131
|
-
if (droppable) {
|
4132
|
-
candidates.push(droppable);
|
4133
|
-
}
|
4134
|
-
}
|
4135
|
-
}
|
4136
|
-
}
|
4137
|
-
return candidates;
|
4138
|
-
};
|
4139
|
-
var findDeepestCandidate = (position, manager) => {
|
4140
|
-
var _a;
|
4141
|
-
const candidates = getPointerCollisions(position, manager);
|
4142
|
-
if (candidates.length > 0) {
|
4143
|
-
const sortedCandidates = depthSort(candidates);
|
4144
|
-
const draggable = manager.dragOperation.source;
|
4145
|
-
const draggedCandidateIndex = sortedCandidates.findIndex(
|
4146
|
-
(candidate) => candidate.id === (draggable == null ? void 0 : draggable.id)
|
4147
|
-
);
|
4148
|
-
const draggedCandidateId = draggable == null ? void 0 : draggable.id;
|
4149
|
-
let filteredCandidates = [...sortedCandidates];
|
4150
|
-
if (draggedCandidateId && draggedCandidateIndex > -1) {
|
4151
|
-
filteredCandidates.splice(draggedCandidateIndex, 1);
|
4152
|
-
}
|
4153
|
-
filteredCandidates = filteredCandidates.filter((candidate) => {
|
4154
|
-
const candidateData = candidate.data;
|
4155
|
-
if (draggedCandidateId && draggedCandidateIndex > -1) {
|
4156
|
-
if (candidateData.path.indexOf(draggedCandidateId) > -1) {
|
4157
|
-
return false;
|
4158
|
-
}
|
4159
|
-
}
|
4160
|
-
if (candidate.type === "dropzone") {
|
4161
|
-
const candidateData2 = candidate.data;
|
4162
|
-
if (!candidateData2.isDroppableTarget) {
|
4163
|
-
return false;
|
4164
|
-
}
|
4165
|
-
if (candidateData2.areaId === draggedCandidateId) {
|
4166
|
-
return false;
|
4167
|
-
}
|
4168
|
-
} else if (candidate.type === "component") {
|
4169
|
-
const candidateData2 = candidate.data;
|
4170
|
-
if (!candidateData2.inDroppableZone) {
|
4171
|
-
return false;
|
4172
|
-
}
|
4173
|
-
}
|
4174
|
-
return true;
|
4175
|
-
});
|
4176
|
-
filteredCandidates.reverse();
|
4177
|
-
const zone = getZoneId2(filteredCandidates[0]);
|
4178
|
-
const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
|
4179
|
-
return { zone, area };
|
4180
|
-
}
|
4181
|
-
return {
|
4182
|
-
zone: "default-zone",
|
4183
|
-
area: null
|
4184
|
-
};
|
4185
|
-
};
|
4186
|
-
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4187
|
-
constructor(manager, options) {
|
4188
|
-
super(manager);
|
4189
|
-
if (typeof window === "undefined") {
|
4190
|
-
return;
|
4191
|
-
}
|
4192
|
-
const cleanupEffect = (0, import_state.effects)(() => {
|
4193
|
-
const handleMove = (event) => {
|
4194
|
-
const target = event.originalTarget || event.target;
|
4195
|
-
const position = new GlobalPosition(target, {
|
4196
|
-
x: event.clientX,
|
4197
|
-
y: event.clientY
|
4198
|
-
});
|
4199
|
-
const elements = document.elementsFromPoint(
|
4200
|
-
position.global.x,
|
4201
|
-
position.global.y
|
4202
|
-
);
|
4203
|
-
const overEl = elements.some((el) => el.id === id);
|
4204
|
-
if (overEl) {
|
4205
|
-
onChange(findDeepestCandidate(position, manager), manager);
|
4206
|
-
}
|
4207
|
-
};
|
4208
|
-
const handleMoveThrottled = throttle(handleMove, 50);
|
4209
|
-
const handlePointerMove = (event) => {
|
4210
|
-
handleMoveThrottled(event);
|
4211
|
-
};
|
4212
|
-
document.body.addEventListener("pointermove", handlePointerMove, {
|
4213
|
-
capture: true
|
4214
|
-
// dndkit's PointerSensor prevents propagation during drag
|
4215
|
-
});
|
4216
|
-
this.destroy = () => {
|
4217
|
-
document.body.removeEventListener("pointermove", handlePointerMove, {
|
4218
|
-
capture: true
|
4219
|
-
});
|
4220
|
-
cleanupEffect();
|
4221
|
-
};
|
4222
|
-
});
|
4312
|
+
}
|
4313
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
4223
4314
|
}
|
4224
|
-
|
4225
|
-
|
4226
|
-
// lib/insert-component.ts
|
4227
|
-
init_react_import();
|
4228
|
-
|
4229
|
-
// reducer/index.ts
|
4230
|
-
init_react_import();
|
4231
|
-
|
4232
|
-
// reducer/data.ts
|
4233
|
-
init_react_import();
|
4315
|
+
);
|
4234
4316
|
|
4235
|
-
// lib/
|
4317
|
+
// lib/get-zone-id.ts
|
4236
4318
|
init_react_import();
|
4237
|
-
var
|
4238
|
-
|
4239
|
-
|
4240
|
-
|
4319
|
+
var getZoneId = (zoneCompound) => {
|
4320
|
+
if (!zoneCompound) {
|
4321
|
+
return [];
|
4322
|
+
}
|
4323
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
4324
|
+
return zoneCompound.split(":");
|
4325
|
+
}
|
4326
|
+
return [rootDroppableId, zoneCompound];
|
4241
4327
|
};
|
4242
4328
|
|
4243
|
-
// lib/
|
4329
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
4244
4330
|
init_react_import();
|
4245
|
-
|
4246
|
-
|
4247
|
-
zones: Object.keys(data.zones || {}).reduce(
|
4248
|
-
(acc, key) => {
|
4249
|
-
const [parentId] = getZoneId(key);
|
4250
|
-
if (parentId === item.props.id) {
|
4251
|
-
const zones = data.zones;
|
4252
|
-
return fn(acc, key, zones[key]);
|
4253
|
-
}
|
4254
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: data.zones[key] });
|
4255
|
-
},
|
4256
|
-
{}
|
4257
|
-
)
|
4258
|
-
});
|
4259
|
-
}
|
4260
|
-
var findRelatedByZoneId = (zoneId, data) => {
|
4261
|
-
const [zoneParentId] = getZoneId(zoneId);
|
4262
|
-
return (data.zones[zoneId] || []).reduce(
|
4263
|
-
(acc, zoneItem) => {
|
4264
|
-
const related = findRelatedByItem(zoneItem, data);
|
4265
|
-
if (zoneItem.props.id === zoneParentId) {
|
4266
|
-
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
|
4267
|
-
}
|
4268
|
-
return __spreadValues(__spreadValues({}, acc), related);
|
4269
|
-
},
|
4270
|
-
{}
|
4271
|
-
);
|
4272
|
-
};
|
4273
|
-
var findRelatedByItem = (item, data) => {
|
4274
|
-
return Object.keys(data.zones || {}).reduce(
|
4275
|
-
(acc, zoneId) => {
|
4276
|
-
const [zoneParentId] = getZoneId(zoneId);
|
4277
|
-
if (item.props.id === zoneParentId) {
|
4278
|
-
const related = findRelatedByZoneId(zoneId, data);
|
4279
|
-
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
|
4280
|
-
[zoneId]: data.zones[zoneId]
|
4281
|
-
});
|
4282
|
-
}
|
4283
|
-
return acc;
|
4284
|
-
},
|
4285
|
-
{}
|
4286
|
-
);
|
4287
|
-
};
|
4288
|
-
var removeRelatedZones = (item, data) => {
|
4289
|
-
const newData = __spreadValues({}, data);
|
4290
|
-
const related = findRelatedByItem(item, data);
|
4291
|
-
Object.keys(related).forEach((key) => {
|
4292
|
-
delete newData.zones[key];
|
4293
|
-
});
|
4294
|
-
return newData;
|
4295
|
-
};
|
4296
|
-
function duplicateRelatedZones(item, data, newId) {
|
4297
|
-
return reduceRelatedZones(item, data, (acc, key, zone) => {
|
4298
|
-
const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
|
4299
|
-
props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
|
4300
|
-
}));
|
4301
|
-
const dupeOfDupes = dupedZone.reduce(
|
4302
|
-
(dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
|
4303
|
-
acc
|
4304
|
-
);
|
4305
|
-
const [_, zoneId] = getZoneId(key);
|
4306
|
-
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
4307
|
-
[key]: zone,
|
4308
|
-
[`${newId}:${zoneId}`]: dupedZone
|
4309
|
-
});
|
4310
|
-
});
|
4311
|
-
}
|
4331
|
+
var import_abstract10 = require("@dnd-kit/abstract");
|
4332
|
+
var import_state2 = require("@dnd-kit/state");
|
4312
4333
|
|
4313
|
-
//
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4318
|
-
var replaceAction = (data, action) => {
|
4319
|
-
if (action.destinationZone === rootDroppableId) {
|
4320
|
-
return __spreadProps(__spreadValues({}, data), {
|
4321
|
-
content: replace(data.content, action.destinationIndex, action.data)
|
4322
|
-
});
|
4323
|
-
}
|
4324
|
-
const newData = setupZone(data, action.destinationZone);
|
4325
|
-
return __spreadProps(__spreadValues({}, newData), {
|
4326
|
-
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4327
|
-
[action.destinationZone]: replace(
|
4328
|
-
newData.zones[action.destinationZone],
|
4329
|
-
action.destinationIndex,
|
4330
|
-
action.data
|
4331
|
-
)
|
4332
|
-
})
|
4333
|
-
});
|
4334
|
-
};
|
4335
|
-
function insertAction(data, action, config) {
|
4336
|
-
const emptyComponentData = {
|
4337
|
-
type: action.componentType,
|
4338
|
-
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
4339
|
-
id: action.id || generateId(action.componentType)
|
4340
|
-
})
|
4341
|
-
};
|
4342
|
-
if (action.destinationZone === rootDroppableId) {
|
4343
|
-
return __spreadProps(__spreadValues({}, data), {
|
4344
|
-
content: insert(
|
4345
|
-
data.content,
|
4346
|
-
action.destinationIndex,
|
4347
|
-
emptyComponentData
|
4348
|
-
)
|
4349
|
-
});
|
4350
|
-
}
|
4351
|
-
const newData = setupZone(data, action.destinationZone);
|
4352
|
-
return __spreadProps(__spreadValues({}, data), {
|
4353
|
-
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4354
|
-
[action.destinationZone]: insert(
|
4355
|
-
newData.zones[action.destinationZone],
|
4356
|
-
action.destinationIndex,
|
4357
|
-
emptyComponentData
|
4358
|
-
)
|
4359
|
-
})
|
4360
|
-
});
|
4334
|
+
// lib/throttle.ts
|
4335
|
+
init_react_import();
|
4336
|
+
function timeout2(callback, duration) {
|
4337
|
+
const id = setTimeout(callback, duration);
|
4338
|
+
return () => clearTimeout(id);
|
4361
4339
|
}
|
4362
|
-
|
4363
|
-
|
4364
|
-
|
4365
|
-
|
4366
|
-
|
4367
|
-
|
4368
|
-
|
4369
|
-
|
4370
|
-
|
4371
|
-
|
4372
|
-
|
4373
|
-
|
4374
|
-
|
4375
|
-
|
4376
|
-
|
4377
|
-
|
4378
|
-
action.destinationIndex
|
4379
|
-
)
|
4380
|
-
})
|
4381
|
-
});
|
4382
|
-
};
|
4383
|
-
function reduceData(data, action, config) {
|
4384
|
-
if (action.type === "insert") {
|
4385
|
-
return insertAction(data, action, config);
|
4386
|
-
}
|
4387
|
-
if (action.type === "duplicate") {
|
4388
|
-
const item = getItem(
|
4389
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
4390
|
-
data
|
4391
|
-
);
|
4392
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
4393
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
4394
|
-
id: generateId(item.type)
|
4395
|
-
})
|
4396
|
-
});
|
4397
|
-
const dataWithRelatedDuplicated = duplicateRelatedZones(
|
4398
|
-
item,
|
4399
|
-
data,
|
4400
|
-
newItem.props.id
|
4401
|
-
);
|
4402
|
-
if (action.sourceZone === rootDroppableId) {
|
4403
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
4404
|
-
content: insert(data.content, action.sourceIndex + 1, newItem)
|
4405
|
-
});
|
4406
|
-
}
|
4407
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
4408
|
-
zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
|
4409
|
-
[action.sourceZone]: insert(
|
4410
|
-
dataWithRelatedDuplicated.zones[action.sourceZone],
|
4411
|
-
action.sourceIndex + 1,
|
4412
|
-
newItem
|
4413
|
-
)
|
4414
|
-
})
|
4415
|
-
});
|
4416
|
-
}
|
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
|
-
});
|
4340
|
+
function throttle(func, limit) {
|
4341
|
+
const time = () => performance.now();
|
4342
|
+
let cancel;
|
4343
|
+
let lastRan = 0;
|
4344
|
+
return function(...args) {
|
4345
|
+
const now = time();
|
4346
|
+
const context = this;
|
4347
|
+
if (now - lastRan >= limit) {
|
4348
|
+
func.apply(context, args);
|
4349
|
+
lastRan = now;
|
4350
|
+
} else {
|
4351
|
+
cancel == null ? void 0 : cancel();
|
4352
|
+
cancel = timeout2(() => {
|
4353
|
+
func.apply(context, args);
|
4354
|
+
lastRan = time();
|
4355
|
+
}, limit - (now - lastRan));
|
4457
4356
|
}
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4462
|
-
|
4463
|
-
|
4464
|
-
|
4465
|
-
|
4466
|
-
|
4467
|
-
|
4468
|
-
)
|
4469
|
-
})
|
4470
|
-
});
|
4471
|
-
}
|
4472
|
-
if (action.type === "replace") {
|
4473
|
-
return replaceAction(data, action);
|
4357
|
+
};
|
4358
|
+
}
|
4359
|
+
|
4360
|
+
// lib/get-frame.ts
|
4361
|
+
init_react_import();
|
4362
|
+
var getFrame = () => {
|
4363
|
+
if (typeof window === "undefined") return;
|
4364
|
+
let frameEl = document.querySelector("#preview-frame");
|
4365
|
+
if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
|
4366
|
+
return frameEl.contentDocument || document;
|
4474
4367
|
}
|
4475
|
-
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
|
4483
|
-
|
4484
|
-
|
4368
|
+
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
4369
|
+
};
|
4370
|
+
|
4371
|
+
// lib/global-position.ts
|
4372
|
+
init_react_import();
|
4373
|
+
var GlobalPosition = class {
|
4374
|
+
constructor(target, original) {
|
4375
|
+
this.scaleFactor = 1;
|
4376
|
+
this.frameEl = null;
|
4377
|
+
this.frameRect = null;
|
4378
|
+
var _a;
|
4379
|
+
this.target = target;
|
4380
|
+
this.original = original;
|
4381
|
+
this.frameEl = document.querySelector("iframe");
|
4382
|
+
if (this.frameEl) {
|
4383
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
4384
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4485
4385
|
}
|
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
4386
|
}
|
4495
|
-
|
4496
|
-
|
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);
|
4387
|
+
get x() {
|
4388
|
+
return this.original.x;
|
4504
4389
|
}
|
4505
|
-
|
4506
|
-
|
4507
|
-
|
4508
|
-
|
4509
|
-
|
4390
|
+
get y() {
|
4391
|
+
return this.original.y;
|
4392
|
+
}
|
4393
|
+
get global() {
|
4394
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
4395
|
+
return {
|
4396
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
4397
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
4398
|
+
};
|
4510
4399
|
}
|
4511
|
-
return
|
4400
|
+
return this.original;
|
4512
4401
|
}
|
4513
|
-
|
4514
|
-
if (
|
4515
|
-
return
|
4402
|
+
get frame() {
|
4403
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
4404
|
+
return {
|
4405
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
4406
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
4407
|
+
};
|
4516
4408
|
}
|
4517
|
-
return
|
4409
|
+
return this.original;
|
4518
4410
|
}
|
4519
|
-
|
4520
|
-
}
|
4411
|
+
};
|
4521
4412
|
|
4522
|
-
//
|
4413
|
+
// lib/bubble-pointer-event.ts
|
4523
4414
|
init_react_import();
|
4524
|
-
var
|
4525
|
-
|
4526
|
-
|
4527
|
-
|
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
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
4433
|
+
var depthSort = (candidates) => {
|
4434
|
+
return candidates.sort((a, b) => {
|
4435
|
+
const aData = a.data;
|
4436
|
+
const bData = b.data;
|
4437
|
+
if (aData.depth > bData.depth) {
|
4438
|
+
return 1;
|
4528
4439
|
}
|
4529
|
-
|
4440
|
+
if (bData.depth > aData.depth) {
|
4441
|
+
return -1;
|
4442
|
+
}
|
4443
|
+
return 0;
|
4444
|
+
});
|
4445
|
+
};
|
4446
|
+
var getZoneId2 = (candidate) => {
|
4447
|
+
let id = candidate == null ? void 0 : candidate.id;
|
4448
|
+
if (!candidate) return null;
|
4449
|
+
if (candidate.type === "component") {
|
4450
|
+
const data = candidate.data;
|
4451
|
+
if (data.containsActiveZone) {
|
4452
|
+
id = null;
|
4453
|
+
} else {
|
4454
|
+
id = data.zone;
|
4455
|
+
}
|
4456
|
+
} else if (candidate.type === "void") {
|
4457
|
+
return "void";
|
4530
4458
|
}
|
4531
|
-
|
4532
|
-
|
4533
|
-
|
4459
|
+
return id;
|
4460
|
+
};
|
4461
|
+
var getPointerCollisions = (position, manager) => {
|
4462
|
+
const candidates = [];
|
4463
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
4464
|
+
position.x,
|
4465
|
+
position.y
|
4466
|
+
);
|
4467
|
+
const previewFrame = elements.find(
|
4468
|
+
(el) => el.getAttribute("data-puck-preview")
|
4469
|
+
);
|
4470
|
+
const drawer = elements.find((el) => el.getAttribute("data-puck-drawer"));
|
4471
|
+
if (drawer) {
|
4472
|
+
elements = [drawer];
|
4473
|
+
}
|
4474
|
+
if (previewFrame) {
|
4475
|
+
const frame = getFrame();
|
4476
|
+
if (frame) {
|
4477
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
4478
|
+
}
|
4479
|
+
}
|
4480
|
+
if (elements) {
|
4481
|
+
for (let i = 0; i < elements.length; i++) {
|
4482
|
+
const element = elements[i];
|
4483
|
+
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
4484
|
+
if (dropzoneId) {
|
4485
|
+
const droppable = manager.registry.droppables.get(dropzoneId);
|
4486
|
+
if (droppable) {
|
4487
|
+
candidates.push(droppable);
|
4488
|
+
}
|
4489
|
+
}
|
4490
|
+
const id = element.getAttribute("data-puck-dnd");
|
4491
|
+
if (id) {
|
4492
|
+
const droppable = manager.registry.droppables.get(id);
|
4493
|
+
if (droppable) {
|
4494
|
+
candidates.push(droppable);
|
4495
|
+
}
|
4496
|
+
}
|
4497
|
+
}
|
4498
|
+
}
|
4499
|
+
return candidates;
|
4500
|
+
};
|
4501
|
+
var findDeepestCandidate = (position, manager) => {
|
4502
|
+
var _a;
|
4503
|
+
const candidates = getPointerCollisions(position, manager);
|
4504
|
+
if (candidates.length > 0) {
|
4505
|
+
const sortedCandidates = depthSort(candidates);
|
4506
|
+
const draggable = manager.dragOperation.source;
|
4507
|
+
const draggedCandidateIndex = sortedCandidates.findIndex(
|
4508
|
+
(candidate) => candidate.id === (draggable == null ? void 0 : draggable.id)
|
4509
|
+
);
|
4510
|
+
const draggedCandidateId = draggable == null ? void 0 : draggable.id;
|
4511
|
+
let filteredCandidates = [...sortedCandidates];
|
4512
|
+
if (draggedCandidateId && draggedCandidateIndex > -1) {
|
4513
|
+
filteredCandidates.splice(draggedCandidateIndex, 1);
|
4514
|
+
}
|
4515
|
+
filteredCandidates = filteredCandidates.filter((candidate) => {
|
4516
|
+
const candidateData = candidate.data;
|
4517
|
+
if (draggedCandidateId && draggedCandidateIndex > -1) {
|
4518
|
+
if (candidateData.path.indexOf(draggedCandidateId) > -1) {
|
4519
|
+
return false;
|
4520
|
+
}
|
4521
|
+
}
|
4522
|
+
if (candidate.type === "dropzone") {
|
4523
|
+
const candidateData2 = candidate.data;
|
4524
|
+
if (!candidateData2.isDroppableTarget) {
|
4525
|
+
return false;
|
4526
|
+
}
|
4527
|
+
if (candidateData2.areaId === draggedCandidateId) {
|
4528
|
+
return false;
|
4529
|
+
}
|
4530
|
+
} else if (candidate.type === "component") {
|
4531
|
+
const candidateData2 = candidate.data;
|
4532
|
+
if (!candidateData2.inDroppableZone) {
|
4533
|
+
return false;
|
4534
|
+
}
|
4535
|
+
}
|
4536
|
+
return true;
|
4534
4537
|
});
|
4538
|
+
filteredCandidates.reverse();
|
4539
|
+
const zone = getZoneId2(filteredCandidates[0]);
|
4540
|
+
const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
|
4541
|
+
return { zone, area };
|
4535
4542
|
}
|
4536
|
-
|
4537
|
-
|
4538
|
-
|
4543
|
+
return {
|
4544
|
+
zone: "default-zone",
|
4545
|
+
area: null
|
4546
|
+
};
|
4547
|
+
};
|
4548
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract10.Plugin {
|
4549
|
+
constructor(manager, options) {
|
4550
|
+
super(manager);
|
4551
|
+
if (typeof window === "undefined") {
|
4552
|
+
return;
|
4553
|
+
}
|
4554
|
+
const cleanupEffect = (0, import_state2.effects)(() => {
|
4555
|
+
const handleMove = (event) => {
|
4556
|
+
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
4557
|
+
const position = new GlobalPosition(target, {
|
4558
|
+
x: event.clientX,
|
4559
|
+
y: event.clientY
|
4560
|
+
});
|
4561
|
+
const elements = document.elementsFromPoint(
|
4562
|
+
position.global.x,
|
4563
|
+
position.global.y
|
4564
|
+
);
|
4565
|
+
const overEl = elements.some((el) => el.id === id);
|
4566
|
+
if (overEl) {
|
4567
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
4568
|
+
}
|
4569
|
+
};
|
4570
|
+
const handleMoveThrottled = throttle(handleMove, 50);
|
4571
|
+
const handlePointerMove = (event) => {
|
4572
|
+
handleMoveThrottled(event);
|
4573
|
+
};
|
4574
|
+
document.body.addEventListener("pointermove", handlePointerMove, {
|
4575
|
+
capture: true
|
4576
|
+
// dndkit's PointerSensor prevents propagation during drag
|
4577
|
+
});
|
4578
|
+
this.destroy = () => {
|
4579
|
+
document.body.removeEventListener("pointermove", handlePointerMove, {
|
4580
|
+
capture: true
|
4581
|
+
});
|
4582
|
+
cleanupEffect();
|
4583
|
+
};
|
4539
4584
|
});
|
4540
4585
|
}
|
4541
|
-
return ui;
|
4542
4586
|
};
|
4543
4587
|
|
4544
|
-
//
|
4588
|
+
// lib/insert-component.ts
|
4545
4589
|
init_react_import();
|
4546
4590
|
|
4547
4591
|
// reducer/index.ts
|
4548
|
-
|
4549
|
-
|
4550
|
-
|
4551
|
-
|
4552
|
-
|
4553
|
-
|
4554
|
-
|
4555
|
-
|
4556
|
-
|
4557
|
-
|
4558
|
-
|
4559
|
-
|
4560
|
-
|
4561
|
-
|
4562
|
-
|
4563
|
-
|
4592
|
+
init_react_import();
|
4593
|
+
|
4594
|
+
// reducer/data.ts
|
4595
|
+
init_react_import();
|
4596
|
+
|
4597
|
+
// lib/remove.ts
|
4598
|
+
init_react_import();
|
4599
|
+
var remove = (list, index) => {
|
4600
|
+
const result = Array.from(list);
|
4601
|
+
result.splice(index, 1);
|
4602
|
+
return result;
|
4603
|
+
};
|
4604
|
+
|
4605
|
+
// lib/reduce-related-zones.ts
|
4606
|
+
init_react_import();
|
4607
|
+
function reduceRelatedZones(item, data, fn) {
|
4608
|
+
return __spreadProps(__spreadValues({}, data), {
|
4609
|
+
zones: Object.keys(data.zones || {}).reduce(
|
4610
|
+
(acc, key) => {
|
4611
|
+
const [parentId] = getZoneId(key);
|
4612
|
+
if (parentId === item.props.id) {
|
4613
|
+
const zones = data.zones;
|
4614
|
+
return fn(acc, key, zones[key]);
|
4615
|
+
}
|
4616
|
+
return __spreadProps(__spreadValues({}, acc), { [key]: data.zones[key] });
|
4617
|
+
},
|
4618
|
+
{}
|
4619
|
+
)
|
4620
|
+
});
|
4564
4621
|
}
|
4565
|
-
var
|
4566
|
-
|
4567
|
-
|
4568
|
-
|
4569
|
-
|
4622
|
+
var findRelatedByZoneId = (zoneId, data) => {
|
4623
|
+
const [zoneParentId] = getZoneId(zoneId);
|
4624
|
+
return (data.zones[zoneId] || []).reduce(
|
4625
|
+
(acc, zoneItem) => {
|
4626
|
+
const related = findRelatedByItem(zoneItem, data);
|
4627
|
+
if (zoneItem.props.id === zoneParentId) {
|
4628
|
+
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
|
4629
|
+
}
|
4630
|
+
return __spreadValues(__spreadValues({}, acc), related);
|
4631
|
+
},
|
4632
|
+
{}
|
4633
|
+
);
|
4570
4634
|
};
|
4571
|
-
|
4572
|
-
|
4573
|
-
|
4574
|
-
|
4575
|
-
|
4576
|
-
|
4577
|
-
|
4578
|
-
|
4579
|
-
|
4580
|
-
if (action.type === "set") {
|
4581
|
-
return setAction(state, action);
|
4635
|
+
var findRelatedByItem = (item, data) => {
|
4636
|
+
return Object.keys(data.zones || {}).reduce(
|
4637
|
+
(acc, zoneId) => {
|
4638
|
+
const [zoneParentId] = getZoneId(zoneId);
|
4639
|
+
if (item.props.id === zoneParentId) {
|
4640
|
+
const related = findRelatedByZoneId(zoneId, data);
|
4641
|
+
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
|
4642
|
+
[zoneId]: data.zones[zoneId]
|
4643
|
+
});
|
4582
4644
|
}
|
4583
|
-
return
|
4645
|
+
return acc;
|
4584
4646
|
},
|
4585
|
-
|
4586
|
-
onAction
|
4647
|
+
{}
|
4587
4648
|
);
|
4649
|
+
};
|
4650
|
+
var removeRelatedZones = (item, data) => {
|
4651
|
+
const newData = __spreadValues({}, data);
|
4652
|
+
const related = findRelatedByItem(item, data);
|
4653
|
+
Object.keys(related).forEach((key) => {
|
4654
|
+
delete newData.zones[key];
|
4655
|
+
});
|
4656
|
+
return newData;
|
4657
|
+
};
|
4658
|
+
function duplicateRelatedZones(item, data, newId) {
|
4659
|
+
return reduceRelatedZones(item, data, (acc, key, zone) => {
|
4660
|
+
const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
|
4661
|
+
props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
|
4662
|
+
}));
|
4663
|
+
const dupeOfDupes = dupedZone.reduce(
|
4664
|
+
(dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
|
4665
|
+
acc
|
4666
|
+
);
|
4667
|
+
const [_, zoneId] = getZoneId(key);
|
4668
|
+
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
4669
|
+
[key]: zone,
|
4670
|
+
[`${newId}:${zoneId}`]: dupedZone
|
4671
|
+
});
|
4672
|
+
});
|
4588
4673
|
}
|
4589
4674
|
|
4590
|
-
//
|
4591
|
-
var
|
4592
|
-
|
4593
|
-
|
4594
|
-
|
4595
|
-
|
4596
|
-
|
4597
|
-
|
4598
|
-
|
4599
|
-
|
4600
|
-
|
4601
|
-
|
4602
|
-
|
4603
|
-
|
4604
|
-
|
4605
|
-
|
4606
|
-
|
4607
|
-
|
4608
|
-
|
4609
|
-
|
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 })
|
4675
|
+
// reducer/data.ts
|
4676
|
+
var zoneCache = {};
|
4677
|
+
var addToZoneCache = (key, data) => {
|
4678
|
+
zoneCache[key] = data;
|
4679
|
+
};
|
4680
|
+
var replaceAction = (data, action) => {
|
4681
|
+
if (action.destinationZone === rootDroppableId) {
|
4682
|
+
return __spreadProps(__spreadValues({}, data), {
|
4683
|
+
content: replace(data.content, action.destinationIndex, action.data)
|
4684
|
+
});
|
4685
|
+
}
|
4686
|
+
const newData = setupZone(data, action.destinationZone);
|
4687
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4688
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4689
|
+
[action.destinationZone]: replace(
|
4690
|
+
newData.zones[action.destinationZone],
|
4691
|
+
action.destinationIndex,
|
4692
|
+
action.data
|
4693
|
+
)
|
4694
|
+
})
|
4621
4695
|
});
|
4622
4696
|
};
|
4623
|
-
|
4624
|
-
|
4625
|
-
|
4626
|
-
|
4627
|
-
|
4628
|
-
|
4629
|
-
|
4630
|
-
|
4631
|
-
|
4632
|
-
|
4633
|
-
|
4634
|
-
|
4635
|
-
|
4636
|
-
|
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
|
-
};
|
4697
|
+
function insertAction(data, action, config) {
|
4698
|
+
const emptyComponentData = {
|
4699
|
+
type: action.componentType,
|
4700
|
+
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
4701
|
+
id: action.id || generateId(action.componentType)
|
4702
|
+
})
|
4703
|
+
};
|
4704
|
+
if (action.destinationZone === rootDroppableId) {
|
4705
|
+
return __spreadProps(__spreadValues({}, data), {
|
4706
|
+
content: insert(
|
4707
|
+
data.content,
|
4708
|
+
action.destinationIndex,
|
4709
|
+
emptyComponentData
|
4710
|
+
)
|
4652
4711
|
});
|
4653
4712
|
}
|
4654
|
-
|
4655
|
-
|
4656
|
-
|
4657
|
-
|
4658
|
-
|
4659
|
-
|
4660
|
-
|
4661
|
-
|
4662
|
-
|
4663
|
-
|
4664
|
-
|
4665
|
-
|
4666
|
-
|
4667
|
-
|
4668
|
-
|
4669
|
-
|
4713
|
+
const newData = setupZone(data, action.destinationZone);
|
4714
|
+
return __spreadProps(__spreadValues({}, data), {
|
4715
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4716
|
+
[action.destinationZone]: insert(
|
4717
|
+
newData.zones[action.destinationZone],
|
4718
|
+
action.destinationIndex,
|
4719
|
+
emptyComponentData
|
4720
|
+
)
|
4721
|
+
})
|
4722
|
+
});
|
4723
|
+
}
|
4724
|
+
var reorderAction = (data, action) => {
|
4725
|
+
if (action.destinationZone === rootDroppableId) {
|
4726
|
+
return __spreadProps(__spreadValues({}, data), {
|
4727
|
+
content: reorder(
|
4728
|
+
data.content,
|
4729
|
+
action.sourceIndex,
|
4730
|
+
action.destinationIndex
|
4731
|
+
)
|
4670
4732
|
});
|
4671
|
-
return unbind;
|
4672
4733
|
}
|
4673
|
-
|
4674
|
-
|
4675
|
-
|
4676
|
-
|
4677
|
-
|
4678
|
-
|
4679
|
-
|
4680
|
-
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
|
4688
|
-
|
4689
|
-
|
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
|
-
])
|
4734
|
+
const newData = setupZone(data, action.destinationZone);
|
4735
|
+
return __spreadProps(__spreadValues({}, data), {
|
4736
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4737
|
+
[action.destinationZone]: reorder(
|
4738
|
+
newData.zones[action.destinationZone],
|
4739
|
+
action.sourceIndex,
|
4740
|
+
action.destinationIndex
|
4741
|
+
)
|
4742
|
+
})
|
4743
|
+
});
|
4744
|
+
};
|
4745
|
+
function reduceData(data, action, config) {
|
4746
|
+
if (action.type === "insert") {
|
4747
|
+
return insertAction(data, action, config);
|
4748
|
+
}
|
4749
|
+
if (action.type === "duplicate") {
|
4750
|
+
const item = getItem(
|
4751
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
4752
|
+
data
|
4704
4753
|
);
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
4709
|
-
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
|
4718
|
-
|
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
|
-
}
|
4754
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
4755
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
4756
|
+
id: generateId(item.type)
|
4757
|
+
})
|
4758
|
+
});
|
4759
|
+
const dataWithRelatedDuplicated = duplicateRelatedZones(
|
4760
|
+
item,
|
4761
|
+
data,
|
4762
|
+
newItem.props.id
|
4763
|
+
);
|
4764
|
+
if (action.sourceZone === rootDroppableId) {
|
4765
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
4766
|
+
content: insert(data.content, action.sourceIndex + 1, newItem)
|
4767
|
+
});
|
4736
4768
|
}
|
4737
|
-
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4769
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
4770
|
+
zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
|
4771
|
+
[action.sourceZone]: insert(
|
4772
|
+
dataWithRelatedDuplicated.zones[action.sourceZone],
|
4773
|
+
action.sourceIndex + 1,
|
4774
|
+
newItem
|
4775
|
+
)
|
4776
|
+
})
|
4777
|
+
});
|
4744
4778
|
}
|
4745
|
-
|
4746
|
-
|
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
|
-
}
|
4779
|
+
if (action.type === "reorder") {
|
4780
|
+
return reorderAction(data, action);
|
4789
4781
|
}
|
4790
|
-
|
4791
|
-
if (
|
4792
|
-
return;
|
4793
|
-
}
|
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 });
|
4782
|
+
if (action.type === "move") {
|
4783
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
4784
|
+
return data;
|
4800
4785
|
}
|
4801
|
-
|
4802
|
-
|
4803
|
-
|
4804
|
-
|
4805
|
-
|
4806
|
-
|
4807
|
-
|
4786
|
+
const newData = setupZone(
|
4787
|
+
setupZone(data, action.sourceZone),
|
4788
|
+
action.destinationZone
|
4789
|
+
);
|
4790
|
+
const item = getItem(
|
4791
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
4792
|
+
newData
|
4793
|
+
);
|
4794
|
+
if (action.sourceZone === action.destinationZone) {
|
4795
|
+
return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
|
4808
4796
|
}
|
4809
|
-
|
4810
|
-
|
4811
|
-
|
4812
|
-
|
4813
|
-
|
4814
|
-
|
4815
|
-
|
4797
|
+
if (action.sourceZone === rootDroppableId) {
|
4798
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4799
|
+
content: remove(newData.content, action.sourceIndex),
|
4800
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4801
|
+
[action.destinationZone]: insert(
|
4802
|
+
newData.zones[action.destinationZone],
|
4803
|
+
action.destinationIndex,
|
4804
|
+
item
|
4805
|
+
)
|
4806
|
+
})
|
4807
|
+
});
|
4816
4808
|
}
|
4817
|
-
if (
|
4818
|
-
return
|
4809
|
+
if (action.destinationZone === rootDroppableId) {
|
4810
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4811
|
+
content: insert(newData.content, action.destinationIndex, item),
|
4812
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4813
|
+
[action.sourceZone]: remove(
|
4814
|
+
newData.zones[action.sourceZone],
|
4815
|
+
action.sourceIndex
|
4816
|
+
)
|
4817
|
+
})
|
4818
|
+
});
|
4819
4819
|
}
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
|
4820
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4821
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4822
|
+
[action.sourceZone]: remove(
|
4823
|
+
newData.zones[action.sourceZone],
|
4824
|
+
action.sourceIndex
|
4825
|
+
),
|
4826
|
+
[action.destinationZone]: insert(
|
4827
|
+
newData.zones[action.destinationZone],
|
4828
|
+
action.destinationIndex,
|
4829
|
+
item
|
4830
|
+
)
|
4831
|
+
})
|
4832
|
+
});
|
4833
|
+
}
|
4834
|
+
if (action.type === "replace") {
|
4835
|
+
return replaceAction(data, action);
|
4836
|
+
}
|
4837
|
+
if (action.type === "remove") {
|
4838
|
+
const item = getItem({ index: action.index, zone: action.zone }, data);
|
4839
|
+
const dataWithRelatedRemoved = setupZone(
|
4840
|
+
removeRelatedZones(item, data),
|
4841
|
+
action.zone
|
4842
|
+
);
|
4843
|
+
if (action.zone === rootDroppableId) {
|
4844
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
4845
|
+
content: remove(data.content, action.index)
|
4846
|
+
});
|
4847
|
+
}
|
4848
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
4849
|
+
zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
|
4850
|
+
[action.zone]: remove(
|
4851
|
+
dataWithRelatedRemoved.zones[action.zone],
|
4852
|
+
action.index
|
4853
|
+
)
|
4854
|
+
})
|
4824
4855
|
});
|
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);
|
4847
4856
|
}
|
4848
|
-
|
4849
|
-
|
4850
|
-
|
4851
|
-
|
4857
|
+
if (action.type === "registerZone") {
|
4858
|
+
if (zoneCache[action.zone]) {
|
4859
|
+
return __spreadProps(__spreadValues({}, data), {
|
4860
|
+
zones: __spreadProps(__spreadValues({}, data.zones), {
|
4861
|
+
[action.zone]: zoneCache[action.zone]
|
4862
|
+
})
|
4863
|
+
});
|
4852
4864
|
}
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4856
|
-
}
|
4857
|
-
|
4865
|
+
return setupZone(data, action.zone);
|
4866
|
+
}
|
4867
|
+
if (action.type === "unregisterZone") {
|
4868
|
+
const _zones = __spreadValues({}, data.zones || {});
|
4869
|
+
if (_zones[action.zone]) {
|
4870
|
+
zoneCache[action.zone] = _zones[action.zone];
|
4871
|
+
delete _zones[action.zone];
|
4858
4872
|
}
|
4873
|
+
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
4859
4874
|
}
|
4860
|
-
|
4861
|
-
|
4862
|
-
|
4863
|
-
this.manager.actions.stop({ canceled: true });
|
4875
|
+
if (action.type === "setData") {
|
4876
|
+
if (typeof action.data === "object") {
|
4877
|
+
return __spreadValues(__spreadValues({}, data), action.data);
|
4864
4878
|
}
|
4865
|
-
|
4866
|
-
this.cleanup.clear();
|
4879
|
+
return __spreadValues(__spreadValues({}, data), action.data(data));
|
4867
4880
|
}
|
4868
|
-
|
4869
|
-
|
4881
|
+
return data;
|
4882
|
+
}
|
4883
|
+
|
4884
|
+
// reducer/state.ts
|
4885
|
+
init_react_import();
|
4886
|
+
var reduceUi = (ui, action) => {
|
4887
|
+
if (action.type === "setUi") {
|
4888
|
+
if (typeof action.ui === "object") {
|
4889
|
+
return __spreadValues(__spreadValues({}, ui), action.ui);
|
4890
|
+
}
|
4891
|
+
return __spreadValues(__spreadValues({}, ui), action.ui(ui));
|
4892
|
+
}
|
4893
|
+
if (action.type === "duplicate") {
|
4894
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4895
|
+
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4896
|
+
});
|
4897
|
+
}
|
4898
|
+
if (action.type === "remove") {
|
4899
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4900
|
+
itemSelector: null
|
4901
|
+
});
|
4870
4902
|
}
|
4903
|
+
return ui;
|
4871
4904
|
};
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4878
|
-
|
4905
|
+
|
4906
|
+
// reducer/actions.tsx
|
4907
|
+
init_react_import();
|
4908
|
+
|
4909
|
+
// reducer/index.ts
|
4910
|
+
function storeInterceptor(reducer, record, onAction) {
|
4911
|
+
return (state, action) => {
|
4912
|
+
const newAppState = reducer(state, action);
|
4913
|
+
const isValidType = ![
|
4914
|
+
"registerZone",
|
4915
|
+
"unregisterZone",
|
4916
|
+
"setData",
|
4917
|
+
"setUi",
|
4918
|
+
"set"
|
4919
|
+
].includes(action.type);
|
4920
|
+
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
4921
|
+
if (record) record(newAppState);
|
4922
|
+
}
|
4923
|
+
onAction == null ? void 0 : onAction(action, newAppState, state);
|
4924
|
+
return newAppState;
|
4925
|
+
};
|
4879
4926
|
}
|
4880
|
-
var
|
4881
|
-
|
4882
|
-
|
4883
|
-
return;
|
4927
|
+
var setAction = (state, action) => {
|
4928
|
+
if (typeof action.state === "object") {
|
4929
|
+
return __spreadValues(__spreadValues({}, state), action.state);
|
4884
4930
|
}
|
4885
|
-
|
4886
|
-
|
4887
|
-
|
4888
|
-
|
4889
|
-
|
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
|
+
);
|
4890
4950
|
}
|
4891
4951
|
|
4952
|
+
// lib/insert-component.ts
|
4953
|
+
var insertComponent = (componentType, zone, index, {
|
4954
|
+
config,
|
4955
|
+
dispatch,
|
4956
|
+
resolveData,
|
4957
|
+
state
|
4958
|
+
}) => {
|
4959
|
+
const id = generateId(componentType);
|
4960
|
+
const insertActionData = {
|
4961
|
+
type: "insert",
|
4962
|
+
componentType,
|
4963
|
+
destinationIndex: index,
|
4964
|
+
destinationZone: zone,
|
4965
|
+
id
|
4966
|
+
};
|
4967
|
+
const insertedData = insertAction(state.data, insertActionData, config);
|
4968
|
+
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
4969
|
+
// Dispatch insert rather set, as user's may rely on this via onAction
|
4970
|
+
// We must always record history here so the insert is added to user history
|
4971
|
+
// If the user has defined a resolveData method, they will end up with 2 history
|
4972
|
+
// entries on insert - one for the initial insert, and one when the data resolves
|
4973
|
+
recordHistory: true
|
4974
|
+
}));
|
4975
|
+
const itemSelector = {
|
4976
|
+
index,
|
4977
|
+
zone
|
4978
|
+
};
|
4979
|
+
dispatch({ type: "setUi", ui: { itemSelector } });
|
4980
|
+
resolveData({
|
4981
|
+
data: insertedData,
|
4982
|
+
ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
|
4983
|
+
});
|
4984
|
+
};
|
4985
|
+
|
4892
4986
|
// components/DragDropContext/index.tsx
|
4987
|
+
var import_use_debounce2 = require("use-debounce");
|
4893
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);
|
4997
|
+
}
|
4998
|
+
return el ? findDir(el) : "ltr";
|
4999
|
+
}
|
5000
|
+
|
5001
|
+
// components/DragDropContext/index.tsx
|
4894
5002
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
4895
5003
|
var DEBUG3 = false;
|
4896
|
-
var dragListenerContext = (0,
|
5004
|
+
var dragListenerContext = (0, import_react32.createContext)({
|
4897
5005
|
dragListeners: {}
|
4898
5006
|
});
|
4899
5007
|
function useDragListener(type, fn, deps = []) {
|
4900
|
-
const { setDragListeners } = (0,
|
4901
|
-
(0,
|
5008
|
+
const { setDragListeners } = (0, import_react32.useContext)(dragListenerContext);
|
5009
|
+
(0, import_react32.useEffect)(() => {
|
4902
5010
|
if (setDragListeners) {
|
4903
5011
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4904
5012
|
[type]: [...old[type] || [], fn]
|
@@ -4908,8 +5016,8 @@ function useDragListener(type, fn, deps = []) {
|
|
4908
5016
|
}
|
4909
5017
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4910
5018
|
var useTempDisableFallback = (timeout3) => {
|
4911
|
-
const lastFallbackDisable = (0,
|
4912
|
-
return (0,
|
5019
|
+
const lastFallbackDisable = (0, import_react32.useRef)(null);
|
5020
|
+
return (0, import_react32.useCallback)((manager) => {
|
4913
5021
|
collisionStore.setState({ fallbackEnabled: false });
|
4914
5022
|
const fallbackId = generateId();
|
4915
5023
|
lastFallbackDisable.current = fallbackId;
|
@@ -4926,11 +5034,11 @@ var DragDropContextClient = ({
|
|
4926
5034
|
disableAutoScroll
|
4927
5035
|
}) => {
|
4928
5036
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4929
|
-
const id = (0,
|
5037
|
+
const id = (0, import_react32.useId)();
|
4930
5038
|
const { data } = state;
|
4931
|
-
const debouncedParamsRef = (0,
|
5039
|
+
const debouncedParamsRef = (0, import_react32.useRef)(null);
|
4932
5040
|
const tempDisableFallback = useTempDisableFallback(100);
|
4933
|
-
const [zoneStore] = (0,
|
5041
|
+
const [zoneStore] = (0, import_react32.useState)(
|
4934
5042
|
() => (0, import_zustand3.createStore)(() => ({
|
4935
5043
|
zoneDepthIndex: {},
|
4936
5044
|
nextZoneDepthIndex: {},
|
@@ -4940,7 +5048,7 @@ var DragDropContextClient = ({
|
|
4940
5048
|
previewIndex: {}
|
4941
5049
|
}))
|
4942
5050
|
);
|
4943
|
-
const getChanged2 = (0,
|
5051
|
+
const getChanged2 = (0, import_react32.useCallback)(
|
4944
5052
|
(params, id2) => {
|
4945
5053
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4946
5054
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -4961,7 +5069,7 @@ var DragDropContextClient = ({
|
|
4961
5069
|
},
|
4962
5070
|
[zoneStore]
|
4963
5071
|
);
|
4964
|
-
const setDeepestAndCollide = (0,
|
5072
|
+
const setDeepestAndCollide = (0, import_react32.useCallback)(
|
4965
5073
|
(params, manager) => {
|
4966
5074
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4967
5075
|
if (!zoneChanged && !areaChanged) return;
|
@@ -4985,7 +5093,7 @@ var DragDropContextClient = ({
|
|
4985
5093
|
setDeepestDb.cancel();
|
4986
5094
|
debouncedParamsRef.current = null;
|
4987
5095
|
};
|
4988
|
-
(0,
|
5096
|
+
(0, import_react32.useEffect)(() => {
|
4989
5097
|
if (DEBUG3) {
|
4990
5098
|
zoneStore.subscribe(
|
4991
5099
|
(s) => {
|
@@ -4999,7 +5107,7 @@ var DragDropContextClient = ({
|
|
4999
5107
|
);
|
5000
5108
|
}
|
5001
5109
|
}, []);
|
5002
|
-
const [plugins] = (0,
|
5110
|
+
const [plugins] = (0, import_react32.useState)(() => [
|
5003
5111
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5004
5112
|
createNestedDroppablePlugin(
|
5005
5113
|
{
|
@@ -5046,29 +5154,11 @@ var DragDropContextClient = ({
|
|
5046
5154
|
id
|
5047
5155
|
)
|
5048
5156
|
]);
|
5049
|
-
const
|
5050
|
-
|
5051
|
-
|
5052
|
-
|
5053
|
-
|
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)(
|
5157
|
+
const sensors = useSensors();
|
5158
|
+
const [dragListeners, setDragListeners] = (0, import_react32.useState)({});
|
5159
|
+
const [pathData, setPathData] = (0, import_react32.useState)();
|
5160
|
+
const dragMode = (0, import_react32.useRef)(null);
|
5161
|
+
const registerPath = (0, import_react32.useCallback)(
|
5072
5162
|
(id2, selector, label) => {
|
5073
5163
|
const [area] = getZoneId(selector.zone);
|
5074
5164
|
setPathData((latestPathData = {}) => {
|
@@ -5086,7 +5176,7 @@ var DragDropContextClient = ({
|
|
5086
5176
|
},
|
5087
5177
|
[data, setPathData]
|
5088
5178
|
);
|
5089
|
-
const unregisterPath = (0,
|
5179
|
+
const unregisterPath = (0, import_react32.useCallback)(
|
5090
5180
|
(id2) => {
|
5091
5181
|
setPathData((latestPathData = {}) => {
|
5092
5182
|
const newPathData = __spreadValues({}, latestPathData);
|
@@ -5096,7 +5186,7 @@ var DragDropContextClient = ({
|
|
5096
5186
|
},
|
5097
5187
|
[data, setPathData]
|
5098
5188
|
);
|
5099
|
-
const initialSelector = (0,
|
5189
|
+
const initialSelector = (0, import_react32.useRef)(void 0);
|
5100
5190
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5101
5191
|
dragListenerContext.Provider,
|
5102
5192
|
{
|
@@ -5105,7 +5195,7 @@ var DragDropContextClient = ({
|
|
5105
5195
|
setDragListeners
|
5106
5196
|
},
|
5107
5197
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5108
|
-
|
5198
|
+
import_react31.DragDropProvider,
|
5109
5199
|
{
|
5110
5200
|
plugins,
|
5111
5201
|
sensors,
|
@@ -5127,6 +5217,13 @@ var DragDropContextClient = ({
|
|
5127
5217
|
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
5128
5218
|
fn(event, manager);
|
5129
5219
|
});
|
5220
|
+
dispatch({
|
5221
|
+
type: "setUi",
|
5222
|
+
ui: {
|
5223
|
+
itemSelector: null,
|
5224
|
+
isDragging: false
|
5225
|
+
}
|
5226
|
+
});
|
5130
5227
|
return;
|
5131
5228
|
}
|
5132
5229
|
if (thisPreview) {
|
@@ -5184,7 +5281,8 @@ var DragDropContextClient = ({
|
|
5184
5281
|
targetZone = targetData.zone;
|
5185
5282
|
targetIndex = targetData.index;
|
5186
5283
|
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
5187
|
-
const
|
5284
|
+
const dir = getDeepDir(target.element);
|
5285
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
|
5188
5286
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
5189
5287
|
targetIndex = targetIndex - 1;
|
5190
5288
|
}
|
@@ -5326,7 +5424,7 @@ var DrawerItemInner = ({
|
|
5326
5424
|
dragRef,
|
5327
5425
|
isDragDisabled
|
5328
5426
|
}) => {
|
5329
|
-
const CustomInner = (0,
|
5427
|
+
const CustomInner = (0, import_react33.useMemo)(
|
5330
5428
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5331
5429
|
[children]
|
5332
5430
|
);
|
@@ -5380,7 +5478,7 @@ var DrawerItem = ({
|
|
5380
5478
|
isDragDisabled
|
5381
5479
|
}) => {
|
5382
5480
|
const resolvedId = id || name;
|
5383
|
-
const [dynamicId, setDynamicId] = (0,
|
5481
|
+
const [dynamicId, setDynamicId] = (0, import_react33.useState)(generateId(resolvedId));
|
5384
5482
|
if (typeof index !== "undefined") {
|
5385
5483
|
console.error(
|
5386
5484
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5419,7 +5517,7 @@ var Drawer = ({
|
|
5419
5517
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5420
5518
|
);
|
5421
5519
|
}
|
5422
|
-
const id = (0,
|
5520
|
+
const id = (0, import_react33.useId)();
|
5423
5521
|
const { ref } = useDroppableSafe({
|
5424
5522
|
id,
|
5425
5523
|
type: "void",
|
@@ -5441,18 +5539,18 @@ Drawer.Item = DrawerItem;
|
|
5441
5539
|
|
5442
5540
|
// components/Puck/index.tsx
|
5443
5541
|
init_react_import();
|
5444
|
-
var
|
5542
|
+
var import_react51 = require("react");
|
5445
5543
|
|
5446
5544
|
// components/SidebarSection/index.tsx
|
5447
5545
|
init_react_import();
|
5448
5546
|
|
5449
5547
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
5450
5548
|
init_react_import();
|
5451
|
-
var styles_module_default13 = { "SidebarSection": "
|
5549
|
+
var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
|
5452
5550
|
|
5453
5551
|
// lib/use-breadcrumbs.ts
|
5454
5552
|
init_react_import();
|
5455
|
-
var
|
5553
|
+
var import_react34 = require("react");
|
5456
5554
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5457
5555
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5458
5556
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5502,8 +5600,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5502
5600
|
state: { data },
|
5503
5601
|
selectedItem
|
5504
5602
|
} = useAppContext();
|
5505
|
-
const dzContext = (0,
|
5506
|
-
return (0,
|
5603
|
+
const dzContext = (0, import_react34.useContext)(dropZoneContext);
|
5604
|
+
return (0, import_react34.useMemo)(() => {
|
5507
5605
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5508
5606
|
selectedItem,
|
5509
5607
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5627,7 +5725,7 @@ function MenuBar({
|
|
5627
5725
|
|
5628
5726
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5629
5727
|
init_react_import();
|
5630
|
-
var styles_module_default15 = { "Puck": "
|
5728
|
+
var styles_module_default15 = { "Puck": "_Puck_11o75_19", "Puck-portal": "_Puck-portal_11o75_24", "PuckLayout-inner": "_PuckLayout-inner_11o75_31", "PuckLayout--mounted": "_PuckLayout--mounted_11o75_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_11o75_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_11o75_53", "PuckLayout-mounted": "_PuckLayout-mounted_11o75_67", "PuckLayout": "_PuckLayout_11o75_31", "PuckLayout-header": "_PuckLayout-header_11o75_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_11o75_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_11o75_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_11o75_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_11o75_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_11o75_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_11o75_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_11o75_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_11o75_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_11o75_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_11o75_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_11o75_134" };
|
5631
5729
|
|
5632
5730
|
// components/Puck/components/Fields/index.tsx
|
5633
5731
|
init_react_import();
|
@@ -5637,15 +5735,15 @@ init_react_import();
|
|
5637
5735
|
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" };
|
5638
5736
|
|
5639
5737
|
// components/Puck/components/Fields/index.tsx
|
5640
|
-
var
|
5738
|
+
var import_react38 = require("react");
|
5641
5739
|
|
5642
5740
|
// lib/use-resolved-fields.ts
|
5643
5741
|
init_react_import();
|
5644
|
-
var
|
5742
|
+
var import_react37 = require("react");
|
5645
5743
|
|
5646
5744
|
// lib/use-parent.ts
|
5647
5745
|
init_react_import();
|
5648
|
-
var
|
5746
|
+
var import_react35 = require("react");
|
5649
5747
|
var getParent = (itemSelector, pathData, data) => {
|
5650
5748
|
var _a;
|
5651
5749
|
if (!itemSelector) return null;
|
@@ -5657,8 +5755,8 @@ var getParent = (itemSelector, pathData, data) => {
|
|
5657
5755
|
};
|
5658
5756
|
var useGetParent = () => {
|
5659
5757
|
const { state } = useAppContext();
|
5660
|
-
const { pathData } = (0,
|
5661
|
-
return (0,
|
5758
|
+
const { pathData } = (0, import_react35.useContext)(dropZoneContext) || {};
|
5759
|
+
return (0, import_react35.useCallback)(
|
5662
5760
|
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5663
5761
|
[state.ui.itemSelector, pathData, state.data]
|
5664
5762
|
);
|
@@ -5669,10 +5767,10 @@ var useParent = () => {
|
|
5669
5767
|
|
5670
5768
|
// lib/use-on-value-change.ts
|
5671
5769
|
init_react_import();
|
5672
|
-
var
|
5770
|
+
var import_react36 = require("react");
|
5673
5771
|
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5674
|
-
const tracked = (0,
|
5675
|
-
(0,
|
5772
|
+
const tracked = (0, import_react36.useRef)(value);
|
5773
|
+
(0, import_react36.useEffect)(() => {
|
5676
5774
|
const oldValue = tracked.current;
|
5677
5775
|
if (!compare(value, oldValue)) {
|
5678
5776
|
tracked.current = value;
|
@@ -5689,28 +5787,37 @@ var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0
|
|
5689
5787
|
var defaultPageFields = {
|
5690
5788
|
title: { type: "text" }
|
5691
5789
|
};
|
5692
|
-
var useResolvedFields = (
|
5790
|
+
var useResolvedFields = ({
|
5791
|
+
_skipValueCheck,
|
5792
|
+
_skipIdCheck
|
5793
|
+
} = {}) => {
|
5693
5794
|
var _a, _b;
|
5694
5795
|
const { selectedItem, state, config } = useAppContext();
|
5695
5796
|
const parent = useParent();
|
5696
5797
|
const { data } = state;
|
5697
5798
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5698
5799
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5699
|
-
const defaultFields = (0,
|
5800
|
+
const defaultFields = (0, import_react37.useMemo)(
|
5700
5801
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5701
5802
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5702
5803
|
);
|
5703
5804
|
const rootProps = data.root.props || data.root;
|
5704
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5705
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5706
|
-
|
5707
|
-
|
5805
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react37.useState)({});
|
5806
|
+
const [resolvedFields, setResolvedFields] = (0, import_react37.useState)({
|
5807
|
+
fields: defaultFields,
|
5808
|
+
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5809
|
+
});
|
5810
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react37.useState)(false);
|
5811
|
+
const lastFields = (0, import_react37.useRef)(defaultFields);
|
5708
5812
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5709
|
-
const componentData =
|
5813
|
+
const componentData = (0, import_react37.useMemo)(
|
5814
|
+
() => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
|
5815
|
+
[selectedItem, rootProps, data.root.readOnly]
|
5816
|
+
);
|
5710
5817
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5711
5818
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5712
5819
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5713
|
-
const resolveFields = (0,
|
5820
|
+
const resolveFields = (0, import_react37.useCallback)(
|
5714
5821
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5715
5822
|
var _a2;
|
5716
5823
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5748,21 +5855,31 @@ var useResolvedFields = () => {
|
|
5748
5855
|
}),
|
5749
5856
|
[data, config, componentData, selectedItem, state, parent]
|
5750
5857
|
);
|
5751
|
-
const triggerResolver = (0,
|
5858
|
+
const triggerResolver = (0, import_react37.useCallback)(() => {
|
5752
5859
|
var _a2, _b2;
|
5753
5860
|
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5754
5861
|
if (hasResolver) {
|
5755
5862
|
setFieldsLoading(true);
|
5756
5863
|
resolveFields(defaultFields).then((fields) => {
|
5757
|
-
setResolvedFields(
|
5864
|
+
setResolvedFields({
|
5865
|
+
fields: fields || {},
|
5866
|
+
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5867
|
+
});
|
5758
5868
|
lastFields.current = fields;
|
5759
5869
|
setFieldsLoading(false);
|
5760
5870
|
});
|
5761
5871
|
return;
|
5762
5872
|
}
|
5763
5873
|
}
|
5764
|
-
setResolvedFields(defaultFields);
|
5765
|
-
}, [
|
5874
|
+
setResolvedFields({ fields: defaultFields, id: selectedItem == null ? void 0 : selectedItem.props.id });
|
5875
|
+
}, [
|
5876
|
+
defaultFields,
|
5877
|
+
state.ui.itemSelector,
|
5878
|
+
selectedItem,
|
5879
|
+
hasResolver,
|
5880
|
+
parent,
|
5881
|
+
resolveFields
|
5882
|
+
]);
|
5766
5883
|
useOnValueChange(
|
5767
5884
|
state.ui.itemSelector,
|
5768
5885
|
() => {
|
@@ -5773,14 +5890,18 @@ var useResolvedFields = () => {
|
|
5773
5890
|
useOnValueChange(
|
5774
5891
|
{ data, parent, itemSelector: state.ui.itemSelector },
|
5775
5892
|
() => {
|
5893
|
+
if (_skipValueCheck) return;
|
5776
5894
|
triggerResolver();
|
5777
5895
|
},
|
5778
5896
|
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5779
5897
|
);
|
5780
|
-
(0,
|
5898
|
+
(0, import_react37.useEffect)(() => {
|
5781
5899
|
triggerResolver();
|
5782
5900
|
}, []);
|
5783
|
-
|
5901
|
+
if (resolvedFields.id !== (selectedItem == null ? void 0 : selectedItem.props.id) && !_skipIdCheck) {
|
5902
|
+
return [defaultFields, fieldsLoading];
|
5903
|
+
}
|
5904
|
+
return [resolvedFields.fields, fieldsLoading];
|
5784
5905
|
};
|
5785
5906
|
|
5786
5907
|
// components/Puck/components/Fields/index.tsx
|
@@ -5809,7 +5930,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
5809
5930
|
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;
|
5810
5931
|
const isLoading = fieldsResolving || componentResolving;
|
5811
5932
|
const rootProps = data.root.props || data.root;
|
5812
|
-
const Wrapper = (0,
|
5933
|
+
const Wrapper = (0, import_react38.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5813
5934
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5814
5935
|
"form",
|
5815
5936
|
{
|
@@ -5930,14 +6051,14 @@ init_react_import();
|
|
5930
6051
|
|
5931
6052
|
// lib/use-component-list.tsx
|
5932
6053
|
init_react_import();
|
5933
|
-
var
|
6054
|
+
var import_react39 = require("react");
|
5934
6055
|
|
5935
6056
|
// components/ComponentList/index.tsx
|
5936
6057
|
init_react_import();
|
5937
6058
|
|
5938
6059
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
5939
6060
|
init_react_import();
|
5940
|
-
var styles_module_default17 = { "ComponentList": "
|
6061
|
+
var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
5941
6062
|
|
5942
6063
|
// components/ComponentList/index.tsx
|
5943
6064
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
@@ -5997,8 +6118,8 @@ ComponentList.Item = ComponentListItem;
|
|
5997
6118
|
// lib/use-component-list.tsx
|
5998
6119
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5999
6120
|
var useComponentList = (config, ui) => {
|
6000
|
-
const [componentList, setComponentList] = (0,
|
6001
|
-
(0,
|
6121
|
+
const [componentList, setComponentList] = (0, import_react39.useState)();
|
6122
|
+
(0, import_react39.useEffect)(() => {
|
6002
6123
|
var _a, _b, _c;
|
6003
6124
|
if (Object.keys(ui.componentList).length > 0) {
|
6004
6125
|
const matchedComponents = [];
|
@@ -6067,22 +6188,22 @@ var useComponentList = (config, ui) => {
|
|
6067
6188
|
};
|
6068
6189
|
|
6069
6190
|
// components/Puck/components/Components/index.tsx
|
6070
|
-
var
|
6191
|
+
var import_react40 = require("react");
|
6071
6192
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6072
6193
|
var Components = () => {
|
6073
6194
|
const { config, state, overrides } = useAppContext();
|
6074
6195
|
const componentList = useComponentList(config, state.ui);
|
6075
|
-
const Wrapper = (0,
|
6196
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.components || "div", [overrides]);
|
6076
6197
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6077
6198
|
};
|
6078
6199
|
|
6079
6200
|
// components/Puck/components/Preview/index.tsx
|
6080
6201
|
init_react_import();
|
6081
|
-
var
|
6202
|
+
var import_react42 = require("react");
|
6082
6203
|
|
6083
6204
|
// components/AutoFrame/index.tsx
|
6084
6205
|
init_react_import();
|
6085
|
-
var
|
6206
|
+
var import_react41 = require("react");
|
6086
6207
|
var import_object_hash = __toESM(require("object-hash"));
|
6087
6208
|
var import_react_dom3 = require("react-dom");
|
6088
6209
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6128,7 +6249,7 @@ var CopyHostStyles = ({
|
|
6128
6249
|
onStylesLoaded = () => null
|
6129
6250
|
}) => {
|
6130
6251
|
const { document: doc, window: win } = useFrame();
|
6131
|
-
(0,
|
6252
|
+
(0, import_react41.useEffect)(() => {
|
6132
6253
|
if (!win || !doc) {
|
6133
6254
|
return () => {
|
6134
6255
|
};
|
@@ -6287,8 +6408,8 @@ var CopyHostStyles = ({
|
|
6287
6408
|
}, []);
|
6288
6409
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6289
6410
|
};
|
6290
|
-
var autoFrameContext = (0,
|
6291
|
-
var useFrame = () => (0,
|
6411
|
+
var autoFrameContext = (0, import_react41.createContext)({});
|
6412
|
+
var useFrame = () => (0, import_react41.useContext)(autoFrameContext);
|
6292
6413
|
function AutoFrame(_a) {
|
6293
6414
|
var _b = _a, {
|
6294
6415
|
children,
|
@@ -6305,10 +6426,10 @@ function AutoFrame(_a) {
|
|
6305
6426
|
"onStylesLoaded",
|
6306
6427
|
"frameRef"
|
6307
6428
|
]);
|
6308
|
-
const [loaded, setLoaded] = (0,
|
6309
|
-
const [ctx, setCtx] = (0,
|
6310
|
-
const [mountTarget, setMountTarget] = (0,
|
6311
|
-
(0,
|
6429
|
+
const [loaded, setLoaded] = (0, import_react41.useState)(false);
|
6430
|
+
const [ctx, setCtx] = (0, import_react41.useState)({});
|
6431
|
+
const [mountTarget, setMountTarget] = (0, import_react41.useState)();
|
6432
|
+
(0, import_react41.useEffect)(() => {
|
6312
6433
|
var _a2;
|
6313
6434
|
if (frameRef.current) {
|
6314
6435
|
setCtx({
|
@@ -6370,13 +6491,14 @@ function Render({
|
|
6370
6491
|
config.root.render,
|
6371
6492
|
__spreadProps(__spreadValues({}, rootProps), {
|
6372
6493
|
puck: {
|
6373
|
-
renderDropZone:
|
6374
|
-
isEditing: false
|
6494
|
+
renderDropZone: DropZonePure,
|
6495
|
+
isEditing: false,
|
6496
|
+
dragRef: null
|
6375
6497
|
},
|
6376
6498
|
title,
|
6377
6499
|
editMode: false,
|
6378
6500
|
id: "puck-root",
|
6379
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6501
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
|
6380
6502
|
})
|
6381
6503
|
)
|
6382
6504
|
}
|
@@ -6392,7 +6514,7 @@ function Render({
|
|
6392
6514
|
depth: 0,
|
6393
6515
|
path: []
|
6394
6516
|
},
|
6395
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6517
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
|
6396
6518
|
}
|
6397
6519
|
);
|
6398
6520
|
}
|
@@ -6402,25 +6524,12 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6402
6524
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6403
6525
|
var useBubbleIframeEvents = (ref) => {
|
6404
6526
|
const { status } = useAppContext();
|
6405
|
-
(0,
|
6527
|
+
(0, import_react42.useEffect)(() => {
|
6406
6528
|
var _a;
|
6407
6529
|
if (ref.current && status === "READY") {
|
6408
6530
|
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
|
-
}
|
6422
6531
|
const handlePointerMove = (event) => {
|
6423
|
-
const evt = new
|
6532
|
+
const evt = new BubbledPointerEvent("pointermove", __spreadProps(__spreadValues({}, event), {
|
6424
6533
|
bubbles: true,
|
6425
6534
|
cancelable: false,
|
6426
6535
|
clientX: event.clientX,
|
@@ -6448,7 +6557,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6448
6557
|
};
|
6449
6558
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6450
6559
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6451
|
-
const Page = (0,
|
6560
|
+
const Page = (0, import_react42.useCallback)(
|
6452
6561
|
(pageProps) => {
|
6453
6562
|
var _a, _b;
|
6454
6563
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6457,20 +6566,20 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6457
6566
|
},
|
6458
6567
|
[config.root]
|
6459
6568
|
);
|
6460
|
-
const Frame = (0,
|
6569
|
+
const Frame = (0, import_react42.useMemo)(() => overrides.iframe, [overrides]);
|
6461
6570
|
const rootProps = state.data.root.props || state.data.root;
|
6462
|
-
const ref = (0,
|
6571
|
+
const ref = (0, import_react42.useRef)(null);
|
6463
6572
|
useBubbleIframeEvents(ref);
|
6464
6573
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6465
6574
|
Page,
|
6466
6575
|
__spreadProps(__spreadValues({}, rootProps), {
|
6467
6576
|
puck: {
|
6468
|
-
renderDropZone:
|
6577
|
+
renderDropZone: DropZonePure,
|
6469
6578
|
isEditing: true,
|
6470
6579
|
dragRef: null
|
6471
6580
|
},
|
6472
6581
|
editMode: true,
|
6473
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6582
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZonePure, { zone: rootDroppableId })
|
6474
6583
|
})
|
6475
6584
|
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
|
6476
6585
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
@@ -6542,7 +6651,7 @@ init_react_import();
|
|
6542
6651
|
|
6543
6652
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
6544
6653
|
init_react_import();
|
6545
|
-
var styles_module_default19 = { "LayerTree": "
|
6654
|
+
var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
|
6546
6655
|
|
6547
6656
|
// lib/scroll-into-view.ts
|
6548
6657
|
init_react_import();
|
@@ -6556,7 +6665,7 @@ var scrollIntoView = (el) => {
|
|
6556
6665
|
};
|
6557
6666
|
|
6558
6667
|
// components/LayerTree/index.tsx
|
6559
|
-
var
|
6668
|
+
var import_react43 = require("react");
|
6560
6669
|
|
6561
6670
|
// lib/is-child-of-zone.ts
|
6562
6671
|
init_react_import();
|
@@ -6602,7 +6711,7 @@ var LayerTree = ({
|
|
6602
6711
|
label
|
6603
6712
|
}) => {
|
6604
6713
|
const zones = data.zones || {};
|
6605
|
-
const ctx = (0,
|
6714
|
+
const ctx = (0, import_react43.useContext)(dropZoneContext);
|
6606
6715
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6607
6716
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6608
6717
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6709,13 +6818,13 @@ var LayerTree = ({
|
|
6709
6818
|
};
|
6710
6819
|
|
6711
6820
|
// components/Puck/components/Outline/index.tsx
|
6712
|
-
var
|
6821
|
+
var import_react44 = require("react");
|
6713
6822
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6714
6823
|
var Outline = () => {
|
6715
6824
|
const { dispatch, state, overrides, config } = useAppContext();
|
6716
6825
|
const { data, ui } = state;
|
6717
6826
|
const { itemSelector } = ui;
|
6718
|
-
const setItemSelector = (0,
|
6827
|
+
const setItemSelector = (0, import_react44.useCallback)(
|
6719
6828
|
(newItemSelector) => {
|
6720
6829
|
dispatch({
|
6721
6830
|
type: "setUi",
|
@@ -6724,7 +6833,7 @@ var Outline = () => {
|
|
6724
6833
|
},
|
6725
6834
|
[]
|
6726
6835
|
);
|
6727
|
-
const Wrapper = (0,
|
6836
|
+
const Wrapper = (0, import_react44.useMemo)(() => overrides.outline || "div", [overrides]);
|
6728
6837
|
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: [
|
6729
6838
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6730
6839
|
LayerTree,
|
@@ -6838,19 +6947,19 @@ function usePuckHistory({
|
|
6838
6947
|
|
6839
6948
|
// lib/use-history-store.ts
|
6840
6949
|
init_react_import();
|
6841
|
-
var
|
6950
|
+
var import_react45 = require("react");
|
6842
6951
|
var import_use_debounce3 = require("use-debounce");
|
6843
6952
|
var EMPTY_HISTORY_INDEX = 0;
|
6844
6953
|
function useHistoryStore(initialHistory) {
|
6845
6954
|
var _a, _b;
|
6846
|
-
const [histories, setHistories] = (0,
|
6955
|
+
const [histories, setHistories] = (0, import_react45.useState)(
|
6847
6956
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6848
6957
|
);
|
6849
6958
|
const updateHistories = (histories2) => {
|
6850
6959
|
setHistories(histories2);
|
6851
6960
|
setIndex(histories2.length - 1);
|
6852
6961
|
};
|
6853
|
-
const [index, setIndex] = (0,
|
6962
|
+
const [index, setIndex] = (0, import_react45.useState)(
|
6854
6963
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6855
6964
|
);
|
6856
6965
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -7010,15 +7119,15 @@ var getBox = function getBox2(el) {
|
|
7010
7119
|
};
|
7011
7120
|
|
7012
7121
|
// components/Puck/components/Canvas/index.tsx
|
7013
|
-
var
|
7122
|
+
var import_react47 = require("react");
|
7014
7123
|
|
7015
7124
|
// components/ViewportControls/index.tsx
|
7016
7125
|
init_react_import();
|
7017
|
-
var
|
7126
|
+
var import_react46 = require("react");
|
7018
7127
|
|
7019
7128
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7020
7129
|
init_react_import();
|
7021
|
-
var styles_module_default20 = { "ViewportControls": "
|
7130
|
+
var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
|
7022
7131
|
|
7023
7132
|
// components/ViewportControls/index.tsx
|
7024
7133
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
@@ -7037,8 +7146,8 @@ var ViewportButton = ({
|
|
7037
7146
|
onClick
|
7038
7147
|
}) => {
|
7039
7148
|
const { state } = useAppContext();
|
7040
|
-
const [isActive, setIsActive] = (0,
|
7041
|
-
(0,
|
7149
|
+
const [isActive, setIsActive] = (0, import_react46.useState)(false);
|
7150
|
+
(0, import_react46.useEffect)(() => {
|
7042
7151
|
setIsActive(width === state.ui.viewports.current.width);
|
7043
7152
|
}, [width, state.ui.viewports.current.width]);
|
7044
7153
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -7074,7 +7183,7 @@ var ViewportControls = ({
|
|
7074
7183
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7075
7184
|
(option) => option.value === autoZoom
|
7076
7185
|
);
|
7077
|
-
const zoomOptions = (0,
|
7186
|
+
const zoomOptions = (0, import_react46.useMemo)(
|
7078
7187
|
() => [
|
7079
7188
|
...defaultZoomOptions,
|
7080
7189
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7197,17 +7306,17 @@ var Canvas = () => {
|
|
7197
7306
|
const { status, iframe } = useAppContext();
|
7198
7307
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7199
7308
|
const { ui } = state;
|
7200
|
-
const frameRef = (0,
|
7201
|
-
const [showTransition, setShowTransition] = (0,
|
7202
|
-
const defaultRender = (0,
|
7309
|
+
const frameRef = (0, import_react47.useRef)(null);
|
7310
|
+
const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
|
7311
|
+
const defaultRender = (0, import_react47.useMemo)(() => {
|
7203
7312
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7204
7313
|
return PuckDefault;
|
7205
7314
|
}, []);
|
7206
|
-
const CustomPreview = (0,
|
7315
|
+
const CustomPreview = (0, import_react47.useMemo)(
|
7207
7316
|
() => overrides.preview || defaultRender,
|
7208
7317
|
[overrides]
|
7209
7318
|
);
|
7210
|
-
const getFrameDimensions = (0,
|
7319
|
+
const getFrameDimensions = (0, import_react47.useCallback)(() => {
|
7211
7320
|
if (frameRef.current) {
|
7212
7321
|
const frame = frameRef.current;
|
7213
7322
|
const box = getBox(frame);
|
@@ -7215,7 +7324,7 @@ var Canvas = () => {
|
|
7215
7324
|
}
|
7216
7325
|
return { width: 0, height: 0 };
|
7217
7326
|
}, [frameRef]);
|
7218
|
-
const resetAutoZoom = (0,
|
7327
|
+
const resetAutoZoom = (0, import_react47.useCallback)(
|
7219
7328
|
(ui2 = state.ui) => {
|
7220
7329
|
if (frameRef.current) {
|
7221
7330
|
setZoomConfig(
|
@@ -7225,11 +7334,11 @@ var Canvas = () => {
|
|
7225
7334
|
},
|
7226
7335
|
[frameRef, zoomConfig, state.ui]
|
7227
7336
|
);
|
7228
|
-
(0,
|
7337
|
+
(0, import_react47.useEffect)(() => {
|
7229
7338
|
setShowTransition(false);
|
7230
7339
|
resetAutoZoom();
|
7231
7340
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7232
|
-
(0,
|
7341
|
+
(0, import_react47.useEffect)(() => {
|
7233
7342
|
const { height: frameHeight } = getFrameDimensions();
|
7234
7343
|
if (ui.viewports.current.height === "auto") {
|
7235
7344
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7237,13 +7346,13 @@ var Canvas = () => {
|
|
7237
7346
|
}));
|
7238
7347
|
}
|
7239
7348
|
}, [zoomConfig.zoom]);
|
7240
|
-
(0,
|
7349
|
+
(0, import_react47.useEffect)(() => {
|
7241
7350
|
if (ZOOM_ON_CHANGE) {
|
7242
7351
|
setShowTransition(true);
|
7243
7352
|
resetAutoZoom(ui);
|
7244
7353
|
}
|
7245
7354
|
}, [ui.viewports.current.width]);
|
7246
|
-
(0,
|
7355
|
+
(0, import_react47.useEffect)(() => {
|
7247
7356
|
const cb = () => {
|
7248
7357
|
setShowTransition(false);
|
7249
7358
|
resetAutoZoom();
|
@@ -7253,8 +7362,8 @@ var Canvas = () => {
|
|
7253
7362
|
window.removeEventListener("resize", cb);
|
7254
7363
|
};
|
7255
7364
|
}, []);
|
7256
|
-
const [showLoader, setShowLoader] = (0,
|
7257
|
-
(0,
|
7365
|
+
const [showLoader, setShowLoader] = (0, import_react47.useState)(false);
|
7366
|
+
(0, import_react47.useEffect)(() => {
|
7258
7367
|
setTimeout(() => {
|
7259
7368
|
setShowLoader(true);
|
7260
7369
|
}, 500);
|
@@ -7332,7 +7441,7 @@ var Canvas = () => {
|
|
7332
7441
|
|
7333
7442
|
// lib/use-loaded-overrides.ts
|
7334
7443
|
init_react_import();
|
7335
|
-
var
|
7444
|
+
var import_react48 = require("react");
|
7336
7445
|
|
7337
7446
|
// lib/load-overrides.ts
|
7338
7447
|
init_react_import();
|
@@ -7371,7 +7480,7 @@ var useLoadedOverrides = ({
|
|
7371
7480
|
overrides,
|
7372
7481
|
plugins
|
7373
7482
|
}) => {
|
7374
|
-
return (0,
|
7483
|
+
return (0, import_react48.useMemo)(() => {
|
7375
7484
|
return loadOverrides({ overrides, plugins });
|
7376
7485
|
}, [plugins, overrides]);
|
7377
7486
|
};
|
@@ -7383,14 +7492,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7383
7492
|
|
7384
7493
|
// lib/use-inject-css.ts
|
7385
7494
|
init_react_import();
|
7386
|
-
var
|
7495
|
+
var import_react49 = require("react");
|
7387
7496
|
var styles = ``;
|
7388
7497
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7389
|
-
const [el, setEl] = (0,
|
7390
|
-
(0,
|
7498
|
+
const [el, setEl] = (0, import_react49.useState)();
|
7499
|
+
(0, import_react49.useEffect)(() => {
|
7391
7500
|
setEl(document.createElement("style"));
|
7392
7501
|
}, []);
|
7393
|
-
(0,
|
7502
|
+
(0, import_react49.useEffect)(() => {
|
7394
7503
|
var _a;
|
7395
7504
|
if (!el || typeof window === "undefined") {
|
7396
7505
|
return;
|
@@ -7410,10 +7519,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7410
7519
|
|
7411
7520
|
// lib/use-preview-mode-hotkeys.ts
|
7412
7521
|
init_react_import();
|
7413
|
-
var
|
7522
|
+
var import_react50 = require("react");
|
7414
7523
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7415
7524
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7416
|
-
const toggleInteractive = (0,
|
7525
|
+
const toggleInteractive = (0, import_react50.useCallback)(() => {
|
7417
7526
|
dispatch({
|
7418
7527
|
type: "setUi",
|
7419
7528
|
ui: (ui) => ({
|
@@ -7470,7 +7579,7 @@ function Puck({
|
|
7470
7579
|
waitForStyles: true
|
7471
7580
|
}, _iframe);
|
7472
7581
|
useInjectGlobalCss(iframe.enabled);
|
7473
|
-
const [generatedAppState] = (0,
|
7582
|
+
const [generatedAppState] = (0, import_react51.useState)(() => {
|
7474
7583
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7475
7584
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7476
7585
|
let clientUiState = {};
|
@@ -7542,14 +7651,14 @@ function Puck({
|
|
7542
7651
|
histories,
|
7543
7652
|
index: initialHistoryIndex
|
7544
7653
|
});
|
7545
|
-
const [reducer] = (0,
|
7654
|
+
const [reducer] = (0, import_react51.useState)(
|
7546
7655
|
() => createReducer({
|
7547
7656
|
config,
|
7548
7657
|
record: historyStore.record,
|
7549
7658
|
onAction
|
7550
7659
|
})
|
7551
7660
|
);
|
7552
|
-
const [appState, dispatch] = (0,
|
7661
|
+
const [appState, dispatch] = (0, import_react51.useReducer)(
|
7553
7662
|
reducer,
|
7554
7663
|
flushZones(initialAppState)
|
7555
7664
|
);
|
@@ -7560,14 +7669,14 @@ function Puck({
|
|
7560
7669
|
historyStore,
|
7561
7670
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7562
7671
|
});
|
7563
|
-
const [menuOpen, setMenuOpen] = (0,
|
7672
|
+
const [menuOpen, setMenuOpen] = (0, import_react51.useState)(false);
|
7564
7673
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7565
7674
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7566
|
-
(0,
|
7675
|
+
(0, import_react51.useEffect)(() => {
|
7567
7676
|
if (onChange) onChange(data);
|
7568
7677
|
}, [data]);
|
7569
7678
|
const rootProps = data.root.props || data.root;
|
7570
|
-
const toggleSidebars = (0,
|
7679
|
+
const toggleSidebars = (0, import_react51.useCallback)(
|
7571
7680
|
(sidebar) => {
|
7572
7681
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7573
7682
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7581,7 +7690,7 @@ function Puck({
|
|
7581
7690
|
},
|
7582
7691
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7583
7692
|
);
|
7584
|
-
(0,
|
7693
|
+
(0, import_react51.useEffect)(() => {
|
7585
7694
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7586
7695
|
dispatch({
|
7587
7696
|
type: "setUi",
|
@@ -7604,7 +7713,7 @@ function Puck({
|
|
7604
7713
|
window.removeEventListener("resize", handleResize);
|
7605
7714
|
};
|
7606
7715
|
}, []);
|
7607
|
-
const defaultHeaderRender = (0,
|
7716
|
+
const defaultHeaderRender = (0, import_react51.useMemo)(() => {
|
7608
7717
|
if (renderHeader) {
|
7609
7718
|
console.warn(
|
7610
7719
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7618,7 +7727,7 @@ function Puck({
|
|
7618
7727
|
}
|
7619
7728
|
return DefaultOverride;
|
7620
7729
|
}, [renderHeader]);
|
7621
|
-
const defaultHeaderActionsRender = (0,
|
7730
|
+
const defaultHeaderActionsRender = (0, import_react51.useMemo)(() => {
|
7622
7731
|
if (renderHeaderActions) {
|
7623
7732
|
console.warn(
|
7624
7733
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7635,20 +7744,20 @@ function Puck({
|
|
7635
7744
|
overrides,
|
7636
7745
|
plugins
|
7637
7746
|
});
|
7638
|
-
const CustomPuck = (0,
|
7747
|
+
const CustomPuck = (0, import_react51.useMemo)(
|
7639
7748
|
() => loadedOverrides.puck || DefaultOverride,
|
7640
7749
|
[loadedOverrides]
|
7641
7750
|
);
|
7642
|
-
const CustomHeader = (0,
|
7751
|
+
const CustomHeader = (0, import_react51.useMemo)(
|
7643
7752
|
() => loadedOverrides.header || defaultHeaderRender,
|
7644
7753
|
[loadedOverrides]
|
7645
7754
|
);
|
7646
|
-
const CustomHeaderActions = (0,
|
7755
|
+
const CustomHeaderActions = (0, import_react51.useMemo)(
|
7647
7756
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7648
7757
|
[loadedOverrides]
|
7649
7758
|
);
|
7650
|
-
const [mounted, setMounted] = (0,
|
7651
|
-
(0,
|
7759
|
+
const [mounted, setMounted] = (0, import_react51.useState)(false);
|
7760
|
+
(0, import_react51.useEffect)(() => {
|
7652
7761
|
setMounted(true);
|
7653
7762
|
}, []);
|
7654
7763
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
@@ -7953,14 +8062,12 @@ var usePuck = () => {
|
|
7953
8062
|
Button,
|
7954
8063
|
Drawer,
|
7955
8064
|
DropZone,
|
7956
|
-
DropZoneProvider,
|
7957
8065
|
FieldLabel,
|
7958
8066
|
Group,
|
7959
8067
|
IconButton,
|
7960
8068
|
Label,
|
7961
8069
|
Puck,
|
7962
8070
|
Render,
|
7963
|
-
dropZoneContext,
|
7964
8071
|
migrate,
|
7965
8072
|
overrideKeys,
|
7966
8073
|
resolveAllData,
|