@measured/puck 0.18.0-canary.066aba9 → 0.18.0-canary.37cfc43
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/{chunk-EXKSBUY5.mjs → chunk-CHWFBYEM.mjs} +2 -4
- package/dist/index.css +27 -34
- package/dist/index.d.mts +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +1224 -880
- package/dist/index.mjs +1156 -809
- package/dist/rsc.js +2 -4
- package/dist/rsc.mjs +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
@@ -311,7 +311,7 @@ init_react_import();
|
|
311
311
|
var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
|
312
312
|
|
313
313
|
// components/AutoField/index.tsx
|
314
|
-
var
|
314
|
+
var import_react20 = require("react");
|
315
315
|
|
316
316
|
// components/AutoField/fields/index.tsx
|
317
317
|
init_react_import();
|
@@ -771,7 +771,7 @@ var IconButton = ({
|
|
771
771
|
};
|
772
772
|
|
773
773
|
// components/AutoField/fields/ArrayField/index.tsx
|
774
|
-
var
|
774
|
+
var import_react12 = require("react");
|
775
775
|
|
776
776
|
// components/DragIcon/index.tsx
|
777
777
|
init_react_import();
|
@@ -988,13 +988,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
988
988
|
onResolveStart(item);
|
989
989
|
}
|
990
990
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
991
|
-
const { readOnly: existingReadOnly = {} } = item || {};
|
992
|
-
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
993
991
|
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
994
992
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
995
993
|
});
|
996
|
-
if (Object.keys(
|
997
|
-
resolvedItem.readOnly =
|
994
|
+
if (Object.keys(readOnly).length) {
|
995
|
+
resolvedItem.readOnly = readOnly;
|
998
996
|
}
|
999
997
|
cache.lastChange[item.props.id] = {
|
1000
998
|
item,
|
@@ -1284,7 +1282,7 @@ init_react_import();
|
|
1284
1282
|
var import_react9 = require("@dnd-kit/react");
|
1285
1283
|
var import_react10 = require("react");
|
1286
1284
|
|
1287
|
-
// lib/dnd-kit/safe.ts
|
1285
|
+
// lib/dnd/dnd-kit/safe.ts
|
1288
1286
|
init_react_import();
|
1289
1287
|
var import_react8 = require("@dnd-kit/react");
|
1290
1288
|
var import_sortable = require("@dnd-kit/react/sortable");
|
@@ -1361,8 +1359,53 @@ var Sortable = ({
|
|
1361
1359
|
return children({ status, ref: sortableRef });
|
1362
1360
|
};
|
1363
1361
|
|
1364
|
-
// components/AutoField/
|
1362
|
+
// components/AutoField/context.tsx
|
1363
|
+
init_react_import();
|
1364
|
+
var import_react11 = require("react");
|
1365
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
|
+
};
|
1406
|
+
|
1407
|
+
// components/AutoField/fields/ArrayField/index.tsx
|
1408
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
1366
1409
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
1367
1410
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
1368
1411
|
var ArrayField = ({
|
@@ -1373,10 +1416,10 @@ var ArrayField = ({
|
|
1373
1416
|
label,
|
1374
1417
|
readOnly,
|
1375
1418
|
id,
|
1376
|
-
Label: Label2 = (props) => /* @__PURE__ */ (0,
|
1419
|
+
Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadValues({}, props))
|
1377
1420
|
}) => {
|
1378
1421
|
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
1379
|
-
const readOnlyFields =
|
1422
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
1380
1423
|
const value = _value;
|
1381
1424
|
const arrayState = state.ui.arrayState[id] || {
|
1382
1425
|
items: Array.from(value || []).map((item, idx) => {
|
@@ -1387,11 +1430,11 @@ var ArrayField = ({
|
|
1387
1430
|
}),
|
1388
1431
|
openId: ""
|
1389
1432
|
};
|
1390
|
-
const [localState, setLocalState] = (0,
|
1391
|
-
(0,
|
1433
|
+
const [localState, setLocalState] = (0, import_react12.useState)({ arrayState, value });
|
1434
|
+
(0, import_react12.useEffect)(() => {
|
1392
1435
|
setLocalState({ arrayState, value });
|
1393
1436
|
}, [value, state.ui.arrayState[id]]);
|
1394
|
-
const mapArrayStateToUi = (0,
|
1437
|
+
const mapArrayStateToUi = (0, import_react12.useCallback)(
|
1395
1438
|
(partialArrayState) => {
|
1396
1439
|
return {
|
1397
1440
|
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
@@ -1401,13 +1444,13 @@ var ArrayField = ({
|
|
1401
1444
|
},
|
1402
1445
|
[arrayState]
|
1403
1446
|
);
|
1404
|
-
const getHighestIndex = (0,
|
1447
|
+
const getHighestIndex = (0, import_react12.useCallback)(() => {
|
1405
1448
|
return arrayState.items.reduce(
|
1406
1449
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
1407
1450
|
-1
|
1408
1451
|
);
|
1409
1452
|
}, [arrayState]);
|
1410
|
-
const regenerateArrayState = (0,
|
1453
|
+
const regenerateArrayState = (0, import_react12.useCallback)(
|
1411
1454
|
(value2) => {
|
1412
1455
|
let highestIndex = getHighestIndex();
|
1413
1456
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -1426,7 +1469,7 @@ var ArrayField = ({
|
|
1426
1469
|
},
|
1427
1470
|
[arrayState]
|
1428
1471
|
);
|
1429
|
-
(0,
|
1472
|
+
(0, import_react12.useEffect)(() => {
|
1430
1473
|
if (arrayState.items.length > 0) {
|
1431
1474
|
setUi(mapArrayStateToUi(arrayState));
|
1432
1475
|
}
|
@@ -1436,14 +1479,14 @@ var ArrayField = ({
|
|
1436
1479
|
return null;
|
1437
1480
|
}
|
1438
1481
|
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
1439
|
-
return /* @__PURE__ */ (0,
|
1482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1440
1483
|
Label2,
|
1441
1484
|
{
|
1442
1485
|
label: label || name,
|
1443
|
-
icon: /* @__PURE__ */ (0,
|
1486
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(List, { size: 16 }),
|
1444
1487
|
el: "div",
|
1445
1488
|
readOnly,
|
1446
|
-
children: /* @__PURE__ */ (0,
|
1489
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1447
1490
|
SortableProvider,
|
1448
1491
|
{
|
1449
1492
|
onMove: (move) => {
|
@@ -1465,7 +1508,7 @@ var ArrayField = ({
|
|
1465
1508
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
1466
1509
|
});
|
1467
1510
|
},
|
1468
|
-
children: /* @__PURE__ */ (0,
|
1511
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
1469
1512
|
"div",
|
1470
1513
|
{
|
1471
1514
|
className: getClassName5({
|
@@ -1479,13 +1522,13 @@ var ArrayField = ({
|
|
1479
1522
|
localState.arrayState.items.map((item, i) => {
|
1480
1523
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
1481
1524
|
const data = Array.from(localState.value || [])[i] || {};
|
1482
|
-
return /* @__PURE__ */ (0,
|
1525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1483
1526
|
Sortable,
|
1484
1527
|
{
|
1485
1528
|
id: _arrayId,
|
1486
1529
|
index: i,
|
1487
1530
|
disabled: readOnly,
|
1488
|
-
children: ({ status, ref }) => /* @__PURE__ */ (0,
|
1531
|
+
children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
1489
1532
|
"div",
|
1490
1533
|
{
|
1491
1534
|
ref,
|
@@ -1495,7 +1538,7 @@ var ArrayField = ({
|
|
1495
1538
|
readOnly
|
1496
1539
|
}),
|
1497
1540
|
children: [
|
1498
|
-
/* @__PURE__ */ (0,
|
1541
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
1499
1542
|
"div",
|
1500
1543
|
{
|
1501
1544
|
onClick: (e) => {
|
@@ -1518,9 +1561,9 @@ var ArrayField = ({
|
|
1518
1561
|
className: getClassNameItem("summary"),
|
1519
1562
|
children: [
|
1520
1563
|
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
1521
|
-
/* @__PURE__ */ (0,
|
1522
|
-
!readOnly && /* @__PURE__ */ (0,
|
1523
|
-
/* @__PURE__ */ (0,
|
1564
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
1565
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1524
1567
|
IconButton,
|
1525
1568
|
{
|
1526
1569
|
type: "button",
|
@@ -1537,10 +1580,10 @@ var ArrayField = ({
|
|
1537
1580
|
);
|
1538
1581
|
},
|
1539
1582
|
title: "Duplicate",
|
1540
|
-
children: /* @__PURE__ */ (0,
|
1583
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
|
1541
1584
|
}
|
1542
1585
|
) }),
|
1543
|
-
/* @__PURE__ */ (0,
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1544
1587
|
IconButton,
|
1545
1588
|
{
|
1546
1589
|
type: "button",
|
@@ -1561,39 +1604,56 @@ var ArrayField = ({
|
|
1561
1604
|
);
|
1562
1605
|
},
|
1563
1606
|
title: "Delete",
|
1564
|
-
children: /* @__PURE__ */ (0,
|
1607
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
|
1565
1608
|
}
|
1566
1609
|
) })
|
1567
1610
|
] }),
|
1568
|
-
/* @__PURE__ */ (0,
|
1611
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
|
1569
1612
|
] })
|
1570
1613
|
]
|
1571
1614
|
}
|
1572
1615
|
),
|
1573
|
-
/* @__PURE__ */ (0,
|
1574
|
-
const subField = field.arrayFields[
|
1575
|
-
const
|
1576
|
-
const
|
1577
|
-
const
|
1578
|
-
|
1579
|
-
|
1616
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
1617
|
+
const subField = field.arrayFields[subName];
|
1618
|
+
const indexName = `${name}[${i}]`;
|
1619
|
+
const subPath = `${indexName}.${subName}`;
|
1620
|
+
const localIndexName = `${localName}[${i}]`;
|
1621
|
+
const localWildcardName = `${localName}[*]`;
|
1622
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
1623
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
1624
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
1625
|
+
const label2 = subField.label || subName;
|
1626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1627
|
+
NestedFieldProvider,
|
1580
1628
|
{
|
1581
|
-
name:
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
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
|
+
)
|
1595
1655
|
},
|
1596
|
-
|
1656
|
+
subPath
|
1597
1657
|
);
|
1598
1658
|
}) }) })
|
1599
1659
|
]
|
@@ -1603,7 +1663,7 @@ var ArrayField = ({
|
|
1603
1663
|
_arrayId
|
1604
1664
|
);
|
1605
1665
|
}),
|
1606
|
-
!addDisabled && /* @__PURE__ */ (0,
|
1666
|
+
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1607
1667
|
"button",
|
1608
1668
|
{
|
1609
1669
|
type: "button",
|
@@ -1617,7 +1677,7 @@ var ArrayField = ({
|
|
1617
1677
|
const newArrayState = regenerateArrayState(newValue);
|
1618
1678
|
onChange(newValue, mapArrayStateToUi(newArrayState));
|
1619
1679
|
},
|
1620
|
-
children: /* @__PURE__ */ (0,
|
1680
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Plus, { size: 21 })
|
1621
1681
|
}
|
1622
1682
|
)
|
1623
1683
|
]
|
@@ -1631,7 +1691,7 @@ var ArrayField = ({
|
|
1631
1691
|
|
1632
1692
|
// components/AutoField/fields/DefaultField/index.tsx
|
1633
1693
|
init_react_import();
|
1634
|
-
var
|
1694
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
1635
1695
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
1636
1696
|
var DefaultField = ({
|
1637
1697
|
field,
|
@@ -1643,16 +1703,16 @@ var DefaultField = ({
|
|
1643
1703
|
Label: Label2,
|
1644
1704
|
id
|
1645
1705
|
}) => {
|
1646
|
-
return /* @__PURE__ */ (0,
|
1706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1647
1707
|
Label2,
|
1648
1708
|
{
|
1649
1709
|
label: label || name,
|
1650
|
-
icon: /* @__PURE__ */ (0,
|
1651
|
-
field.type === "text" && /* @__PURE__ */ (0,
|
1652
|
-
field.type === "number" && /* @__PURE__ */ (0,
|
1710
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
1711
|
+
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Type, { size: 16 }),
|
1712
|
+
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Hash, { size: 16 })
|
1653
1713
|
] }),
|
1654
1714
|
readOnly,
|
1655
|
-
children: /* @__PURE__ */ (0,
|
1715
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1656
1716
|
"input",
|
1657
1717
|
{
|
1658
1718
|
className: getClassName6("input"),
|
@@ -1663,7 +1723,14 @@ var DefaultField = ({
|
|
1663
1723
|
value: typeof value === "undefined" ? "" : value.toString(),
|
1664
1724
|
onChange: (e) => {
|
1665
1725
|
if (field.type === "number") {
|
1666
|
-
|
1726
|
+
const numberValue = Number(e.currentTarget.value);
|
1727
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
1728
|
+
return;
|
1729
|
+
}
|
1730
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
1731
|
+
return;
|
1732
|
+
}
|
1733
|
+
onChange(numberValue);
|
1667
1734
|
} else {
|
1668
1735
|
onChange(e.currentTarget.value);
|
1669
1736
|
}
|
@@ -1681,11 +1748,11 @@ var DefaultField = ({
|
|
1681
1748
|
|
1682
1749
|
// components/AutoField/fields/ExternalField/index.tsx
|
1683
1750
|
init_react_import();
|
1684
|
-
var
|
1751
|
+
var import_react16 = require("react");
|
1685
1752
|
|
1686
1753
|
// components/ExternalInput/index.tsx
|
1687
1754
|
init_react_import();
|
1688
|
-
var
|
1755
|
+
var import_react15 = require("react");
|
1689
1756
|
|
1690
1757
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
1691
1758
|
init_react_import();
|
@@ -1693,7 +1760,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
1693
1760
|
|
1694
1761
|
// components/Modal/index.tsx
|
1695
1762
|
init_react_import();
|
1696
|
-
var
|
1763
|
+
var import_react13 = require("react");
|
1697
1764
|
|
1698
1765
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
1699
1766
|
init_react_import();
|
@@ -1701,22 +1768,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1701
1768
|
|
1702
1769
|
// components/Modal/index.tsx
|
1703
1770
|
var import_react_dom = require("react-dom");
|
1704
|
-
var
|
1771
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
1705
1772
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1706
1773
|
var Modal = ({
|
1707
1774
|
children,
|
1708
1775
|
onClose,
|
1709
1776
|
isOpen
|
1710
1777
|
}) => {
|
1711
|
-
const [rootEl, setRootEl] = (0,
|
1712
|
-
(0,
|
1778
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
1779
|
+
(0, import_react13.useEffect)(() => {
|
1713
1780
|
setRootEl(document.getElementById("puck-portal-root"));
|
1714
1781
|
}, []);
|
1715
1782
|
if (!rootEl) {
|
1716
|
-
return /* @__PURE__ */ (0,
|
1783
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
|
1717
1784
|
}
|
1718
1785
|
return (0, import_react_dom.createPortal)(
|
1719
|
-
/* @__PURE__ */ (0,
|
1786
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1720
1787
|
"div",
|
1721
1788
|
{
|
1722
1789
|
className: getClassName7("inner"),
|
@@ -1736,11 +1803,11 @@ init_react_import();
|
|
1736
1803
|
var styles_module_default8 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
|
1737
1804
|
|
1738
1805
|
// components/Heading/index.tsx
|
1739
|
-
var
|
1806
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
1740
1807
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1741
1808
|
var Heading = ({ children, rank, size = "m" }) => {
|
1742
1809
|
const Tag = rank ? `h${rank}` : "span";
|
1743
|
-
return /* @__PURE__ */ (0,
|
1810
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
1744
1811
|
Tag,
|
1745
1812
|
{
|
1746
1813
|
className: getClassName8({
|
@@ -1756,7 +1823,7 @@ init_react_import();
|
|
1756
1823
|
|
1757
1824
|
// components/Button/Button.tsx
|
1758
1825
|
init_react_import();
|
1759
|
-
var
|
1826
|
+
var import_react14 = require("react");
|
1760
1827
|
|
1761
1828
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
1762
1829
|
init_react_import();
|
@@ -1776,7 +1843,7 @@ var filterDataAttrs = (props) => {
|
|
1776
1843
|
};
|
1777
1844
|
|
1778
1845
|
// components/Button/Button.tsx
|
1779
|
-
var
|
1846
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
1780
1847
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1781
1848
|
var Button = (_a) => {
|
1782
1849
|
var _b = _a, {
|
@@ -1806,11 +1873,11 @@ var Button = (_a) => {
|
|
1806
1873
|
"size",
|
1807
1874
|
"loading"
|
1808
1875
|
]);
|
1809
|
-
const [loading, setLoading] = (0,
|
1810
|
-
(0,
|
1876
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
1877
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
1811
1878
|
const ElementType = href ? "a" : type ? "button" : "span";
|
1812
1879
|
const dataAttrs = filterDataAttrs(props);
|
1813
|
-
const el = /* @__PURE__ */ (0,
|
1880
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
1814
1881
|
ElementType,
|
1815
1882
|
__spreadProps(__spreadValues({
|
1816
1883
|
className: getClassName9({
|
@@ -1835,9 +1902,9 @@ var Button = (_a) => {
|
|
1835
1902
|
href
|
1836
1903
|
}, dataAttrs), {
|
1837
1904
|
children: [
|
1838
|
-
icon && /* @__PURE__ */ (0,
|
1905
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
1839
1906
|
children,
|
1840
|
-
loading && /* @__PURE__ */ (0,
|
1907
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 14 }) })
|
1841
1908
|
]
|
1842
1909
|
})
|
1843
1910
|
);
|
@@ -1845,7 +1912,7 @@ var Button = (_a) => {
|
|
1845
1912
|
};
|
1846
1913
|
|
1847
1914
|
// components/ExternalInput/index.tsx
|
1848
|
-
var
|
1915
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
1849
1916
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1850
1917
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1851
1918
|
var dataCache = {};
|
@@ -1862,28 +1929,28 @@ var ExternalInput = ({
|
|
1862
1929
|
mapRow = (val) => val,
|
1863
1930
|
filterFields
|
1864
1931
|
} = field || {};
|
1865
|
-
const [data, setData] = (0,
|
1866
|
-
const [isOpen, setOpen] = (0,
|
1867
|
-
const [isLoading, setIsLoading] = (0,
|
1932
|
+
const [data, setData] = (0, import_react15.useState)([]);
|
1933
|
+
const [isOpen, setOpen] = (0, import_react15.useState)(false);
|
1934
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
|
1868
1935
|
const hasFilterFields = !!filterFields;
|
1869
|
-
const [filters, setFilters] = (0,
|
1870
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
1871
|
-
const mappedData = (0,
|
1936
|
+
const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
|
1937
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
|
1938
|
+
const mappedData = (0, import_react15.useMemo)(() => {
|
1872
1939
|
return data.map(mapRow);
|
1873
1940
|
}, [data]);
|
1874
|
-
const keys = (0,
|
1941
|
+
const keys = (0, import_react15.useMemo)(() => {
|
1875
1942
|
const validKeys = /* @__PURE__ */ new Set();
|
1876
1943
|
for (const item of mappedData) {
|
1877
1944
|
for (const key of Object.keys(item)) {
|
1878
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
1945
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
|
1879
1946
|
validKeys.add(key);
|
1880
1947
|
}
|
1881
1948
|
}
|
1882
1949
|
}
|
1883
1950
|
return Array.from(validKeys);
|
1884
1951
|
}, [mappedData]);
|
1885
|
-
const [searchQuery, setSearchQuery] = (0,
|
1886
|
-
const search = (0,
|
1952
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
1953
|
+
const search = (0, import_react15.useCallback)(
|
1887
1954
|
(query, filters2) => __async(void 0, null, function* () {
|
1888
1955
|
setIsLoading(true);
|
1889
1956
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -1896,18 +1963,18 @@ var ExternalInput = ({
|
|
1896
1963
|
}),
|
1897
1964
|
[id, field]
|
1898
1965
|
);
|
1899
|
-
const Footer = (0,
|
1900
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
1966
|
+
const Footer = (0, import_react15.useCallback)(
|
1967
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
1901
1968
|
props.items.length,
|
1902
1969
|
" result",
|
1903
1970
|
props.items.length === 1 ? "" : "s"
|
1904
1971
|
] }),
|
1905
1972
|
[field.renderFooter]
|
1906
1973
|
);
|
1907
|
-
(0,
|
1974
|
+
(0, import_react15.useEffect)(() => {
|
1908
1975
|
search(searchQuery, filters);
|
1909
1976
|
}, []);
|
1910
|
-
return /* @__PURE__ */ (0,
|
1977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1911
1978
|
"div",
|
1912
1979
|
{
|
1913
1980
|
className: getClassName10({
|
@@ -1917,21 +1984,21 @@ var ExternalInput = ({
|
|
1917
1984
|
}),
|
1918
1985
|
id,
|
1919
1986
|
children: [
|
1920
|
-
/* @__PURE__ */ (0,
|
1921
|
-
/* @__PURE__ */ (0,
|
1987
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("actions"), children: [
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1922
1989
|
"button",
|
1923
1990
|
{
|
1924
1991
|
type: "button",
|
1925
1992
|
onClick: () => setOpen(true),
|
1926
1993
|
className: getClassName10("button"),
|
1927
1994
|
disabled: readOnly,
|
1928
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
1929
|
-
/* @__PURE__ */ (0,
|
1930
|
-
/* @__PURE__ */ (0,
|
1995
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
1996
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: "16" }),
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: field.placeholder })
|
1931
1998
|
] })
|
1932
1999
|
}
|
1933
2000
|
),
|
1934
|
-
value && /* @__PURE__ */ (0,
|
2001
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1935
2002
|
"button",
|
1936
2003
|
{
|
1937
2004
|
type: "button",
|
@@ -1940,11 +2007,11 @@ var ExternalInput = ({
|
|
1940
2007
|
onChange(null);
|
1941
2008
|
},
|
1942
2009
|
disabled: readOnly,
|
1943
|
-
children: /* @__PURE__ */ (0,
|
2010
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LockOpen, { size: 16 })
|
1944
2011
|
}
|
1945
2012
|
)
|
1946
2013
|
] }),
|
1947
|
-
/* @__PURE__ */ (0,
|
2014
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1948
2015
|
"form",
|
1949
2016
|
{
|
1950
2017
|
className: getClassNameModal({
|
@@ -1958,11 +2025,11 @@ var ExternalInput = ({
|
|
1958
2025
|
search(searchQuery, filters);
|
1959
2026
|
},
|
1960
2027
|
children: [
|
1961
|
-
/* @__PURE__ */ (0,
|
1962
|
-
/* @__PURE__ */ (0,
|
1963
|
-
/* @__PURE__ */ (0,
|
1964
|
-
/* @__PURE__ */ (0,
|
1965
|
-
/* @__PURE__ */ (0,
|
2028
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: getClassNameModal("search"), children: [
|
2030
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Search, { size: "18" }) }),
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1966
2033
|
"input",
|
1967
2034
|
{
|
1968
2035
|
className: getClassNameModal("searchInput"),
|
@@ -1977,9 +2044,9 @@ var ExternalInput = ({
|
|
1977
2044
|
}
|
1978
2045
|
)
|
1979
2046
|
] }),
|
1980
|
-
/* @__PURE__ */ (0,
|
1981
|
-
/* @__PURE__ */ (0,
|
1982
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2047
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
2048
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
2049
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1983
2050
|
IconButton,
|
1984
2051
|
{
|
1985
2052
|
title: "Toggle filters",
|
@@ -1988,15 +2055,15 @@ var ExternalInput = ({
|
|
1988
2055
|
e.stopPropagation();
|
1989
2056
|
setFiltersToggled(!filtersToggled);
|
1990
2057
|
},
|
1991
|
-
children: /* @__PURE__ */ (0,
|
2058
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SlidersHorizontal, { size: 20 })
|
1992
2059
|
}
|
1993
2060
|
) })
|
1994
2061
|
] })
|
1995
|
-
] }) : /* @__PURE__ */ (0,
|
1996
|
-
/* @__PURE__ */ (0,
|
1997
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2062
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
2063
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
2064
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
1998
2065
|
const filterField = filterFields[fieldName];
|
1999
|
-
return /* @__PURE__ */ (0,
|
2066
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2000
2067
|
AutoFieldPrivate,
|
2001
2068
|
{
|
2002
2069
|
field: filterField,
|
@@ -2013,9 +2080,9 @@ var ExternalInput = ({
|
|
2013
2080
|
fieldName
|
2014
2081
|
);
|
2015
2082
|
}) }),
|
2016
|
-
/* @__PURE__ */ (0,
|
2017
|
-
/* @__PURE__ */ (0,
|
2018
|
-
/* @__PURE__ */ (0,
|
2083
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
2084
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: getClassNameModal("table"), children: [
|
2085
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2019
2086
|
"th",
|
2020
2087
|
{
|
2021
2088
|
className: getClassNameModal("th"),
|
@@ -2024,8 +2091,8 @@ var ExternalInput = ({
|
|
2024
2091
|
},
|
2025
2092
|
key
|
2026
2093
|
)) }) }),
|
2027
|
-
/* @__PURE__ */ (0,
|
2028
|
-
return /* @__PURE__ */ (0,
|
2094
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
2095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2029
2096
|
"tr",
|
2030
2097
|
{
|
2031
2098
|
style: { whiteSpace: "nowrap" },
|
@@ -2034,16 +2101,16 @@ var ExternalInput = ({
|
|
2034
2101
|
onChange(mapProp(data[i]));
|
2035
2102
|
setOpen(false);
|
2036
2103
|
},
|
2037
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
2104
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
2038
2105
|
},
|
2039
2106
|
i
|
2040
2107
|
);
|
2041
2108
|
}) })
|
2042
2109
|
] }),
|
2043
|
-
/* @__PURE__ */ (0,
|
2110
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 24 }) })
|
2044
2111
|
] })
|
2045
2112
|
] }),
|
2046
|
-
/* @__PURE__ */ (0,
|
2113
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footer, { items: mappedData }) })
|
2047
2114
|
]
|
2048
2115
|
}
|
2049
2116
|
) })
|
@@ -2053,7 +2120,7 @@ var ExternalInput = ({
|
|
2053
2120
|
};
|
2054
2121
|
|
2055
2122
|
// components/AutoField/fields/ExternalField/index.tsx
|
2056
|
-
var
|
2123
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
2057
2124
|
var ExternalField = ({
|
2058
2125
|
field,
|
2059
2126
|
onChange,
|
@@ -2067,7 +2134,7 @@ var ExternalField = ({
|
|
2067
2134
|
var _a, _b, _c;
|
2068
2135
|
const validField = field;
|
2069
2136
|
const deprecatedField = field;
|
2070
|
-
(0,
|
2137
|
+
(0, import_react16.useEffect)(() => {
|
2071
2138
|
if (deprecatedField.adaptor) {
|
2072
2139
|
console.error(
|
2073
2140
|
"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."
|
@@ -2077,7 +2144,7 @@ var ExternalField = ({
|
|
2077
2144
|
if (field.type !== "external") {
|
2078
2145
|
return null;
|
2079
2146
|
}
|
2080
|
-
return /* @__PURE__ */ (0,
|
2147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
2081
2148
|
ExternalInput,
|
2082
2149
|
{
|
2083
2150
|
name,
|
@@ -2102,7 +2169,7 @@ var ExternalField = ({
|
|
2102
2169
|
|
2103
2170
|
// components/AutoField/fields/RadioField/index.tsx
|
2104
2171
|
init_react_import();
|
2105
|
-
var
|
2172
|
+
var import_react17 = require("react");
|
2106
2173
|
|
2107
2174
|
// lib/safe-json-parse.ts
|
2108
2175
|
init_react_import();
|
@@ -2116,7 +2183,7 @@ var safeJsonParse = (str) => {
|
|
2116
2183
|
};
|
2117
2184
|
|
2118
2185
|
// components/AutoField/fields/RadioField/index.tsx
|
2119
|
-
var
|
2186
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
2120
2187
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
2121
2188
|
var RadioField = ({
|
2122
2189
|
field,
|
@@ -2128,26 +2195,26 @@ var RadioField = ({
|
|
2128
2195
|
label,
|
2129
2196
|
Label: Label2
|
2130
2197
|
}) => {
|
2131
|
-
const flatOptions = (0,
|
2198
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2132
2199
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2133
2200
|
[field]
|
2134
2201
|
);
|
2135
2202
|
if (field.type !== "radio" || !field.options) {
|
2136
2203
|
return null;
|
2137
2204
|
}
|
2138
|
-
return /* @__PURE__ */ (0,
|
2205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2139
2206
|
Label2,
|
2140
2207
|
{
|
2141
|
-
icon: /* @__PURE__ */ (0,
|
2208
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CircleCheckBig, { size: 16 }),
|
2142
2209
|
label: label || name,
|
2143
2210
|
readOnly,
|
2144
2211
|
el: "div",
|
2145
|
-
children: /* @__PURE__ */ (0,
|
2212
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
2146
2213
|
"label",
|
2147
2214
|
{
|
2148
2215
|
className: getClassName11("radio"),
|
2149
2216
|
children: [
|
2150
|
-
/* @__PURE__ */ (0,
|
2217
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2151
2218
|
"input",
|
2152
2219
|
{
|
2153
2220
|
type: "radio",
|
@@ -2167,7 +2234,7 @@ var RadioField = ({
|
|
2167
2234
|
checked: value === option.value
|
2168
2235
|
}
|
2169
2236
|
),
|
2170
|
-
/* @__PURE__ */ (0,
|
2237
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
2171
2238
|
]
|
2172
2239
|
},
|
2173
2240
|
option.label + option.value
|
@@ -2178,8 +2245,8 @@ var RadioField = ({
|
|
2178
2245
|
|
2179
2246
|
// components/AutoField/fields/SelectField/index.tsx
|
2180
2247
|
init_react_import();
|
2181
|
-
var
|
2182
|
-
var
|
2248
|
+
var import_react18 = require("react");
|
2249
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2183
2250
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2184
2251
|
var SelectField = ({
|
2185
2252
|
field,
|
@@ -2191,20 +2258,20 @@ var SelectField = ({
|
|
2191
2258
|
readOnly,
|
2192
2259
|
id
|
2193
2260
|
}) => {
|
2194
|
-
const flatOptions = (0,
|
2261
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2195
2262
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2196
2263
|
[field]
|
2197
2264
|
);
|
2198
2265
|
if (field.type !== "select" || !field.options) {
|
2199
2266
|
return null;
|
2200
2267
|
}
|
2201
|
-
return /* @__PURE__ */ (0,
|
2268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2202
2269
|
Label2,
|
2203
2270
|
{
|
2204
2271
|
label: label || name,
|
2205
|
-
icon: /* @__PURE__ */ (0,
|
2272
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronDown, { size: 16 }),
|
2206
2273
|
readOnly,
|
2207
|
-
children: /* @__PURE__ */ (0,
|
2274
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2208
2275
|
"select",
|
2209
2276
|
{
|
2210
2277
|
id,
|
@@ -2221,7 +2288,7 @@ var SelectField = ({
|
|
2221
2288
|
}
|
2222
2289
|
},
|
2223
2290
|
value,
|
2224
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
2291
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2225
2292
|
"option",
|
2226
2293
|
{
|
2227
2294
|
label: option.label,
|
@@ -2237,7 +2304,7 @@ var SelectField = ({
|
|
2237
2304
|
|
2238
2305
|
// components/AutoField/fields/TextareaField/index.tsx
|
2239
2306
|
init_react_import();
|
2240
|
-
var
|
2307
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
2241
2308
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2242
2309
|
var TextareaField = ({
|
2243
2310
|
onChange,
|
@@ -2248,7 +2315,7 @@ var TextareaField = ({
|
|
2248
2315
|
Label: Label2,
|
2249
2316
|
id
|
2250
2317
|
}) => {
|
2251
|
-
return /* @__PURE__ */ (0,
|
2318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
2252
2319
|
"textarea",
|
2253
2320
|
{
|
2254
2321
|
id,
|
@@ -2275,7 +2342,7 @@ init_react_import();
|
|
2275
2342
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2276
2343
|
|
2277
2344
|
// components/AutoField/fields/ObjectField/index.tsx
|
2278
|
-
var
|
2345
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
2279
2346
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2280
2347
|
var ObjectField = ({
|
2281
2348
|
field,
|
@@ -2287,43 +2354,54 @@ var ObjectField = ({
|
|
2287
2354
|
readOnly,
|
2288
2355
|
id
|
2289
2356
|
}) => {
|
2290
|
-
const {
|
2357
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2291
2358
|
if (field.type !== "object" || !field.objectFields) {
|
2292
2359
|
return null;
|
2293
2360
|
}
|
2294
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2295
2361
|
const data = value || {};
|
2296
|
-
return /* @__PURE__ */ (0,
|
2362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2297
2363
|
Label2,
|
2298
2364
|
{
|
2299
2365
|
label: label || name,
|
2300
|
-
icon: /* @__PURE__ */ (0,
|
2366
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EllipsisVertical, { size: 16 }),
|
2301
2367
|
el: "div",
|
2302
2368
|
readOnly,
|
2303
|
-
children: /* @__PURE__ */ (0,
|
2304
|
-
const subField = field.objectFields[
|
2305
|
-
const
|
2306
|
-
const
|
2307
|
-
const subReadOnly = readOnly ? readOnly :
|
2308
|
-
|
2309
|
-
|
2369
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
2370
|
+
const subField = field.objectFields[subName];
|
2371
|
+
const subPath = `${name}.${subName}`;
|
2372
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2373
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2374
|
+
const label2 = subField.label || subName;
|
2375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2376
|
+
NestedFieldProvider,
|
2310
2377
|
{
|
2311
|
-
name:
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2378
|
+
name: localName || id,
|
2379
|
+
subName,
|
2380
|
+
readOnlyFields,
|
2381
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2382
|
+
AutoFieldPrivate,
|
2383
|
+
{
|
2384
|
+
name: subPath,
|
2385
|
+
label: subPath,
|
2386
|
+
id: `${id}_${subName}`,
|
2387
|
+
readOnly: subReadOnly,
|
2388
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2389
|
+
label: label2
|
2390
|
+
// May be used by custom fields
|
2321
2391
|
}),
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2392
|
+
value: data[subName],
|
2393
|
+
onChange: (val, ui) => {
|
2394
|
+
onChange(
|
2395
|
+
__spreadProps(__spreadValues({}, data), {
|
2396
|
+
[subName]: val
|
2397
|
+
}),
|
2398
|
+
ui
|
2399
|
+
);
|
2400
|
+
}
|
2401
|
+
}
|
2402
|
+
)
|
2325
2403
|
},
|
2326
|
-
|
2404
|
+
subPath
|
2327
2405
|
);
|
2328
2406
|
}) }) })
|
2329
2407
|
}
|
@@ -2332,7 +2410,7 @@ var ObjectField = ({
|
|
2332
2410
|
|
2333
2411
|
// lib/use-safe-id.ts
|
2334
2412
|
init_react_import();
|
2335
|
-
var
|
2413
|
+
var import_react19 = __toESM(require("react"));
|
2336
2414
|
|
2337
2415
|
// lib/generate-id.ts
|
2338
2416
|
init_react_import();
|
@@ -2341,15 +2419,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
2341
2419
|
|
2342
2420
|
// lib/use-safe-id.ts
|
2343
2421
|
var useSafeId = () => {
|
2344
|
-
if (typeof
|
2345
|
-
return
|
2422
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
2423
|
+
return import_react19.default.useId();
|
2346
2424
|
}
|
2347
|
-
const [id] = (0,
|
2425
|
+
const [id] = (0, import_react19.useState)(generateId());
|
2348
2426
|
return id;
|
2349
2427
|
};
|
2350
2428
|
|
2351
2429
|
// components/AutoField/index.tsx
|
2352
|
-
var
|
2430
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
2353
2431
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2354
2432
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2355
2433
|
var FieldLabel = ({
|
@@ -2361,16 +2439,16 @@ var FieldLabel = ({
|
|
2361
2439
|
className
|
2362
2440
|
}) => {
|
2363
2441
|
const El = el;
|
2364
|
-
return /* @__PURE__ */ (0,
|
2365
|
-
/* @__PURE__ */ (0,
|
2366
|
-
icon ? /* @__PURE__ */ (0,
|
2442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(El, { className, children: [
|
2443
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName15("label"), children: [
|
2444
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {}),
|
2367
2445
|
label,
|
2368
|
-
readOnly && /* @__PURE__ */ (0,
|
2446
|
+
readOnly && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Lock, { size: "12" }) })
|
2369
2447
|
] }),
|
2370
2448
|
children
|
2371
2449
|
] });
|
2372
2450
|
};
|
2373
|
-
var
|
2451
|
+
var FieldLabelInternal = ({
|
2374
2452
|
children,
|
2375
2453
|
icon,
|
2376
2454
|
label,
|
@@ -2378,14 +2456,14 @@ var FieldLabelInternal2 = ({
|
|
2378
2456
|
readOnly
|
2379
2457
|
}) => {
|
2380
2458
|
const { overrides } = useAppContext();
|
2381
|
-
const Wrapper = (0,
|
2459
|
+
const Wrapper = (0, import_react20.useMemo)(
|
2382
2460
|
() => overrides.fieldLabel || FieldLabel,
|
2383
2461
|
[overrides]
|
2384
2462
|
);
|
2385
2463
|
if (!label) {
|
2386
|
-
return /* @__PURE__ */ (0,
|
2464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
2387
2465
|
}
|
2388
|
-
return /* @__PURE__ */ (0,
|
2466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2389
2467
|
Wrapper,
|
2390
2468
|
{
|
2391
2469
|
label,
|
@@ -2399,8 +2477,9 @@ var FieldLabelInternal2 = ({
|
|
2399
2477
|
};
|
2400
2478
|
function AutoFieldInternal(props) {
|
2401
2479
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2402
|
-
const { dispatch, overrides } = useAppContext();
|
2403
|
-
const
|
2480
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2481
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
2482
|
+
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2404
2483
|
const field = props.field;
|
2405
2484
|
const label = field.label;
|
2406
2485
|
const defaultId = useSafeId();
|
@@ -2431,7 +2510,7 @@ function AutoFieldInternal(props) {
|
|
2431
2510
|
Label: Label2,
|
2432
2511
|
id: resolvedId
|
2433
2512
|
});
|
2434
|
-
const onFocus = (0,
|
2513
|
+
const onFocus = (0, import_react20.useCallback)(
|
2435
2514
|
(e) => {
|
2436
2515
|
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
2437
2516
|
e.stopPropagation();
|
@@ -2445,7 +2524,7 @@ function AutoFieldInternal(props) {
|
|
2445
2524
|
},
|
2446
2525
|
[mergedProps.name]
|
2447
2526
|
);
|
2448
|
-
const onBlur = (0,
|
2527
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
2449
2528
|
if ("name" in e.target) {
|
2450
2529
|
dispatch({
|
2451
2530
|
type: "setUi",
|
@@ -2460,27 +2539,36 @@ function AutoFieldInternal(props) {
|
|
2460
2539
|
return null;
|
2461
2540
|
}
|
2462
2541
|
const CustomField = field.render;
|
2463
|
-
return /* @__PURE__ */ (0,
|
2542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
|
2464
2543
|
}
|
2465
2544
|
const children = defaultFields[field.type](mergedProps);
|
2466
2545
|
const Render2 = render[field.type];
|
2467
|
-
return /* @__PURE__ */ (0,
|
2468
|
-
|
2546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2547
|
+
NestedFieldContext.Provider,
|
2469
2548
|
{
|
2470
|
-
|
2471
|
-
|
2472
|
-
|
2473
|
-
onClick: (e) => {
|
2474
|
-
e.stopPropagation();
|
2549
|
+
value: {
|
2550
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2551
|
+
localName: nestedFieldContext.localName
|
2475
2552
|
},
|
2476
|
-
children: /* @__PURE__ */ (0,
|
2553
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2554
|
+
"div",
|
2555
|
+
{
|
2556
|
+
className: getClassNameWrapper(),
|
2557
|
+
onFocus,
|
2558
|
+
onBlur,
|
2559
|
+
onClick: (e) => {
|
2560
|
+
e.stopPropagation();
|
2561
|
+
},
|
2562
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2563
|
+
}
|
2564
|
+
)
|
2477
2565
|
}
|
2478
2566
|
);
|
2479
2567
|
}
|
2480
2568
|
function AutoFieldPrivate(props) {
|
2481
2569
|
const { state } = useAppContext();
|
2482
2570
|
const { value, onChange } = props;
|
2483
|
-
const [localValue, setLocalValue] = (0,
|
2571
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
2484
2572
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
2485
2573
|
(val, ui) => {
|
2486
2574
|
onChange(val, ui);
|
@@ -2488,11 +2576,11 @@ function AutoFieldPrivate(props) {
|
|
2488
2576
|
50,
|
2489
2577
|
{ leading: true }
|
2490
2578
|
);
|
2491
|
-
const onChangeLocal = (0,
|
2579
|
+
const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
|
2492
2580
|
setLocalValue(val);
|
2493
2581
|
onChangeDb(val, ui);
|
2494
2582
|
}, []);
|
2495
|
-
(0,
|
2583
|
+
(0, import_react20.useEffect)(() => {
|
2496
2584
|
if (state.ui.field.focus !== props.name) {
|
2497
2585
|
setLocalValue(value);
|
2498
2586
|
}
|
@@ -2501,11 +2589,11 @@ function AutoFieldPrivate(props) {
|
|
2501
2589
|
value: localValue,
|
2502
2590
|
onChange: onChangeLocal
|
2503
2591
|
};
|
2504
|
-
return /* @__PURE__ */ (0,
|
2592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2505
2593
|
}
|
2506
2594
|
function AutoField(props) {
|
2507
|
-
const DefaultLabel = (0,
|
2508
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
2595
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
2596
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2509
2597
|
"div",
|
2510
2598
|
__spreadProps(__spreadValues({}, labelProps), {
|
2511
2599
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2513,7 +2601,7 @@ function AutoField(props) {
|
|
2513
2601
|
);
|
2514
2602
|
return DefaultLabel2;
|
2515
2603
|
}, [props.readOnly]);
|
2516
|
-
return /* @__PURE__ */ (0,
|
2604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2517
2605
|
}
|
2518
2606
|
|
2519
2607
|
// components/Drawer/index.tsx
|
@@ -2524,21 +2612,21 @@ init_react_import();
|
|
2524
2612
|
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" };
|
2525
2613
|
|
2526
2614
|
// components/Drawer/index.tsx
|
2527
|
-
var
|
2615
|
+
var import_react32 = require("react");
|
2528
2616
|
|
2529
2617
|
// components/DragDropContext/index.tsx
|
2530
2618
|
init_react_import();
|
2531
|
-
var
|
2532
|
-
var
|
2619
|
+
var import_react30 = require("@dnd-kit/react");
|
2620
|
+
var import_react31 = require("react");
|
2533
2621
|
var import_dom = require("@dnd-kit/dom");
|
2534
2622
|
|
2535
2623
|
// components/DropZone/index.tsx
|
2536
2624
|
init_react_import();
|
2537
|
-
var
|
2625
|
+
var import_react29 = require("react");
|
2538
2626
|
|
2539
2627
|
// components/DraggableComponent/index.tsx
|
2540
2628
|
init_react_import();
|
2541
|
-
var
|
2629
|
+
var import_react23 = require("react");
|
2542
2630
|
|
2543
2631
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2544
2632
|
init_react_import();
|
@@ -2547,15 +2635,15 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
|
|
2547
2635
|
// components/DraggableComponent/index.tsx
|
2548
2636
|
var import_react_dom2 = require("react-dom");
|
2549
2637
|
|
2550
|
-
//
|
2638
|
+
// lib/dnd/collision/dynamic/index.ts
|
2551
2639
|
init_react_import();
|
2552
2640
|
var import_abstract8 = require("@dnd-kit/abstract");
|
2553
2641
|
|
2554
|
-
//
|
2642
|
+
// lib/dnd/collision/directional/index.ts
|
2555
2643
|
init_react_import();
|
2556
2644
|
var import_abstract = require("@dnd-kit/abstract");
|
2557
2645
|
|
2558
|
-
//
|
2646
|
+
// lib/dnd/collision/collision-debug.ts
|
2559
2647
|
init_react_import();
|
2560
2648
|
var DEBUG = false;
|
2561
2649
|
var debugElements = {};
|
@@ -2604,7 +2692,7 @@ var collisionDebug = (a, b, id, color, label) => {
|
|
2604
2692
|
});
|
2605
2693
|
};
|
2606
2694
|
|
2607
|
-
//
|
2695
|
+
// lib/dnd/collision/directional/index.ts
|
2608
2696
|
var distanceChange = "increasing";
|
2609
2697
|
var directionalCollision = (input, previous) => {
|
2610
2698
|
var _a;
|
@@ -2637,7 +2725,7 @@ var directionalCollision = (input, previous) => {
|
|
2637
2725
|
return null;
|
2638
2726
|
};
|
2639
2727
|
|
2640
|
-
//
|
2728
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
2641
2729
|
init_react_import();
|
2642
2730
|
var getDirection = (dragAxis, delta) => {
|
2643
2731
|
if (dragAxis === "dynamic") {
|
@@ -2652,7 +2740,7 @@ var getDirection = (dragAxis, delta) => {
|
|
2652
2740
|
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2653
2741
|
};
|
2654
2742
|
|
2655
|
-
//
|
2743
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
2656
2744
|
init_react_import();
|
2657
2745
|
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2658
2746
|
const dragRect = dragShape.boundingRectangle;
|
@@ -2671,7 +2759,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2671
2759
|
return dragRect.right - offset >= dropCenter.x;
|
2672
2760
|
};
|
2673
2761
|
|
2674
|
-
//
|
2762
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2675
2763
|
init_react_import();
|
2676
2764
|
var import_geometry = require("@dnd-kit/geometry");
|
2677
2765
|
var INTERVAL_SENSITIVITY = 10;
|
@@ -2775,7 +2863,14 @@ var closestCorners = (input) => {
|
|
2775
2863
|
};
|
2776
2864
|
};
|
2777
2865
|
|
2778
|
-
//
|
2866
|
+
// lib/dnd/collision/dynamic/store.ts
|
2867
|
+
init_react_import();
|
2868
|
+
var import_vanilla = require("zustand/vanilla");
|
2869
|
+
var collisionStore = (0, import_vanilla.createStore)(() => ({
|
2870
|
+
fallbackEnabled: false
|
2871
|
+
}));
|
2872
|
+
|
2873
|
+
// lib/dnd/collision/dynamic/index.ts
|
2779
2874
|
var flushNext = "";
|
2780
2875
|
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2781
2876
|
var _a, _b, _c, _d, _e;
|
@@ -2787,6 +2882,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2787
2882
|
return null;
|
2788
2883
|
}
|
2789
2884
|
const { center: dragCenter } = dragShape;
|
2885
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2790
2886
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2791
2887
|
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2792
2888
|
direction: interval.direction
|
@@ -2832,7 +2928,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2832
2928
|
flushNext = "";
|
2833
2929
|
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2834
2930
|
}
|
2835
|
-
if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2931
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2836
2932
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2837
2933
|
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2838
2934
|
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
@@ -2893,8 +2989,102 @@ function getDeepScrollPosition(element) {
|
|
2893
2989
|
return totalScroll;
|
2894
2990
|
}
|
2895
2991
|
|
2992
|
+
// components/DropZone/context.tsx
|
2993
|
+
init_react_import();
|
2994
|
+
var import_react21 = require("react");
|
2995
|
+
var import_zustand = require("zustand");
|
2996
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2997
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2998
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
2999
|
+
(0, import_zustand.createStore)(() => ({
|
3000
|
+
zoneDepthIndex: {},
|
3001
|
+
nextZoneDepthIndex: {},
|
3002
|
+
areaDepthIndex: {},
|
3003
|
+
nextAreaDepthIndex: {},
|
3004
|
+
draggedItem: null,
|
3005
|
+
previewIndex: {}
|
3006
|
+
}))
|
3007
|
+
);
|
3008
|
+
var ZoneStoreProvider = ({
|
3009
|
+
children,
|
3010
|
+
store
|
3011
|
+
}) => {
|
3012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
3013
|
+
};
|
3014
|
+
var DropZoneProvider = ({
|
3015
|
+
children,
|
3016
|
+
value
|
3017
|
+
}) => {
|
3018
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3019
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3020
|
+
{}
|
3021
|
+
);
|
3022
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3023
|
+
const { dispatch } = useAppContext();
|
3024
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
3025
|
+
(area) => {
|
3026
|
+
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3027
|
+
},
|
3028
|
+
[setAreasWithZones]
|
3029
|
+
);
|
3030
|
+
const registerZone = (0, import_react21.useCallback)(
|
3031
|
+
(zoneCompound) => {
|
3032
|
+
if (!dispatch) {
|
3033
|
+
return;
|
3034
|
+
}
|
3035
|
+
dispatch({
|
3036
|
+
type: "registerZone",
|
3037
|
+
zone: zoneCompound
|
3038
|
+
});
|
3039
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
3040
|
+
},
|
3041
|
+
[setActiveZones, dispatch]
|
3042
|
+
);
|
3043
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
3044
|
+
(zoneCompound) => {
|
3045
|
+
if (!dispatch) {
|
3046
|
+
return;
|
3047
|
+
}
|
3048
|
+
dispatch({
|
3049
|
+
type: "unregisterZone",
|
3050
|
+
zone: zoneCompound
|
3051
|
+
});
|
3052
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
3053
|
+
[zoneCompound]: false
|
3054
|
+
}));
|
3055
|
+
},
|
3056
|
+
[setActiveZones, dispatch]
|
3057
|
+
);
|
3058
|
+
const memoValue = (0, import_react21.useMemo)(
|
3059
|
+
() => __spreadValues({
|
3060
|
+
hoveringComponent,
|
3061
|
+
setHoveringComponent,
|
3062
|
+
registerZoneArea,
|
3063
|
+
areasWithZones,
|
3064
|
+
registerZone,
|
3065
|
+
unregisterZone,
|
3066
|
+
activeZones
|
3067
|
+
}, value),
|
3068
|
+
[value, hoveringComponent, areasWithZones, activeZones]
|
3069
|
+
);
|
3070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
3071
|
+
};
|
3072
|
+
|
3073
|
+
// lib/use-context-store.ts
|
3074
|
+
init_react_import();
|
3075
|
+
var import_react22 = require("react");
|
3076
|
+
var import_zustand2 = require("zustand");
|
3077
|
+
var import_shallow = require("zustand/react/shallow");
|
3078
|
+
function useContextStore(context, selector) {
|
3079
|
+
const store = (0, import_react22.useContext)(context);
|
3080
|
+
if (!store) {
|
3081
|
+
throw new Error("useContextStore must be used inside context");
|
3082
|
+
}
|
3083
|
+
return (0, import_zustand2.useStore)(store, (0, import_shallow.useShallow)(selector));
|
3084
|
+
}
|
3085
|
+
|
2896
3086
|
// components/DraggableComponent/index.tsx
|
2897
|
-
var
|
3087
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
2898
3088
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2899
3089
|
var DEBUG2 = false;
|
2900
3090
|
var space = 8;
|
@@ -2905,12 +3095,12 @@ var DefaultActionBar = ({
|
|
2905
3095
|
label,
|
2906
3096
|
children,
|
2907
3097
|
parentAction
|
2908
|
-
}) => /* @__PURE__ */ (0,
|
2909
|
-
/* @__PURE__ */ (0,
|
3098
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar, { children: [
|
3099
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar.Group, { children: [
|
2910
3100
|
parentAction,
|
2911
|
-
label && /* @__PURE__ */ (0,
|
3101
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Label, { label })
|
2912
3102
|
] }),
|
2913
|
-
/* @__PURE__ */ (0,
|
3103
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Group, { children })
|
2914
3104
|
] });
|
2915
3105
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
2916
3106
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -2945,9 +3135,9 @@ var DraggableComponent = ({
|
|
2945
3135
|
iframe,
|
2946
3136
|
state
|
2947
3137
|
} = useAppContext();
|
2948
|
-
const ctx = (0,
|
2949
|
-
const [localZones, setLocalZones] = (0,
|
2950
|
-
const registerLocalZone = (0,
|
3138
|
+
const ctx = (0, import_react23.useContext)(dropZoneContext);
|
3139
|
+
const [localZones, setLocalZones] = (0, import_react23.useState)({});
|
3140
|
+
const registerLocalZone = (0, import_react23.useCallback)(
|
2951
3141
|
(zoneCompound2, active) => {
|
2952
3142
|
var _a;
|
2953
3143
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -2957,7 +3147,7 @@ var DraggableComponent = ({
|
|
2957
3147
|
},
|
2958
3148
|
[setLocalZones]
|
2959
3149
|
);
|
2960
|
-
const unregisterLocalZone = (0,
|
3150
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
2961
3151
|
(zoneCompound2) => {
|
2962
3152
|
var _a;
|
2963
3153
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -2971,8 +3161,8 @@ var DraggableComponent = ({
|
|
2971
3161
|
);
|
2972
3162
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
2973
3163
|
const { path = [] } = ctx || {};
|
2974
|
-
const [canDrag, setCanDrag] = (0,
|
2975
|
-
(0,
|
3164
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3165
|
+
(0, import_react23.useEffect)(() => {
|
2976
3166
|
var _a;
|
2977
3167
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
2978
3168
|
if (item) {
|
@@ -2982,10 +3172,13 @@ var DraggableComponent = ({
|
|
2982
3172
|
setCanDrag((_a = perms.drag) != null ? _a : true);
|
2983
3173
|
}
|
2984
3174
|
}, [state, index, zoneCompound, getPermissions]);
|
2985
|
-
const userIsDragging =
|
3175
|
+
const userIsDragging = useContextStore(
|
3176
|
+
ZoneStoreContext,
|
3177
|
+
(s) => !!s.draggedItem
|
3178
|
+
);
|
2986
3179
|
const canCollide = canDrag || userIsDragging;
|
2987
3180
|
const disabled = !isEnabled || !canCollide;
|
2988
|
-
const [dragAxis, setDragAxis] = (0,
|
3181
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
2989
3182
|
const { ref: sortableRef, status } = useSortableSafe({
|
2990
3183
|
id,
|
2991
3184
|
index,
|
@@ -3011,8 +3204,8 @@ var DraggableComponent = ({
|
|
3011
3204
|
}
|
3012
3205
|
});
|
3013
3206
|
const thisIsDragging = status === "dragging";
|
3014
|
-
const ref = (0,
|
3015
|
-
const refSetter = (0,
|
3207
|
+
const ref = (0, import_react23.useRef)(null);
|
3208
|
+
const refSetter = (0, import_react23.useCallback)(
|
3016
3209
|
(el) => {
|
3017
3210
|
sortableRef(el);
|
3018
3211
|
if (el) {
|
@@ -3021,14 +3214,14 @@ var DraggableComponent = ({
|
|
3021
3214
|
},
|
3022
3215
|
[sortableRef]
|
3023
3216
|
);
|
3024
|
-
const [portalEl, setPortalEl] = (0,
|
3025
|
-
(0,
|
3217
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3218
|
+
(0, import_react23.useEffect)(() => {
|
3026
3219
|
var _a, _b, _c;
|
3027
3220
|
setPortalEl(
|
3028
3221
|
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
|
3029
3222
|
);
|
3030
3223
|
}, [iframe.enabled, ref.current]);
|
3031
|
-
const getStyle = (0,
|
3224
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3032
3225
|
var _a, _b, _c;
|
3033
3226
|
if (!ref.current) return;
|
3034
3227
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3048,11 +3241,11 @@ var DraggableComponent = ({
|
|
3048
3241
|
};
|
3049
3242
|
return style2;
|
3050
3243
|
}, [ref.current]);
|
3051
|
-
const [style, setStyle] = (0,
|
3052
|
-
const sync = (0,
|
3244
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3245
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3053
3246
|
setStyle(getStyle());
|
3054
3247
|
}, [ref.current, iframe]);
|
3055
|
-
(0,
|
3248
|
+
(0, import_react23.useEffect)(() => {
|
3056
3249
|
if (ref.current) {
|
3057
3250
|
const observer = new ResizeObserver(sync);
|
3058
3251
|
observer.observe(ref.current);
|
@@ -3061,20 +3254,22 @@ var DraggableComponent = ({
|
|
3061
3254
|
};
|
3062
3255
|
}
|
3063
3256
|
}, [ref.current]);
|
3064
|
-
(0,
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3257
|
+
(0, import_react23.useEffect)(() => {
|
3258
|
+
if (isSelected) {
|
3259
|
+
ctx == null ? void 0 : ctx.registerPath({
|
3260
|
+
index,
|
3261
|
+
zone: zoneCompound
|
3262
|
+
});
|
3263
|
+
}
|
3069
3264
|
}, [isSelected]);
|
3070
|
-
const CustomActionBar = (0,
|
3265
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3071
3266
|
() => overrides.actionBar || DefaultActionBar,
|
3072
3267
|
[overrides.actionBar]
|
3073
3268
|
);
|
3074
3269
|
const permissions = getPermissions({
|
3075
3270
|
item: selectedItem
|
3076
3271
|
});
|
3077
|
-
const onClick = (0,
|
3272
|
+
const onClick = (0, import_react23.useCallback)(
|
3078
3273
|
(e) => {
|
3079
3274
|
e.stopPropagation();
|
3080
3275
|
dispatch({
|
@@ -3086,7 +3281,7 @@ var DraggableComponent = ({
|
|
3086
3281
|
},
|
3087
3282
|
[index, zoneCompound, id]
|
3088
3283
|
);
|
3089
|
-
const onSelectParent = (0,
|
3284
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3090
3285
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3091
3286
|
return;
|
3092
3287
|
}
|
@@ -3104,23 +3299,23 @@ var DraggableComponent = ({
|
|
3104
3299
|
}
|
3105
3300
|
});
|
3106
3301
|
}, [ctx, path]);
|
3107
|
-
const onDuplicate = (0,
|
3302
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3108
3303
|
dispatch({
|
3109
3304
|
type: "duplicate",
|
3110
3305
|
sourceIndex: index,
|
3111
3306
|
sourceZone: zoneCompound
|
3112
3307
|
});
|
3113
3308
|
}, [index, zoneCompound]);
|
3114
|
-
const onDelete = (0,
|
3309
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3115
3310
|
dispatch({
|
3116
3311
|
type: "remove",
|
3117
3312
|
index,
|
3118
3313
|
zone: zoneCompound
|
3119
3314
|
});
|
3120
3315
|
}, [index, zoneCompound]);
|
3121
|
-
const [hover, setHover] = (0,
|
3316
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3122
3317
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3123
|
-
(0,
|
3318
|
+
(0, import_react23.useEffect)(() => {
|
3124
3319
|
if (!ref.current) {
|
3125
3320
|
return;
|
3126
3321
|
}
|
@@ -3170,7 +3365,7 @@ var DraggableComponent = ({
|
|
3170
3365
|
thisIsDragging,
|
3171
3366
|
inDroppableZone
|
3172
3367
|
]);
|
3173
|
-
(0,
|
3368
|
+
(0, import_react23.useEffect)(() => {
|
3174
3369
|
if (ref.current && disabled) {
|
3175
3370
|
ref.current.setAttribute("data-puck-disabled", "");
|
3176
3371
|
return () => {
|
@@ -3179,8 +3374,8 @@ var DraggableComponent = ({
|
|
3179
3374
|
};
|
3180
3375
|
}
|
3181
3376
|
}, [disabled, ref]);
|
3182
|
-
const [isVisible, setIsVisible] = (0,
|
3183
|
-
(0,
|
3377
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3378
|
+
(0, import_react23.useEffect)(() => {
|
3184
3379
|
sync();
|
3185
3380
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3186
3381
|
setIsVisible(true);
|
@@ -3188,7 +3383,7 @@ var DraggableComponent = ({
|
|
3188
3383
|
setIsVisible(false);
|
3189
3384
|
}
|
3190
3385
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3191
|
-
const syncActionsPosition = (0,
|
3386
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3192
3387
|
(el) => {
|
3193
3388
|
if (el) {
|
3194
3389
|
const view = el.ownerDocument.defaultView;
|
@@ -3205,7 +3400,7 @@ var DraggableComponent = ({
|
|
3205
3400
|
},
|
3206
3401
|
[zoomConfig]
|
3207
3402
|
);
|
3208
|
-
(0,
|
3403
|
+
(0, import_react23.useEffect)(() => {
|
3209
3404
|
if (userDragAxis) {
|
3210
3405
|
setDragAxis(userDragAxis);
|
3211
3406
|
return;
|
@@ -3219,8 +3414,8 @@ var DraggableComponent = ({
|
|
3219
3414
|
}
|
3220
3415
|
setDragAxis(autoDragAxis);
|
3221
3416
|
}, [ref, userDragAxis, autoDragAxis]);
|
3222
|
-
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0,
|
3223
|
-
return /* @__PURE__ */ (0,
|
3417
|
+
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CornerLeftUp, { size: 16 }) });
|
3418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3224
3419
|
DropZoneProvider,
|
3225
3420
|
{
|
3226
3421
|
value: __spreadProps(__spreadValues({}, ctx), {
|
@@ -3234,7 +3429,7 @@ var DraggableComponent = ({
|
|
3234
3429
|
}),
|
3235
3430
|
children: [
|
3236
3431
|
isVisible && (0, import_react_dom2.createPortal)(
|
3237
|
-
/* @__PURE__ */ (0,
|
3432
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3238
3433
|
"div",
|
3239
3434
|
{
|
3240
3435
|
className: getClassName16({
|
@@ -3246,15 +3441,15 @@ var DraggableComponent = ({
|
|
3246
3441
|
"data-puck-overlay": true,
|
3247
3442
|
children: [
|
3248
3443
|
debug,
|
3249
|
-
isLoading && /* @__PURE__ */ (0,
|
3250
|
-
/* @__PURE__ */ (0,
|
3444
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {}) }),
|
3445
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3251
3446
|
"div",
|
3252
3447
|
{
|
3253
3448
|
className: getClassName16("actionsOverlay"),
|
3254
3449
|
style: {
|
3255
3450
|
top: actionsOverlayTop / zoomConfig.zoom
|
3256
3451
|
},
|
3257
|
-
children: /* @__PURE__ */ (0,
|
3452
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3258
3453
|
"div",
|
3259
3454
|
{
|
3260
3455
|
className: getClassName16("actions"),
|
@@ -3266,14 +3461,14 @@ var DraggableComponent = ({
|
|
3266
3461
|
paddingRight: actionsSide
|
3267
3462
|
},
|
3268
3463
|
ref: syncActionsPosition,
|
3269
|
-
children: /* @__PURE__ */ (0,
|
3464
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3270
3465
|
CustomActionBar,
|
3271
3466
|
{
|
3272
3467
|
parentAction,
|
3273
3468
|
label: DEBUG2 ? id : label,
|
3274
3469
|
children: [
|
3275
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
3276
|
-
permissions.delete && /* @__PURE__ */ (0,
|
3470
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Copy, { size: 16 }) }),
|
3471
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Trash, { size: 16 }) })
|
3277
3472
|
]
|
3278
3473
|
}
|
3279
3474
|
)
|
@@ -3281,7 +3476,7 @@ var DraggableComponent = ({
|
|
3281
3476
|
)
|
3282
3477
|
}
|
3283
3478
|
),
|
3284
|
-
/* @__PURE__ */ (0,
|
3479
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("overlay") })
|
3285
3480
|
]
|
3286
3481
|
}
|
3287
3482
|
),
|
@@ -3297,93 +3492,26 @@ var DraggableComponent = ({
|
|
3297
3492
|
init_react_import();
|
3298
3493
|
var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isActive": "_DropZone--isActive_kmkdc_10", "DropZone--hasChildren": "_DropZone--hasChildren_kmkdc_14", "DropZone--userIsDragging": "_DropZone--userIsDragging_kmkdc_22", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_kmkdc_26", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_kmkdc_27", "DropZone--isRootZone": "_DropZone--isRootZone_kmkdc_27", "DropZone--isDestination": "_DropZone--isDestination_kmkdc_37", "DropZone-item": "_DropZone-item_kmkdc_49", "DropZone-hitbox": "_DropZone-hitbox_kmkdc_53", "DropZone--isEnabled": "_DropZone--isEnabled_kmkdc_61", "DropZone--isAnimating": "_DropZone--isAnimating_kmkdc_70" };
|
3299
3494
|
|
3300
|
-
// components/DropZone/
|
3495
|
+
// components/DropZone/lib/use-min-empty-height.ts
|
3301
3496
|
init_react_import();
|
3302
|
-
var
|
3303
|
-
var import_jsx_runtime20 = require("react/jsx-runtime");
|
3304
|
-
var dropZoneContext = (0, import_react21.createContext)(null);
|
3305
|
-
var DropZoneProvider = ({
|
3306
|
-
children,
|
3307
|
-
value
|
3308
|
-
}) => {
|
3309
|
-
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3310
|
-
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3311
|
-
{}
|
3312
|
-
);
|
3313
|
-
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3314
|
-
const { dispatch } = useAppContext();
|
3315
|
-
const registerZoneArea = (0, import_react21.useCallback)(
|
3316
|
-
(area) => {
|
3317
|
-
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3318
|
-
},
|
3319
|
-
[setAreasWithZones]
|
3320
|
-
);
|
3321
|
-
const registerZone = (0, import_react21.useCallback)(
|
3322
|
-
(zoneCompound) => {
|
3323
|
-
if (!dispatch) {
|
3324
|
-
return;
|
3325
|
-
}
|
3326
|
-
dispatch({
|
3327
|
-
type: "registerZone",
|
3328
|
-
zone: zoneCompound
|
3329
|
-
});
|
3330
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
3331
|
-
},
|
3332
|
-
[setActiveZones, dispatch]
|
3333
|
-
);
|
3334
|
-
const unregisterZone = (0, import_react21.useCallback)(
|
3335
|
-
(zoneCompound) => {
|
3336
|
-
if (!dispatch) {
|
3337
|
-
return;
|
3338
|
-
}
|
3339
|
-
dispatch({
|
3340
|
-
type: "unregisterZone",
|
3341
|
-
zone: zoneCompound
|
3342
|
-
});
|
3343
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
3344
|
-
[zoneCompound]: false
|
3345
|
-
}));
|
3346
|
-
},
|
3347
|
-
[setActiveZones, dispatch]
|
3348
|
-
);
|
3349
|
-
const memoValue = (0, import_react21.useMemo)(
|
3350
|
-
() => __spreadValues({
|
3351
|
-
hoveringComponent,
|
3352
|
-
setHoveringComponent,
|
3353
|
-
registerZoneArea,
|
3354
|
-
areasWithZones,
|
3355
|
-
registerZone,
|
3356
|
-
unregisterZone,
|
3357
|
-
activeZones
|
3358
|
-
}, value),
|
3359
|
-
[value, hoveringComponent, areasWithZones, activeZones]
|
3360
|
-
);
|
3361
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
3362
|
-
};
|
3363
|
-
|
3364
|
-
// lib/insert.ts
|
3365
|
-
init_react_import();
|
3366
|
-
var insert = (list, index, item) => {
|
3367
|
-
const result = Array.from(list);
|
3368
|
-
result.splice(index, 0, item);
|
3369
|
-
return result;
|
3370
|
-
};
|
3371
|
-
|
3372
|
-
// components/DropZone/use-min-empty-height.ts
|
3373
|
-
init_react_import();
|
3374
|
-
var import_react22 = require("react");
|
3497
|
+
var import_react24 = require("react");
|
3375
3498
|
var useMinEmptyHeight = ({
|
3376
|
-
draggedItem,
|
3377
3499
|
zoneCompound,
|
3378
3500
|
userMinEmptyHeight,
|
3379
3501
|
ref
|
3380
3502
|
}) => {
|
3381
|
-
const [prevHeight, setPrevHeight] = (0,
|
3382
|
-
const [isAnimating, setIsAnimating] = (0,
|
3383
|
-
(
|
3503
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3504
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3505
|
+
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3506
|
+
var _a, _b;
|
3507
|
+
return {
|
3508
|
+
draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
|
3509
|
+
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3510
|
+
};
|
3511
|
+
});
|
3512
|
+
(0, import_react24.useEffect)(() => {
|
3384
3513
|
if (draggedItem && ref.current) {
|
3385
|
-
|
3386
|
-
if (componentData.zone === zoneCompound) {
|
3514
|
+
if (isZone) {
|
3387
3515
|
const rect = ref.current.getBoundingClientRect();
|
3388
3516
|
setPrevHeight(rect.height);
|
3389
3517
|
setIsAnimating(true);
|
@@ -3413,14 +3541,129 @@ function assignRefs(refs, node) {
|
|
3413
3541
|
});
|
3414
3542
|
}
|
3415
3543
|
|
3416
|
-
// components/DropZone/
|
3417
|
-
|
3418
|
-
var
|
3419
|
-
|
3544
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3545
|
+
init_react_import();
|
3546
|
+
var import_react27 = require("react");
|
3547
|
+
|
3548
|
+
// lib/dnd/use-rendered-callback.ts
|
3549
|
+
init_react_import();
|
3550
|
+
var import_react25 = require("@dnd-kit/react");
|
3551
|
+
var import_react26 = require("react");
|
3552
|
+
function useRenderedCallback(callback, deps) {
|
3553
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3554
|
+
return (0, import_react26.useCallback)(
|
3555
|
+
(...args) => __async(this, null, function* () {
|
3556
|
+
yield manager == null ? void 0 : manager.renderer.rendering;
|
3557
|
+
return callback(...args);
|
3558
|
+
}),
|
3559
|
+
[...deps, manager]
|
3560
|
+
);
|
3561
|
+
}
|
3562
|
+
|
3563
|
+
// lib/insert.ts
|
3564
|
+
init_react_import();
|
3565
|
+
var insert = (list, index, item) => {
|
3566
|
+
const result = Array.from(list);
|
3567
|
+
result.splice(index, 0, item);
|
3568
|
+
return result;
|
3569
|
+
};
|
3570
|
+
|
3571
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3572
|
+
var useContentWithPreview = (content, zoneCompound) => {
|
3573
|
+
const { draggedItemId, preview, previewExists } = useContextStore(
|
3574
|
+
ZoneStoreContext,
|
3575
|
+
(s) => {
|
3576
|
+
var _a;
|
3577
|
+
return {
|
3578
|
+
draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
|
3579
|
+
preview: s.previewIndex[zoneCompound],
|
3580
|
+
previewExists: Object.keys(s.previewIndex || {}).length > 0
|
3581
|
+
};
|
3582
|
+
}
|
3583
|
+
);
|
3584
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3585
|
+
const updateContent = useRenderedCallback(
|
3586
|
+
(content2, preview2) => {
|
3587
|
+
if (preview2) {
|
3588
|
+
if (preview2.type === "insert") {
|
3589
|
+
setContentWithPreview(
|
3590
|
+
insert(
|
3591
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3592
|
+
preview2.index,
|
3593
|
+
{
|
3594
|
+
type: "preview",
|
3595
|
+
props: { id: preview2.props.id }
|
3596
|
+
}
|
3597
|
+
)
|
3598
|
+
);
|
3599
|
+
} else {
|
3600
|
+
setContentWithPreview(
|
3601
|
+
insert(
|
3602
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3603
|
+
preview2.index,
|
3604
|
+
{
|
3605
|
+
type: preview2.componentType,
|
3606
|
+
props: preview2.props
|
3607
|
+
}
|
3608
|
+
)
|
3609
|
+
);
|
3610
|
+
}
|
3611
|
+
} else {
|
3612
|
+
setContentWithPreview(
|
3613
|
+
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3614
|
+
);
|
3615
|
+
}
|
3616
|
+
},
|
3617
|
+
[draggedItemId, previewExists]
|
3618
|
+
);
|
3619
|
+
(0, import_react27.useEffect)(() => {
|
3620
|
+
updateContent(content, preview);
|
3621
|
+
}, [content, preview]);
|
3622
|
+
return contentWithPreview;
|
3623
|
+
};
|
3624
|
+
|
3625
|
+
// components/DropZone/lib/use-drag-axis.ts
|
3626
|
+
init_react_import();
|
3627
|
+
var import_react28 = require("react");
|
3420
3628
|
var GRID_DRAG_AXIS = "dynamic";
|
3421
3629
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3422
3630
|
var DEFAULT_DRAG_AXIS = "y";
|
3423
|
-
var
|
3631
|
+
var useDragAxis = (ref, collisionAxis) => {
|
3632
|
+
const { status } = useAppContext();
|
3633
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3634
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
3635
|
+
);
|
3636
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3637
|
+
if (ref.current) {
|
3638
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
3639
|
+
if (computedStyle.display === "grid") {
|
3640
|
+
setDragAxis(GRID_DRAG_AXIS);
|
3641
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3642
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3643
|
+
} else {
|
3644
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
3645
|
+
}
|
3646
|
+
}
|
3647
|
+
}, [ref.current]);
|
3648
|
+
(0, import_react28.useEffect)(() => {
|
3649
|
+
const onViewportChange = () => {
|
3650
|
+
calculateDragAxis();
|
3651
|
+
};
|
3652
|
+
window.addEventListener("viewportchange", onViewportChange);
|
3653
|
+
return () => {
|
3654
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
3655
|
+
};
|
3656
|
+
}, []);
|
3657
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
3658
|
+
return [dragAxis, calculateDragAxis];
|
3659
|
+
};
|
3660
|
+
|
3661
|
+
// components/DropZone/index.tsx
|
3662
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
3663
|
+
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3664
|
+
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3665
|
+
var RENDER_DEBUG = false;
|
3666
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
3424
3667
|
function DropZoneEdit2({
|
3425
3668
|
zone,
|
3426
3669
|
allow,
|
@@ -3431,31 +3674,50 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3431
3674
|
collisionAxis
|
3432
3675
|
}, userRef) {
|
3433
3676
|
const appContext2 = useAppContext();
|
3434
|
-
const ctx = (0,
|
3677
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3435
3678
|
const {
|
3436
3679
|
// These all need setting via context
|
3437
3680
|
data,
|
3438
3681
|
config,
|
3439
3682
|
areaId,
|
3440
|
-
draggedItem,
|
3441
3683
|
registerZoneArea,
|
3442
3684
|
depth,
|
3443
3685
|
registerLocalZone,
|
3444
3686
|
unregisterLocalZone,
|
3445
|
-
deepestZone = rootDroppableId,
|
3446
|
-
deepestArea,
|
3447
|
-
nextDeepestArea,
|
3448
3687
|
path = [],
|
3449
3688
|
activeZones
|
3450
3689
|
} = ctx;
|
3451
|
-
const { itemSelector } = appContext2.state.ui;
|
3452
3690
|
let zoneCompound = rootDroppableId;
|
3453
|
-
|
3691
|
+
if (areaId) {
|
3692
|
+
if (zone !== rootDroppableId) {
|
3693
|
+
zoneCompound = `${areaId}:${zone}`;
|
3694
|
+
}
|
3695
|
+
}
|
3696
|
+
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
3697
|
+
const {
|
3698
|
+
isDeepestZone,
|
3699
|
+
inNextDeepestArea,
|
3700
|
+
draggedComponentType,
|
3701
|
+
userIsDragging,
|
3702
|
+
preview
|
3703
|
+
} = useContextStore(ZoneStoreContext, (s) => {
|
3704
|
+
var _a, _b, _c;
|
3705
|
+
return {
|
3706
|
+
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
3707
|
+
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3708
|
+
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3709
|
+
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3710
|
+
userIsDragging: !!s.draggedItem,
|
3711
|
+
preview: s.previewIndex[zoneCompound]
|
3712
|
+
};
|
3713
|
+
});
|
3714
|
+
const { itemSelector } = appContext2.state.ui;
|
3715
|
+
(0, import_react29.useEffect)(() => {
|
3454
3716
|
if (areaId && registerZoneArea) {
|
3455
3717
|
registerZoneArea(areaId);
|
3456
3718
|
}
|
3457
3719
|
}, [areaId]);
|
3458
|
-
(0,
|
3720
|
+
(0, import_react29.useEffect)(() => {
|
3459
3721
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3460
3722
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3461
3723
|
}
|
@@ -3465,25 +3727,18 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3465
3727
|
}
|
3466
3728
|
};
|
3467
3729
|
}, []);
|
3468
|
-
|
3469
|
-
if (zone !== rootDroppableId) {
|
3470
|
-
zoneCompound = `${areaId}:${zone}`;
|
3471
|
-
}
|
3472
|
-
}
|
3473
|
-
const content = (0, import_react23.useMemo)(() => {
|
3730
|
+
const content = (0, import_react29.useMemo)(() => {
|
3474
3731
|
if (areaId && zone !== rootDroppableId) {
|
3475
3732
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3476
3733
|
}
|
3477
3734
|
return data.content || [];
|
3478
3735
|
}, [data, zoneCompound]);
|
3479
|
-
const ref = (0,
|
3480
|
-
const acceptsTarget = (0,
|
3481
|
-
(
|
3482
|
-
if (!
|
3736
|
+
const ref = (0, import_react29.useRef)(null);
|
3737
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
3738
|
+
(componentType) => {
|
3739
|
+
if (!componentType) {
|
3483
3740
|
return true;
|
3484
3741
|
}
|
3485
|
-
const data2 = target.data;
|
3486
|
-
const { componentType } = data2;
|
3487
3742
|
if (disallow) {
|
3488
3743
|
const defaultedAllow = allow || [];
|
3489
3744
|
const filteredDisallow = (disallow || []).filter(
|
@@ -3501,49 +3756,26 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3501
3756
|
},
|
3502
3757
|
[allow, disallow]
|
3503
3758
|
);
|
3504
|
-
(0,
|
3759
|
+
(0, import_react29.useEffect)(() => {
|
3505
3760
|
if (registerLocalZone) {
|
3506
|
-
registerLocalZone(zoneCompound, acceptsTarget(
|
3761
|
+
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3507
3762
|
}
|
3508
3763
|
return () => {
|
3509
3764
|
if (unregisterLocalZone) {
|
3510
3765
|
unregisterLocalZone(zoneCompound);
|
3511
3766
|
}
|
3512
3767
|
};
|
3513
|
-
}, [
|
3514
|
-
const
|
3515
|
-
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3516
|
-
const userIsDragging = !!draggedItem;
|
3768
|
+
}, [draggedComponentType, zoneCompound]);
|
3769
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
3517
3770
|
let isEnabled = true;
|
3518
|
-
if (
|
3519
|
-
isEnabled =
|
3771
|
+
if (userIsDragging) {
|
3772
|
+
isEnabled = isDeepestZone;
|
3520
3773
|
}
|
3521
3774
|
if (isEnabled) {
|
3522
|
-
isEnabled = acceptsTarget(
|
3523
|
-
}
|
3524
|
-
const
|
3525
|
-
const
|
3526
|
-
const contentWithPreview = (0, import_react23.useMemo)(() => {
|
3527
|
-
let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
|
3528
|
-
if (previewInZone) {
|
3529
|
-
contentWithPreview2 = content.filter(
|
3530
|
-
(item) => item.props.id !== preview.props.id
|
3531
|
-
);
|
3532
|
-
if (preview.type === "insert") {
|
3533
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3534
|
-
type: "preview",
|
3535
|
-
props: { id: preview.props.id }
|
3536
|
-
});
|
3537
|
-
} else {
|
3538
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3539
|
-
type: preview.componentType,
|
3540
|
-
props: preview.props
|
3541
|
-
});
|
3542
|
-
}
|
3543
|
-
}
|
3544
|
-
return contentWithPreview2;
|
3545
|
-
}, [preview, content]);
|
3546
|
-
const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3775
|
+
isEnabled = acceptsTarget(draggedComponentType);
|
3776
|
+
}
|
3777
|
+
const contentWithPreview = useContentWithPreview(content, zoneCompound);
|
3778
|
+
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3547
3779
|
const droppableConfig = {
|
3548
3780
|
id: zoneCompound,
|
3549
3781
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -3553,45 +3785,20 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3553
3785
|
data: {
|
3554
3786
|
areaId,
|
3555
3787
|
depth,
|
3556
|
-
isDroppableTarget: acceptsTarget(
|
3788
|
+
isDroppableTarget: acceptsTarget(draggedComponentType),
|
3557
3789
|
path
|
3558
3790
|
}
|
3559
3791
|
};
|
3560
3792
|
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
3561
3793
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3562
3794
|
const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
|
3563
|
-
const [dragAxis
|
3564
|
-
collisionAxis || DEFAULT_DRAG_AXIS
|
3565
|
-
);
|
3566
|
-
const calculateDragAxis = (0, import_react23.useCallback)(() => {
|
3567
|
-
if (ref.current) {
|
3568
|
-
const computedStyle = window.getComputedStyle(ref.current);
|
3569
|
-
if (computedStyle.display === "grid") {
|
3570
|
-
setDragAxis(GRID_DRAG_AXIS);
|
3571
|
-
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3572
|
-
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3573
|
-
} else {
|
3574
|
-
setDragAxis(DEFAULT_DRAG_AXIS);
|
3575
|
-
}
|
3576
|
-
}
|
3577
|
-
}, [ref.current]);
|
3578
|
-
(0, import_react23.useEffect)(calculateDragAxis, [appContext2.status, collisionAxis]);
|
3579
|
-
(0, import_react23.useEffect)(() => {
|
3580
|
-
const onViewportChange = () => {
|
3581
|
-
calculateDragAxis();
|
3582
|
-
};
|
3583
|
-
window.addEventListener("viewportchange", onViewportChange);
|
3584
|
-
return () => {
|
3585
|
-
window.removeEventListener("viewportchange", onViewportChange);
|
3586
|
-
};
|
3587
|
-
}, []);
|
3795
|
+
const [dragAxis] = useDragAxis(ref, collisionAxis);
|
3588
3796
|
const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
|
3589
|
-
draggedItem,
|
3590
3797
|
zoneCompound,
|
3591
3798
|
userMinEmptyHeight,
|
3592
3799
|
ref
|
3593
3800
|
});
|
3594
|
-
return /* @__PURE__ */ (0,
|
3801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3595
3802
|
"div",
|
3596
3803
|
{
|
3597
3804
|
className: `${getClassName17({
|
@@ -3611,88 +3818,83 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3611
3818
|
"data-puck-dropzone": zoneCompound,
|
3612
3819
|
"data-puck-dnd": zoneCompound,
|
3613
3820
|
style: __spreadProps(__spreadValues({}, style), {
|
3614
|
-
"--min-empty-height": `${minEmptyHeight}px
|
3821
|
+
"--min-empty-height": `${minEmptyHeight}px`,
|
3822
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3615
3823
|
}),
|
3616
|
-
children:
|
3617
|
-
|
3618
|
-
|
3619
|
-
|
3620
|
-
|
3621
|
-
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3824
|
+
children: contentWithPreview.map((item, i) => {
|
3825
|
+
var _a, _b, _c, _d, _e;
|
3826
|
+
const componentId = item.props.id;
|
3827
|
+
const puckProps = {
|
3828
|
+
renderDropZone: DropZone,
|
3829
|
+
isEditing: true,
|
3830
|
+
dragRef: null
|
3831
|
+
};
|
3832
|
+
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
|
3833
|
+
puck: puckProps,
|
3834
|
+
editMode: true
|
3835
|
+
// DEPRECATED
|
3836
|
+
});
|
3837
|
+
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3838
|
+
let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
3839
|
+
"No configuration for ",
|
3840
|
+
item.type
|
3841
|
+
] });
|
3842
|
+
const componentConfig = config.components[item.type];
|
3843
|
+
let componentType = item.type;
|
3844
|
+
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3845
|
+
if (item.type === "preview" && preview) {
|
3846
|
+
let Preview4 = function() {
|
3847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3628
3848
|
};
|
3629
|
-
|
3630
|
-
|
3631
|
-
|
3632
|
-
|
3633
|
-
|
3634
|
-
|
3635
|
-
|
3636
|
-
|
3637
|
-
|
3638
|
-
|
3639
|
-
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3655
|
-
|
3656
|
-
|
3657
|
-
|
3658
|
-
id: componentId,
|
3659
|
-
componentType,
|
3660
|
-
zoneCompound,
|
3661
|
-
depth: depth + 1,
|
3662
|
-
index: i,
|
3663
|
-
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3664
|
-
isSelected,
|
3665
|
-
label,
|
3666
|
-
isEnabled,
|
3667
|
-
autoDragAxis: dragAxis,
|
3668
|
-
userDragAxis: collisionAxis,
|
3669
|
-
inDroppableZone: acceptsTarget(draggedItem),
|
3670
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3671
|
-
Render2,
|
3672
|
-
__spreadProps(__spreadValues({}, defaultedProps), {
|
3673
|
-
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3674
|
-
dragRef
|
3675
|
-
})
|
3849
|
+
var Preview3 = Preview4;
|
3850
|
+
componentType = preview.componentType;
|
3851
|
+
label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
|
3852
|
+
Render2 = Preview4;
|
3853
|
+
}
|
3854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3855
|
+
DropZoneProvider,
|
3856
|
+
{
|
3857
|
+
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3858
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3859
|
+
DraggableComponent,
|
3860
|
+
{
|
3861
|
+
id: componentId,
|
3862
|
+
componentType,
|
3863
|
+
zoneCompound,
|
3864
|
+
depth: depth + 1,
|
3865
|
+
index: i,
|
3866
|
+
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3867
|
+
isSelected,
|
3868
|
+
label,
|
3869
|
+
isEnabled,
|
3870
|
+
autoDragAxis: dragAxis,
|
3871
|
+
userDragAxis: collisionAxis,
|
3872
|
+
inDroppableZone: acceptsTarget(draggedComponentType),
|
3873
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3874
|
+
Render2,
|
3875
|
+
__spreadProps(__spreadValues({}, defaultedProps), {
|
3876
|
+
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3877
|
+
dragRef
|
3676
3878
|
})
|
3677
|
-
|
3678
|
-
}
|
3679
|
-
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
|
3684
|
-
|
3879
|
+
})
|
3880
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3881
|
+
}
|
3882
|
+
)
|
3883
|
+
},
|
3884
|
+
componentId
|
3885
|
+
);
|
3886
|
+
})
|
3685
3887
|
}
|
3686
3888
|
);
|
3687
3889
|
}
|
3688
3890
|
);
|
3689
|
-
var DropZoneRender = (0,
|
3891
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
3690
3892
|
function DropZoneRender2({ className, style, zone }, ref) {
|
3691
|
-
const ctx = (0,
|
3893
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3692
3894
|
const { data, areaId = "root", config } = ctx || {};
|
3693
3895
|
let zoneCompound = rootDroppableId;
|
3694
3896
|
let content = (data == null ? void 0 : data.content) || [];
|
3695
|
-
(0,
|
3897
|
+
(0, import_react29.useEffect)(() => {
|
3696
3898
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3697
3899
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3698
3900
|
}
|
@@ -3709,10 +3911,10 @@ var DropZoneRender = (0, import_react23.forwardRef)(
|
|
3709
3911
|
zoneCompound = `${areaId}:${zone}`;
|
3710
3912
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3711
3913
|
}
|
3712
|
-
return /* @__PURE__ */ (0,
|
3914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
3713
3915
|
const Component = config.components[item.type];
|
3714
3916
|
if (Component) {
|
3715
|
-
return /* @__PURE__ */ (0,
|
3917
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3716
3918
|
DropZoneProvider,
|
3717
3919
|
{
|
3718
3920
|
value: {
|
@@ -3722,7 +3924,7 @@ var DropZoneRender = (0, import_react23.forwardRef)(
|
|
3722
3924
|
depth: 1,
|
3723
3925
|
path: []
|
3724
3926
|
},
|
3725
|
-
children: /* @__PURE__ */ (0,
|
3927
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3726
3928
|
Component.render,
|
3727
3929
|
__spreadProps(__spreadValues({}, item.props), {
|
3728
3930
|
puck: { renderDropZone: DropZoneRender2 }
|
@@ -3736,13 +3938,13 @@ var DropZoneRender = (0, import_react23.forwardRef)(
|
|
3736
3938
|
}) });
|
3737
3939
|
}
|
3738
3940
|
);
|
3739
|
-
var DropZone = (0,
|
3941
|
+
var DropZone = (0, import_react29.forwardRef)(
|
3740
3942
|
function DropZone2(props, ref) {
|
3741
|
-
const ctx = (0,
|
3943
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3742
3944
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3743
|
-
return /* @__PURE__ */ (0,
|
3945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3744
3946
|
}
|
3745
|
-
return /* @__PURE__ */ (0,
|
3947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3746
3948
|
}
|
3747
3949
|
);
|
3748
3950
|
|
@@ -3758,7 +3960,7 @@ var getZoneId = (zoneCompound) => {
|
|
3758
3960
|
return [rootDroppableId, zoneCompound];
|
3759
3961
|
};
|
3760
3962
|
|
3761
|
-
//
|
3963
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3762
3964
|
init_react_import();
|
3763
3965
|
var import_abstract9 = require("@dnd-kit/abstract");
|
3764
3966
|
var import_state = require("@dnd-kit/state");
|
@@ -3800,7 +4002,49 @@ var getFrame = () => {
|
|
3800
4002
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3801
4003
|
};
|
3802
4004
|
|
3803
|
-
//
|
4005
|
+
// lib/global-position.ts
|
4006
|
+
init_react_import();
|
4007
|
+
var GlobalPosition = class {
|
4008
|
+
constructor(target, original) {
|
4009
|
+
this.scaleFactor = 1;
|
4010
|
+
this.frameEl = null;
|
4011
|
+
this.frameRect = null;
|
4012
|
+
var _a;
|
4013
|
+
this.target = target;
|
4014
|
+
this.original = original;
|
4015
|
+
this.frameEl = document.querySelector("iframe");
|
4016
|
+
if (this.frameEl) {
|
4017
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
4018
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4019
|
+
}
|
4020
|
+
}
|
4021
|
+
get x() {
|
4022
|
+
return this.original.x;
|
4023
|
+
}
|
4024
|
+
get y() {
|
4025
|
+
return this.original.y;
|
4026
|
+
}
|
4027
|
+
get global() {
|
4028
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
4029
|
+
return {
|
4030
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
4031
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
4032
|
+
};
|
4033
|
+
}
|
4034
|
+
return this.original;
|
4035
|
+
}
|
4036
|
+
get frame() {
|
4037
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
4038
|
+
return {
|
4039
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
4040
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
4041
|
+
};
|
4042
|
+
}
|
4043
|
+
return this.original;
|
4044
|
+
}
|
4045
|
+
};
|
4046
|
+
|
4047
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3804
4048
|
var depthSort = (candidates) => {
|
3805
4049
|
return candidates.sort((a, b) => {
|
3806
4050
|
const aData = a.data;
|
@@ -3829,10 +4073,12 @@ var getZoneId2 = (candidate) => {
|
|
3829
4073
|
}
|
3830
4074
|
return id;
|
3831
4075
|
};
|
3832
|
-
var getPointerCollisions = (position, manager
|
3833
|
-
var _a;
|
4076
|
+
var getPointerCollisions = (position, manager) => {
|
3834
4077
|
const candidates = [];
|
3835
|
-
let elements = ownerDocument.elementsFromPoint(
|
4078
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
4079
|
+
position.x,
|
4080
|
+
position.y
|
4081
|
+
);
|
3836
4082
|
const previewFrame = elements.find(
|
3837
4083
|
(el) => el.getAttribute("data-puck-preview")
|
3838
4084
|
);
|
@@ -3841,17 +4087,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3841
4087
|
elements = [drawer];
|
3842
4088
|
}
|
3843
4089
|
if (previewFrame) {
|
3844
|
-
const
|
3845
|
-
if (
|
3846
|
-
|
3847
|
-
const frame = getFrame();
|
3848
|
-
if (frame) {
|
3849
|
-
const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
3850
|
-
elements = frame.elementsFromPoint(
|
3851
|
-
(position.x - rect.left) / scaleFactor,
|
3852
|
-
(position.y - rect.top) / scaleFactor
|
3853
|
-
);
|
3854
|
-
}
|
4090
|
+
const frame = getFrame();
|
4091
|
+
if (frame) {
|
4092
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
3855
4093
|
}
|
3856
4094
|
}
|
3857
4095
|
if (elements) {
|
@@ -3868,9 +4106,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3868
4106
|
}
|
3869
4107
|
return candidates;
|
3870
4108
|
};
|
3871
|
-
var findDeepestCandidate = (position, manager
|
4109
|
+
var findDeepestCandidate = (position, manager) => {
|
3872
4110
|
var _a;
|
3873
|
-
const candidates = getPointerCollisions(position, manager
|
4111
|
+
const candidates = getPointerCollisions(position, manager);
|
3874
4112
|
if (candidates.length > 0) {
|
3875
4113
|
const sortedCandidates = depthSort(candidates);
|
3876
4114
|
const draggable = manager.dragOperation.source;
|
@@ -3915,9 +4153,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
|
|
3915
4153
|
area: null
|
3916
4154
|
};
|
3917
4155
|
};
|
3918
|
-
var createNestedDroppablePlugin = ({
|
3919
|
-
onChange
|
3920
|
-
}) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4156
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
3921
4157
|
constructor(manager, options) {
|
3922
4158
|
super(manager);
|
3923
4159
|
if (typeof window === "undefined") {
|
@@ -3925,16 +4161,19 @@ var createNestedDroppablePlugin = ({
|
|
3925
4161
|
}
|
3926
4162
|
const cleanupEffect = (0, import_state.effects)(() => {
|
3927
4163
|
const handleMove = (event) => {
|
3928
|
-
const
|
4164
|
+
const target = event.originalTarget || event.target;
|
4165
|
+
const position = new GlobalPosition(target, {
|
3929
4166
|
x: event.clientX,
|
3930
4167
|
y: event.clientY
|
3931
|
-
};
|
3932
|
-
const
|
3933
|
-
|
3934
|
-
|
3935
|
-
findDeepestCandidate(position, manager, ownerDocument),
|
3936
|
-
manager
|
4168
|
+
});
|
4169
|
+
const elements = document.elementsFromPoint(
|
4170
|
+
position.global.x,
|
4171
|
+
position.global.y
|
3937
4172
|
);
|
4173
|
+
const overEl = elements.some((el) => el.id === id);
|
4174
|
+
if (overEl) {
|
4175
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
4176
|
+
}
|
3938
4177
|
};
|
3939
4178
|
const handleMoveThrottled = throttle(handleMove, 50);
|
3940
4179
|
const handlePointerMove = (event) => {
|
@@ -4351,7 +4590,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4351
4590
|
var import_use_debounce2 = require("use-debounce");
|
4352
4591
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
4353
4592
|
|
4354
|
-
//
|
4593
|
+
// lib/dnd/PointerSensor.ts
|
4355
4594
|
init_react_import();
|
4356
4595
|
var import_state3 = require("@dnd-kit/state");
|
4357
4596
|
var import_abstract10 = require("@dnd-kit/abstract");
|
@@ -4613,13 +4852,15 @@ function patchWindow(window2) {
|
|
4613
4852
|
}
|
4614
4853
|
|
4615
4854
|
// components/DragDropContext/index.tsx
|
4616
|
-
var
|
4617
|
-
var
|
4855
|
+
var import_zustand3 = require("zustand");
|
4856
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
4857
|
+
var DEBUG3 = false;
|
4858
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
4618
4859
|
dragListeners: {}
|
4619
4860
|
});
|
4620
4861
|
function useDragListener(type, fn, deps = []) {
|
4621
|
-
const { setDragListeners } = (0,
|
4622
|
-
(0,
|
4862
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
4863
|
+
(0, import_react31.useEffect)(() => {
|
4623
4864
|
if (setDragListeners) {
|
4624
4865
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4625
4866
|
[type]: [...old[type] || [], fn]
|
@@ -4627,80 +4868,147 @@ function useDragListener(type, fn, deps = []) {
|
|
4627
4868
|
}
|
4628
4869
|
}, deps);
|
4629
4870
|
}
|
4630
|
-
var previewContext = (0, import_react25.createContext)(null);
|
4631
4871
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4872
|
+
var useTempDisableFallback = (timeout3) => {
|
4873
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
4874
|
+
return (0, import_react31.useCallback)((manager) => {
|
4875
|
+
collisionStore.setState({ fallbackEnabled: false });
|
4876
|
+
const fallbackId = generateId();
|
4877
|
+
lastFallbackDisable.current = fallbackId;
|
4878
|
+
setTimeout(() => {
|
4879
|
+
if (lastFallbackDisable.current === fallbackId) {
|
4880
|
+
collisionStore.setState({ fallbackEnabled: true });
|
4881
|
+
manager.collisionObserver.forceUpdate(true);
|
4882
|
+
}
|
4883
|
+
}, timeout3);
|
4884
|
+
}, []);
|
4885
|
+
};
|
4632
4886
|
var DragDropContextClient = ({
|
4633
4887
|
children,
|
4634
4888
|
disableAutoScroll
|
4635
4889
|
}) => {
|
4636
4890
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4637
|
-
const
|
4638
|
-
const previewRef = (0, import_react25.useRef)(null);
|
4891
|
+
const id = (0, import_react31.useId)();
|
4639
4892
|
const { data } = state;
|
4640
|
-
const
|
4641
|
-
const
|
4642
|
-
const
|
4643
|
-
|
4644
|
-
|
4893
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
4894
|
+
const tempDisableFallback = useTempDisableFallback(100);
|
4895
|
+
const [zoneStore] = (0, import_react31.useState)(
|
4896
|
+
() => (0, import_zustand3.createStore)(() => ({
|
4897
|
+
zoneDepthIndex: {},
|
4898
|
+
nextZoneDepthIndex: {},
|
4899
|
+
areaDepthIndex: {},
|
4900
|
+
nextAreaDepthIndex: {},
|
4901
|
+
draggedItem: null,
|
4902
|
+
previewIndex: {}
|
4903
|
+
}))
|
4904
|
+
);
|
4905
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
4906
|
+
(params, id2) => {
|
4907
|
+
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4908
|
+
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
4909
|
+
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
4910
|
+
let zoneChanged = false;
|
4911
|
+
let areaChanged = false;
|
4912
|
+
if (params.zone && !zoneDepthIndex[params.zone]) {
|
4913
|
+
zoneChanged = true;
|
4914
|
+
} else if (!params.zone && stateHasZone) {
|
4915
|
+
zoneChanged = true;
|
4916
|
+
}
|
4917
|
+
if (params.area && !areaDepthIndex[params.area]) {
|
4918
|
+
areaChanged = true;
|
4919
|
+
} else if (!params.area && stateHasArea) {
|
4920
|
+
areaChanged = true;
|
4921
|
+
}
|
4922
|
+
return { zoneChanged, areaChanged };
|
4923
|
+
},
|
4924
|
+
[zoneStore]
|
4925
|
+
);
|
4926
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
4645
4927
|
(params, manager) => {
|
4646
|
-
|
4928
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4929
|
+
if (!zoneChanged && !areaChanged) return;
|
4930
|
+
zoneStore.setState({
|
4931
|
+
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
4932
|
+
areaDepthIndex: params.area ? { [params.area]: true } : {}
|
4933
|
+
});
|
4934
|
+
tempDisableFallback(manager);
|
4647
4935
|
setTimeout(() => {
|
4648
4936
|
manager.collisionObserver.forceUpdate(true);
|
4649
4937
|
}, 50);
|
4650
4938
|
debouncedParamsRef.current = null;
|
4651
4939
|
},
|
4652
|
-
[]
|
4940
|
+
[zoneStore]
|
4653
4941
|
);
|
4654
4942
|
const setDeepestDb = (0, import_use_debounce2.useDebouncedCallback)(
|
4655
4943
|
setDeepestAndCollide,
|
4656
4944
|
AREA_CHANGE_DEBOUNCE_MS
|
4657
4945
|
);
|
4658
|
-
(0, import_react25.useEffect)(() => {
|
4659
|
-
deepestRef.current = deepest;
|
4660
|
-
}, [deepest]);
|
4661
4946
|
const cancelDb = () => {
|
4662
4947
|
setDeepestDb.cancel();
|
4663
4948
|
debouncedParamsRef.current = null;
|
4664
4949
|
};
|
4665
|
-
|
4666
|
-
|
4667
|
-
|
4668
|
-
|
4669
|
-
|
4670
|
-
|
4671
|
-
|
4672
|
-
|
4673
|
-
|
4674
|
-
|
4675
|
-
}
|
4676
|
-
if (params.zone !== "void" && (lastParams == null ? void 0 : lastParams.zone) === "void") {
|
4677
|
-
setDeepest(params);
|
4678
|
-
manager.collisionObserver.forceUpdate(true);
|
4679
|
-
return;
|
4950
|
+
(0, import_react31.useEffect)(() => {
|
4951
|
+
if (DEBUG3) {
|
4952
|
+
zoneStore.subscribe(
|
4953
|
+
(s) => {
|
4954
|
+
var _a, _b;
|
4955
|
+
return console.log(
|
4956
|
+
s.previewIndex,
|
4957
|
+
(_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
|
4958
|
+
(_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
|
4959
|
+
);
|
4680
4960
|
}
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4961
|
+
);
|
4962
|
+
}
|
4963
|
+
}, []);
|
4964
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
4965
|
+
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
4966
|
+
createNestedDroppablePlugin(
|
4967
|
+
{
|
4968
|
+
onChange: (params, manager) => {
|
4969
|
+
const state2 = zoneStore.getState();
|
4970
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4971
|
+
const isDragging = manager.dragOperation.status.dragging;
|
4972
|
+
if (areaChanged || zoneChanged) {
|
4973
|
+
let nextZoneDepthIndex = {};
|
4974
|
+
let nextAreaDepthIndex = {};
|
4975
|
+
if (params.zone) {
|
4976
|
+
nextZoneDepthIndex = { [params.zone]: true };
|
4977
|
+
}
|
4978
|
+
if (params.area) {
|
4979
|
+
nextAreaDepthIndex = { [params.area]: true };
|
4980
|
+
}
|
4981
|
+
zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
|
4982
|
+
}
|
4983
|
+
if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
|
4984
|
+
setDeepestAndCollide(params, manager);
|
4985
|
+
return;
|
4986
|
+
}
|
4987
|
+
if (areaChanged) {
|
4988
|
+
if (isDragging) {
|
4989
|
+
const debouncedParams = debouncedParamsRef.current;
|
4990
|
+
const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
|
4991
|
+
if (!isSameParams) {
|
4992
|
+
cancelDb();
|
4993
|
+
setDeepestDb(params, manager);
|
4994
|
+
debouncedParamsRef.current = params;
|
4995
|
+
}
|
4996
|
+
} else {
|
4686
4997
|
cancelDb();
|
4687
|
-
|
4688
|
-
debouncedParamsRef.current = params;
|
4998
|
+
setDeepestAndCollide(params, manager);
|
4689
4999
|
}
|
4690
|
-
|
4691
|
-
|
5000
|
+
return;
|
5001
|
+
}
|
5002
|
+
if (zoneChanged) {
|
4692
5003
|
setDeepestAndCollide(params, manager);
|
4693
5004
|
}
|
4694
|
-
|
4695
|
-
}
|
4696
|
-
if (zoneChanged) {
|
4697
|
-
setDeepestAndCollide(params, manager);
|
5005
|
+
cancelDb();
|
4698
5006
|
}
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
5007
|
+
},
|
5008
|
+
id
|
5009
|
+
)
|
4702
5010
|
]);
|
4703
|
-
const [sensors] = (0,
|
5011
|
+
const [sensors] = (0, import_react31.useState)(() => [
|
4704
5012
|
PointerSensor.configure({
|
4705
5013
|
activationConstraints(event, source) {
|
4706
5014
|
var _a;
|
@@ -4719,11 +5027,10 @@ var DragDropContextClient = ({
|
|
4719
5027
|
}
|
4720
5028
|
})
|
4721
5029
|
]);
|
4722
|
-
const [
|
4723
|
-
const [
|
4724
|
-
const
|
4725
|
-
const
|
4726
|
-
const registerPath = (0, import_react25.useCallback)(
|
5030
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
5031
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
5032
|
+
const dragMode = (0, import_react31.useRef)(null);
|
5033
|
+
const registerPath = (0, import_react31.useCallback)(
|
4727
5034
|
(selector) => {
|
4728
5035
|
const item = getItem(selector, data);
|
4729
5036
|
if (!item) {
|
@@ -4745,41 +5052,41 @@ var DragDropContextClient = ({
|
|
4745
5052
|
},
|
4746
5053
|
[data, setPathData]
|
4747
5054
|
);
|
4748
|
-
const initialSelector = (0,
|
4749
|
-
return /* @__PURE__ */ (0,
|
5055
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4750
5057
|
dragListenerContext.Provider,
|
4751
5058
|
{
|
4752
5059
|
value: {
|
4753
5060
|
dragListeners,
|
4754
5061
|
setDragListeners
|
4755
5062
|
},
|
4756
|
-
children: /* @__PURE__ */ (0,
|
4757
|
-
|
5063
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5064
|
+
import_react30.DragDropProvider,
|
4758
5065
|
{
|
4759
5066
|
plugins,
|
4760
5067
|
sensors,
|
4761
5068
|
onDragEnd: (event, manager) => {
|
5069
|
+
var _a;
|
4762
5070
|
const { source, target } = event.operation;
|
4763
|
-
deepestRef.current = null;
|
4764
5071
|
if (!source) {
|
4765
|
-
|
5072
|
+
zoneStore.setState({ draggedItem: null });
|
4766
5073
|
return;
|
4767
5074
|
}
|
4768
5075
|
const { zone, index } = source.data;
|
4769
|
-
const
|
4770
|
-
|
5076
|
+
const { previewIndex = {} } = zoneStore.getState() || {};
|
5077
|
+
const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
|
4771
5078
|
setTimeout(() => {
|
4772
|
-
var
|
4773
|
-
|
5079
|
+
var _a2, _b;
|
5080
|
+
zoneStore.setState({ draggedItem: null });
|
4774
5081
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4775
|
-
|
4776
|
-
(
|
5082
|
+
zoneStore.setState({ previewIndex: {} });
|
5083
|
+
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
4777
5084
|
fn(event, manager);
|
4778
5085
|
});
|
4779
5086
|
return;
|
4780
5087
|
}
|
4781
5088
|
if (thisPreview) {
|
4782
|
-
|
5089
|
+
zoneStore.setState({ previewIndex: {} });
|
4783
5090
|
if (thisPreview.type === "insert") {
|
4784
5091
|
insertComponent(
|
4785
5092
|
thisPreview.componentType,
|
@@ -4814,8 +5121,9 @@ var DragDropContextClient = ({
|
|
4814
5121
|
}, 250);
|
4815
5122
|
},
|
4816
5123
|
onDragOver: (event, manager) => {
|
4817
|
-
var _a, _b, _c, _d;
|
5124
|
+
var _a, _b, _c, _d, _e;
|
4818
5125
|
event.preventDefault();
|
5126
|
+
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
4819
5127
|
if (!draggedItem) return;
|
4820
5128
|
cancelDb();
|
4821
5129
|
const { source, target } = event.operation;
|
@@ -4831,7 +5139,7 @@ var DragDropContextClient = ({
|
|
4831
5139
|
const targetData = target.data;
|
4832
5140
|
targetZone = targetData.zone;
|
4833
5141
|
targetIndex = targetData.index;
|
4834
|
-
const collisionData = (
|
5142
|
+
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
4835
5143
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4836
5144
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4837
5145
|
targetIndex = targetIndex - 1;
|
@@ -4843,23 +5151,26 @@ var DragDropContextClient = ({
|
|
4843
5151
|
targetZone = target.id.toString();
|
4844
5152
|
targetIndex = 0;
|
4845
5153
|
}
|
4846
|
-
if (targetId === sourceId || ((
|
5154
|
+
if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
|
4847
5155
|
const [pathId] = path.split(":");
|
4848
5156
|
return pathId === sourceId;
|
4849
5157
|
}))) {
|
4850
5158
|
return;
|
4851
5159
|
}
|
4852
5160
|
if (dragMode.current === "new") {
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4857
|
-
|
4858
|
-
|
4859
|
-
|
5161
|
+
zoneStore.setState({
|
5162
|
+
previewIndex: {
|
5163
|
+
[targetZone]: {
|
5164
|
+
componentType: sourceData.componentType,
|
5165
|
+
type: "insert",
|
5166
|
+
index: targetIndex,
|
5167
|
+
zone: targetZone,
|
5168
|
+
props: {
|
5169
|
+
id: source.id.toString()
|
5170
|
+
}
|
5171
|
+
}
|
4860
5172
|
}
|
4861
|
-
};
|
4862
|
-
setPreview(previewRef.current);
|
5173
|
+
});
|
4863
5174
|
} else {
|
4864
5175
|
if (!initialSelector.current) {
|
4865
5176
|
initialSelector.current = {
|
@@ -4869,17 +5180,20 @@ var DragDropContextClient = ({
|
|
4869
5180
|
}
|
4870
5181
|
const item = getItem(initialSelector.current, data);
|
4871
5182
|
if (item) {
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4878
|
-
|
4879
|
-
|
5183
|
+
zoneStore.setState({
|
5184
|
+
previewIndex: {
|
5185
|
+
[targetZone]: {
|
5186
|
+
componentType: sourceData.componentType,
|
5187
|
+
type: "move",
|
5188
|
+
index: targetIndex,
|
5189
|
+
zone: targetZone,
|
5190
|
+
props: item.props
|
5191
|
+
}
|
5192
|
+
}
|
5193
|
+
});
|
4880
5194
|
}
|
4881
5195
|
}
|
4882
|
-
(
|
5196
|
+
(_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
|
4883
5197
|
fn(event, manager);
|
4884
5198
|
});
|
4885
5199
|
},
|
@@ -4889,45 +5203,61 @@ var DragDropContextClient = ({
|
|
4889
5203
|
type: "setUi",
|
4890
5204
|
ui: { itemSelector: null, isDragging: true }
|
4891
5205
|
});
|
5206
|
+
const { source } = event.operation;
|
5207
|
+
if (source && source.type !== "void") {
|
5208
|
+
const sourceData = source.data;
|
5209
|
+
const item = getItem(
|
5210
|
+
{
|
5211
|
+
zone: sourceData.zone,
|
5212
|
+
index: sourceData.index
|
5213
|
+
},
|
5214
|
+
data
|
5215
|
+
);
|
5216
|
+
if (item) {
|
5217
|
+
zoneStore.setState({
|
5218
|
+
previewIndex: {
|
5219
|
+
[sourceData.zone]: {
|
5220
|
+
componentType: sourceData.componentType,
|
5221
|
+
type: "move",
|
5222
|
+
index: sourceData.index,
|
5223
|
+
zone: sourceData.zone,
|
5224
|
+
props: item.props
|
5225
|
+
}
|
5226
|
+
}
|
5227
|
+
});
|
5228
|
+
}
|
5229
|
+
}
|
4892
5230
|
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4893
5231
|
fn(event, manager);
|
4894
5232
|
});
|
4895
5233
|
},
|
4896
5234
|
onBeforeDragStart: (event) => {
|
4897
5235
|
var _a;
|
4898
|
-
if (draggedItem) {
|
4899
|
-
console.warn("New drag started before previous drag cleaned up");
|
4900
|
-
}
|
4901
5236
|
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4902
5237
|
dragMode.current = isNewComponent ? "new" : "existing";
|
4903
5238
|
initialSelector.current = void 0;
|
4904
|
-
|
5239
|
+
zoneStore.setState({ draggedItem: event.operation.source });
|
4905
5240
|
},
|
4906
|
-
children: /* @__PURE__ */ (0,
|
5241
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4907
5242
|
DropZoneProvider,
|
4908
5243
|
{
|
4909
5244
|
value: {
|
4910
5245
|
data,
|
4911
5246
|
config,
|
4912
|
-
draggedItem,
|
4913
5247
|
mode: "edit",
|
4914
5248
|
areaId: "root",
|
4915
5249
|
depth: 0,
|
4916
5250
|
registerPath,
|
4917
5251
|
pathData,
|
4918
|
-
deepestZone: deepest == null ? void 0 : deepest.zone,
|
4919
|
-
deepestArea: deepest == null ? void 0 : deepest.area,
|
4920
|
-
nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
|
4921
|
-
nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
|
4922
5252
|
path: []
|
4923
5253
|
},
|
4924
5254
|
children
|
4925
5255
|
}
|
4926
|
-
)
|
5256
|
+
) })
|
4927
5257
|
}
|
4928
|
-
)
|
5258
|
+
)
|
4929
5259
|
}
|
4930
|
-
);
|
5260
|
+
) });
|
4931
5261
|
};
|
4932
5262
|
var DragDropContext = ({
|
4933
5263
|
children,
|
@@ -4937,11 +5267,11 @@ var DragDropContext = ({
|
|
4937
5267
|
if (status === "LOADING") {
|
4938
5268
|
return children;
|
4939
5269
|
}
|
4940
|
-
return /* @__PURE__ */ (0,
|
5270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
4941
5271
|
};
|
4942
5272
|
|
4943
5273
|
// components/Drawer/index.tsx
|
4944
|
-
var
|
5274
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
4945
5275
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
4946
5276
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
4947
5277
|
var DrawerItemInner = ({
|
@@ -4951,11 +5281,11 @@ var DrawerItemInner = ({
|
|
4951
5281
|
dragRef,
|
4952
5282
|
isDragDisabled
|
4953
5283
|
}) => {
|
4954
|
-
const CustomInner = (0,
|
4955
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
5284
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5285
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
4956
5286
|
[children]
|
4957
5287
|
);
|
4958
|
-
return /* @__PURE__ */ (0,
|
5288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
4959
5289
|
"div",
|
4960
5290
|
{
|
4961
5291
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -4963,9 +5293,9 @@ var DrawerItemInner = ({
|
|
4963
5293
|
onMouseDown: (e) => e.preventDefault(),
|
4964
5294
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
4965
5295
|
"data-puck-drawer-item": true,
|
4966
|
-
children: /* @__PURE__ */ (0,
|
4967
|
-
/* @__PURE__ */ (0,
|
4968
|
-
/* @__PURE__ */ (0,
|
5296
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
|
5297
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
5298
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragIcon, {}) })
|
4969
5299
|
] }) }) })
|
4970
5300
|
}
|
4971
5301
|
);
|
@@ -4982,9 +5312,9 @@ var DrawerItemDraggable = ({
|
|
4982
5312
|
data: { type: "drawer", componentType: name },
|
4983
5313
|
disabled: isDragDisabled
|
4984
5314
|
});
|
4985
|
-
return /* @__PURE__ */ (0,
|
4986
|
-
/* @__PURE__ */ (0,
|
4987
|
-
/* @__PURE__ */ (0,
|
5315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName18("draggable"), children: [
|
5316
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DrawerItemInner, { name, label, children }) }),
|
5317
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
4988
5318
|
DrawerItemInner,
|
4989
5319
|
{
|
4990
5320
|
name,
|
@@ -5005,7 +5335,7 @@ var DrawerItem = ({
|
|
5005
5335
|
isDragDisabled
|
5006
5336
|
}) => {
|
5007
5337
|
const resolvedId = id || name;
|
5008
|
-
const [dynamicId, setDynamicId] = (0,
|
5338
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5009
5339
|
if (typeof index !== "undefined") {
|
5010
5340
|
console.error(
|
5011
5341
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5018,7 +5348,7 @@ var DrawerItem = ({
|
|
5018
5348
|
},
|
5019
5349
|
[resolvedId]
|
5020
5350
|
);
|
5021
|
-
return /* @__PURE__ */ (0,
|
5351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5022
5352
|
DrawerItemDraggable,
|
5023
5353
|
{
|
5024
5354
|
name,
|
@@ -5044,14 +5374,14 @@ var Drawer = ({
|
|
5044
5374
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5045
5375
|
);
|
5046
5376
|
}
|
5047
|
-
const [id] = (0,
|
5377
|
+
const [id] = (0, import_react32.useState)(generateId());
|
5048
5378
|
const { ref } = useDroppableSafe({
|
5049
5379
|
id,
|
5050
5380
|
type: "void",
|
5051
5381
|
collisionPriority: 0
|
5052
5382
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
5053
5383
|
});
|
5054
|
-
return /* @__PURE__ */ (0,
|
5384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5055
5385
|
"div",
|
5056
5386
|
{
|
5057
5387
|
className: getClassName18(),
|
@@ -5066,7 +5396,7 @@ Drawer.Item = DrawerItem;
|
|
5066
5396
|
|
5067
5397
|
// components/Puck/index.tsx
|
5068
5398
|
init_react_import();
|
5069
|
-
var
|
5399
|
+
var import_react48 = require("react");
|
5070
5400
|
|
5071
5401
|
// components/SidebarSection/index.tsx
|
5072
5402
|
init_react_import();
|
@@ -5077,7 +5407,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
5077
5407
|
|
5078
5408
|
// lib/use-breadcrumbs.ts
|
5079
5409
|
init_react_import();
|
5080
|
-
var
|
5410
|
+
var import_react33 = require("react");
|
5081
5411
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5082
5412
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5083
5413
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5127,8 +5457,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5127
5457
|
state: { data },
|
5128
5458
|
selectedItem
|
5129
5459
|
} = useAppContext();
|
5130
|
-
const dzContext = (0,
|
5131
|
-
return (0,
|
5460
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5461
|
+
return (0, import_react33.useMemo)(() => {
|
5132
5462
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5133
5463
|
selectedItem,
|
5134
5464
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5142,7 +5472,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
5142
5472
|
};
|
5143
5473
|
|
5144
5474
|
// components/SidebarSection/index.tsx
|
5145
|
-
var
|
5475
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
5146
5476
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5147
5477
|
var SidebarSection = ({
|
5148
5478
|
children,
|
@@ -5155,15 +5485,15 @@ var SidebarSection = ({
|
|
5155
5485
|
}) => {
|
5156
5486
|
const { setUi } = useAppContext();
|
5157
5487
|
const breadcrumbs = useBreadcrumbs(1);
|
5158
|
-
return /* @__PURE__ */ (0,
|
5488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
5159
5489
|
"div",
|
5160
5490
|
{
|
5161
5491
|
className: getClassName19({ noBorderTop, noPadding }),
|
5162
5492
|
style: { background },
|
5163
5493
|
children: [
|
5164
|
-
/* @__PURE__ */ (0,
|
5165
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
5166
|
-
/* @__PURE__ */ (0,
|
5494
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
5495
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
5496
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5167
5497
|
"button",
|
5168
5498
|
{
|
5169
5499
|
type: "button",
|
@@ -5172,12 +5502,12 @@ var SidebarSection = ({
|
|
5172
5502
|
children: breadcrumb.label
|
5173
5503
|
}
|
5174
5504
|
),
|
5175
|
-
/* @__PURE__ */ (0,
|
5505
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
|
5176
5506
|
] }, i)) : null,
|
5177
|
-
/* @__PURE__ */ (0,
|
5507
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
5178
5508
|
] }) }),
|
5179
|
-
/* @__PURE__ */ (0,
|
5180
|
-
isLoading && /* @__PURE__ */ (0,
|
5509
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
|
5510
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
|
5181
5511
|
]
|
5182
5512
|
}
|
5183
5513
|
);
|
@@ -5208,7 +5538,7 @@ init_react_import();
|
|
5208
5538
|
var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
5209
5539
|
|
5210
5540
|
// components/MenuBar/index.tsx
|
5211
|
-
var
|
5541
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
5212
5542
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5213
5543
|
function MenuBar({
|
5214
5544
|
appState,
|
@@ -5222,7 +5552,7 @@ function MenuBar({
|
|
5222
5552
|
history: { back, forward, historyStore }
|
5223
5553
|
} = useAppContext();
|
5224
5554
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5225
|
-
return /* @__PURE__ */ (0,
|
5555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
5226
5556
|
"div",
|
5227
5557
|
{
|
5228
5558
|
className: getClassName20({ menuOpen }),
|
@@ -5236,12 +5566,12 @@ function MenuBar({
|
|
5236
5566
|
setMenuOpen(false);
|
5237
5567
|
}
|
5238
5568
|
},
|
5239
|
-
children: /* @__PURE__ */ (0,
|
5240
|
-
/* @__PURE__ */ (0,
|
5241
|
-
/* @__PURE__ */ (0,
|
5242
|
-
/* @__PURE__ */ (0,
|
5569
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
|
5570
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
|
5571
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
|
5572
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
|
5243
5573
|
] }),
|
5244
|
-
/* @__PURE__ */ (0,
|
5574
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
5245
5575
|
state: appState,
|
5246
5576
|
dispatch
|
5247
5577
|
}) })
|
@@ -5252,7 +5582,7 @@ function MenuBar({
|
|
5252
5582
|
|
5253
5583
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5254
5584
|
init_react_import();
|
5255
|
-
var styles_module_default15 = { "Puck": "
|
5585
|
+
var styles_module_default15 = { "Puck": "_Puck_12s9r_19", "Puck-portal": "_Puck-portal_12s9r_24", "PuckLayout-inner": "_PuckLayout-inner_12s9r_31", "PuckLayout--mounted": "_PuckLayout--mounted_12s9r_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_12s9r_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_12s9r_53", "PuckLayout-mounted": "_PuckLayout-mounted_12s9r_67", "PuckLayout": "_PuckLayout_12s9r_31", "PuckLayout-header": "_PuckLayout-header_12s9r_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_12s9r_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_12s9r_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_12s9r_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_12s9r_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_12s9r_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_12s9r_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_12s9r_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_12s9r_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_12s9r_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_12s9r_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_12s9r_134" };
|
5256
5586
|
|
5257
5587
|
// components/Puck/components/Fields/index.tsx
|
5258
5588
|
init_react_import();
|
@@ -5262,15 +5592,15 @@ init_react_import();
|
|
5262
5592
|
var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
|
5263
5593
|
|
5264
5594
|
// components/Puck/components/Fields/index.tsx
|
5265
|
-
var
|
5595
|
+
var import_react35 = require("react");
|
5266
5596
|
|
5267
5597
|
// lib/use-parent.ts
|
5268
5598
|
init_react_import();
|
5269
|
-
var
|
5599
|
+
var import_react34 = require("react");
|
5270
5600
|
var useParent = (itemSelector) => {
|
5271
5601
|
var _a;
|
5272
5602
|
const { selectedItem, state } = useAppContext();
|
5273
|
-
const { pathData } = (0,
|
5603
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5274
5604
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
5275
5605
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5276
5606
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -5279,7 +5609,7 @@ var useParent = (itemSelector) => {
|
|
5279
5609
|
};
|
5280
5610
|
|
5281
5611
|
// components/Puck/components/Fields/index.tsx
|
5282
|
-
var
|
5612
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
5283
5613
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5284
5614
|
var defaultPageFields = {
|
5285
5615
|
title: { type: "text" }
|
@@ -5287,7 +5617,7 @@ var defaultPageFields = {
|
|
5287
5617
|
var DefaultFields = ({
|
5288
5618
|
children
|
5289
5619
|
}) => {
|
5290
|
-
return /* @__PURE__ */ (0,
|
5620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5291
5621
|
};
|
5292
5622
|
var useResolvedFields = () => {
|
5293
5623
|
var _a, _b;
|
@@ -5296,20 +5626,20 @@ var useResolvedFields = () => {
|
|
5296
5626
|
const { data } = state;
|
5297
5627
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5298
5628
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5299
|
-
const defaultFields = (0,
|
5629
|
+
const defaultFields = (0, import_react35.useMemo)(
|
5300
5630
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5301
5631
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5302
5632
|
);
|
5303
5633
|
const rootProps = data.root.props || data.root;
|
5304
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5305
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5306
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5634
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react35.useState)({});
|
5635
|
+
const [resolvedFields, setResolvedFields] = (0, import_react35.useState)(defaultFields);
|
5636
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react35.useState)(false);
|
5307
5637
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5308
5638
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5309
5639
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5310
5640
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5311
5641
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5312
|
-
const resolveFields = (0,
|
5642
|
+
const resolveFields = (0, import_react35.useCallback)(
|
5313
5643
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5314
5644
|
var _a2;
|
5315
5645
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5345,19 +5675,33 @@ var useResolvedFields = () => {
|
|
5345
5675
|
lastData
|
5346
5676
|
});
|
5347
5677
|
}),
|
5348
|
-
[data, config, componentData, selectedItem, resolvedFields, state]
|
5678
|
+
[data, config, componentData, selectedItem, resolvedFields, state, parent]
|
5349
5679
|
);
|
5350
|
-
(0,
|
5351
|
-
|
5352
|
-
|
5353
|
-
|
5354
|
-
|
5355
|
-
|
5356
|
-
|
5357
|
-
|
5358
|
-
|
5680
|
+
const [hasParent, setHasParent] = (0, import_react35.useState)(false);
|
5681
|
+
(0, import_react35.useEffect)(() => {
|
5682
|
+
setHasParent(!!parent);
|
5683
|
+
}, [parent]);
|
5684
|
+
(0, import_react35.useEffect)(() => {
|
5685
|
+
var _a2;
|
5686
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || hasParent) {
|
5687
|
+
if (hasResolver) {
|
5688
|
+
setFieldsLoading(true);
|
5689
|
+
resolveFields(defaultFields).then((fields) => {
|
5690
|
+
setResolvedFields(fields || {});
|
5691
|
+
setFieldsLoading(false);
|
5692
|
+
});
|
5693
|
+
} else {
|
5694
|
+
setResolvedFields(defaultFields);
|
5695
|
+
}
|
5359
5696
|
}
|
5360
|
-
}, [
|
5697
|
+
}, [
|
5698
|
+
data,
|
5699
|
+
defaultFields,
|
5700
|
+
state.ui.itemSelector,
|
5701
|
+
selectedItem,
|
5702
|
+
hasResolver,
|
5703
|
+
hasParent
|
5704
|
+
]);
|
5361
5705
|
return [resolvedFields, fieldsLoading];
|
5362
5706
|
};
|
5363
5707
|
var Fields = () => {
|
@@ -5378,8 +5722,8 @@ var Fields = () => {
|
|
5378
5722
|
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;
|
5379
5723
|
const isLoading = fieldsResolving || componentResolving;
|
5380
5724
|
const rootProps = data.root.props || data.root;
|
5381
|
-
const Wrapper = (0,
|
5382
|
-
return /* @__PURE__ */ (0,
|
5725
|
+
const Wrapper = (0, import_react35.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5383
5727
|
"form",
|
5384
5728
|
{
|
5385
5729
|
className: getClassName21(),
|
@@ -5387,7 +5731,7 @@ var Fields = () => {
|
|
5387
5731
|
e.preventDefault();
|
5388
5732
|
},
|
5389
5733
|
children: [
|
5390
|
-
/* @__PURE__ */ (0,
|
5734
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5391
5735
|
const field = fields[fieldName];
|
5392
5736
|
if (!(field == null ? void 0 : field.type)) return null;
|
5393
5737
|
const onChange = (value, updatedUi) => {
|
@@ -5458,7 +5802,7 @@ var Fields = () => {
|
|
5458
5802
|
item: selectedItem
|
5459
5803
|
});
|
5460
5804
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5461
|
-
return /* @__PURE__ */ (0,
|
5805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5462
5806
|
AutoFieldPrivate,
|
5463
5807
|
{
|
5464
5808
|
field,
|
@@ -5476,7 +5820,7 @@ var Fields = () => {
|
|
5476
5820
|
root: true
|
5477
5821
|
});
|
5478
5822
|
const id = `root_${field.type}_${fieldName}`;
|
5479
|
-
return /* @__PURE__ */ (0,
|
5823
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5480
5824
|
AutoFieldPrivate,
|
5481
5825
|
{
|
5482
5826
|
field,
|
@@ -5490,7 +5834,7 @@ var Fields = () => {
|
|
5490
5834
|
);
|
5491
5835
|
}
|
5492
5836
|
}) }),
|
5493
|
-
isLoading && /* @__PURE__ */ (0,
|
5837
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Loader, { size: 16 }) }) })
|
5494
5838
|
]
|
5495
5839
|
}
|
5496
5840
|
);
|
@@ -5501,7 +5845,7 @@ init_react_import();
|
|
5501
5845
|
|
5502
5846
|
// lib/use-component-list.tsx
|
5503
5847
|
init_react_import();
|
5504
|
-
var
|
5848
|
+
var import_react36 = require("react");
|
5505
5849
|
|
5506
5850
|
// components/ComponentList/index.tsx
|
5507
5851
|
init_react_import();
|
@@ -5511,7 +5855,7 @@ init_react_import();
|
|
5511
5855
|
var styles_module_default17 = { "ComponentList": "_ComponentList_odh9d_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_odh9d_5", "ComponentList-content": "_ComponentList-content_odh9d_9", "ComponentList-title": "_ComponentList-title_odh9d_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_odh9d_53" };
|
5512
5856
|
|
5513
5857
|
// components/ComponentList/index.tsx
|
5514
|
-
var
|
5858
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
5515
5859
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5516
5860
|
var ComponentListItem = ({
|
5517
5861
|
name,
|
@@ -5521,7 +5865,7 @@ var ComponentListItem = ({
|
|
5521
5865
|
const canInsert = getPermissions({
|
5522
5866
|
type: name
|
5523
5867
|
}).insert;
|
5524
|
-
return /* @__PURE__ */ (0,
|
5868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5525
5869
|
};
|
5526
5870
|
var ComponentList = ({
|
5527
5871
|
children,
|
@@ -5530,8 +5874,8 @@ var ComponentList = ({
|
|
5530
5874
|
}) => {
|
5531
5875
|
const { config, state, setUi } = useAppContext();
|
5532
5876
|
const { expanded = true } = state.ui.componentList[id] || {};
|
5533
|
-
return /* @__PURE__ */ (0,
|
5534
|
-
title && /* @__PURE__ */ (0,
|
5877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
5878
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
5535
5879
|
"button",
|
5536
5880
|
{
|
5537
5881
|
type: "button",
|
@@ -5545,14 +5889,14 @@ var ComponentList = ({
|
|
5545
5889
|
}),
|
5546
5890
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5547
5891
|
children: [
|
5548
|
-
/* @__PURE__ */ (0,
|
5549
|
-
/* @__PURE__ */ (0,
|
5892
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
|
5893
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronDown, { size: 12 }) })
|
5550
5894
|
]
|
5551
5895
|
}
|
5552
5896
|
),
|
5553
|
-
/* @__PURE__ */ (0,
|
5897
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
5554
5898
|
var _a;
|
5555
|
-
return /* @__PURE__ */ (0,
|
5899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
5556
5900
|
ComponentListItem,
|
5557
5901
|
{
|
5558
5902
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5566,10 +5910,10 @@ var ComponentList = ({
|
|
5566
5910
|
ComponentList.Item = ComponentListItem;
|
5567
5911
|
|
5568
5912
|
// lib/use-component-list.tsx
|
5569
|
-
var
|
5913
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5570
5914
|
var useComponentList = (config, ui) => {
|
5571
|
-
const [componentList, setComponentList] = (0,
|
5572
|
-
(0,
|
5915
|
+
const [componentList, setComponentList] = (0, import_react36.useState)();
|
5916
|
+
(0, import_react36.useEffect)(() => {
|
5573
5917
|
var _a, _b, _c;
|
5574
5918
|
if (Object.keys(ui.componentList).length > 0) {
|
5575
5919
|
const matchedComponents = [];
|
@@ -5579,7 +5923,7 @@ var useComponentList = (config, ui) => {
|
|
5579
5923
|
if (category.visible === false || !category.components) {
|
5580
5924
|
return null;
|
5581
5925
|
}
|
5582
|
-
return /* @__PURE__ */ (0,
|
5926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5583
5927
|
ComponentList,
|
5584
5928
|
{
|
5585
5929
|
id: categoryKey,
|
@@ -5588,7 +5932,7 @@ var useComponentList = (config, ui) => {
|
|
5588
5932
|
var _a2;
|
5589
5933
|
matchedComponents.push(componentName);
|
5590
5934
|
const componentConf = config.components[componentName] || {};
|
5591
|
-
return /* @__PURE__ */ (0,
|
5935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5592
5936
|
ComponentList.Item,
|
5593
5937
|
{
|
5594
5938
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5608,7 +5952,7 @@ var useComponentList = (config, ui) => {
|
|
5608
5952
|
);
|
5609
5953
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5610
5954
|
_componentList.push(
|
5611
|
-
/* @__PURE__ */ (0,
|
5955
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5612
5956
|
ComponentList,
|
5613
5957
|
{
|
5614
5958
|
id: "other",
|
@@ -5616,7 +5960,7 @@ var useComponentList = (config, ui) => {
|
|
5616
5960
|
children: remainingComponents.map((componentName, i) => {
|
5617
5961
|
var _a2;
|
5618
5962
|
const componentConf = config.components[componentName] || {};
|
5619
|
-
return /* @__PURE__ */ (0,
|
5963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5620
5964
|
ComponentList.Item,
|
5621
5965
|
{
|
5622
5966
|
name: componentName,
|
@@ -5638,25 +5982,25 @@ var useComponentList = (config, ui) => {
|
|
5638
5982
|
};
|
5639
5983
|
|
5640
5984
|
// components/Puck/components/Components/index.tsx
|
5641
|
-
var
|
5642
|
-
var
|
5985
|
+
var import_react37 = require("react");
|
5986
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5643
5987
|
var Components = () => {
|
5644
5988
|
const { config, state, overrides } = useAppContext();
|
5645
5989
|
const componentList = useComponentList(config, state.ui);
|
5646
|
-
const Wrapper = (0,
|
5647
|
-
return /* @__PURE__ */ (0,
|
5990
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.components || "div", [overrides]);
|
5991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
5648
5992
|
};
|
5649
5993
|
|
5650
5994
|
// components/Puck/components/Preview/index.tsx
|
5651
5995
|
init_react_import();
|
5652
|
-
var
|
5996
|
+
var import_react39 = require("react");
|
5653
5997
|
|
5654
5998
|
// components/AutoFrame/index.tsx
|
5655
5999
|
init_react_import();
|
5656
|
-
var
|
6000
|
+
var import_react38 = require("react");
|
5657
6001
|
var import_object_hash = __toESM(require("object-hash"));
|
5658
6002
|
var import_react_dom3 = require("react-dom");
|
5659
|
-
var
|
6003
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
5660
6004
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5661
6005
|
var collectStyles = (doc) => {
|
5662
6006
|
const collected = [];
|
@@ -5699,7 +6043,7 @@ var CopyHostStyles = ({
|
|
5699
6043
|
onStylesLoaded = () => null
|
5700
6044
|
}) => {
|
5701
6045
|
const { document: doc, window: win } = useFrame();
|
5702
|
-
(0,
|
6046
|
+
(0, import_react38.useEffect)(() => {
|
5703
6047
|
if (!win || !doc) {
|
5704
6048
|
return () => {
|
5705
6049
|
};
|
@@ -5856,10 +6200,10 @@ var CopyHostStyles = ({
|
|
5856
6200
|
observer.disconnect();
|
5857
6201
|
};
|
5858
6202
|
}, []);
|
5859
|
-
return /* @__PURE__ */ (0,
|
6203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
5860
6204
|
};
|
5861
|
-
var autoFrameContext = (0,
|
5862
|
-
var useFrame = () => (0,
|
6205
|
+
var autoFrameContext = (0, import_react38.createContext)({});
|
6206
|
+
var useFrame = () => (0, import_react38.useContext)(autoFrameContext);
|
5863
6207
|
function AutoFrame(_a) {
|
5864
6208
|
var _b = _a, {
|
5865
6209
|
children,
|
@@ -5876,10 +6220,10 @@ function AutoFrame(_a) {
|
|
5876
6220
|
"onStylesLoaded",
|
5877
6221
|
"frameRef"
|
5878
6222
|
]);
|
5879
|
-
const [loaded, setLoaded] = (0,
|
5880
|
-
const [ctx, setCtx] = (0,
|
5881
|
-
const [mountTarget, setMountTarget] = (0,
|
5882
|
-
(0,
|
6223
|
+
const [loaded, setLoaded] = (0, import_react38.useState)(false);
|
6224
|
+
const [ctx, setCtx] = (0, import_react38.useState)({});
|
6225
|
+
const [mountTarget, setMountTarget] = (0, import_react38.useState)();
|
6226
|
+
(0, import_react38.useEffect)(() => {
|
5883
6227
|
var _a2;
|
5884
6228
|
if (frameRef.current) {
|
5885
6229
|
setCtx({
|
@@ -5891,7 +6235,7 @@ function AutoFrame(_a) {
|
|
5891
6235
|
);
|
5892
6236
|
}
|
5893
6237
|
}, [frameRef, loaded]);
|
5894
|
-
return /* @__PURE__ */ (0,
|
6238
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
5895
6239
|
"iframe",
|
5896
6240
|
__spreadProps(__spreadValues({}, props), {
|
5897
6241
|
className,
|
@@ -5901,7 +6245,7 @@ function AutoFrame(_a) {
|
|
5901
6245
|
onLoad: () => {
|
5902
6246
|
setLoaded(true);
|
5903
6247
|
},
|
5904
|
-
children: /* @__PURE__ */ (0,
|
6248
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CopyHostStyles, { debug, onStylesLoaded, children: (0, import_react_dom3.createPortal)(children, mountTarget) }) })
|
5905
6249
|
})
|
5906
6250
|
);
|
5907
6251
|
}
|
@@ -5914,7 +6258,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
|
|
5914
6258
|
|
5915
6259
|
// components/Render/index.tsx
|
5916
6260
|
init_react_import();
|
5917
|
-
var
|
6261
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
5918
6262
|
function Render({
|
5919
6263
|
config,
|
5920
6264
|
data
|
@@ -5927,7 +6271,7 @@ function Render({
|
|
5927
6271
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
5928
6272
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
5929
6273
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5930
|
-
return /* @__PURE__ */ (0,
|
6274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
5931
6275
|
DropZoneProvider,
|
5932
6276
|
{
|
5933
6277
|
value: {
|
@@ -5937,7 +6281,7 @@ function Render({
|
|
5937
6281
|
depth: 0,
|
5938
6282
|
path: []
|
5939
6283
|
},
|
5940
|
-
children: /* @__PURE__ */ (0,
|
6284
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
5941
6285
|
config.root.render,
|
5942
6286
|
__spreadProps(__spreadValues({}, rootProps), {
|
5943
6287
|
puck: {
|
@@ -5947,13 +6291,13 @@ function Render({
|
|
5947
6291
|
title,
|
5948
6292
|
editMode: false,
|
5949
6293
|
id: "puck-root",
|
5950
|
-
children: /* @__PURE__ */ (0,
|
6294
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
5951
6295
|
})
|
5952
6296
|
)
|
5953
6297
|
}
|
5954
6298
|
);
|
5955
6299
|
}
|
5956
|
-
return /* @__PURE__ */ (0,
|
6300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
5957
6301
|
DropZoneProvider,
|
5958
6302
|
{
|
5959
6303
|
value: {
|
@@ -5963,17 +6307,17 @@ function Render({
|
|
5963
6307
|
depth: 0,
|
5964
6308
|
path: []
|
5965
6309
|
},
|
5966
|
-
children: /* @__PURE__ */ (0,
|
6310
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
5967
6311
|
}
|
5968
6312
|
);
|
5969
6313
|
}
|
5970
6314
|
|
5971
6315
|
// components/Puck/components/Preview/index.tsx
|
5972
|
-
var
|
6316
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
5973
6317
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5974
6318
|
var useBubbleIframeEvents = (ref) => {
|
5975
6319
|
const { status } = useAppContext();
|
5976
|
-
(0,
|
6320
|
+
(0, import_react39.useEffect)(() => {
|
5977
6321
|
var _a;
|
5978
6322
|
if (ref.current && status === "READY") {
|
5979
6323
|
const iframe = ref.current;
|
@@ -6010,22 +6354,22 @@ var useBubbleIframeEvents = (ref) => {
|
|
6010
6354
|
}
|
6011
6355
|
}, [status]);
|
6012
6356
|
};
|
6013
|
-
var
|
6357
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
6014
6358
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6015
|
-
const Page = (0,
|
6359
|
+
const Page = (0, import_react39.useCallback)(
|
6016
6360
|
(pageProps) => {
|
6017
6361
|
var _a, _b;
|
6018
6362
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
6019
6363
|
id: "puck-root"
|
6020
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
6364
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
6021
6365
|
},
|
6022
6366
|
[config.root]
|
6023
6367
|
);
|
6024
|
-
const Frame = (0,
|
6368
|
+
const Frame = (0, import_react39.useMemo)(() => overrides.iframe, [overrides]);
|
6025
6369
|
const rootProps = state.data.root.props || state.data.root;
|
6026
|
-
const ref = (0,
|
6370
|
+
const ref = (0, import_react39.useRef)(null);
|
6027
6371
|
useBubbleIframeEvents(ref);
|
6028
|
-
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0,
|
6372
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6029
6373
|
Page,
|
6030
6374
|
__spreadProps(__spreadValues({}, rootProps), {
|
6031
6375
|
puck: {
|
@@ -6034,10 +6378,10 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6034
6378
|
dragRef: null
|
6035
6379
|
},
|
6036
6380
|
editMode: true,
|
6037
|
-
children: /* @__PURE__ */ (0,
|
6381
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
6038
6382
|
})
|
6039
|
-
) : /* @__PURE__ */ (0,
|
6040
|
-
return /* @__PURE__ */ (0,
|
6383
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
|
6384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6041
6385
|
"div",
|
6042
6386
|
{
|
6043
6387
|
className: getClassName23(),
|
@@ -6046,7 +6390,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6046
6390
|
onClick: () => {
|
6047
6391
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
6048
6392
|
},
|
6049
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
6393
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6050
6394
|
AutoFrame_default,
|
6051
6395
|
{
|
6052
6396
|
id: "preview-frame",
|
@@ -6056,14 +6400,14 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6056
6400
|
setStatus("READY");
|
6057
6401
|
},
|
6058
6402
|
frameRef: ref,
|
6059
|
-
children: /* @__PURE__ */ (0,
|
6403
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
6060
6404
|
if (Frame) {
|
6061
|
-
return /* @__PURE__ */ (0,
|
6405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
6062
6406
|
}
|
6063
6407
|
return inner;
|
6064
6408
|
} })
|
6065
6409
|
}
|
6066
|
-
) : /* @__PURE__ */ (0,
|
6410
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6067
6411
|
"div",
|
6068
6412
|
{
|
6069
6413
|
id: "preview-frame",
|
@@ -6120,7 +6464,7 @@ var scrollIntoView = (el) => {
|
|
6120
6464
|
};
|
6121
6465
|
|
6122
6466
|
// components/LayerTree/index.tsx
|
6123
|
-
var
|
6467
|
+
var import_react40 = require("react");
|
6124
6468
|
|
6125
6469
|
// lib/is-child-of-zone.ts
|
6126
6470
|
init_react_import();
|
@@ -6153,7 +6497,7 @@ var onScrollEnd = (frame, cb) => {
|
|
6153
6497
|
};
|
6154
6498
|
|
6155
6499
|
// components/LayerTree/index.tsx
|
6156
|
-
var
|
6500
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6157
6501
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6158
6502
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6159
6503
|
var LayerTree = ({
|
@@ -6166,15 +6510,15 @@ var LayerTree = ({
|
|
6166
6510
|
label
|
6167
6511
|
}) => {
|
6168
6512
|
const zones = data.zones || {};
|
6169
|
-
const ctx = (0,
|
6170
|
-
return /* @__PURE__ */ (0,
|
6171
|
-
label && /* @__PURE__ */ (0,
|
6172
|
-
/* @__PURE__ */ (0,
|
6513
|
+
const ctx = (0, import_react40.useContext)(dropZoneContext);
|
6514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6515
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6516
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
6173
6517
|
" ",
|
6174
6518
|
label
|
6175
6519
|
] }),
|
6176
|
-
/* @__PURE__ */ (0,
|
6177
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
6520
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
|
6521
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
6178
6522
|
zoneContent.map((item, i) => {
|
6179
6523
|
var _a;
|
6180
6524
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6187,7 +6531,7 @@ var LayerTree = ({
|
|
6187
6531
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
6188
6532
|
const componentConfig = config.components[item.type];
|
6189
6533
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
6190
|
-
return /* @__PURE__ */ (0,
|
6534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6191
6535
|
"li",
|
6192
6536
|
{
|
6193
6537
|
className: getClassNameLayer({
|
@@ -6197,7 +6541,7 @@ var LayerTree = ({
|
|
6197
6541
|
childIsSelected
|
6198
6542
|
}),
|
6199
6543
|
children: [
|
6200
|
-
/* @__PURE__ */ (0,
|
6544
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6201
6545
|
"button",
|
6202
6546
|
{
|
6203
6547
|
type: "button",
|
@@ -6236,22 +6580,22 @@ var LayerTree = ({
|
|
6236
6580
|
setHoveringComponent(null);
|
6237
6581
|
},
|
6238
6582
|
children: [
|
6239
|
-
containsZone && /* @__PURE__ */ (0,
|
6583
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6240
6584
|
"div",
|
6241
6585
|
{
|
6242
6586
|
className: getClassNameLayer("chevron"),
|
6243
6587
|
title: isSelected ? "Collapse" : "Expand",
|
6244
|
-
children: /* @__PURE__ */ (0,
|
6588
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
6245
6589
|
}
|
6246
6590
|
),
|
6247
|
-
/* @__PURE__ */ (0,
|
6248
|
-
/* @__PURE__ */ (0,
|
6249
|
-
/* @__PURE__ */ (0,
|
6591
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
6592
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(LayoutGrid, { size: "16" }) }),
|
6593
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
6250
6594
|
] })
|
6251
6595
|
]
|
6252
6596
|
}
|
6253
6597
|
) }),
|
6254
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
6598
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6255
6599
|
LayerTree,
|
6256
6600
|
{
|
6257
6601
|
config,
|
@@ -6273,13 +6617,13 @@ var LayerTree = ({
|
|
6273
6617
|
};
|
6274
6618
|
|
6275
6619
|
// components/Puck/components/Outline/index.tsx
|
6276
|
-
var
|
6277
|
-
var
|
6620
|
+
var import_react41 = require("react");
|
6621
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6278
6622
|
var Outline = () => {
|
6279
6623
|
const { dispatch, state, overrides, config } = useAppContext();
|
6280
6624
|
const { data, ui } = state;
|
6281
6625
|
const { itemSelector } = ui;
|
6282
|
-
const setItemSelector = (0,
|
6626
|
+
const setItemSelector = (0, import_react41.useCallback)(
|
6283
6627
|
(newItemSelector) => {
|
6284
6628
|
dispatch({
|
6285
6629
|
type: "setUi",
|
@@ -6288,9 +6632,9 @@ var Outline = () => {
|
|
6288
6632
|
},
|
6289
6633
|
[]
|
6290
6634
|
);
|
6291
|
-
const Wrapper = (0,
|
6292
|
-
return /* @__PURE__ */ (0,
|
6293
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
6635
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.outline || "div", [overrides]);
|
6636
|
+
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: [
|
6637
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6294
6638
|
LayerTree,
|
6295
6639
|
{
|
6296
6640
|
config,
|
@@ -6303,7 +6647,7 @@ var Outline = () => {
|
|
6303
6647
|
),
|
6304
6648
|
Object.entries(findZonesForArea(data, "root")).map(
|
6305
6649
|
([zoneKey, zone]) => {
|
6306
|
-
return /* @__PURE__ */ (0,
|
6650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6307
6651
|
LayerTree,
|
6308
6652
|
{
|
6309
6653
|
config,
|
@@ -6402,19 +6746,19 @@ function usePuckHistory({
|
|
6402
6746
|
|
6403
6747
|
// lib/use-history-store.ts
|
6404
6748
|
init_react_import();
|
6405
|
-
var
|
6749
|
+
var import_react42 = require("react");
|
6406
6750
|
var import_use_debounce3 = require("use-debounce");
|
6407
6751
|
var EMPTY_HISTORY_INDEX = 0;
|
6408
6752
|
function useHistoryStore(initialHistory) {
|
6409
6753
|
var _a, _b;
|
6410
|
-
const [histories, setHistories] = (0,
|
6754
|
+
const [histories, setHistories] = (0, import_react42.useState)(
|
6411
6755
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6412
6756
|
);
|
6413
6757
|
const updateHistories = (histories2) => {
|
6414
6758
|
setHistories(histories2);
|
6415
6759
|
setIndex(histories2.length - 1);
|
6416
6760
|
};
|
6417
|
-
const [index, setIndex] = (0,
|
6761
|
+
const [index, setIndex] = (0, import_react42.useState)(
|
6418
6762
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6419
6763
|
);
|
6420
6764
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6574,22 +6918,22 @@ var getBox = function getBox2(el) {
|
|
6574
6918
|
};
|
6575
6919
|
|
6576
6920
|
// components/Puck/components/Canvas/index.tsx
|
6577
|
-
var
|
6921
|
+
var import_react44 = require("react");
|
6578
6922
|
|
6579
6923
|
// components/ViewportControls/index.tsx
|
6580
6924
|
init_react_import();
|
6581
|
-
var
|
6925
|
+
var import_react43 = require("react");
|
6582
6926
|
|
6583
6927
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6584
6928
|
init_react_import();
|
6585
6929
|
var styles_module_default20 = { "ViewportControls": "_ViewportControls_g1wgg_1", "ViewportControls-divider": "_ViewportControls-divider_g1wgg_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_g1wgg_21", "ViewportButton--isActive": "_ViewportButton--isActive_g1wgg_34", "ViewportButton-inner": "_ViewportButton-inner_g1wgg_34" };
|
6586
6930
|
|
6587
6931
|
// components/ViewportControls/index.tsx
|
6588
|
-
var
|
6932
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
6589
6933
|
var icons = {
|
6590
|
-
Smartphone: /* @__PURE__ */ (0,
|
6591
|
-
Tablet: /* @__PURE__ */ (0,
|
6592
|
-
Monitor: /* @__PURE__ */ (0,
|
6934
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
|
6935
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
|
6936
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
|
6593
6937
|
};
|
6594
6938
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6595
6939
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6601,11 +6945,11 @@ var ViewportButton = ({
|
|
6601
6945
|
onClick
|
6602
6946
|
}) => {
|
6603
6947
|
const { state } = useAppContext();
|
6604
|
-
const [isActive, setIsActive] = (0,
|
6605
|
-
(0,
|
6948
|
+
const [isActive, setIsActive] = (0, import_react43.useState)(false);
|
6949
|
+
(0, import_react43.useEffect)(() => {
|
6606
6950
|
setIsActive(width === state.ui.viewports.current.width);
|
6607
6951
|
}, [width, state.ui.viewports.current.width]);
|
6608
|
-
return /* @__PURE__ */ (0,
|
6952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6609
6953
|
IconButton,
|
6610
6954
|
{
|
6611
6955
|
title,
|
@@ -6614,7 +6958,7 @@ var ViewportButton = ({
|
|
6614
6958
|
e.stopPropagation();
|
6615
6959
|
onClick({ width, height });
|
6616
6960
|
},
|
6617
|
-
children: /* @__PURE__ */ (0,
|
6961
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
|
6618
6962
|
}
|
6619
6963
|
) });
|
6620
6964
|
};
|
@@ -6638,7 +6982,7 @@ var ViewportControls = ({
|
|
6638
6982
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6639
6983
|
(option) => option.value === autoZoom
|
6640
6984
|
);
|
6641
|
-
const zoomOptions = (0,
|
6985
|
+
const zoomOptions = (0, import_react43.useMemo)(
|
6642
6986
|
() => [
|
6643
6987
|
...defaultZoomOptions,
|
6644
6988
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6650,8 +6994,8 @@ var ViewportControls = ({
|
|
6650
6994
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
6651
6995
|
[autoZoom]
|
6652
6996
|
);
|
6653
|
-
return /* @__PURE__ */ (0,
|
6654
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
6997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
|
6998
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6655
6999
|
ViewportButton,
|
6656
7000
|
{
|
6657
7001
|
height: viewport.height,
|
@@ -6662,8 +7006,8 @@ var ViewportControls = ({
|
|
6662
7006
|
},
|
6663
7007
|
i
|
6664
7008
|
)),
|
6665
|
-
/* @__PURE__ */ (0,
|
6666
|
-
/* @__PURE__ */ (0,
|
7009
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7010
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6667
7011
|
IconButton,
|
6668
7012
|
{
|
6669
7013
|
title: "Zoom viewport out",
|
@@ -6677,10 +7021,10 @@ var ViewportControls = ({
|
|
6677
7021
|
)].value
|
6678
7022
|
);
|
6679
7023
|
},
|
6680
|
-
children: /* @__PURE__ */ (0,
|
7024
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
|
6681
7025
|
}
|
6682
7026
|
),
|
6683
|
-
/* @__PURE__ */ (0,
|
7027
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6684
7028
|
IconButton,
|
6685
7029
|
{
|
6686
7030
|
title: "Zoom viewport in",
|
@@ -6694,11 +7038,11 @@ var ViewportControls = ({
|
|
6694
7038
|
)].value
|
6695
7039
|
);
|
6696
7040
|
},
|
6697
|
-
children: /* @__PURE__ */ (0,
|
7041
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
|
6698
7042
|
}
|
6699
7043
|
),
|
6700
|
-
/* @__PURE__ */ (0,
|
6701
|
-
/* @__PURE__ */ (0,
|
7044
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7045
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6702
7046
|
"select",
|
6703
7047
|
{
|
6704
7048
|
className: getClassName25("zoomSelect"),
|
@@ -6706,7 +7050,7 @@ var ViewportControls = ({
|
|
6706
7050
|
onChange: (e) => {
|
6707
7051
|
onZoom(parseFloat(e.currentTarget.value));
|
6708
7052
|
},
|
6709
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
7053
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6710
7054
|
"option",
|
6711
7055
|
{
|
6712
7056
|
value: option.value,
|
@@ -6754,24 +7098,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6754
7098
|
};
|
6755
7099
|
|
6756
7100
|
// components/Puck/components/Canvas/index.tsx
|
6757
|
-
var
|
7101
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
6758
7102
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6759
7103
|
var ZOOM_ON_CHANGE = true;
|
6760
7104
|
var Canvas = () => {
|
6761
7105
|
const { status, iframe } = useAppContext();
|
6762
7106
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6763
7107
|
const { ui } = state;
|
6764
|
-
const frameRef = (0,
|
6765
|
-
const [showTransition, setShowTransition] = (0,
|
6766
|
-
const defaultRender = (0,
|
6767
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
7108
|
+
const frameRef = (0, import_react44.useRef)(null);
|
7109
|
+
const [showTransition, setShowTransition] = (0, import_react44.useState)(false);
|
7110
|
+
const defaultRender = (0, import_react44.useMemo)(() => {
|
7111
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
6768
7112
|
return PuckDefault;
|
6769
7113
|
}, []);
|
6770
|
-
const CustomPreview = (0,
|
7114
|
+
const CustomPreview = (0, import_react44.useMemo)(
|
6771
7115
|
() => overrides.preview || defaultRender,
|
6772
7116
|
[overrides]
|
6773
7117
|
);
|
6774
|
-
const getFrameDimensions = (0,
|
7118
|
+
const getFrameDimensions = (0, import_react44.useCallback)(() => {
|
6775
7119
|
if (frameRef.current) {
|
6776
7120
|
const frame = frameRef.current;
|
6777
7121
|
const box = getBox(frame);
|
@@ -6779,7 +7123,7 @@ var Canvas = () => {
|
|
6779
7123
|
}
|
6780
7124
|
return { width: 0, height: 0 };
|
6781
7125
|
}, [frameRef]);
|
6782
|
-
const resetAutoZoom = (0,
|
7126
|
+
const resetAutoZoom = (0, import_react44.useCallback)(
|
6783
7127
|
(ui2 = state.ui) => {
|
6784
7128
|
if (frameRef.current) {
|
6785
7129
|
setZoomConfig(
|
@@ -6789,11 +7133,11 @@ var Canvas = () => {
|
|
6789
7133
|
},
|
6790
7134
|
[frameRef, zoomConfig, state.ui]
|
6791
7135
|
);
|
6792
|
-
(0,
|
7136
|
+
(0, import_react44.useEffect)(() => {
|
6793
7137
|
setShowTransition(false);
|
6794
7138
|
resetAutoZoom();
|
6795
7139
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6796
|
-
(0,
|
7140
|
+
(0, import_react44.useEffect)(() => {
|
6797
7141
|
const { height: frameHeight } = getFrameDimensions();
|
6798
7142
|
if (ui.viewports.current.height === "auto") {
|
6799
7143
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6801,13 +7145,13 @@ var Canvas = () => {
|
|
6801
7145
|
}));
|
6802
7146
|
}
|
6803
7147
|
}, [zoomConfig.zoom]);
|
6804
|
-
(0,
|
7148
|
+
(0, import_react44.useEffect)(() => {
|
6805
7149
|
if (ZOOM_ON_CHANGE) {
|
6806
7150
|
setShowTransition(true);
|
6807
7151
|
resetAutoZoom(ui);
|
6808
7152
|
}
|
6809
7153
|
}, [ui.viewports.current.width]);
|
6810
|
-
(0,
|
7154
|
+
(0, import_react44.useEffect)(() => {
|
6811
7155
|
const cb = () => {
|
6812
7156
|
setShowTransition(false);
|
6813
7157
|
resetAutoZoom();
|
@@ -6817,13 +7161,13 @@ var Canvas = () => {
|
|
6817
7161
|
window.removeEventListener("resize", cb);
|
6818
7162
|
};
|
6819
7163
|
}, []);
|
6820
|
-
const [showLoader, setShowLoader] = (0,
|
6821
|
-
(0,
|
7164
|
+
const [showLoader, setShowLoader] = (0, import_react44.useState)(false);
|
7165
|
+
(0, import_react44.useEffect)(() => {
|
6822
7166
|
setTimeout(() => {
|
6823
7167
|
setShowLoader(true);
|
6824
7168
|
}, 500);
|
6825
7169
|
}, []);
|
6826
|
-
return /* @__PURE__ */ (0,
|
7170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
6827
7171
|
"div",
|
6828
7172
|
{
|
6829
7173
|
className: getClassName26({
|
@@ -6836,7 +7180,7 @@ var Canvas = () => {
|
|
6836
7180
|
recordHistory: true
|
6837
7181
|
}),
|
6838
7182
|
children: [
|
6839
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
7183
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
6840
7184
|
ViewportControls,
|
6841
7185
|
{
|
6842
7186
|
autoZoom: zoomConfig.autoZoom,
|
@@ -6862,8 +7206,8 @@ var Canvas = () => {
|
|
6862
7206
|
}
|
6863
7207
|
}
|
6864
7208
|
) }),
|
6865
|
-
/* @__PURE__ */ (0,
|
6866
|
-
/* @__PURE__ */ (0,
|
7209
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7210
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
6867
7211
|
"div",
|
6868
7212
|
{
|
6869
7213
|
className: getClassName26("root"),
|
@@ -6884,10 +7228,10 @@ var Canvas = () => {
|
|
6884
7228
|
})
|
6885
7229
|
);
|
6886
7230
|
},
|
6887
|
-
children: /* @__PURE__ */ (0,
|
7231
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview2, {}) })
|
6888
7232
|
}
|
6889
7233
|
),
|
6890
|
-
/* @__PURE__ */ (0,
|
7234
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
6891
7235
|
] })
|
6892
7236
|
]
|
6893
7237
|
}
|
@@ -6896,7 +7240,7 @@ var Canvas = () => {
|
|
6896
7240
|
|
6897
7241
|
// lib/use-loaded-overrides.ts
|
6898
7242
|
init_react_import();
|
6899
|
-
var
|
7243
|
+
var import_react45 = require("react");
|
6900
7244
|
|
6901
7245
|
// lib/load-overrides.ts
|
6902
7246
|
init_react_import();
|
@@ -6935,26 +7279,26 @@ var useLoadedOverrides = ({
|
|
6935
7279
|
overrides,
|
6936
7280
|
plugins
|
6937
7281
|
}) => {
|
6938
|
-
return (0,
|
7282
|
+
return (0, import_react45.useMemo)(() => {
|
6939
7283
|
return loadOverrides({ overrides, plugins });
|
6940
7284
|
}, [plugins, overrides]);
|
6941
7285
|
};
|
6942
7286
|
|
6943
7287
|
// components/DefaultOverride/index.tsx
|
6944
7288
|
init_react_import();
|
6945
|
-
var
|
6946
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
7289
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7290
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
6947
7291
|
|
6948
7292
|
// lib/use-inject-css.ts
|
6949
7293
|
init_react_import();
|
6950
|
-
var
|
7294
|
+
var import_react46 = require("react");
|
6951
7295
|
var styles = ``;
|
6952
7296
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6953
|
-
const [el, setEl] = (0,
|
6954
|
-
(0,
|
7297
|
+
const [el, setEl] = (0, import_react46.useState)();
|
7298
|
+
(0, import_react46.useEffect)(() => {
|
6955
7299
|
setEl(document.createElement("style"));
|
6956
7300
|
}, []);
|
6957
|
-
(0,
|
7301
|
+
(0, import_react46.useEffect)(() => {
|
6958
7302
|
var _a;
|
6959
7303
|
if (!el || typeof window === "undefined") {
|
6960
7304
|
return;
|
@@ -6974,10 +7318,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
6974
7318
|
|
6975
7319
|
// lib/use-preview-mode-hotkeys.ts
|
6976
7320
|
init_react_import();
|
6977
|
-
var
|
7321
|
+
var import_react47 = require("react");
|
6978
7322
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
6979
7323
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
6980
|
-
const toggleInteractive = (0,
|
7324
|
+
const toggleInteractive = (0, import_react47.useCallback)(() => {
|
6981
7325
|
dispatch({
|
6982
7326
|
type: "setUi",
|
6983
7327
|
ui: (ui) => ({
|
@@ -7000,7 +7344,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
|
7000
7344
|
};
|
7001
7345
|
|
7002
7346
|
// components/Puck/index.tsx
|
7003
|
-
var
|
7347
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
7004
7348
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
7005
7349
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
7006
7350
|
function Puck({
|
@@ -7029,7 +7373,7 @@ function Puck({
|
|
7029
7373
|
waitForStyles: true
|
7030
7374
|
}, _iframe);
|
7031
7375
|
useInjectGlobalCss(iframe.enabled);
|
7032
|
-
const [generatedAppState] = (0,
|
7376
|
+
const [generatedAppState] = (0, import_react48.useState)(() => {
|
7033
7377
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7034
7378
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7035
7379
|
let clientUiState = {};
|
@@ -7101,14 +7445,14 @@ function Puck({
|
|
7101
7445
|
histories,
|
7102
7446
|
index: initialHistoryIndex
|
7103
7447
|
});
|
7104
|
-
const [reducer] = (0,
|
7448
|
+
const [reducer] = (0, import_react48.useState)(
|
7105
7449
|
() => createReducer({
|
7106
7450
|
config,
|
7107
7451
|
record: historyStore.record,
|
7108
7452
|
onAction
|
7109
7453
|
})
|
7110
7454
|
);
|
7111
|
-
const [appState, dispatch] = (0,
|
7455
|
+
const [appState, dispatch] = (0, import_react48.useReducer)(
|
7112
7456
|
reducer,
|
7113
7457
|
flushZones(initialAppState)
|
7114
7458
|
);
|
@@ -7119,14 +7463,14 @@ function Puck({
|
|
7119
7463
|
historyStore,
|
7120
7464
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7121
7465
|
});
|
7122
|
-
const [menuOpen, setMenuOpen] = (0,
|
7466
|
+
const [menuOpen, setMenuOpen] = (0, import_react48.useState)(false);
|
7123
7467
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7124
7468
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7125
|
-
(0,
|
7469
|
+
(0, import_react48.useEffect)(() => {
|
7126
7470
|
if (onChange) onChange(data);
|
7127
7471
|
}, [data]);
|
7128
7472
|
const rootProps = data.root.props || data.root;
|
7129
|
-
const toggleSidebars = (0,
|
7473
|
+
const toggleSidebars = (0, import_react48.useCallback)(
|
7130
7474
|
(sidebar) => {
|
7131
7475
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7132
7476
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7140,7 +7484,7 @@ function Puck({
|
|
7140
7484
|
},
|
7141
7485
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7142
7486
|
);
|
7143
|
-
(0,
|
7487
|
+
(0, import_react48.useEffect)(() => {
|
7144
7488
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7145
7489
|
dispatch({
|
7146
7490
|
type: "setUi",
|
@@ -7163,7 +7507,7 @@ function Puck({
|
|
7163
7507
|
window.removeEventListener("resize", handleResize);
|
7164
7508
|
};
|
7165
7509
|
}, []);
|
7166
|
-
const defaultHeaderRender = (0,
|
7510
|
+
const defaultHeaderRender = (0, import_react48.useMemo)(() => {
|
7167
7511
|
if (renderHeader) {
|
7168
7512
|
console.warn(
|
7169
7513
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7171,20 +7515,20 @@ function Puck({
|
|
7171
7515
|
const RenderHeader = (_a2) => {
|
7172
7516
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
7173
7517
|
const Comp = renderHeader;
|
7174
|
-
return /* @__PURE__ */ (0,
|
7518
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7175
7519
|
};
|
7176
7520
|
return RenderHeader;
|
7177
7521
|
}
|
7178
7522
|
return DefaultOverride;
|
7179
7523
|
}, [renderHeader]);
|
7180
|
-
const defaultHeaderActionsRender = (0,
|
7524
|
+
const defaultHeaderActionsRender = (0, import_react48.useMemo)(() => {
|
7181
7525
|
if (renderHeaderActions) {
|
7182
7526
|
console.warn(
|
7183
7527
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7184
7528
|
);
|
7185
7529
|
const RenderHeader = (props) => {
|
7186
7530
|
const Comp = renderHeaderActions;
|
7187
|
-
return /* @__PURE__ */ (0,
|
7531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7188
7532
|
};
|
7189
7533
|
return RenderHeader;
|
7190
7534
|
}
|
@@ -7194,27 +7538,27 @@ function Puck({
|
|
7194
7538
|
overrides,
|
7195
7539
|
plugins
|
7196
7540
|
});
|
7197
|
-
const CustomPuck = (0,
|
7541
|
+
const CustomPuck = (0, import_react48.useMemo)(
|
7198
7542
|
() => loadedOverrides.puck || DefaultOverride,
|
7199
7543
|
[loadedOverrides]
|
7200
7544
|
);
|
7201
|
-
const CustomHeader = (0,
|
7545
|
+
const CustomHeader = (0, import_react48.useMemo)(
|
7202
7546
|
() => loadedOverrides.header || defaultHeaderRender,
|
7203
7547
|
[loadedOverrides]
|
7204
7548
|
);
|
7205
|
-
const CustomHeaderActions = (0,
|
7549
|
+
const CustomHeaderActions = (0, import_react48.useMemo)(
|
7206
7550
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7207
7551
|
[loadedOverrides]
|
7208
7552
|
);
|
7209
|
-
const [mounted, setMounted] = (0,
|
7210
|
-
(0,
|
7553
|
+
const [mounted, setMounted] = (0, import_react48.useState)(false);
|
7554
|
+
(0, import_react48.useEffect)(() => {
|
7211
7555
|
setMounted(true);
|
7212
7556
|
}, []);
|
7213
7557
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7214
7558
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7215
7559
|
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7216
|
-
return /* @__PURE__ */ (0,
|
7217
|
-
/* @__PURE__ */ (0,
|
7560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
7561
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7218
7562
|
AppProvider,
|
7219
7563
|
{
|
7220
7564
|
value: {
|
@@ -7236,7 +7580,7 @@ function Puck({
|
|
7236
7580
|
getPermissions: () => ({}),
|
7237
7581
|
refreshPermissions: () => null
|
7238
7582
|
},
|
7239
|
-
children: /* @__PURE__ */ (0,
|
7583
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7240
7584
|
"div",
|
7241
7585
|
{
|
7242
7586
|
className: getLayoutClassName({
|
@@ -7245,60 +7589,60 @@ function Puck({
|
|
7245
7589
|
mounted,
|
7246
7590
|
rightSideBarVisible
|
7247
7591
|
}),
|
7248
|
-
children: /* @__PURE__ */ (0,
|
7249
|
-
/* @__PURE__ */ (0,
|
7592
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
7593
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7250
7594
|
CustomHeader,
|
7251
7595
|
{
|
7252
|
-
actions: /* @__PURE__ */ (0,
|
7596
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7253
7597
|
Button,
|
7254
7598
|
{
|
7255
7599
|
onClick: () => {
|
7256
7600
|
onPublish && onPublish(data);
|
7257
7601
|
},
|
7258
|
-
icon: /* @__PURE__ */ (0,
|
7602
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7259
7603
|
children: "Publish"
|
7260
7604
|
}
|
7261
7605
|
) }) }),
|
7262
|
-
children: /* @__PURE__ */ (0,
|
7263
|
-
/* @__PURE__ */ (0,
|
7264
|
-
/* @__PURE__ */ (0,
|
7606
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
7607
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
|
7608
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7265
7609
|
"div",
|
7266
7610
|
{
|
7267
7611
|
className: getLayoutClassName("leftSideBarToggle"),
|
7268
|
-
children: /* @__PURE__ */ (0,
|
7612
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7269
7613
|
IconButton,
|
7270
7614
|
{
|
7271
7615
|
onClick: () => {
|
7272
7616
|
toggleSidebars("left");
|
7273
7617
|
},
|
7274
7618
|
title: "Toggle left sidebar",
|
7275
|
-
children: /* @__PURE__ */ (0,
|
7619
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
7276
7620
|
}
|
7277
7621
|
)
|
7278
7622
|
}
|
7279
7623
|
),
|
7280
|
-
/* @__PURE__ */ (0,
|
7624
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7281
7625
|
"div",
|
7282
7626
|
{
|
7283
7627
|
className: getLayoutClassName("rightSideBarToggle"),
|
7284
|
-
children: /* @__PURE__ */ (0,
|
7628
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7285
7629
|
IconButton,
|
7286
7630
|
{
|
7287
7631
|
onClick: () => {
|
7288
7632
|
toggleSidebars("right");
|
7289
7633
|
},
|
7290
7634
|
title: "Toggle right sidebar",
|
7291
|
-
children: /* @__PURE__ */ (0,
|
7635
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
7292
7636
|
}
|
7293
7637
|
)
|
7294
7638
|
}
|
7295
7639
|
)
|
7296
7640
|
] }),
|
7297
|
-
/* @__PURE__ */ (0,
|
7641
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
7298
7642
|
headerTitle || rootProps.title || "Page",
|
7299
|
-
headerPath && /* @__PURE__ */ (0,
|
7643
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
7300
7644
|
" ",
|
7301
|
-
/* @__PURE__ */ (0,
|
7645
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7302
7646
|
"code",
|
7303
7647
|
{
|
7304
7648
|
className: getLayoutClassName("headerPath"),
|
@@ -7307,31 +7651,31 @@ function Puck({
|
|
7307
7651
|
)
|
7308
7652
|
] })
|
7309
7653
|
] }) }),
|
7310
|
-
/* @__PURE__ */ (0,
|
7311
|
-
/* @__PURE__ */ (0,
|
7654
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
|
7655
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7312
7656
|
IconButton,
|
7313
7657
|
{
|
7314
7658
|
onClick: () => {
|
7315
7659
|
return setMenuOpen(!menuOpen);
|
7316
7660
|
},
|
7317
7661
|
title: "Toggle menu bar",
|
7318
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
7662
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
7319
7663
|
}
|
7320
7664
|
) }),
|
7321
|
-
/* @__PURE__ */ (0,
|
7665
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7322
7666
|
MenuBar,
|
7323
7667
|
{
|
7324
7668
|
appState,
|
7325
7669
|
dispatch,
|
7326
7670
|
onPublish,
|
7327
7671
|
menuOpen,
|
7328
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
7672
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7329
7673
|
Button,
|
7330
7674
|
{
|
7331
7675
|
onClick: () => {
|
7332
7676
|
onPublish && onPublish(data);
|
7333
7677
|
},
|
7334
|
-
icon: /* @__PURE__ */ (0,
|
7678
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7335
7679
|
children: "Publish"
|
7336
7680
|
}
|
7337
7681
|
) }),
|
@@ -7342,19 +7686,19 @@ function Puck({
|
|
7342
7686
|
] }) })
|
7343
7687
|
}
|
7344
7688
|
),
|
7345
|
-
/* @__PURE__ */ (0,
|
7346
|
-
/* @__PURE__ */ (0,
|
7347
|
-
/* @__PURE__ */ (0,
|
7689
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7690
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
|
7691
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
|
7348
7692
|
] }),
|
7349
|
-
/* @__PURE__ */ (0,
|
7350
|
-
/* @__PURE__ */ (0,
|
7693
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
|
7694
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7351
7695
|
SidebarSection,
|
7352
7696
|
{
|
7353
7697
|
noPadding: true,
|
7354
7698
|
noBorderTop: true,
|
7355
7699
|
showBreadcrumbs: true,
|
7356
7700
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7357
|
-
children: /* @__PURE__ */ (0,
|
7701
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
|
7358
7702
|
}
|
7359
7703
|
) })
|
7360
7704
|
] })
|
@@ -7362,13 +7706,13 @@ function Puck({
|
|
7362
7706
|
) }) })
|
7363
7707
|
}
|
7364
7708
|
),
|
7365
|
-
/* @__PURE__ */ (0,
|
7709
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7366
7710
|
] });
|
7367
7711
|
}
|
7368
7712
|
Puck.Components = Components;
|
7369
7713
|
Puck.Fields = Fields;
|
7370
7714
|
Puck.Outline = Outline;
|
7371
|
-
Puck.Preview =
|
7715
|
+
Puck.Preview = Preview2;
|
7372
7716
|
|
7373
7717
|
// lib/migrate.ts
|
7374
7718
|
init_react_import();
|