@measured/puck 0.18.0-canary.beb05b5 → 0.18.0-canary.c6df5b2
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 +1158 -867
- package/dist/index.mjs +1072 -778
- 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"),
|
@@ -1681,11 +1741,11 @@ var DefaultField = ({
|
|
1681
1741
|
|
1682
1742
|
// components/AutoField/fields/ExternalField/index.tsx
|
1683
1743
|
init_react_import();
|
1684
|
-
var
|
1744
|
+
var import_react16 = require("react");
|
1685
1745
|
|
1686
1746
|
// components/ExternalInput/index.tsx
|
1687
1747
|
init_react_import();
|
1688
|
-
var
|
1748
|
+
var import_react15 = require("react");
|
1689
1749
|
|
1690
1750
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
1691
1751
|
init_react_import();
|
@@ -1693,7 +1753,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
1693
1753
|
|
1694
1754
|
// components/Modal/index.tsx
|
1695
1755
|
init_react_import();
|
1696
|
-
var
|
1756
|
+
var import_react13 = require("react");
|
1697
1757
|
|
1698
1758
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
1699
1759
|
init_react_import();
|
@@ -1701,22 +1761,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1701
1761
|
|
1702
1762
|
// components/Modal/index.tsx
|
1703
1763
|
var import_react_dom = require("react-dom");
|
1704
|
-
var
|
1764
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
1705
1765
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1706
1766
|
var Modal = ({
|
1707
1767
|
children,
|
1708
1768
|
onClose,
|
1709
1769
|
isOpen
|
1710
1770
|
}) => {
|
1711
|
-
const [rootEl, setRootEl] = (0,
|
1712
|
-
(0,
|
1771
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
1772
|
+
(0, import_react13.useEffect)(() => {
|
1713
1773
|
setRootEl(document.getElementById("puck-portal-root"));
|
1714
1774
|
}, []);
|
1715
1775
|
if (!rootEl) {
|
1716
|
-
return /* @__PURE__ */ (0,
|
1776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
|
1717
1777
|
}
|
1718
1778
|
return (0, import_react_dom.createPortal)(
|
1719
|
-
/* @__PURE__ */ (0,
|
1779
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1720
1780
|
"div",
|
1721
1781
|
{
|
1722
1782
|
className: getClassName7("inner"),
|
@@ -1736,11 +1796,11 @@ init_react_import();
|
|
1736
1796
|
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
1797
|
|
1738
1798
|
// components/Heading/index.tsx
|
1739
|
-
var
|
1799
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
1740
1800
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1741
1801
|
var Heading = ({ children, rank, size = "m" }) => {
|
1742
1802
|
const Tag = rank ? `h${rank}` : "span";
|
1743
|
-
return /* @__PURE__ */ (0,
|
1803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
1744
1804
|
Tag,
|
1745
1805
|
{
|
1746
1806
|
className: getClassName8({
|
@@ -1756,7 +1816,7 @@ init_react_import();
|
|
1756
1816
|
|
1757
1817
|
// components/Button/Button.tsx
|
1758
1818
|
init_react_import();
|
1759
|
-
var
|
1819
|
+
var import_react14 = require("react");
|
1760
1820
|
|
1761
1821
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
1762
1822
|
init_react_import();
|
@@ -1776,7 +1836,7 @@ var filterDataAttrs = (props) => {
|
|
1776
1836
|
};
|
1777
1837
|
|
1778
1838
|
// components/Button/Button.tsx
|
1779
|
-
var
|
1839
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
1780
1840
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1781
1841
|
var Button = (_a) => {
|
1782
1842
|
var _b = _a, {
|
@@ -1806,11 +1866,11 @@ var Button = (_a) => {
|
|
1806
1866
|
"size",
|
1807
1867
|
"loading"
|
1808
1868
|
]);
|
1809
|
-
const [loading, setLoading] = (0,
|
1810
|
-
(0,
|
1869
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
1870
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
1811
1871
|
const ElementType = href ? "a" : type ? "button" : "span";
|
1812
1872
|
const dataAttrs = filterDataAttrs(props);
|
1813
|
-
const el = /* @__PURE__ */ (0,
|
1873
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
1814
1874
|
ElementType,
|
1815
1875
|
__spreadProps(__spreadValues({
|
1816
1876
|
className: getClassName9({
|
@@ -1835,9 +1895,9 @@ var Button = (_a) => {
|
|
1835
1895
|
href
|
1836
1896
|
}, dataAttrs), {
|
1837
1897
|
children: [
|
1838
|
-
icon && /* @__PURE__ */ (0,
|
1898
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
1839
1899
|
children,
|
1840
|
-
loading && /* @__PURE__ */ (0,
|
1900
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 14 }) })
|
1841
1901
|
]
|
1842
1902
|
})
|
1843
1903
|
);
|
@@ -1845,7 +1905,7 @@ var Button = (_a) => {
|
|
1845
1905
|
};
|
1846
1906
|
|
1847
1907
|
// components/ExternalInput/index.tsx
|
1848
|
-
var
|
1908
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
1849
1909
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1850
1910
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1851
1911
|
var dataCache = {};
|
@@ -1862,28 +1922,28 @@ var ExternalInput = ({
|
|
1862
1922
|
mapRow = (val) => val,
|
1863
1923
|
filterFields
|
1864
1924
|
} = field || {};
|
1865
|
-
const [data, setData] = (0,
|
1866
|
-
const [isOpen, setOpen] = (0,
|
1867
|
-
const [isLoading, setIsLoading] = (0,
|
1925
|
+
const [data, setData] = (0, import_react15.useState)([]);
|
1926
|
+
const [isOpen, setOpen] = (0, import_react15.useState)(false);
|
1927
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
|
1868
1928
|
const hasFilterFields = !!filterFields;
|
1869
|
-
const [filters, setFilters] = (0,
|
1870
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
1871
|
-
const mappedData = (0,
|
1929
|
+
const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
|
1930
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
|
1931
|
+
const mappedData = (0, import_react15.useMemo)(() => {
|
1872
1932
|
return data.map(mapRow);
|
1873
1933
|
}, [data]);
|
1874
|
-
const keys = (0,
|
1934
|
+
const keys = (0, import_react15.useMemo)(() => {
|
1875
1935
|
const validKeys = /* @__PURE__ */ new Set();
|
1876
1936
|
for (const item of mappedData) {
|
1877
1937
|
for (const key of Object.keys(item)) {
|
1878
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
1938
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
|
1879
1939
|
validKeys.add(key);
|
1880
1940
|
}
|
1881
1941
|
}
|
1882
1942
|
}
|
1883
1943
|
return Array.from(validKeys);
|
1884
1944
|
}, [mappedData]);
|
1885
|
-
const [searchQuery, setSearchQuery] = (0,
|
1886
|
-
const search = (0,
|
1945
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
1946
|
+
const search = (0, import_react15.useCallback)(
|
1887
1947
|
(query, filters2) => __async(void 0, null, function* () {
|
1888
1948
|
setIsLoading(true);
|
1889
1949
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -1896,18 +1956,18 @@ var ExternalInput = ({
|
|
1896
1956
|
}),
|
1897
1957
|
[id, field]
|
1898
1958
|
);
|
1899
|
-
const Footer = (0,
|
1900
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
1959
|
+
const Footer = (0, import_react15.useCallback)(
|
1960
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
1901
1961
|
props.items.length,
|
1902
1962
|
" result",
|
1903
1963
|
props.items.length === 1 ? "" : "s"
|
1904
1964
|
] }),
|
1905
1965
|
[field.renderFooter]
|
1906
1966
|
);
|
1907
|
-
(0,
|
1967
|
+
(0, import_react15.useEffect)(() => {
|
1908
1968
|
search(searchQuery, filters);
|
1909
1969
|
}, []);
|
1910
|
-
return /* @__PURE__ */ (0,
|
1970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1911
1971
|
"div",
|
1912
1972
|
{
|
1913
1973
|
className: getClassName10({
|
@@ -1917,21 +1977,21 @@ var ExternalInput = ({
|
|
1917
1977
|
}),
|
1918
1978
|
id,
|
1919
1979
|
children: [
|
1920
|
-
/* @__PURE__ */ (0,
|
1921
|
-
/* @__PURE__ */ (0,
|
1980
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("actions"), children: [
|
1981
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1922
1982
|
"button",
|
1923
1983
|
{
|
1924
1984
|
type: "button",
|
1925
1985
|
onClick: () => setOpen(true),
|
1926
1986
|
className: getClassName10("button"),
|
1927
1987
|
disabled: readOnly,
|
1928
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
1929
|
-
/* @__PURE__ */ (0,
|
1930
|
-
/* @__PURE__ */ (0,
|
1988
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
1989
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: "16" }),
|
1990
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: field.placeholder })
|
1931
1991
|
] })
|
1932
1992
|
}
|
1933
1993
|
),
|
1934
|
-
value && /* @__PURE__ */ (0,
|
1994
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1935
1995
|
"button",
|
1936
1996
|
{
|
1937
1997
|
type: "button",
|
@@ -1940,11 +2000,11 @@ var ExternalInput = ({
|
|
1940
2000
|
onChange(null);
|
1941
2001
|
},
|
1942
2002
|
disabled: readOnly,
|
1943
|
-
children: /* @__PURE__ */ (0,
|
2003
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LockOpen, { size: 16 })
|
1944
2004
|
}
|
1945
2005
|
)
|
1946
2006
|
] }),
|
1947
|
-
/* @__PURE__ */ (0,
|
2007
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1948
2008
|
"form",
|
1949
2009
|
{
|
1950
2010
|
className: getClassNameModal({
|
@@ -1958,11 +2018,11 @@ var ExternalInput = ({
|
|
1958
2018
|
search(searchQuery, filters);
|
1959
2019
|
},
|
1960
2020
|
children: [
|
1961
|
-
/* @__PURE__ */ (0,
|
1962
|
-
/* @__PURE__ */ (0,
|
1963
|
-
/* @__PURE__ */ (0,
|
1964
|
-
/* @__PURE__ */ (0,
|
1965
|
-
/* @__PURE__ */ (0,
|
2021
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
2022
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: getClassNameModal("search"), children: [
|
2023
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
2024
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Search, { size: "18" }) }),
|
2025
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1966
2026
|
"input",
|
1967
2027
|
{
|
1968
2028
|
className: getClassNameModal("searchInput"),
|
@@ -1977,9 +2037,9 @@ var ExternalInput = ({
|
|
1977
2037
|
}
|
1978
2038
|
)
|
1979
2039
|
] }),
|
1980
|
-
/* @__PURE__ */ (0,
|
1981
|
-
/* @__PURE__ */ (0,
|
1982
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2040
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
2041
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
2042
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1983
2043
|
IconButton,
|
1984
2044
|
{
|
1985
2045
|
title: "Toggle filters",
|
@@ -1988,15 +2048,15 @@ var ExternalInput = ({
|
|
1988
2048
|
e.stopPropagation();
|
1989
2049
|
setFiltersToggled(!filtersToggled);
|
1990
2050
|
},
|
1991
|
-
children: /* @__PURE__ */ (0,
|
2051
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SlidersHorizontal, { size: 20 })
|
1992
2052
|
}
|
1993
2053
|
) })
|
1994
2054
|
] })
|
1995
|
-
] }) : /* @__PURE__ */ (0,
|
1996
|
-
/* @__PURE__ */ (0,
|
1997
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2055
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
2056
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
2057
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
1998
2058
|
const filterField = filterFields[fieldName];
|
1999
|
-
return /* @__PURE__ */ (0,
|
2059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2000
2060
|
AutoFieldPrivate,
|
2001
2061
|
{
|
2002
2062
|
field: filterField,
|
@@ -2013,9 +2073,9 @@ var ExternalInput = ({
|
|
2013
2073
|
fieldName
|
2014
2074
|
);
|
2015
2075
|
}) }),
|
2016
|
-
/* @__PURE__ */ (0,
|
2017
|
-
/* @__PURE__ */ (0,
|
2018
|
-
/* @__PURE__ */ (0,
|
2076
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
2077
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: getClassNameModal("table"), children: [
|
2078
|
+
/* @__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
2079
|
"th",
|
2020
2080
|
{
|
2021
2081
|
className: getClassNameModal("th"),
|
@@ -2024,8 +2084,8 @@ var ExternalInput = ({
|
|
2024
2084
|
},
|
2025
2085
|
key
|
2026
2086
|
)) }) }),
|
2027
|
-
/* @__PURE__ */ (0,
|
2028
|
-
return /* @__PURE__ */ (0,
|
2087
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
2088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2029
2089
|
"tr",
|
2030
2090
|
{
|
2031
2091
|
style: { whiteSpace: "nowrap" },
|
@@ -2034,16 +2094,16 @@ var ExternalInput = ({
|
|
2034
2094
|
onChange(mapProp(data[i]));
|
2035
2095
|
setOpen(false);
|
2036
2096
|
},
|
2037
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
2097
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
2038
2098
|
},
|
2039
2099
|
i
|
2040
2100
|
);
|
2041
2101
|
}) })
|
2042
2102
|
] }),
|
2043
|
-
/* @__PURE__ */ (0,
|
2103
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 24 }) })
|
2044
2104
|
] })
|
2045
2105
|
] }),
|
2046
|
-
/* @__PURE__ */ (0,
|
2106
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footer, { items: mappedData }) })
|
2047
2107
|
]
|
2048
2108
|
}
|
2049
2109
|
) })
|
@@ -2053,7 +2113,7 @@ var ExternalInput = ({
|
|
2053
2113
|
};
|
2054
2114
|
|
2055
2115
|
// components/AutoField/fields/ExternalField/index.tsx
|
2056
|
-
var
|
2116
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
2057
2117
|
var ExternalField = ({
|
2058
2118
|
field,
|
2059
2119
|
onChange,
|
@@ -2067,7 +2127,7 @@ var ExternalField = ({
|
|
2067
2127
|
var _a, _b, _c;
|
2068
2128
|
const validField = field;
|
2069
2129
|
const deprecatedField = field;
|
2070
|
-
(0,
|
2130
|
+
(0, import_react16.useEffect)(() => {
|
2071
2131
|
if (deprecatedField.adaptor) {
|
2072
2132
|
console.error(
|
2073
2133
|
"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 +2137,7 @@ var ExternalField = ({
|
|
2077
2137
|
if (field.type !== "external") {
|
2078
2138
|
return null;
|
2079
2139
|
}
|
2080
|
-
return /* @__PURE__ */ (0,
|
2140
|
+
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
2141
|
ExternalInput,
|
2082
2142
|
{
|
2083
2143
|
name,
|
@@ -2102,7 +2162,7 @@ var ExternalField = ({
|
|
2102
2162
|
|
2103
2163
|
// components/AutoField/fields/RadioField/index.tsx
|
2104
2164
|
init_react_import();
|
2105
|
-
var
|
2165
|
+
var import_react17 = require("react");
|
2106
2166
|
|
2107
2167
|
// lib/safe-json-parse.ts
|
2108
2168
|
init_react_import();
|
@@ -2116,7 +2176,7 @@ var safeJsonParse = (str) => {
|
|
2116
2176
|
};
|
2117
2177
|
|
2118
2178
|
// components/AutoField/fields/RadioField/index.tsx
|
2119
|
-
var
|
2179
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
2120
2180
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
2121
2181
|
var RadioField = ({
|
2122
2182
|
field,
|
@@ -2128,26 +2188,26 @@ var RadioField = ({
|
|
2128
2188
|
label,
|
2129
2189
|
Label: Label2
|
2130
2190
|
}) => {
|
2131
|
-
const flatOptions = (0,
|
2191
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2132
2192
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2133
2193
|
[field]
|
2134
2194
|
);
|
2135
2195
|
if (field.type !== "radio" || !field.options) {
|
2136
2196
|
return null;
|
2137
2197
|
}
|
2138
|
-
return /* @__PURE__ */ (0,
|
2198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2139
2199
|
Label2,
|
2140
2200
|
{
|
2141
|
-
icon: /* @__PURE__ */ (0,
|
2201
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CircleCheckBig, { size: 16 }),
|
2142
2202
|
label: label || name,
|
2143
2203
|
readOnly,
|
2144
2204
|
el: "div",
|
2145
|
-
children: /* @__PURE__ */ (0,
|
2205
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
2146
2206
|
"label",
|
2147
2207
|
{
|
2148
2208
|
className: getClassName11("radio"),
|
2149
2209
|
children: [
|
2150
|
-
/* @__PURE__ */ (0,
|
2210
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2151
2211
|
"input",
|
2152
2212
|
{
|
2153
2213
|
type: "radio",
|
@@ -2167,7 +2227,7 @@ var RadioField = ({
|
|
2167
2227
|
checked: value === option.value
|
2168
2228
|
}
|
2169
2229
|
),
|
2170
|
-
/* @__PURE__ */ (0,
|
2230
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
2171
2231
|
]
|
2172
2232
|
},
|
2173
2233
|
option.label + option.value
|
@@ -2178,8 +2238,8 @@ var RadioField = ({
|
|
2178
2238
|
|
2179
2239
|
// components/AutoField/fields/SelectField/index.tsx
|
2180
2240
|
init_react_import();
|
2181
|
-
var
|
2182
|
-
var
|
2241
|
+
var import_react18 = require("react");
|
2242
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2183
2243
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2184
2244
|
var SelectField = ({
|
2185
2245
|
field,
|
@@ -2191,20 +2251,20 @@ var SelectField = ({
|
|
2191
2251
|
readOnly,
|
2192
2252
|
id
|
2193
2253
|
}) => {
|
2194
|
-
const flatOptions = (0,
|
2254
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2195
2255
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2196
2256
|
[field]
|
2197
2257
|
);
|
2198
2258
|
if (field.type !== "select" || !field.options) {
|
2199
2259
|
return null;
|
2200
2260
|
}
|
2201
|
-
return /* @__PURE__ */ (0,
|
2261
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2202
2262
|
Label2,
|
2203
2263
|
{
|
2204
2264
|
label: label || name,
|
2205
|
-
icon: /* @__PURE__ */ (0,
|
2265
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronDown, { size: 16 }),
|
2206
2266
|
readOnly,
|
2207
|
-
children: /* @__PURE__ */ (0,
|
2267
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2208
2268
|
"select",
|
2209
2269
|
{
|
2210
2270
|
id,
|
@@ -2221,7 +2281,7 @@ var SelectField = ({
|
|
2221
2281
|
}
|
2222
2282
|
},
|
2223
2283
|
value,
|
2224
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
2284
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2225
2285
|
"option",
|
2226
2286
|
{
|
2227
2287
|
label: option.label,
|
@@ -2237,7 +2297,7 @@ var SelectField = ({
|
|
2237
2297
|
|
2238
2298
|
// components/AutoField/fields/TextareaField/index.tsx
|
2239
2299
|
init_react_import();
|
2240
|
-
var
|
2300
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
2241
2301
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2242
2302
|
var TextareaField = ({
|
2243
2303
|
onChange,
|
@@ -2248,7 +2308,7 @@ var TextareaField = ({
|
|
2248
2308
|
Label: Label2,
|
2249
2309
|
id
|
2250
2310
|
}) => {
|
2251
|
-
return /* @__PURE__ */ (0,
|
2311
|
+
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
2312
|
"textarea",
|
2253
2313
|
{
|
2254
2314
|
id,
|
@@ -2275,7 +2335,7 @@ init_react_import();
|
|
2275
2335
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2276
2336
|
|
2277
2337
|
// components/AutoField/fields/ObjectField/index.tsx
|
2278
|
-
var
|
2338
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
2279
2339
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2280
2340
|
var ObjectField = ({
|
2281
2341
|
field,
|
@@ -2287,43 +2347,54 @@ var ObjectField = ({
|
|
2287
2347
|
readOnly,
|
2288
2348
|
id
|
2289
2349
|
}) => {
|
2290
|
-
const {
|
2350
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2291
2351
|
if (field.type !== "object" || !field.objectFields) {
|
2292
2352
|
return null;
|
2293
2353
|
}
|
2294
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2295
2354
|
const data = value || {};
|
2296
|
-
return /* @__PURE__ */ (0,
|
2355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2297
2356
|
Label2,
|
2298
2357
|
{
|
2299
2358
|
label: label || name,
|
2300
|
-
icon: /* @__PURE__ */ (0,
|
2359
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EllipsisVertical, { size: 16 }),
|
2301
2360
|
el: "div",
|
2302
2361
|
readOnly,
|
2303
|
-
children: /* @__PURE__ */ (0,
|
2304
|
-
const subField = field.objectFields[
|
2305
|
-
const
|
2306
|
-
const
|
2307
|
-
const subReadOnly = readOnly ? readOnly :
|
2308
|
-
|
2309
|
-
|
2362
|
+
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) => {
|
2363
|
+
const subField = field.objectFields[subName];
|
2364
|
+
const subPath = `${name}.${subName}`;
|
2365
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2366
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2367
|
+
const label2 = subField.label || subName;
|
2368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2369
|
+
NestedFieldProvider,
|
2310
2370
|
{
|
2311
|
-
name:
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2371
|
+
name: localName || id,
|
2372
|
+
subName,
|
2373
|
+
readOnlyFields,
|
2374
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2375
|
+
AutoFieldPrivate,
|
2376
|
+
{
|
2377
|
+
name: subPath,
|
2378
|
+
label: subPath,
|
2379
|
+
id: `${id}_${subName}`,
|
2380
|
+
readOnly: subReadOnly,
|
2381
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2382
|
+
label: label2
|
2383
|
+
// May be used by custom fields
|
2321
2384
|
}),
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2385
|
+
value: data[subName],
|
2386
|
+
onChange: (val, ui) => {
|
2387
|
+
onChange(
|
2388
|
+
__spreadProps(__spreadValues({}, data), {
|
2389
|
+
[subName]: val
|
2390
|
+
}),
|
2391
|
+
ui
|
2392
|
+
);
|
2393
|
+
}
|
2394
|
+
}
|
2395
|
+
)
|
2325
2396
|
},
|
2326
|
-
|
2397
|
+
subPath
|
2327
2398
|
);
|
2328
2399
|
}) }) })
|
2329
2400
|
}
|
@@ -2332,7 +2403,7 @@ var ObjectField = ({
|
|
2332
2403
|
|
2333
2404
|
// lib/use-safe-id.ts
|
2334
2405
|
init_react_import();
|
2335
|
-
var
|
2406
|
+
var import_react19 = __toESM(require("react"));
|
2336
2407
|
|
2337
2408
|
// lib/generate-id.ts
|
2338
2409
|
init_react_import();
|
@@ -2341,15 +2412,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
2341
2412
|
|
2342
2413
|
// lib/use-safe-id.ts
|
2343
2414
|
var useSafeId = () => {
|
2344
|
-
if (typeof
|
2345
|
-
return
|
2415
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
2416
|
+
return import_react19.default.useId();
|
2346
2417
|
}
|
2347
|
-
const [id] = (0,
|
2418
|
+
const [id] = (0, import_react19.useState)(generateId());
|
2348
2419
|
return id;
|
2349
2420
|
};
|
2350
2421
|
|
2351
2422
|
// components/AutoField/index.tsx
|
2352
|
-
var
|
2423
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
2353
2424
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2354
2425
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2355
2426
|
var FieldLabel = ({
|
@@ -2361,16 +2432,16 @@ var FieldLabel = ({
|
|
2361
2432
|
className
|
2362
2433
|
}) => {
|
2363
2434
|
const El = el;
|
2364
|
-
return /* @__PURE__ */ (0,
|
2365
|
-
/* @__PURE__ */ (0,
|
2366
|
-
icon ? /* @__PURE__ */ (0,
|
2435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(El, { className, children: [
|
2436
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName15("label"), children: [
|
2437
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {}),
|
2367
2438
|
label,
|
2368
|
-
readOnly && /* @__PURE__ */ (0,
|
2439
|
+
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
2440
|
] }),
|
2370
2441
|
children
|
2371
2442
|
] });
|
2372
2443
|
};
|
2373
|
-
var
|
2444
|
+
var FieldLabelInternal = ({
|
2374
2445
|
children,
|
2375
2446
|
icon,
|
2376
2447
|
label,
|
@@ -2378,14 +2449,14 @@ var FieldLabelInternal2 = ({
|
|
2378
2449
|
readOnly
|
2379
2450
|
}) => {
|
2380
2451
|
const { overrides } = useAppContext();
|
2381
|
-
const Wrapper = (0,
|
2452
|
+
const Wrapper = (0, import_react20.useMemo)(
|
2382
2453
|
() => overrides.fieldLabel || FieldLabel,
|
2383
2454
|
[overrides]
|
2384
2455
|
);
|
2385
2456
|
if (!label) {
|
2386
|
-
return /* @__PURE__ */ (0,
|
2457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
2387
2458
|
}
|
2388
|
-
return /* @__PURE__ */ (0,
|
2459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2389
2460
|
Wrapper,
|
2390
2461
|
{
|
2391
2462
|
label,
|
@@ -2399,8 +2470,8 @@ var FieldLabelInternal2 = ({
|
|
2399
2470
|
};
|
2400
2471
|
function AutoFieldInternal(props) {
|
2401
2472
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2402
|
-
const { dispatch, overrides } = useAppContext();
|
2403
|
-
const { id, Label: Label2 =
|
2473
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2474
|
+
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2404
2475
|
const field = props.field;
|
2405
2476
|
const label = field.label;
|
2406
2477
|
const defaultId = useSafeId();
|
@@ -2431,7 +2502,7 @@ function AutoFieldInternal(props) {
|
|
2431
2502
|
Label: Label2,
|
2432
2503
|
id: resolvedId
|
2433
2504
|
});
|
2434
|
-
const onFocus = (0,
|
2505
|
+
const onFocus = (0, import_react20.useCallback)(
|
2435
2506
|
(e) => {
|
2436
2507
|
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
2437
2508
|
e.stopPropagation();
|
@@ -2445,7 +2516,7 @@ function AutoFieldInternal(props) {
|
|
2445
2516
|
},
|
2446
2517
|
[mergedProps.name]
|
2447
2518
|
);
|
2448
|
-
const onBlur = (0,
|
2519
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
2449
2520
|
if ("name" in e.target) {
|
2450
2521
|
dispatch({
|
2451
2522
|
type: "setUi",
|
@@ -2460,27 +2531,37 @@ function AutoFieldInternal(props) {
|
|
2460
2531
|
return null;
|
2461
2532
|
}
|
2462
2533
|
const CustomField = field.render;
|
2463
|
-
return /* @__PURE__ */ (0,
|
2534
|
+
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
2535
|
}
|
2465
2536
|
const children = defaultFields[field.type](mergedProps);
|
2466
2537
|
const Render2 = render[field.type];
|
2467
|
-
|
2468
|
-
|
2538
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
2539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2540
|
+
NestedFieldContext.Provider,
|
2469
2541
|
{
|
2470
|
-
|
2471
|
-
|
2472
|
-
|
2473
|
-
onClick: (e) => {
|
2474
|
-
e.stopPropagation();
|
2542
|
+
value: {
|
2543
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2544
|
+
localName: nestedFieldContext.localName
|
2475
2545
|
},
|
2476
|
-
children: /* @__PURE__ */ (0,
|
2546
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2547
|
+
"div",
|
2548
|
+
{
|
2549
|
+
className: getClassNameWrapper(),
|
2550
|
+
onFocus,
|
2551
|
+
onBlur,
|
2552
|
+
onClick: (e) => {
|
2553
|
+
e.stopPropagation();
|
2554
|
+
},
|
2555
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2556
|
+
}
|
2557
|
+
)
|
2477
2558
|
}
|
2478
2559
|
);
|
2479
2560
|
}
|
2480
2561
|
function AutoFieldPrivate(props) {
|
2481
2562
|
const { state } = useAppContext();
|
2482
2563
|
const { value, onChange } = props;
|
2483
|
-
const [localValue, setLocalValue] = (0,
|
2564
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
2484
2565
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
2485
2566
|
(val, ui) => {
|
2486
2567
|
onChange(val, ui);
|
@@ -2488,11 +2569,11 @@ function AutoFieldPrivate(props) {
|
|
2488
2569
|
50,
|
2489
2570
|
{ leading: true }
|
2490
2571
|
);
|
2491
|
-
const onChangeLocal = (0,
|
2572
|
+
const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
|
2492
2573
|
setLocalValue(val);
|
2493
2574
|
onChangeDb(val, ui);
|
2494
2575
|
}, []);
|
2495
|
-
(0,
|
2576
|
+
(0, import_react20.useEffect)(() => {
|
2496
2577
|
if (state.ui.field.focus !== props.name) {
|
2497
2578
|
setLocalValue(value);
|
2498
2579
|
}
|
@@ -2501,11 +2582,11 @@ function AutoFieldPrivate(props) {
|
|
2501
2582
|
value: localValue,
|
2502
2583
|
onChange: onChangeLocal
|
2503
2584
|
};
|
2504
|
-
return /* @__PURE__ */ (0,
|
2585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2505
2586
|
}
|
2506
2587
|
function AutoField(props) {
|
2507
|
-
const DefaultLabel = (0,
|
2508
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
2588
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
2589
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2509
2590
|
"div",
|
2510
2591
|
__spreadProps(__spreadValues({}, labelProps), {
|
2511
2592
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2513,7 +2594,7 @@ function AutoField(props) {
|
|
2513
2594
|
);
|
2514
2595
|
return DefaultLabel2;
|
2515
2596
|
}, [props.readOnly]);
|
2516
|
-
return /* @__PURE__ */ (0,
|
2597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2517
2598
|
}
|
2518
2599
|
|
2519
2600
|
// components/Drawer/index.tsx
|
@@ -2524,21 +2605,21 @@ init_react_import();
|
|
2524
2605
|
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
2606
|
|
2526
2607
|
// components/Drawer/index.tsx
|
2527
|
-
var
|
2608
|
+
var import_react32 = require("react");
|
2528
2609
|
|
2529
2610
|
// components/DragDropContext/index.tsx
|
2530
2611
|
init_react_import();
|
2531
|
-
var
|
2532
|
-
var
|
2612
|
+
var import_react30 = require("@dnd-kit/react");
|
2613
|
+
var import_react31 = require("react");
|
2533
2614
|
var import_dom = require("@dnd-kit/dom");
|
2534
2615
|
|
2535
2616
|
// components/DropZone/index.tsx
|
2536
2617
|
init_react_import();
|
2537
|
-
var
|
2618
|
+
var import_react29 = require("react");
|
2538
2619
|
|
2539
2620
|
// components/DraggableComponent/index.tsx
|
2540
2621
|
init_react_import();
|
2541
|
-
var
|
2622
|
+
var import_react23 = require("react");
|
2542
2623
|
|
2543
2624
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2544
2625
|
init_react_import();
|
@@ -2547,15 +2628,15 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
|
|
2547
2628
|
// components/DraggableComponent/index.tsx
|
2548
2629
|
var import_react_dom2 = require("react-dom");
|
2549
2630
|
|
2550
|
-
//
|
2631
|
+
// lib/dnd/collision/dynamic/index.ts
|
2551
2632
|
init_react_import();
|
2552
2633
|
var import_abstract8 = require("@dnd-kit/abstract");
|
2553
2634
|
|
2554
|
-
//
|
2635
|
+
// lib/dnd/collision/directional/index.ts
|
2555
2636
|
init_react_import();
|
2556
2637
|
var import_abstract = require("@dnd-kit/abstract");
|
2557
2638
|
|
2558
|
-
//
|
2639
|
+
// lib/dnd/collision/collision-debug.ts
|
2559
2640
|
init_react_import();
|
2560
2641
|
var DEBUG = false;
|
2561
2642
|
var debugElements = {};
|
@@ -2604,7 +2685,7 @@ var collisionDebug = (a, b, id, color, label) => {
|
|
2604
2685
|
});
|
2605
2686
|
};
|
2606
2687
|
|
2607
|
-
//
|
2688
|
+
// lib/dnd/collision/directional/index.ts
|
2608
2689
|
var distanceChange = "increasing";
|
2609
2690
|
var directionalCollision = (input, previous) => {
|
2610
2691
|
var _a;
|
@@ -2637,7 +2718,7 @@ var directionalCollision = (input, previous) => {
|
|
2637
2718
|
return null;
|
2638
2719
|
};
|
2639
2720
|
|
2640
|
-
//
|
2721
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
2641
2722
|
init_react_import();
|
2642
2723
|
var getDirection = (dragAxis, delta) => {
|
2643
2724
|
if (dragAxis === "dynamic") {
|
@@ -2652,7 +2733,7 @@ var getDirection = (dragAxis, delta) => {
|
|
2652
2733
|
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2653
2734
|
};
|
2654
2735
|
|
2655
|
-
//
|
2736
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
2656
2737
|
init_react_import();
|
2657
2738
|
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2658
2739
|
const dragRect = dragShape.boundingRectangle;
|
@@ -2671,7 +2752,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2671
2752
|
return dragRect.right - offset >= dropCenter.x;
|
2672
2753
|
};
|
2673
2754
|
|
2674
|
-
//
|
2755
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2675
2756
|
init_react_import();
|
2676
2757
|
var import_geometry = require("@dnd-kit/geometry");
|
2677
2758
|
var INTERVAL_SENSITIVITY = 10;
|
@@ -2775,7 +2856,14 @@ var closestCorners = (input) => {
|
|
2775
2856
|
};
|
2776
2857
|
};
|
2777
2858
|
|
2778
|
-
//
|
2859
|
+
// lib/dnd/collision/dynamic/store.ts
|
2860
|
+
init_react_import();
|
2861
|
+
var import_vanilla = require("zustand/vanilla");
|
2862
|
+
var collisionStore = (0, import_vanilla.createStore)(() => ({
|
2863
|
+
fallbackEnabled: false
|
2864
|
+
}));
|
2865
|
+
|
2866
|
+
// lib/dnd/collision/dynamic/index.ts
|
2779
2867
|
var flushNext = "";
|
2780
2868
|
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2781
2869
|
var _a, _b, _c, _d, _e;
|
@@ -2787,6 +2875,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2787
2875
|
return null;
|
2788
2876
|
}
|
2789
2877
|
const { center: dragCenter } = dragShape;
|
2878
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2790
2879
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2791
2880
|
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2792
2881
|
direction: interval.direction
|
@@ -2832,7 +2921,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2832
2921
|
flushNext = "";
|
2833
2922
|
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2834
2923
|
}
|
2835
|
-
if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2924
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2836
2925
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2837
2926
|
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2838
2927
|
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
@@ -2893,8 +2982,102 @@ function getDeepScrollPosition(element) {
|
|
2893
2982
|
return totalScroll;
|
2894
2983
|
}
|
2895
2984
|
|
2985
|
+
// components/DropZone/context.tsx
|
2986
|
+
init_react_import();
|
2987
|
+
var import_react21 = require("react");
|
2988
|
+
var import_zustand = require("zustand");
|
2989
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2990
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2991
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
2992
|
+
(0, import_zustand.createStore)(() => ({
|
2993
|
+
zoneDepthIndex: {},
|
2994
|
+
nextZoneDepthIndex: {},
|
2995
|
+
areaDepthIndex: {},
|
2996
|
+
nextAreaDepthIndex: {},
|
2997
|
+
draggedItem: null,
|
2998
|
+
previewIndex: {}
|
2999
|
+
}))
|
3000
|
+
);
|
3001
|
+
var ZoneStoreProvider = ({
|
3002
|
+
children,
|
3003
|
+
store
|
3004
|
+
}) => {
|
3005
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
3006
|
+
};
|
3007
|
+
var DropZoneProvider = ({
|
3008
|
+
children,
|
3009
|
+
value
|
3010
|
+
}) => {
|
3011
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3012
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3013
|
+
{}
|
3014
|
+
);
|
3015
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3016
|
+
const { dispatch } = useAppContext();
|
3017
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
3018
|
+
(area) => {
|
3019
|
+
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3020
|
+
},
|
3021
|
+
[setAreasWithZones]
|
3022
|
+
);
|
3023
|
+
const registerZone = (0, import_react21.useCallback)(
|
3024
|
+
(zoneCompound) => {
|
3025
|
+
if (!dispatch) {
|
3026
|
+
return;
|
3027
|
+
}
|
3028
|
+
dispatch({
|
3029
|
+
type: "registerZone",
|
3030
|
+
zone: zoneCompound
|
3031
|
+
});
|
3032
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
3033
|
+
},
|
3034
|
+
[setActiveZones, dispatch]
|
3035
|
+
);
|
3036
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
3037
|
+
(zoneCompound) => {
|
3038
|
+
if (!dispatch) {
|
3039
|
+
return;
|
3040
|
+
}
|
3041
|
+
dispatch({
|
3042
|
+
type: "unregisterZone",
|
3043
|
+
zone: zoneCompound
|
3044
|
+
});
|
3045
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
3046
|
+
[zoneCompound]: false
|
3047
|
+
}));
|
3048
|
+
},
|
3049
|
+
[setActiveZones, dispatch]
|
3050
|
+
);
|
3051
|
+
const memoValue = (0, import_react21.useMemo)(
|
3052
|
+
() => __spreadValues({
|
3053
|
+
hoveringComponent,
|
3054
|
+
setHoveringComponent,
|
3055
|
+
registerZoneArea,
|
3056
|
+
areasWithZones,
|
3057
|
+
registerZone,
|
3058
|
+
unregisterZone,
|
3059
|
+
activeZones
|
3060
|
+
}, value),
|
3061
|
+
[value, hoveringComponent, areasWithZones, activeZones]
|
3062
|
+
);
|
3063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
3064
|
+
};
|
3065
|
+
|
3066
|
+
// lib/use-context-store.ts
|
3067
|
+
init_react_import();
|
3068
|
+
var import_react22 = require("react");
|
3069
|
+
var import_zustand2 = require("zustand");
|
3070
|
+
var import_shallow = require("zustand/react/shallow");
|
3071
|
+
function useContextStore(context, selector) {
|
3072
|
+
const store = (0, import_react22.useContext)(context);
|
3073
|
+
if (!store) {
|
3074
|
+
throw new Error("useContextStore must be used inside context");
|
3075
|
+
}
|
3076
|
+
return (0, import_zustand2.useStore)(store, (0, import_shallow.useShallow)(selector));
|
3077
|
+
}
|
3078
|
+
|
2896
3079
|
// components/DraggableComponent/index.tsx
|
2897
|
-
var
|
3080
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
2898
3081
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2899
3082
|
var DEBUG2 = false;
|
2900
3083
|
var space = 8;
|
@@ -2905,12 +3088,12 @@ var DefaultActionBar = ({
|
|
2905
3088
|
label,
|
2906
3089
|
children,
|
2907
3090
|
parentAction
|
2908
|
-
}) => /* @__PURE__ */ (0,
|
2909
|
-
/* @__PURE__ */ (0,
|
3091
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar, { children: [
|
3092
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar.Group, { children: [
|
2910
3093
|
parentAction,
|
2911
|
-
label && /* @__PURE__ */ (0,
|
3094
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Label, { label })
|
2912
3095
|
] }),
|
2913
|
-
/* @__PURE__ */ (0,
|
3096
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Group, { children })
|
2914
3097
|
] });
|
2915
3098
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
2916
3099
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -2945,9 +3128,9 @@ var DraggableComponent = ({
|
|
2945
3128
|
iframe,
|
2946
3129
|
state
|
2947
3130
|
} = useAppContext();
|
2948
|
-
const ctx = (0,
|
2949
|
-
const [localZones, setLocalZones] = (0,
|
2950
|
-
const registerLocalZone = (0,
|
3131
|
+
const ctx = (0, import_react23.useContext)(dropZoneContext);
|
3132
|
+
const [localZones, setLocalZones] = (0, import_react23.useState)({});
|
3133
|
+
const registerLocalZone = (0, import_react23.useCallback)(
|
2951
3134
|
(zoneCompound2, active) => {
|
2952
3135
|
var _a;
|
2953
3136
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -2957,7 +3140,7 @@ var DraggableComponent = ({
|
|
2957
3140
|
},
|
2958
3141
|
[setLocalZones]
|
2959
3142
|
);
|
2960
|
-
const unregisterLocalZone = (0,
|
3143
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
2961
3144
|
(zoneCompound2) => {
|
2962
3145
|
var _a;
|
2963
3146
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -2971,8 +3154,8 @@ var DraggableComponent = ({
|
|
2971
3154
|
);
|
2972
3155
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
2973
3156
|
const { path = [] } = ctx || {};
|
2974
|
-
const [canDrag, setCanDrag] = (0,
|
2975
|
-
(0,
|
3157
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3158
|
+
(0, import_react23.useEffect)(() => {
|
2976
3159
|
var _a;
|
2977
3160
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
2978
3161
|
if (item) {
|
@@ -2982,10 +3165,13 @@ var DraggableComponent = ({
|
|
2982
3165
|
setCanDrag((_a = perms.drag) != null ? _a : true);
|
2983
3166
|
}
|
2984
3167
|
}, [state, index, zoneCompound, getPermissions]);
|
2985
|
-
const userIsDragging =
|
3168
|
+
const userIsDragging = useContextStore(
|
3169
|
+
ZoneStoreContext,
|
3170
|
+
(s) => !!s.draggedItem
|
3171
|
+
);
|
2986
3172
|
const canCollide = canDrag || userIsDragging;
|
2987
3173
|
const disabled = !isEnabled || !canCollide;
|
2988
|
-
const [dragAxis, setDragAxis] = (0,
|
3174
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
2989
3175
|
const { ref: sortableRef, status } = useSortableSafe({
|
2990
3176
|
id,
|
2991
3177
|
index,
|
@@ -3011,8 +3197,8 @@ var DraggableComponent = ({
|
|
3011
3197
|
}
|
3012
3198
|
});
|
3013
3199
|
const thisIsDragging = status === "dragging";
|
3014
|
-
const ref = (0,
|
3015
|
-
const refSetter = (0,
|
3200
|
+
const ref = (0, import_react23.useRef)(null);
|
3201
|
+
const refSetter = (0, import_react23.useCallback)(
|
3016
3202
|
(el) => {
|
3017
3203
|
sortableRef(el);
|
3018
3204
|
if (el) {
|
@@ -3021,14 +3207,14 @@ var DraggableComponent = ({
|
|
3021
3207
|
},
|
3022
3208
|
[sortableRef]
|
3023
3209
|
);
|
3024
|
-
const [portalEl, setPortalEl] = (0,
|
3025
|
-
(0,
|
3210
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3211
|
+
(0, import_react23.useEffect)(() => {
|
3026
3212
|
var _a, _b, _c;
|
3027
3213
|
setPortalEl(
|
3028
3214
|
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
3215
|
);
|
3030
3216
|
}, [iframe.enabled, ref.current]);
|
3031
|
-
const getStyle = (0,
|
3217
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3032
3218
|
var _a, _b, _c;
|
3033
3219
|
if (!ref.current) return;
|
3034
3220
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3048,11 +3234,11 @@ var DraggableComponent = ({
|
|
3048
3234
|
};
|
3049
3235
|
return style2;
|
3050
3236
|
}, [ref.current]);
|
3051
|
-
const [style, setStyle] = (0,
|
3052
|
-
const sync = (0,
|
3237
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3238
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3053
3239
|
setStyle(getStyle());
|
3054
3240
|
}, [ref.current, iframe]);
|
3055
|
-
(0,
|
3241
|
+
(0, import_react23.useEffect)(() => {
|
3056
3242
|
if (ref.current) {
|
3057
3243
|
const observer = new ResizeObserver(sync);
|
3058
3244
|
observer.observe(ref.current);
|
@@ -3061,20 +3247,22 @@ var DraggableComponent = ({
|
|
3061
3247
|
};
|
3062
3248
|
}
|
3063
3249
|
}, [ref.current]);
|
3064
|
-
(0,
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3250
|
+
(0, import_react23.useEffect)(() => {
|
3251
|
+
if (isSelected) {
|
3252
|
+
ctx == null ? void 0 : ctx.registerPath({
|
3253
|
+
index,
|
3254
|
+
zone: zoneCompound
|
3255
|
+
});
|
3256
|
+
}
|
3069
3257
|
}, [isSelected]);
|
3070
|
-
const CustomActionBar = (0,
|
3258
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3071
3259
|
() => overrides.actionBar || DefaultActionBar,
|
3072
3260
|
[overrides.actionBar]
|
3073
3261
|
);
|
3074
3262
|
const permissions = getPermissions({
|
3075
3263
|
item: selectedItem
|
3076
3264
|
});
|
3077
|
-
const onClick = (0,
|
3265
|
+
const onClick = (0, import_react23.useCallback)(
|
3078
3266
|
(e) => {
|
3079
3267
|
e.stopPropagation();
|
3080
3268
|
dispatch({
|
@@ -3086,7 +3274,7 @@ var DraggableComponent = ({
|
|
3086
3274
|
},
|
3087
3275
|
[index, zoneCompound, id]
|
3088
3276
|
);
|
3089
|
-
const onSelectParent = (0,
|
3277
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3090
3278
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3091
3279
|
return;
|
3092
3280
|
}
|
@@ -3104,23 +3292,23 @@ var DraggableComponent = ({
|
|
3104
3292
|
}
|
3105
3293
|
});
|
3106
3294
|
}, [ctx, path]);
|
3107
|
-
const onDuplicate = (0,
|
3295
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3108
3296
|
dispatch({
|
3109
3297
|
type: "duplicate",
|
3110
3298
|
sourceIndex: index,
|
3111
3299
|
sourceZone: zoneCompound
|
3112
3300
|
});
|
3113
3301
|
}, [index, zoneCompound]);
|
3114
|
-
const onDelete = (0,
|
3302
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3115
3303
|
dispatch({
|
3116
3304
|
type: "remove",
|
3117
3305
|
index,
|
3118
3306
|
zone: zoneCompound
|
3119
3307
|
});
|
3120
3308
|
}, [index, zoneCompound]);
|
3121
|
-
const [hover, setHover] = (0,
|
3309
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3122
3310
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3123
|
-
(0,
|
3311
|
+
(0, import_react23.useEffect)(() => {
|
3124
3312
|
if (!ref.current) {
|
3125
3313
|
return;
|
3126
3314
|
}
|
@@ -3170,7 +3358,7 @@ var DraggableComponent = ({
|
|
3170
3358
|
thisIsDragging,
|
3171
3359
|
inDroppableZone
|
3172
3360
|
]);
|
3173
|
-
(0,
|
3361
|
+
(0, import_react23.useEffect)(() => {
|
3174
3362
|
if (ref.current && disabled) {
|
3175
3363
|
ref.current.setAttribute("data-puck-disabled", "");
|
3176
3364
|
return () => {
|
@@ -3179,8 +3367,8 @@ var DraggableComponent = ({
|
|
3179
3367
|
};
|
3180
3368
|
}
|
3181
3369
|
}, [disabled, ref]);
|
3182
|
-
const [isVisible, setIsVisible] = (0,
|
3183
|
-
(0,
|
3370
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3371
|
+
(0, import_react23.useEffect)(() => {
|
3184
3372
|
sync();
|
3185
3373
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3186
3374
|
setIsVisible(true);
|
@@ -3188,7 +3376,7 @@ var DraggableComponent = ({
|
|
3188
3376
|
setIsVisible(false);
|
3189
3377
|
}
|
3190
3378
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3191
|
-
const syncActionsPosition = (0,
|
3379
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3192
3380
|
(el) => {
|
3193
3381
|
if (el) {
|
3194
3382
|
const view = el.ownerDocument.defaultView;
|
@@ -3205,7 +3393,7 @@ var DraggableComponent = ({
|
|
3205
3393
|
},
|
3206
3394
|
[zoomConfig]
|
3207
3395
|
);
|
3208
|
-
(0,
|
3396
|
+
(0, import_react23.useEffect)(() => {
|
3209
3397
|
if (userDragAxis) {
|
3210
3398
|
setDragAxis(userDragAxis);
|
3211
3399
|
return;
|
@@ -3219,8 +3407,8 @@ var DraggableComponent = ({
|
|
3219
3407
|
}
|
3220
3408
|
setDragAxis(autoDragAxis);
|
3221
3409
|
}, [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,
|
3410
|
+
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 }) });
|
3411
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3224
3412
|
DropZoneProvider,
|
3225
3413
|
{
|
3226
3414
|
value: __spreadProps(__spreadValues({}, ctx), {
|
@@ -3234,7 +3422,7 @@ var DraggableComponent = ({
|
|
3234
3422
|
}),
|
3235
3423
|
children: [
|
3236
3424
|
isVisible && (0, import_react_dom2.createPortal)(
|
3237
|
-
/* @__PURE__ */ (0,
|
3425
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3238
3426
|
"div",
|
3239
3427
|
{
|
3240
3428
|
className: getClassName16({
|
@@ -3246,15 +3434,15 @@ var DraggableComponent = ({
|
|
3246
3434
|
"data-puck-overlay": true,
|
3247
3435
|
children: [
|
3248
3436
|
debug,
|
3249
|
-
isLoading && /* @__PURE__ */ (0,
|
3250
|
-
/* @__PURE__ */ (0,
|
3437
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {}) }),
|
3438
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3251
3439
|
"div",
|
3252
3440
|
{
|
3253
3441
|
className: getClassName16("actionsOverlay"),
|
3254
3442
|
style: {
|
3255
3443
|
top: actionsOverlayTop / zoomConfig.zoom
|
3256
3444
|
},
|
3257
|
-
children: /* @__PURE__ */ (0,
|
3445
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3258
3446
|
"div",
|
3259
3447
|
{
|
3260
3448
|
className: getClassName16("actions"),
|
@@ -3266,14 +3454,14 @@ var DraggableComponent = ({
|
|
3266
3454
|
paddingRight: actionsSide
|
3267
3455
|
},
|
3268
3456
|
ref: syncActionsPosition,
|
3269
|
-
children: /* @__PURE__ */ (0,
|
3457
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3270
3458
|
CustomActionBar,
|
3271
3459
|
{
|
3272
3460
|
parentAction,
|
3273
3461
|
label: DEBUG2 ? id : label,
|
3274
3462
|
children: [
|
3275
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
3276
|
-
permissions.delete && /* @__PURE__ */ (0,
|
3463
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Copy, { size: 16 }) }),
|
3464
|
+
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
3465
|
]
|
3278
3466
|
}
|
3279
3467
|
)
|
@@ -3281,7 +3469,7 @@ var DraggableComponent = ({
|
|
3281
3469
|
)
|
3282
3470
|
}
|
3283
3471
|
),
|
3284
|
-
/* @__PURE__ */ (0,
|
3472
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("overlay") })
|
3285
3473
|
]
|
3286
3474
|
}
|
3287
3475
|
),
|
@@ -3297,70 +3485,74 @@ var DraggableComponent = ({
|
|
3297
3485
|
init_react_import();
|
3298
3486
|
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
3487
|
|
3300
|
-
// components/DropZone/
|
3488
|
+
// components/DropZone/lib/use-min-empty-height.ts
|
3301
3489
|
init_react_import();
|
3302
|
-
var
|
3303
|
-
var
|
3304
|
-
|
3305
|
-
|
3306
|
-
|
3307
|
-
value
|
3490
|
+
var import_react24 = require("react");
|
3491
|
+
var useMinEmptyHeight = ({
|
3492
|
+
zoneCompound,
|
3493
|
+
userMinEmptyHeight,
|
3494
|
+
ref
|
3308
3495
|
}) => {
|
3309
|
-
const [
|
3310
|
-
const [
|
3311
|
-
|
3312
|
-
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3316
|
-
|
3317
|
-
|
3318
|
-
|
3319
|
-
|
3320
|
-
|
3321
|
-
|
3322
|
-
|
3323
|
-
|
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) {
|
3496
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3497
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3498
|
+
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3499
|
+
var _a, _b;
|
3500
|
+
return {
|
3501
|
+
draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
|
3502
|
+
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3503
|
+
};
|
3504
|
+
});
|
3505
|
+
(0, import_react24.useEffect)(() => {
|
3506
|
+
if (draggedItem && ref.current) {
|
3507
|
+
if (isZone) {
|
3508
|
+
const rect = ref.current.getBoundingClientRect();
|
3509
|
+
setPrevHeight(rect.height);
|
3510
|
+
setIsAnimating(true);
|
3337
3511
|
return;
|
3338
3512
|
}
|
3339
|
-
|
3340
|
-
|
3341
|
-
|
3342
|
-
|
3343
|
-
|
3344
|
-
|
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 }) });
|
3513
|
+
}
|
3514
|
+
setPrevHeight(0);
|
3515
|
+
setTimeout(() => {
|
3516
|
+
setIsAnimating(false);
|
3517
|
+
}, 400);
|
3518
|
+
}, [ref.current, draggedItem, zoneCompound]);
|
3519
|
+
return [prevHeight || userMinEmptyHeight, isAnimating];
|
3362
3520
|
};
|
3363
3521
|
|
3522
|
+
// lib/assign-refs.ts
|
3523
|
+
init_react_import();
|
3524
|
+
function assignRef(ref, node) {
|
3525
|
+
if (typeof ref === "function") {
|
3526
|
+
ref(node);
|
3527
|
+
} else if (ref && typeof ref === "object" && "current" in ref) {
|
3528
|
+
ref.current = node;
|
3529
|
+
}
|
3530
|
+
}
|
3531
|
+
function assignRefs(refs, node) {
|
3532
|
+
refs.forEach((ref) => {
|
3533
|
+
assignRef(ref, node);
|
3534
|
+
});
|
3535
|
+
}
|
3536
|
+
|
3537
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3538
|
+
init_react_import();
|
3539
|
+
var import_react27 = require("react");
|
3540
|
+
|
3541
|
+
// lib/dnd/use-rendered-callback.ts
|
3542
|
+
init_react_import();
|
3543
|
+
var import_react25 = require("@dnd-kit/react");
|
3544
|
+
var import_react26 = require("react");
|
3545
|
+
function useRenderedCallback(callback, deps) {
|
3546
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3547
|
+
return (0, import_react26.useCallback)(
|
3548
|
+
(...args) => __async(this, null, function* () {
|
3549
|
+
yield manager == null ? void 0 : manager.renderer.rendering;
|
3550
|
+
return callback(...args);
|
3551
|
+
}),
|
3552
|
+
[...deps, manager]
|
3553
|
+
);
|
3554
|
+
}
|
3555
|
+
|
3364
3556
|
// lib/insert.ts
|
3365
3557
|
init_react_import();
|
3366
3558
|
var insert = (list, index, item) => {
|
@@ -3369,58 +3561,102 @@ var insert = (list, index, item) => {
|
|
3369
3561
|
return result;
|
3370
3562
|
};
|
3371
3563
|
|
3372
|
-
// components/DropZone/use-
|
3564
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3565
|
+
var useContentWithPreview = (content, zoneCompound) => {
|
3566
|
+
const { draggedItemId, preview, previewExists } = useContextStore(
|
3567
|
+
ZoneStoreContext,
|
3568
|
+
(s) => {
|
3569
|
+
var _a;
|
3570
|
+
return {
|
3571
|
+
draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
|
3572
|
+
preview: s.previewIndex[zoneCompound],
|
3573
|
+
previewExists: Object.keys(s.previewIndex || {}).length > 0
|
3574
|
+
};
|
3575
|
+
}
|
3576
|
+
);
|
3577
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3578
|
+
const updateContent = useRenderedCallback(
|
3579
|
+
(content2, preview2) => {
|
3580
|
+
if (preview2) {
|
3581
|
+
if (preview2.type === "insert") {
|
3582
|
+
setContentWithPreview(
|
3583
|
+
insert(
|
3584
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3585
|
+
preview2.index,
|
3586
|
+
{
|
3587
|
+
type: "preview",
|
3588
|
+
props: { id: preview2.props.id }
|
3589
|
+
}
|
3590
|
+
)
|
3591
|
+
);
|
3592
|
+
} else {
|
3593
|
+
setContentWithPreview(
|
3594
|
+
insert(
|
3595
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3596
|
+
preview2.index,
|
3597
|
+
{
|
3598
|
+
type: preview2.componentType,
|
3599
|
+
props: preview2.props
|
3600
|
+
}
|
3601
|
+
)
|
3602
|
+
);
|
3603
|
+
}
|
3604
|
+
} else {
|
3605
|
+
setContentWithPreview(
|
3606
|
+
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3607
|
+
);
|
3608
|
+
}
|
3609
|
+
},
|
3610
|
+
[draggedItemId, previewExists]
|
3611
|
+
);
|
3612
|
+
(0, import_react27.useEffect)(() => {
|
3613
|
+
updateContent(content, preview);
|
3614
|
+
}, [content, preview]);
|
3615
|
+
return contentWithPreview;
|
3616
|
+
};
|
3617
|
+
|
3618
|
+
// components/DropZone/lib/use-drag-axis.ts
|
3373
3619
|
init_react_import();
|
3374
|
-
var
|
3375
|
-
var
|
3376
|
-
|
3377
|
-
|
3378
|
-
|
3379
|
-
|
3380
|
-
|
3381
|
-
|
3382
|
-
|
3383
|
-
(0,
|
3384
|
-
if (
|
3385
|
-
const
|
3386
|
-
if (
|
3387
|
-
|
3388
|
-
|
3389
|
-
|
3390
|
-
|
3620
|
+
var import_react28 = require("react");
|
3621
|
+
var GRID_DRAG_AXIS = "dynamic";
|
3622
|
+
var FLEX_ROW_DRAG_AXIS = "x";
|
3623
|
+
var DEFAULT_DRAG_AXIS = "y";
|
3624
|
+
var useDragAxis = (ref, collisionAxis) => {
|
3625
|
+
const { status } = useAppContext();
|
3626
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3627
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
3628
|
+
);
|
3629
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3630
|
+
if (ref.current) {
|
3631
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
3632
|
+
if (computedStyle.display === "grid") {
|
3633
|
+
setDragAxis(GRID_DRAG_AXIS);
|
3634
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3635
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3636
|
+
} else {
|
3637
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
3391
3638
|
}
|
3392
3639
|
}
|
3393
|
-
|
3394
|
-
|
3395
|
-
|
3396
|
-
|
3397
|
-
|
3398
|
-
|
3640
|
+
}, [ref.current]);
|
3641
|
+
(0, import_react28.useEffect)(() => {
|
3642
|
+
const onViewportChange = () => {
|
3643
|
+
calculateDragAxis();
|
3644
|
+
};
|
3645
|
+
window.addEventListener("viewportchange", onViewportChange);
|
3646
|
+
return () => {
|
3647
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
3648
|
+
};
|
3649
|
+
}, []);
|
3650
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
3651
|
+
return [dragAxis, calculateDragAxis];
|
3399
3652
|
};
|
3400
3653
|
|
3401
|
-
// lib/assign-refs.ts
|
3402
|
-
init_react_import();
|
3403
|
-
function assignRef(ref, node) {
|
3404
|
-
if (typeof ref === "function") {
|
3405
|
-
ref(node);
|
3406
|
-
} else if (ref && typeof ref === "object" && "current" in ref) {
|
3407
|
-
ref.current = node;
|
3408
|
-
}
|
3409
|
-
}
|
3410
|
-
function assignRefs(refs, node) {
|
3411
|
-
refs.forEach((ref) => {
|
3412
|
-
assignRef(ref, node);
|
3413
|
-
});
|
3414
|
-
}
|
3415
|
-
|
3416
3654
|
// components/DropZone/index.tsx
|
3417
|
-
var
|
3655
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
3418
3656
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3419
|
-
var
|
3420
|
-
var
|
3421
|
-
var
|
3422
|
-
var DEFAULT_DRAG_AXIS = "y";
|
3423
|
-
var DropZoneEdit = (0, import_react23.forwardRef)(
|
3657
|
+
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3658
|
+
var RENDER_DEBUG = false;
|
3659
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
3424
3660
|
function DropZoneEdit2({
|
3425
3661
|
zone,
|
3426
3662
|
allow,
|
@@ -3431,31 +3667,50 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3431
3667
|
collisionAxis
|
3432
3668
|
}, userRef) {
|
3433
3669
|
const appContext2 = useAppContext();
|
3434
|
-
const ctx = (0,
|
3670
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3435
3671
|
const {
|
3436
3672
|
// These all need setting via context
|
3437
3673
|
data,
|
3438
3674
|
config,
|
3439
3675
|
areaId,
|
3440
|
-
draggedItem,
|
3441
3676
|
registerZoneArea,
|
3442
3677
|
depth,
|
3443
3678
|
registerLocalZone,
|
3444
3679
|
unregisterLocalZone,
|
3445
|
-
deepestZone = rootDroppableId,
|
3446
|
-
deepestArea,
|
3447
|
-
nextDeepestArea,
|
3448
3680
|
path = [],
|
3449
3681
|
activeZones
|
3450
3682
|
} = ctx;
|
3451
|
-
const { itemSelector } = appContext2.state.ui;
|
3452
3683
|
let zoneCompound = rootDroppableId;
|
3453
|
-
|
3684
|
+
if (areaId) {
|
3685
|
+
if (zone !== rootDroppableId) {
|
3686
|
+
zoneCompound = `${areaId}:${zone}`;
|
3687
|
+
}
|
3688
|
+
}
|
3689
|
+
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
3690
|
+
const {
|
3691
|
+
isDeepestZone,
|
3692
|
+
inNextDeepestArea,
|
3693
|
+
draggedComponentType,
|
3694
|
+
userIsDragging,
|
3695
|
+
preview
|
3696
|
+
} = useContextStore(ZoneStoreContext, (s) => {
|
3697
|
+
var _a, _b, _c;
|
3698
|
+
return {
|
3699
|
+
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
3700
|
+
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3701
|
+
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3702
|
+
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3703
|
+
userIsDragging: !!s.draggedItem,
|
3704
|
+
preview: s.previewIndex[zoneCompound]
|
3705
|
+
};
|
3706
|
+
});
|
3707
|
+
const { itemSelector } = appContext2.state.ui;
|
3708
|
+
(0, import_react29.useEffect)(() => {
|
3454
3709
|
if (areaId && registerZoneArea) {
|
3455
3710
|
registerZoneArea(areaId);
|
3456
3711
|
}
|
3457
3712
|
}, [areaId]);
|
3458
|
-
(0,
|
3713
|
+
(0, import_react29.useEffect)(() => {
|
3459
3714
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3460
3715
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3461
3716
|
}
|
@@ -3465,25 +3720,18 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3465
3720
|
}
|
3466
3721
|
};
|
3467
3722
|
}, []);
|
3468
|
-
|
3469
|
-
if (zone !== rootDroppableId) {
|
3470
|
-
zoneCompound = `${areaId}:${zone}`;
|
3471
|
-
}
|
3472
|
-
}
|
3473
|
-
const content = (0, import_react23.useMemo)(() => {
|
3723
|
+
const content = (0, import_react29.useMemo)(() => {
|
3474
3724
|
if (areaId && zone !== rootDroppableId) {
|
3475
3725
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3476
3726
|
}
|
3477
3727
|
return data.content || [];
|
3478
3728
|
}, [data, zoneCompound]);
|
3479
|
-
const ref = (0,
|
3480
|
-
const acceptsTarget = (0,
|
3481
|
-
(
|
3482
|
-
if (!
|
3729
|
+
const ref = (0, import_react29.useRef)(null);
|
3730
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
3731
|
+
(componentType) => {
|
3732
|
+
if (!componentType) {
|
3483
3733
|
return true;
|
3484
3734
|
}
|
3485
|
-
const data2 = target.data;
|
3486
|
-
const { componentType } = data2;
|
3487
3735
|
if (disallow) {
|
3488
3736
|
const defaultedAllow = allow || [];
|
3489
3737
|
const filteredDisallow = (disallow || []).filter(
|
@@ -3501,49 +3749,26 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3501
3749
|
},
|
3502
3750
|
[allow, disallow]
|
3503
3751
|
);
|
3504
|
-
(0,
|
3752
|
+
(0, import_react29.useEffect)(() => {
|
3505
3753
|
if (registerLocalZone) {
|
3506
|
-
registerLocalZone(zoneCompound, acceptsTarget(
|
3754
|
+
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3507
3755
|
}
|
3508
3756
|
return () => {
|
3509
3757
|
if (unregisterLocalZone) {
|
3510
3758
|
unregisterLocalZone(zoneCompound);
|
3511
3759
|
}
|
3512
3760
|
};
|
3513
|
-
}, [
|
3514
|
-
const
|
3515
|
-
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3516
|
-
const userIsDragging = !!draggedItem;
|
3761
|
+
}, [draggedComponentType, zoneCompound]);
|
3762
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
3517
3763
|
let isEnabled = true;
|
3518
|
-
if (
|
3519
|
-
isEnabled =
|
3764
|
+
if (userIsDragging) {
|
3765
|
+
isEnabled = isDeepestZone;
|
3520
3766
|
}
|
3521
3767
|
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);
|
3768
|
+
isEnabled = acceptsTarget(draggedComponentType);
|
3769
|
+
}
|
3770
|
+
const contentWithPreview = useContentWithPreview(content, zoneCompound);
|
3771
|
+
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3547
3772
|
const droppableConfig = {
|
3548
3773
|
id: zoneCompound,
|
3549
3774
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -3553,45 +3778,20 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3553
3778
|
data: {
|
3554
3779
|
areaId,
|
3555
3780
|
depth,
|
3556
|
-
isDroppableTarget: acceptsTarget(
|
3781
|
+
isDroppableTarget: acceptsTarget(draggedComponentType),
|
3557
3782
|
path
|
3558
3783
|
}
|
3559
3784
|
};
|
3560
3785
|
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
3561
3786
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3562
3787
|
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
|
-
}, []);
|
3788
|
+
const [dragAxis] = useDragAxis(ref, collisionAxis);
|
3588
3789
|
const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
|
3589
|
-
draggedItem,
|
3590
3790
|
zoneCompound,
|
3591
3791
|
userMinEmptyHeight,
|
3592
3792
|
ref
|
3593
3793
|
});
|
3594
|
-
return /* @__PURE__ */ (0,
|
3794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3595
3795
|
"div",
|
3596
3796
|
{
|
3597
3797
|
className: `${getClassName17({
|
@@ -3611,88 +3811,83 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3611
3811
|
"data-puck-dropzone": zoneCompound,
|
3612
3812
|
"data-puck-dnd": zoneCompound,
|
3613
3813
|
style: __spreadProps(__spreadValues({}, style), {
|
3614
|
-
"--min-empty-height": `${minEmptyHeight}px
|
3814
|
+
"--min-empty-height": `${minEmptyHeight}px`,
|
3815
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3615
3816
|
}),
|
3616
|
-
children:
|
3617
|
-
|
3618
|
-
|
3619
|
-
|
3620
|
-
|
3621
|
-
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3817
|
+
children: contentWithPreview.map((item, i) => {
|
3818
|
+
var _a, _b, _c, _d, _e;
|
3819
|
+
const componentId = item.props.id;
|
3820
|
+
const puckProps = {
|
3821
|
+
renderDropZone: DropZone,
|
3822
|
+
isEditing: true,
|
3823
|
+
dragRef: null
|
3824
|
+
};
|
3825
|
+
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
|
3826
|
+
puck: puckProps,
|
3827
|
+
editMode: true
|
3828
|
+
// DEPRECATED
|
3829
|
+
});
|
3830
|
+
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3831
|
+
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: [
|
3832
|
+
"No configuration for ",
|
3833
|
+
item.type
|
3834
|
+
] });
|
3835
|
+
const componentConfig = config.components[item.type];
|
3836
|
+
let componentType = item.type;
|
3837
|
+
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3838
|
+
if (item.type === "preview" && preview) {
|
3839
|
+
let Preview4 = function() {
|
3840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3628
3841
|
};
|
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
|
-
})
|
3842
|
+
var Preview3 = Preview4;
|
3843
|
+
componentType = preview.componentType;
|
3844
|
+
label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
|
3845
|
+
Render2 = Preview4;
|
3846
|
+
}
|
3847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3848
|
+
DropZoneProvider,
|
3849
|
+
{
|
3850
|
+
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3851
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3852
|
+
DraggableComponent,
|
3853
|
+
{
|
3854
|
+
id: componentId,
|
3855
|
+
componentType,
|
3856
|
+
zoneCompound,
|
3857
|
+
depth: depth + 1,
|
3858
|
+
index: i,
|
3859
|
+
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3860
|
+
isSelected,
|
3861
|
+
label,
|
3862
|
+
isEnabled,
|
3863
|
+
autoDragAxis: dragAxis,
|
3864
|
+
userDragAxis: collisionAxis,
|
3865
|
+
inDroppableZone: acceptsTarget(draggedComponentType),
|
3866
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3867
|
+
Render2,
|
3868
|
+
__spreadProps(__spreadValues({}, defaultedProps), {
|
3869
|
+
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3870
|
+
dragRef
|
3676
3871
|
})
|
3677
|
-
|
3678
|
-
}
|
3679
|
-
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
|
3684
|
-
|
3872
|
+
})
|
3873
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3874
|
+
}
|
3875
|
+
)
|
3876
|
+
},
|
3877
|
+
componentId
|
3878
|
+
);
|
3879
|
+
})
|
3685
3880
|
}
|
3686
3881
|
);
|
3687
3882
|
}
|
3688
3883
|
);
|
3689
|
-
var DropZoneRender = (0,
|
3884
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
3690
3885
|
function DropZoneRender2({ className, style, zone }, ref) {
|
3691
|
-
const ctx = (0,
|
3886
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3692
3887
|
const { data, areaId = "root", config } = ctx || {};
|
3693
3888
|
let zoneCompound = rootDroppableId;
|
3694
3889
|
let content = (data == null ? void 0 : data.content) || [];
|
3695
|
-
(0,
|
3890
|
+
(0, import_react29.useEffect)(() => {
|
3696
3891
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3697
3892
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3698
3893
|
}
|
@@ -3709,10 +3904,10 @@ var DropZoneRender = (0, import_react23.forwardRef)(
|
|
3709
3904
|
zoneCompound = `${areaId}:${zone}`;
|
3710
3905
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3711
3906
|
}
|
3712
|
-
return /* @__PURE__ */ (0,
|
3907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
3713
3908
|
const Component = config.components[item.type];
|
3714
3909
|
if (Component) {
|
3715
|
-
return /* @__PURE__ */ (0,
|
3910
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3716
3911
|
DropZoneProvider,
|
3717
3912
|
{
|
3718
3913
|
value: {
|
@@ -3722,7 +3917,7 @@ var DropZoneRender = (0, import_react23.forwardRef)(
|
|
3722
3917
|
depth: 1,
|
3723
3918
|
path: []
|
3724
3919
|
},
|
3725
|
-
children: /* @__PURE__ */ (0,
|
3920
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3726
3921
|
Component.render,
|
3727
3922
|
__spreadProps(__spreadValues({}, item.props), {
|
3728
3923
|
puck: { renderDropZone: DropZoneRender2 }
|
@@ -3736,13 +3931,13 @@ var DropZoneRender = (0, import_react23.forwardRef)(
|
|
3736
3931
|
}) });
|
3737
3932
|
}
|
3738
3933
|
);
|
3739
|
-
var DropZone = (0,
|
3934
|
+
var DropZone = (0, import_react29.forwardRef)(
|
3740
3935
|
function DropZone2(props, ref) {
|
3741
|
-
const ctx = (0,
|
3936
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3742
3937
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3743
|
-
return /* @__PURE__ */ (0,
|
3938
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3744
3939
|
}
|
3745
|
-
return /* @__PURE__ */ (0,
|
3940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3746
3941
|
}
|
3747
3942
|
);
|
3748
3943
|
|
@@ -3758,7 +3953,7 @@ var getZoneId = (zoneCompound) => {
|
|
3758
3953
|
return [rootDroppableId, zoneCompound];
|
3759
3954
|
};
|
3760
3955
|
|
3761
|
-
//
|
3956
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3762
3957
|
init_react_import();
|
3763
3958
|
var import_abstract9 = require("@dnd-kit/abstract");
|
3764
3959
|
var import_state = require("@dnd-kit/state");
|
@@ -3800,7 +3995,7 @@ var getFrame = () => {
|
|
3800
3995
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3801
3996
|
};
|
3802
3997
|
|
3803
|
-
//
|
3998
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3804
3999
|
var depthSort = (candidates) => {
|
3805
4000
|
return candidates.sort((a, b) => {
|
3806
4001
|
const aData = a.data;
|
@@ -3915,9 +4110,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
|
|
3915
4110
|
area: null
|
3916
4111
|
};
|
3917
4112
|
};
|
3918
|
-
var createNestedDroppablePlugin = ({
|
3919
|
-
onChange
|
3920
|
-
}) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4113
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
3921
4114
|
constructor(manager, options) {
|
3922
4115
|
super(manager);
|
3923
4116
|
if (typeof window === "undefined") {
|
@@ -3931,10 +4124,17 @@ var createNestedDroppablePlugin = ({
|
|
3931
4124
|
};
|
3932
4125
|
const target = event.originalTarget || event.target;
|
3933
4126
|
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
3934
|
-
|
3935
|
-
|
3936
|
-
|
4127
|
+
const elements = document.elementsFromPoint(
|
4128
|
+
event.clientX,
|
4129
|
+
event.clientY
|
3937
4130
|
);
|
4131
|
+
const overEl = elements.some((el) => el.id === id);
|
4132
|
+
if (overEl) {
|
4133
|
+
onChange(
|
4134
|
+
findDeepestCandidate(position, manager, ownerDocument),
|
4135
|
+
manager
|
4136
|
+
);
|
4137
|
+
}
|
3938
4138
|
};
|
3939
4139
|
const handleMoveThrottled = throttle(handleMove, 50);
|
3940
4140
|
const handlePointerMove = (event) => {
|
@@ -4351,7 +4551,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4351
4551
|
var import_use_debounce2 = require("use-debounce");
|
4352
4552
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
4353
4553
|
|
4354
|
-
//
|
4554
|
+
// lib/dnd/PointerSensor.ts
|
4355
4555
|
init_react_import();
|
4356
4556
|
var import_state3 = require("@dnd-kit/state");
|
4357
4557
|
var import_abstract10 = require("@dnd-kit/abstract");
|
@@ -4613,13 +4813,15 @@ function patchWindow(window2) {
|
|
4613
4813
|
}
|
4614
4814
|
|
4615
4815
|
// components/DragDropContext/index.tsx
|
4616
|
-
var
|
4617
|
-
var
|
4816
|
+
var import_zustand3 = require("zustand");
|
4817
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
4818
|
+
var DEBUG3 = false;
|
4819
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
4618
4820
|
dragListeners: {}
|
4619
4821
|
});
|
4620
4822
|
function useDragListener(type, fn, deps = []) {
|
4621
|
-
const { setDragListeners } = (0,
|
4622
|
-
(0,
|
4823
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
4824
|
+
(0, import_react31.useEffect)(() => {
|
4623
4825
|
if (setDragListeners) {
|
4624
4826
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4625
4827
|
[type]: [...old[type] || [], fn]
|
@@ -4627,80 +4829,147 @@ function useDragListener(type, fn, deps = []) {
|
|
4627
4829
|
}
|
4628
4830
|
}, deps);
|
4629
4831
|
}
|
4630
|
-
var previewContext = (0, import_react25.createContext)(null);
|
4631
4832
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4833
|
+
var useTempDisableFallback = (timeout3) => {
|
4834
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
4835
|
+
return (0, import_react31.useCallback)((manager) => {
|
4836
|
+
collisionStore.setState({ fallbackEnabled: false });
|
4837
|
+
const fallbackId = generateId();
|
4838
|
+
lastFallbackDisable.current = fallbackId;
|
4839
|
+
setTimeout(() => {
|
4840
|
+
if (lastFallbackDisable.current === fallbackId) {
|
4841
|
+
collisionStore.setState({ fallbackEnabled: true });
|
4842
|
+
manager.collisionObserver.forceUpdate(true);
|
4843
|
+
}
|
4844
|
+
}, timeout3);
|
4845
|
+
}, []);
|
4846
|
+
};
|
4632
4847
|
var DragDropContextClient = ({
|
4633
4848
|
children,
|
4634
4849
|
disableAutoScroll
|
4635
4850
|
}) => {
|
4636
4851
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4637
|
-
const
|
4638
|
-
const previewRef = (0, import_react25.useRef)(null);
|
4852
|
+
const id = (0, import_react31.useId)();
|
4639
4853
|
const { data } = state;
|
4640
|
-
const
|
4641
|
-
const
|
4642
|
-
const
|
4643
|
-
|
4644
|
-
|
4854
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
4855
|
+
const tempDisableFallback = useTempDisableFallback(100);
|
4856
|
+
const [zoneStore] = (0, import_react31.useState)(
|
4857
|
+
() => (0, import_zustand3.createStore)(() => ({
|
4858
|
+
zoneDepthIndex: {},
|
4859
|
+
nextZoneDepthIndex: {},
|
4860
|
+
areaDepthIndex: {},
|
4861
|
+
nextAreaDepthIndex: {},
|
4862
|
+
draggedItem: null,
|
4863
|
+
previewIndex: {}
|
4864
|
+
}))
|
4865
|
+
);
|
4866
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
4867
|
+
(params, id2) => {
|
4868
|
+
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4869
|
+
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
4870
|
+
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
4871
|
+
let zoneChanged = false;
|
4872
|
+
let areaChanged = false;
|
4873
|
+
if (params.zone && !zoneDepthIndex[params.zone]) {
|
4874
|
+
zoneChanged = true;
|
4875
|
+
} else if (!params.zone && stateHasZone) {
|
4876
|
+
zoneChanged = true;
|
4877
|
+
}
|
4878
|
+
if (params.area && !areaDepthIndex[params.area]) {
|
4879
|
+
areaChanged = true;
|
4880
|
+
} else if (!params.area && stateHasArea) {
|
4881
|
+
areaChanged = true;
|
4882
|
+
}
|
4883
|
+
return { zoneChanged, areaChanged };
|
4884
|
+
},
|
4885
|
+
[zoneStore]
|
4886
|
+
);
|
4887
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
4645
4888
|
(params, manager) => {
|
4646
|
-
|
4889
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4890
|
+
if (!zoneChanged && !areaChanged) return;
|
4891
|
+
zoneStore.setState({
|
4892
|
+
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
4893
|
+
areaDepthIndex: params.area ? { [params.area]: true } : {}
|
4894
|
+
});
|
4895
|
+
tempDisableFallback(manager);
|
4647
4896
|
setTimeout(() => {
|
4648
4897
|
manager.collisionObserver.forceUpdate(true);
|
4649
4898
|
}, 50);
|
4650
4899
|
debouncedParamsRef.current = null;
|
4651
4900
|
},
|
4652
|
-
[]
|
4901
|
+
[zoneStore]
|
4653
4902
|
);
|
4654
4903
|
const setDeepestDb = (0, import_use_debounce2.useDebouncedCallback)(
|
4655
4904
|
setDeepestAndCollide,
|
4656
4905
|
AREA_CHANGE_DEBOUNCE_MS
|
4657
4906
|
);
|
4658
|
-
(0, import_react25.useEffect)(() => {
|
4659
|
-
deepestRef.current = deepest;
|
4660
|
-
}, [deepest]);
|
4661
4907
|
const cancelDb = () => {
|
4662
4908
|
setDeepestDb.cancel();
|
4663
4909
|
debouncedParamsRef.current = null;
|
4664
4910
|
};
|
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;
|
4911
|
+
(0, import_react31.useEffect)(() => {
|
4912
|
+
if (DEBUG3) {
|
4913
|
+
zoneStore.subscribe(
|
4914
|
+
(s) => {
|
4915
|
+
var _a, _b;
|
4916
|
+
return console.log(
|
4917
|
+
s.previewIndex,
|
4918
|
+
(_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
|
4919
|
+
(_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
|
4920
|
+
);
|
4680
4921
|
}
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4922
|
+
);
|
4923
|
+
}
|
4924
|
+
}, []);
|
4925
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
4926
|
+
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
4927
|
+
createNestedDroppablePlugin(
|
4928
|
+
{
|
4929
|
+
onChange: (params, manager) => {
|
4930
|
+
const state2 = zoneStore.getState();
|
4931
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4932
|
+
const isDragging = manager.dragOperation.status.dragging;
|
4933
|
+
if (areaChanged || zoneChanged) {
|
4934
|
+
let nextZoneDepthIndex = {};
|
4935
|
+
let nextAreaDepthIndex = {};
|
4936
|
+
if (params.zone) {
|
4937
|
+
nextZoneDepthIndex = { [params.zone]: true };
|
4938
|
+
}
|
4939
|
+
if (params.area) {
|
4940
|
+
nextAreaDepthIndex = { [params.area]: true };
|
4941
|
+
}
|
4942
|
+
zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
|
4943
|
+
}
|
4944
|
+
if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
|
4945
|
+
setDeepestAndCollide(params, manager);
|
4946
|
+
return;
|
4947
|
+
}
|
4948
|
+
if (areaChanged) {
|
4949
|
+
if (isDragging) {
|
4950
|
+
const debouncedParams = debouncedParamsRef.current;
|
4951
|
+
const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
|
4952
|
+
if (!isSameParams) {
|
4953
|
+
cancelDb();
|
4954
|
+
setDeepestDb(params, manager);
|
4955
|
+
debouncedParamsRef.current = params;
|
4956
|
+
}
|
4957
|
+
} else {
|
4686
4958
|
cancelDb();
|
4687
|
-
|
4688
|
-
debouncedParamsRef.current = params;
|
4959
|
+
setDeepestAndCollide(params, manager);
|
4689
4960
|
}
|
4690
|
-
|
4691
|
-
|
4961
|
+
return;
|
4962
|
+
}
|
4963
|
+
if (zoneChanged) {
|
4692
4964
|
setDeepestAndCollide(params, manager);
|
4693
4965
|
}
|
4694
|
-
|
4966
|
+
cancelDb();
|
4695
4967
|
}
|
4696
|
-
|
4697
|
-
|
4698
|
-
|
4699
|
-
cancelDb();
|
4700
|
-
}
|
4701
|
-
})
|
4968
|
+
},
|
4969
|
+
id
|
4970
|
+
)
|
4702
4971
|
]);
|
4703
|
-
const [sensors] = (0,
|
4972
|
+
const [sensors] = (0, import_react31.useState)(() => [
|
4704
4973
|
PointerSensor.configure({
|
4705
4974
|
activationConstraints(event, source) {
|
4706
4975
|
var _a;
|
@@ -4719,11 +4988,10 @@ var DragDropContextClient = ({
|
|
4719
4988
|
}
|
4720
4989
|
})
|
4721
4990
|
]);
|
4722
|
-
const [
|
4723
|
-
const [
|
4724
|
-
const
|
4725
|
-
const
|
4726
|
-
const registerPath = (0, import_react25.useCallback)(
|
4991
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
4992
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
4993
|
+
const dragMode = (0, import_react31.useRef)(null);
|
4994
|
+
const registerPath = (0, import_react31.useCallback)(
|
4727
4995
|
(selector) => {
|
4728
4996
|
const item = getItem(selector, data);
|
4729
4997
|
if (!item) {
|
@@ -4745,41 +5013,41 @@ var DragDropContextClient = ({
|
|
4745
5013
|
},
|
4746
5014
|
[data, setPathData]
|
4747
5015
|
);
|
4748
|
-
const initialSelector = (0,
|
4749
|
-
return /* @__PURE__ */ (0,
|
5016
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4750
5018
|
dragListenerContext.Provider,
|
4751
5019
|
{
|
4752
5020
|
value: {
|
4753
5021
|
dragListeners,
|
4754
5022
|
setDragListeners
|
4755
5023
|
},
|
4756
|
-
children: /* @__PURE__ */ (0,
|
4757
|
-
|
5024
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5025
|
+
import_react30.DragDropProvider,
|
4758
5026
|
{
|
4759
5027
|
plugins,
|
4760
5028
|
sensors,
|
4761
5029
|
onDragEnd: (event, manager) => {
|
5030
|
+
var _a;
|
4762
5031
|
const { source, target } = event.operation;
|
4763
|
-
deepestRef.current = null;
|
4764
5032
|
if (!source) {
|
4765
|
-
|
5033
|
+
zoneStore.setState({ draggedItem: null });
|
4766
5034
|
return;
|
4767
5035
|
}
|
4768
5036
|
const { zone, index } = source.data;
|
4769
|
-
const
|
4770
|
-
|
5037
|
+
const { previewIndex = {} } = zoneStore.getState() || {};
|
5038
|
+
const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
|
4771
5039
|
setTimeout(() => {
|
4772
|
-
var
|
4773
|
-
|
5040
|
+
var _a2, _b;
|
5041
|
+
zoneStore.setState({ draggedItem: null });
|
4774
5042
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4775
|
-
|
4776
|
-
(
|
5043
|
+
zoneStore.setState({ previewIndex: {} });
|
5044
|
+
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
4777
5045
|
fn(event, manager);
|
4778
5046
|
});
|
4779
5047
|
return;
|
4780
5048
|
}
|
4781
5049
|
if (thisPreview) {
|
4782
|
-
|
5050
|
+
zoneStore.setState({ previewIndex: {} });
|
4783
5051
|
if (thisPreview.type === "insert") {
|
4784
5052
|
insertComponent(
|
4785
5053
|
thisPreview.componentType,
|
@@ -4814,8 +5082,9 @@ var DragDropContextClient = ({
|
|
4814
5082
|
}, 250);
|
4815
5083
|
},
|
4816
5084
|
onDragOver: (event, manager) => {
|
4817
|
-
var _a, _b, _c, _d;
|
5085
|
+
var _a, _b, _c, _d, _e;
|
4818
5086
|
event.preventDefault();
|
5087
|
+
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
4819
5088
|
if (!draggedItem) return;
|
4820
5089
|
cancelDb();
|
4821
5090
|
const { source, target } = event.operation;
|
@@ -4831,7 +5100,7 @@ var DragDropContextClient = ({
|
|
4831
5100
|
const targetData = target.data;
|
4832
5101
|
targetZone = targetData.zone;
|
4833
5102
|
targetIndex = targetData.index;
|
4834
|
-
const collisionData = (
|
5103
|
+
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
4835
5104
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4836
5105
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4837
5106
|
targetIndex = targetIndex - 1;
|
@@ -4843,23 +5112,26 @@ var DragDropContextClient = ({
|
|
4843
5112
|
targetZone = target.id.toString();
|
4844
5113
|
targetIndex = 0;
|
4845
5114
|
}
|
4846
|
-
if (targetId === sourceId || ((
|
5115
|
+
if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
|
4847
5116
|
const [pathId] = path.split(":");
|
4848
5117
|
return pathId === sourceId;
|
4849
5118
|
}))) {
|
4850
5119
|
return;
|
4851
5120
|
}
|
4852
5121
|
if (dragMode.current === "new") {
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4857
|
-
|
4858
|
-
|
4859
|
-
|
5122
|
+
zoneStore.setState({
|
5123
|
+
previewIndex: {
|
5124
|
+
[targetZone]: {
|
5125
|
+
componentType: sourceData.componentType,
|
5126
|
+
type: "insert",
|
5127
|
+
index: targetIndex,
|
5128
|
+
zone: targetZone,
|
5129
|
+
props: {
|
5130
|
+
id: source.id.toString()
|
5131
|
+
}
|
5132
|
+
}
|
4860
5133
|
}
|
4861
|
-
};
|
4862
|
-
setPreview(previewRef.current);
|
5134
|
+
});
|
4863
5135
|
} else {
|
4864
5136
|
if (!initialSelector.current) {
|
4865
5137
|
initialSelector.current = {
|
@@ -4869,17 +5141,20 @@ var DragDropContextClient = ({
|
|
4869
5141
|
}
|
4870
5142
|
const item = getItem(initialSelector.current, data);
|
4871
5143
|
if (item) {
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4878
|
-
|
4879
|
-
|
5144
|
+
zoneStore.setState({
|
5145
|
+
previewIndex: {
|
5146
|
+
[targetZone]: {
|
5147
|
+
componentType: sourceData.componentType,
|
5148
|
+
type: "move",
|
5149
|
+
index: targetIndex,
|
5150
|
+
zone: targetZone,
|
5151
|
+
props: item.props
|
5152
|
+
}
|
5153
|
+
}
|
5154
|
+
});
|
4880
5155
|
}
|
4881
5156
|
}
|
4882
|
-
(
|
5157
|
+
(_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
|
4883
5158
|
fn(event, manager);
|
4884
5159
|
});
|
4885
5160
|
},
|
@@ -4889,45 +5164,61 @@ var DragDropContextClient = ({
|
|
4889
5164
|
type: "setUi",
|
4890
5165
|
ui: { itemSelector: null, isDragging: true }
|
4891
5166
|
});
|
5167
|
+
const { source } = event.operation;
|
5168
|
+
if (source && source.type !== "void") {
|
5169
|
+
const sourceData = source.data;
|
5170
|
+
const item = getItem(
|
5171
|
+
{
|
5172
|
+
zone: sourceData.zone,
|
5173
|
+
index: sourceData.index
|
5174
|
+
},
|
5175
|
+
data
|
5176
|
+
);
|
5177
|
+
if (item) {
|
5178
|
+
zoneStore.setState({
|
5179
|
+
previewIndex: {
|
5180
|
+
[sourceData.zone]: {
|
5181
|
+
componentType: sourceData.componentType,
|
5182
|
+
type: "move",
|
5183
|
+
index: sourceData.index,
|
5184
|
+
zone: sourceData.zone,
|
5185
|
+
props: item.props
|
5186
|
+
}
|
5187
|
+
}
|
5188
|
+
});
|
5189
|
+
}
|
5190
|
+
}
|
4892
5191
|
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4893
5192
|
fn(event, manager);
|
4894
5193
|
});
|
4895
5194
|
},
|
4896
5195
|
onBeforeDragStart: (event) => {
|
4897
5196
|
var _a;
|
4898
|
-
if (draggedItem) {
|
4899
|
-
console.warn("New drag started before previous drag cleaned up");
|
4900
|
-
}
|
4901
5197
|
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4902
5198
|
dragMode.current = isNewComponent ? "new" : "existing";
|
4903
5199
|
initialSelector.current = void 0;
|
4904
|
-
|
5200
|
+
zoneStore.setState({ draggedItem: event.operation.source });
|
4905
5201
|
},
|
4906
|
-
children: /* @__PURE__ */ (0,
|
5202
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4907
5203
|
DropZoneProvider,
|
4908
5204
|
{
|
4909
5205
|
value: {
|
4910
5206
|
data,
|
4911
5207
|
config,
|
4912
|
-
draggedItem,
|
4913
5208
|
mode: "edit",
|
4914
5209
|
areaId: "root",
|
4915
5210
|
depth: 0,
|
4916
5211
|
registerPath,
|
4917
5212
|
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
5213
|
path: []
|
4923
5214
|
},
|
4924
5215
|
children
|
4925
5216
|
}
|
4926
|
-
)
|
5217
|
+
) })
|
4927
5218
|
}
|
4928
|
-
)
|
5219
|
+
)
|
4929
5220
|
}
|
4930
|
-
);
|
5221
|
+
) });
|
4931
5222
|
};
|
4932
5223
|
var DragDropContext = ({
|
4933
5224
|
children,
|
@@ -4937,11 +5228,11 @@ var DragDropContext = ({
|
|
4937
5228
|
if (status === "LOADING") {
|
4938
5229
|
return children;
|
4939
5230
|
}
|
4940
|
-
return /* @__PURE__ */ (0,
|
5231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
4941
5232
|
};
|
4942
5233
|
|
4943
5234
|
// components/Drawer/index.tsx
|
4944
|
-
var
|
5235
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
4945
5236
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
4946
5237
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
4947
5238
|
var DrawerItemInner = ({
|
@@ -4951,11 +5242,11 @@ var DrawerItemInner = ({
|
|
4951
5242
|
dragRef,
|
4952
5243
|
isDragDisabled
|
4953
5244
|
}) => {
|
4954
|
-
const CustomInner = (0,
|
4955
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
5245
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5246
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
4956
5247
|
[children]
|
4957
5248
|
);
|
4958
|
-
return /* @__PURE__ */ (0,
|
5249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
4959
5250
|
"div",
|
4960
5251
|
{
|
4961
5252
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -4963,9 +5254,9 @@ var DrawerItemInner = ({
|
|
4963
5254
|
onMouseDown: (e) => e.preventDefault(),
|
4964
5255
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
4965
5256
|
"data-puck-drawer-item": true,
|
4966
|
-
children: /* @__PURE__ */ (0,
|
4967
|
-
/* @__PURE__ */ (0,
|
4968
|
-
/* @__PURE__ */ (0,
|
5257
|
+
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: [
|
5258
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
5259
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragIcon, {}) })
|
4969
5260
|
] }) }) })
|
4970
5261
|
}
|
4971
5262
|
);
|
@@ -4982,9 +5273,9 @@ var DrawerItemDraggable = ({
|
|
4982
5273
|
data: { type: "drawer", componentType: name },
|
4983
5274
|
disabled: isDragDisabled
|
4984
5275
|
});
|
4985
|
-
return /* @__PURE__ */ (0,
|
4986
|
-
/* @__PURE__ */ (0,
|
4987
|
-
/* @__PURE__ */ (0,
|
5276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName18("draggable"), children: [
|
5277
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DrawerItemInner, { name, label, children }) }),
|
5278
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
4988
5279
|
DrawerItemInner,
|
4989
5280
|
{
|
4990
5281
|
name,
|
@@ -5005,7 +5296,7 @@ var DrawerItem = ({
|
|
5005
5296
|
isDragDisabled
|
5006
5297
|
}) => {
|
5007
5298
|
const resolvedId = id || name;
|
5008
|
-
const [dynamicId, setDynamicId] = (0,
|
5299
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5009
5300
|
if (typeof index !== "undefined") {
|
5010
5301
|
console.error(
|
5011
5302
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5018,7 +5309,7 @@ var DrawerItem = ({
|
|
5018
5309
|
},
|
5019
5310
|
[resolvedId]
|
5020
5311
|
);
|
5021
|
-
return /* @__PURE__ */ (0,
|
5312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5022
5313
|
DrawerItemDraggable,
|
5023
5314
|
{
|
5024
5315
|
name,
|
@@ -5044,14 +5335,14 @@ var Drawer = ({
|
|
5044
5335
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5045
5336
|
);
|
5046
5337
|
}
|
5047
|
-
const [id] = (0,
|
5338
|
+
const [id] = (0, import_react32.useState)(generateId());
|
5048
5339
|
const { ref } = useDroppableSafe({
|
5049
5340
|
id,
|
5050
5341
|
type: "void",
|
5051
5342
|
collisionPriority: 0
|
5052
5343
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
5053
5344
|
});
|
5054
|
-
return /* @__PURE__ */ (0,
|
5345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5055
5346
|
"div",
|
5056
5347
|
{
|
5057
5348
|
className: getClassName18(),
|
@@ -5066,7 +5357,7 @@ Drawer.Item = DrawerItem;
|
|
5066
5357
|
|
5067
5358
|
// components/Puck/index.tsx
|
5068
5359
|
init_react_import();
|
5069
|
-
var
|
5360
|
+
var import_react48 = require("react");
|
5070
5361
|
|
5071
5362
|
// components/SidebarSection/index.tsx
|
5072
5363
|
init_react_import();
|
@@ -5077,7 +5368,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
5077
5368
|
|
5078
5369
|
// lib/use-breadcrumbs.ts
|
5079
5370
|
init_react_import();
|
5080
|
-
var
|
5371
|
+
var import_react33 = require("react");
|
5081
5372
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5082
5373
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5083
5374
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5127,8 +5418,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5127
5418
|
state: { data },
|
5128
5419
|
selectedItem
|
5129
5420
|
} = useAppContext();
|
5130
|
-
const dzContext = (0,
|
5131
|
-
return (0,
|
5421
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5422
|
+
return (0, import_react33.useMemo)(() => {
|
5132
5423
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5133
5424
|
selectedItem,
|
5134
5425
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5142,7 +5433,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
5142
5433
|
};
|
5143
5434
|
|
5144
5435
|
// components/SidebarSection/index.tsx
|
5145
|
-
var
|
5436
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
5146
5437
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5147
5438
|
var SidebarSection = ({
|
5148
5439
|
children,
|
@@ -5155,15 +5446,15 @@ var SidebarSection = ({
|
|
5155
5446
|
}) => {
|
5156
5447
|
const { setUi } = useAppContext();
|
5157
5448
|
const breadcrumbs = useBreadcrumbs(1);
|
5158
|
-
return /* @__PURE__ */ (0,
|
5449
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
5159
5450
|
"div",
|
5160
5451
|
{
|
5161
5452
|
className: getClassName19({ noBorderTop, noPadding }),
|
5162
5453
|
style: { background },
|
5163
5454
|
children: [
|
5164
|
-
/* @__PURE__ */ (0,
|
5165
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
5166
|
-
/* @__PURE__ */ (0,
|
5455
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
5456
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
5457
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5167
5458
|
"button",
|
5168
5459
|
{
|
5169
5460
|
type: "button",
|
@@ -5172,12 +5463,12 @@ var SidebarSection = ({
|
|
5172
5463
|
children: breadcrumb.label
|
5173
5464
|
}
|
5174
5465
|
),
|
5175
|
-
/* @__PURE__ */ (0,
|
5466
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
|
5176
5467
|
] }, i)) : null,
|
5177
|
-
/* @__PURE__ */ (0,
|
5468
|
+
/* @__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
5469
|
] }) }),
|
5179
|
-
/* @__PURE__ */ (0,
|
5180
|
-
isLoading && /* @__PURE__ */ (0,
|
5470
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
|
5471
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
|
5181
5472
|
]
|
5182
5473
|
}
|
5183
5474
|
);
|
@@ -5208,7 +5499,7 @@ init_react_import();
|
|
5208
5499
|
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
5500
|
|
5210
5501
|
// components/MenuBar/index.tsx
|
5211
|
-
var
|
5502
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
5212
5503
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5213
5504
|
function MenuBar({
|
5214
5505
|
appState,
|
@@ -5222,7 +5513,7 @@ function MenuBar({
|
|
5222
5513
|
history: { back, forward, historyStore }
|
5223
5514
|
} = useAppContext();
|
5224
5515
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5225
|
-
return /* @__PURE__ */ (0,
|
5516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
5226
5517
|
"div",
|
5227
5518
|
{
|
5228
5519
|
className: getClassName20({ menuOpen }),
|
@@ -5236,12 +5527,12 @@ function MenuBar({
|
|
5236
5527
|
setMenuOpen(false);
|
5237
5528
|
}
|
5238
5529
|
},
|
5239
|
-
children: /* @__PURE__ */ (0,
|
5240
|
-
/* @__PURE__ */ (0,
|
5241
|
-
/* @__PURE__ */ (0,
|
5242
|
-
/* @__PURE__ */ (0,
|
5530
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
|
5531
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
|
5532
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
|
5533
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
|
5243
5534
|
] }),
|
5244
|
-
/* @__PURE__ */ (0,
|
5535
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
5245
5536
|
state: appState,
|
5246
5537
|
dispatch
|
5247
5538
|
}) })
|
@@ -5252,7 +5543,7 @@ function MenuBar({
|
|
5252
5543
|
|
5253
5544
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5254
5545
|
init_react_import();
|
5255
|
-
var styles_module_default15 = { "Puck": "
|
5546
|
+
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
5547
|
|
5257
5548
|
// components/Puck/components/Fields/index.tsx
|
5258
5549
|
init_react_import();
|
@@ -5262,15 +5553,15 @@ init_react_import();
|
|
5262
5553
|
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
5554
|
|
5264
5555
|
// components/Puck/components/Fields/index.tsx
|
5265
|
-
var
|
5556
|
+
var import_react35 = require("react");
|
5266
5557
|
|
5267
5558
|
// lib/use-parent.ts
|
5268
5559
|
init_react_import();
|
5269
|
-
var
|
5560
|
+
var import_react34 = require("react");
|
5270
5561
|
var useParent = (itemSelector) => {
|
5271
5562
|
var _a;
|
5272
5563
|
const { selectedItem, state } = useAppContext();
|
5273
|
-
const { pathData } = (0,
|
5564
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5274
5565
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
5275
5566
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5276
5567
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -5279,7 +5570,7 @@ var useParent = (itemSelector) => {
|
|
5279
5570
|
};
|
5280
5571
|
|
5281
5572
|
// components/Puck/components/Fields/index.tsx
|
5282
|
-
var
|
5573
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
5283
5574
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5284
5575
|
var defaultPageFields = {
|
5285
5576
|
title: { type: "text" }
|
@@ -5287,7 +5578,7 @@ var defaultPageFields = {
|
|
5287
5578
|
var DefaultFields = ({
|
5288
5579
|
children
|
5289
5580
|
}) => {
|
5290
|
-
return /* @__PURE__ */ (0,
|
5581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5291
5582
|
};
|
5292
5583
|
var useResolvedFields = () => {
|
5293
5584
|
var _a, _b;
|
@@ -5296,20 +5587,20 @@ var useResolvedFields = () => {
|
|
5296
5587
|
const { data } = state;
|
5297
5588
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5298
5589
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5299
|
-
const defaultFields = (0,
|
5590
|
+
const defaultFields = (0, import_react35.useMemo)(
|
5300
5591
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5301
5592
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5302
5593
|
);
|
5303
5594
|
const rootProps = data.root.props || data.root;
|
5304
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5305
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5306
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5595
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react35.useState)({});
|
5596
|
+
const [resolvedFields, setResolvedFields] = (0, import_react35.useState)(defaultFields);
|
5597
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react35.useState)(false);
|
5307
5598
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5308
5599
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5309
5600
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5310
5601
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5311
5602
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5312
|
-
const resolveFields = (0,
|
5603
|
+
const resolveFields = (0, import_react35.useCallback)(
|
5313
5604
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5314
5605
|
var _a2;
|
5315
5606
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5347,7 +5638,7 @@ var useResolvedFields = () => {
|
|
5347
5638
|
}),
|
5348
5639
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
5349
5640
|
);
|
5350
|
-
(0,
|
5641
|
+
(0, import_react35.useEffect)(() => {
|
5351
5642
|
if (hasResolver) {
|
5352
5643
|
setFieldsLoading(true);
|
5353
5644
|
resolveFields(defaultFields).then((fields) => {
|
@@ -5378,8 +5669,8 @@ var Fields = () => {
|
|
5378
5669
|
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
5670
|
const isLoading = fieldsResolving || componentResolving;
|
5380
5671
|
const rootProps = data.root.props || data.root;
|
5381
|
-
const Wrapper = (0,
|
5382
|
-
return /* @__PURE__ */ (0,
|
5672
|
+
const Wrapper = (0, import_react35.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5383
5674
|
"form",
|
5384
5675
|
{
|
5385
5676
|
className: getClassName21(),
|
@@ -5387,7 +5678,7 @@ var Fields = () => {
|
|
5387
5678
|
e.preventDefault();
|
5388
5679
|
},
|
5389
5680
|
children: [
|
5390
|
-
/* @__PURE__ */ (0,
|
5681
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5391
5682
|
const field = fields[fieldName];
|
5392
5683
|
if (!(field == null ? void 0 : field.type)) return null;
|
5393
5684
|
const onChange = (value, updatedUi) => {
|
@@ -5458,7 +5749,7 @@ var Fields = () => {
|
|
5458
5749
|
item: selectedItem
|
5459
5750
|
});
|
5460
5751
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5461
|
-
return /* @__PURE__ */ (0,
|
5752
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5462
5753
|
AutoFieldPrivate,
|
5463
5754
|
{
|
5464
5755
|
field,
|
@@ -5476,7 +5767,7 @@ var Fields = () => {
|
|
5476
5767
|
root: true
|
5477
5768
|
});
|
5478
5769
|
const id = `root_${field.type}_${fieldName}`;
|
5479
|
-
return /* @__PURE__ */ (0,
|
5770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5480
5771
|
AutoFieldPrivate,
|
5481
5772
|
{
|
5482
5773
|
field,
|
@@ -5490,7 +5781,7 @@ var Fields = () => {
|
|
5490
5781
|
);
|
5491
5782
|
}
|
5492
5783
|
}) }),
|
5493
|
-
isLoading && /* @__PURE__ */ (0,
|
5784
|
+
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
5785
|
]
|
5495
5786
|
}
|
5496
5787
|
);
|
@@ -5501,7 +5792,7 @@ init_react_import();
|
|
5501
5792
|
|
5502
5793
|
// lib/use-component-list.tsx
|
5503
5794
|
init_react_import();
|
5504
|
-
var
|
5795
|
+
var import_react36 = require("react");
|
5505
5796
|
|
5506
5797
|
// components/ComponentList/index.tsx
|
5507
5798
|
init_react_import();
|
@@ -5511,7 +5802,7 @@ init_react_import();
|
|
5511
5802
|
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
5803
|
|
5513
5804
|
// components/ComponentList/index.tsx
|
5514
|
-
var
|
5805
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
5515
5806
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5516
5807
|
var ComponentListItem = ({
|
5517
5808
|
name,
|
@@ -5521,7 +5812,7 @@ var ComponentListItem = ({
|
|
5521
5812
|
const canInsert = getPermissions({
|
5522
5813
|
type: name
|
5523
5814
|
}).insert;
|
5524
|
-
return /* @__PURE__ */ (0,
|
5815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5525
5816
|
};
|
5526
5817
|
var ComponentList = ({
|
5527
5818
|
children,
|
@@ -5530,8 +5821,8 @@ var ComponentList = ({
|
|
5530
5821
|
}) => {
|
5531
5822
|
const { config, state, setUi } = useAppContext();
|
5532
5823
|
const { expanded = true } = state.ui.componentList[id] || {};
|
5533
|
-
return /* @__PURE__ */ (0,
|
5534
|
-
title && /* @__PURE__ */ (0,
|
5824
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
5825
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
5535
5826
|
"button",
|
5536
5827
|
{
|
5537
5828
|
type: "button",
|
@@ -5545,14 +5836,14 @@ var ComponentList = ({
|
|
5545
5836
|
}),
|
5546
5837
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5547
5838
|
children: [
|
5548
|
-
/* @__PURE__ */ (0,
|
5549
|
-
/* @__PURE__ */ (0,
|
5839
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
|
5840
|
+
/* @__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
5841
|
]
|
5551
5842
|
}
|
5552
5843
|
),
|
5553
|
-
/* @__PURE__ */ (0,
|
5844
|
+
/* @__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
5845
|
var _a;
|
5555
|
-
return /* @__PURE__ */ (0,
|
5846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
5556
5847
|
ComponentListItem,
|
5557
5848
|
{
|
5558
5849
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5566,10 +5857,10 @@ var ComponentList = ({
|
|
5566
5857
|
ComponentList.Item = ComponentListItem;
|
5567
5858
|
|
5568
5859
|
// lib/use-component-list.tsx
|
5569
|
-
var
|
5860
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5570
5861
|
var useComponentList = (config, ui) => {
|
5571
|
-
const [componentList, setComponentList] = (0,
|
5572
|
-
(0,
|
5862
|
+
const [componentList, setComponentList] = (0, import_react36.useState)();
|
5863
|
+
(0, import_react36.useEffect)(() => {
|
5573
5864
|
var _a, _b, _c;
|
5574
5865
|
if (Object.keys(ui.componentList).length > 0) {
|
5575
5866
|
const matchedComponents = [];
|
@@ -5579,7 +5870,7 @@ var useComponentList = (config, ui) => {
|
|
5579
5870
|
if (category.visible === false || !category.components) {
|
5580
5871
|
return null;
|
5581
5872
|
}
|
5582
|
-
return /* @__PURE__ */ (0,
|
5873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5583
5874
|
ComponentList,
|
5584
5875
|
{
|
5585
5876
|
id: categoryKey,
|
@@ -5588,7 +5879,7 @@ var useComponentList = (config, ui) => {
|
|
5588
5879
|
var _a2;
|
5589
5880
|
matchedComponents.push(componentName);
|
5590
5881
|
const componentConf = config.components[componentName] || {};
|
5591
|
-
return /* @__PURE__ */ (0,
|
5882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5592
5883
|
ComponentList.Item,
|
5593
5884
|
{
|
5594
5885
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5608,7 +5899,7 @@ var useComponentList = (config, ui) => {
|
|
5608
5899
|
);
|
5609
5900
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5610
5901
|
_componentList.push(
|
5611
|
-
/* @__PURE__ */ (0,
|
5902
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5612
5903
|
ComponentList,
|
5613
5904
|
{
|
5614
5905
|
id: "other",
|
@@ -5616,7 +5907,7 @@ var useComponentList = (config, ui) => {
|
|
5616
5907
|
children: remainingComponents.map((componentName, i) => {
|
5617
5908
|
var _a2;
|
5618
5909
|
const componentConf = config.components[componentName] || {};
|
5619
|
-
return /* @__PURE__ */ (0,
|
5910
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5620
5911
|
ComponentList.Item,
|
5621
5912
|
{
|
5622
5913
|
name: componentName,
|
@@ -5638,25 +5929,25 @@ var useComponentList = (config, ui) => {
|
|
5638
5929
|
};
|
5639
5930
|
|
5640
5931
|
// components/Puck/components/Components/index.tsx
|
5641
|
-
var
|
5642
|
-
var
|
5932
|
+
var import_react37 = require("react");
|
5933
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5643
5934
|
var Components = () => {
|
5644
5935
|
const { config, state, overrides } = useAppContext();
|
5645
5936
|
const componentList = useComponentList(config, state.ui);
|
5646
|
-
const Wrapper = (0,
|
5647
|
-
return /* @__PURE__ */ (0,
|
5937
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.components || "div", [overrides]);
|
5938
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
5648
5939
|
};
|
5649
5940
|
|
5650
5941
|
// components/Puck/components/Preview/index.tsx
|
5651
5942
|
init_react_import();
|
5652
|
-
var
|
5943
|
+
var import_react39 = require("react");
|
5653
5944
|
|
5654
5945
|
// components/AutoFrame/index.tsx
|
5655
5946
|
init_react_import();
|
5656
|
-
var
|
5947
|
+
var import_react38 = require("react");
|
5657
5948
|
var import_object_hash = __toESM(require("object-hash"));
|
5658
5949
|
var import_react_dom3 = require("react-dom");
|
5659
|
-
var
|
5950
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
5660
5951
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5661
5952
|
var collectStyles = (doc) => {
|
5662
5953
|
const collected = [];
|
@@ -5699,7 +5990,7 @@ var CopyHostStyles = ({
|
|
5699
5990
|
onStylesLoaded = () => null
|
5700
5991
|
}) => {
|
5701
5992
|
const { document: doc, window: win } = useFrame();
|
5702
|
-
(0,
|
5993
|
+
(0, import_react38.useEffect)(() => {
|
5703
5994
|
if (!win || !doc) {
|
5704
5995
|
return () => {
|
5705
5996
|
};
|
@@ -5856,10 +6147,10 @@ var CopyHostStyles = ({
|
|
5856
6147
|
observer.disconnect();
|
5857
6148
|
};
|
5858
6149
|
}, []);
|
5859
|
-
return /* @__PURE__ */ (0,
|
6150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
5860
6151
|
};
|
5861
|
-
var autoFrameContext = (0,
|
5862
|
-
var useFrame = () => (0,
|
6152
|
+
var autoFrameContext = (0, import_react38.createContext)({});
|
6153
|
+
var useFrame = () => (0, import_react38.useContext)(autoFrameContext);
|
5863
6154
|
function AutoFrame(_a) {
|
5864
6155
|
var _b = _a, {
|
5865
6156
|
children,
|
@@ -5876,10 +6167,10 @@ function AutoFrame(_a) {
|
|
5876
6167
|
"onStylesLoaded",
|
5877
6168
|
"frameRef"
|
5878
6169
|
]);
|
5879
|
-
const [loaded, setLoaded] = (0,
|
5880
|
-
const [ctx, setCtx] = (0,
|
5881
|
-
const [mountTarget, setMountTarget] = (0,
|
5882
|
-
(0,
|
6170
|
+
const [loaded, setLoaded] = (0, import_react38.useState)(false);
|
6171
|
+
const [ctx, setCtx] = (0, import_react38.useState)({});
|
6172
|
+
const [mountTarget, setMountTarget] = (0, import_react38.useState)();
|
6173
|
+
(0, import_react38.useEffect)(() => {
|
5883
6174
|
var _a2;
|
5884
6175
|
if (frameRef.current) {
|
5885
6176
|
setCtx({
|
@@ -5891,7 +6182,7 @@ function AutoFrame(_a) {
|
|
5891
6182
|
);
|
5892
6183
|
}
|
5893
6184
|
}, [frameRef, loaded]);
|
5894
|
-
return /* @__PURE__ */ (0,
|
6185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
5895
6186
|
"iframe",
|
5896
6187
|
__spreadProps(__spreadValues({}, props), {
|
5897
6188
|
className,
|
@@ -5901,7 +6192,7 @@ function AutoFrame(_a) {
|
|
5901
6192
|
onLoad: () => {
|
5902
6193
|
setLoaded(true);
|
5903
6194
|
},
|
5904
|
-
children: /* @__PURE__ */ (0,
|
6195
|
+
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
6196
|
})
|
5906
6197
|
);
|
5907
6198
|
}
|
@@ -5914,7 +6205,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
|
|
5914
6205
|
|
5915
6206
|
// components/Render/index.tsx
|
5916
6207
|
init_react_import();
|
5917
|
-
var
|
6208
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
5918
6209
|
function Render({
|
5919
6210
|
config,
|
5920
6211
|
data
|
@@ -5927,7 +6218,7 @@ function Render({
|
|
5927
6218
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
5928
6219
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
5929
6220
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5930
|
-
return /* @__PURE__ */ (0,
|
6221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
5931
6222
|
DropZoneProvider,
|
5932
6223
|
{
|
5933
6224
|
value: {
|
@@ -5937,7 +6228,7 @@ function Render({
|
|
5937
6228
|
depth: 0,
|
5938
6229
|
path: []
|
5939
6230
|
},
|
5940
|
-
children: /* @__PURE__ */ (0,
|
6231
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
5941
6232
|
config.root.render,
|
5942
6233
|
__spreadProps(__spreadValues({}, rootProps), {
|
5943
6234
|
puck: {
|
@@ -5947,13 +6238,13 @@ function Render({
|
|
5947
6238
|
title,
|
5948
6239
|
editMode: false,
|
5949
6240
|
id: "puck-root",
|
5950
|
-
children: /* @__PURE__ */ (0,
|
6241
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
5951
6242
|
})
|
5952
6243
|
)
|
5953
6244
|
}
|
5954
6245
|
);
|
5955
6246
|
}
|
5956
|
-
return /* @__PURE__ */ (0,
|
6247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
5957
6248
|
DropZoneProvider,
|
5958
6249
|
{
|
5959
6250
|
value: {
|
@@ -5963,17 +6254,17 @@ function Render({
|
|
5963
6254
|
depth: 0,
|
5964
6255
|
path: []
|
5965
6256
|
},
|
5966
|
-
children: /* @__PURE__ */ (0,
|
6257
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
5967
6258
|
}
|
5968
6259
|
);
|
5969
6260
|
}
|
5970
6261
|
|
5971
6262
|
// components/Puck/components/Preview/index.tsx
|
5972
|
-
var
|
6263
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
5973
6264
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5974
6265
|
var useBubbleIframeEvents = (ref) => {
|
5975
6266
|
const { status } = useAppContext();
|
5976
|
-
(0,
|
6267
|
+
(0, import_react39.useEffect)(() => {
|
5977
6268
|
var _a;
|
5978
6269
|
if (ref.current && status === "READY") {
|
5979
6270
|
const iframe = ref.current;
|
@@ -6010,22 +6301,22 @@ var useBubbleIframeEvents = (ref) => {
|
|
6010
6301
|
}
|
6011
6302
|
}, [status]);
|
6012
6303
|
};
|
6013
|
-
var
|
6304
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
6014
6305
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6015
|
-
const Page = (0,
|
6306
|
+
const Page = (0, import_react39.useCallback)(
|
6016
6307
|
(pageProps) => {
|
6017
6308
|
var _a, _b;
|
6018
6309
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
6019
6310
|
id: "puck-root"
|
6020
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
6311
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
6021
6312
|
},
|
6022
6313
|
[config.root]
|
6023
6314
|
);
|
6024
|
-
const Frame = (0,
|
6315
|
+
const Frame = (0, import_react39.useMemo)(() => overrides.iframe, [overrides]);
|
6025
6316
|
const rootProps = state.data.root.props || state.data.root;
|
6026
|
-
const ref = (0,
|
6317
|
+
const ref = (0, import_react39.useRef)(null);
|
6027
6318
|
useBubbleIframeEvents(ref);
|
6028
|
-
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0,
|
6319
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6029
6320
|
Page,
|
6030
6321
|
__spreadProps(__spreadValues({}, rootProps), {
|
6031
6322
|
puck: {
|
@@ -6034,10 +6325,10 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6034
6325
|
dragRef: null
|
6035
6326
|
},
|
6036
6327
|
editMode: true,
|
6037
|
-
children: /* @__PURE__ */ (0,
|
6328
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
6038
6329
|
})
|
6039
|
-
) : /* @__PURE__ */ (0,
|
6040
|
-
return /* @__PURE__ */ (0,
|
6330
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
|
6331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6041
6332
|
"div",
|
6042
6333
|
{
|
6043
6334
|
className: getClassName23(),
|
@@ -6046,7 +6337,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6046
6337
|
onClick: () => {
|
6047
6338
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
6048
6339
|
},
|
6049
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
6340
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6050
6341
|
AutoFrame_default,
|
6051
6342
|
{
|
6052
6343
|
id: "preview-frame",
|
@@ -6056,14 +6347,14 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6056
6347
|
setStatus("READY");
|
6057
6348
|
},
|
6058
6349
|
frameRef: ref,
|
6059
|
-
children: /* @__PURE__ */ (0,
|
6350
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
6060
6351
|
if (Frame) {
|
6061
|
-
return /* @__PURE__ */ (0,
|
6352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
6062
6353
|
}
|
6063
6354
|
return inner;
|
6064
6355
|
} })
|
6065
6356
|
}
|
6066
|
-
) : /* @__PURE__ */ (0,
|
6357
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6067
6358
|
"div",
|
6068
6359
|
{
|
6069
6360
|
id: "preview-frame",
|
@@ -6120,7 +6411,7 @@ var scrollIntoView = (el) => {
|
|
6120
6411
|
};
|
6121
6412
|
|
6122
6413
|
// components/LayerTree/index.tsx
|
6123
|
-
var
|
6414
|
+
var import_react40 = require("react");
|
6124
6415
|
|
6125
6416
|
// lib/is-child-of-zone.ts
|
6126
6417
|
init_react_import();
|
@@ -6153,7 +6444,7 @@ var onScrollEnd = (frame, cb) => {
|
|
6153
6444
|
};
|
6154
6445
|
|
6155
6446
|
// components/LayerTree/index.tsx
|
6156
|
-
var
|
6447
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6157
6448
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6158
6449
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6159
6450
|
var LayerTree = ({
|
@@ -6166,15 +6457,15 @@ var LayerTree = ({
|
|
6166
6457
|
label
|
6167
6458
|
}) => {
|
6168
6459
|
const zones = data.zones || {};
|
6169
|
-
const ctx = (0,
|
6170
|
-
return /* @__PURE__ */ (0,
|
6171
|
-
label && /* @__PURE__ */ (0,
|
6172
|
-
/* @__PURE__ */ (0,
|
6460
|
+
const ctx = (0, import_react40.useContext)(dropZoneContext);
|
6461
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6462
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6463
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
6173
6464
|
" ",
|
6174
6465
|
label
|
6175
6466
|
] }),
|
6176
|
-
/* @__PURE__ */ (0,
|
6177
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
6467
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
|
6468
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
6178
6469
|
zoneContent.map((item, i) => {
|
6179
6470
|
var _a;
|
6180
6471
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6187,7 +6478,7 @@ var LayerTree = ({
|
|
6187
6478
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
6188
6479
|
const componentConfig = config.components[item.type];
|
6189
6480
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
6190
|
-
return /* @__PURE__ */ (0,
|
6481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6191
6482
|
"li",
|
6192
6483
|
{
|
6193
6484
|
className: getClassNameLayer({
|
@@ -6197,7 +6488,7 @@ var LayerTree = ({
|
|
6197
6488
|
childIsSelected
|
6198
6489
|
}),
|
6199
6490
|
children: [
|
6200
|
-
/* @__PURE__ */ (0,
|
6491
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6201
6492
|
"button",
|
6202
6493
|
{
|
6203
6494
|
type: "button",
|
@@ -6236,22 +6527,22 @@ var LayerTree = ({
|
|
6236
6527
|
setHoveringComponent(null);
|
6237
6528
|
},
|
6238
6529
|
children: [
|
6239
|
-
containsZone && /* @__PURE__ */ (0,
|
6530
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6240
6531
|
"div",
|
6241
6532
|
{
|
6242
6533
|
className: getClassNameLayer("chevron"),
|
6243
6534
|
title: isSelected ? "Collapse" : "Expand",
|
6244
|
-
children: /* @__PURE__ */ (0,
|
6535
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
6245
6536
|
}
|
6246
6537
|
),
|
6247
|
-
/* @__PURE__ */ (0,
|
6248
|
-
/* @__PURE__ */ (0,
|
6249
|
-
/* @__PURE__ */ (0,
|
6538
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
6539
|
+
/* @__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" }) }),
|
6540
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
6250
6541
|
] })
|
6251
6542
|
]
|
6252
6543
|
}
|
6253
6544
|
) }),
|
6254
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
6545
|
+
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
6546
|
LayerTree,
|
6256
6547
|
{
|
6257
6548
|
config,
|
@@ -6273,13 +6564,13 @@ var LayerTree = ({
|
|
6273
6564
|
};
|
6274
6565
|
|
6275
6566
|
// components/Puck/components/Outline/index.tsx
|
6276
|
-
var
|
6277
|
-
var
|
6567
|
+
var import_react41 = require("react");
|
6568
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6278
6569
|
var Outline = () => {
|
6279
6570
|
const { dispatch, state, overrides, config } = useAppContext();
|
6280
6571
|
const { data, ui } = state;
|
6281
6572
|
const { itemSelector } = ui;
|
6282
|
-
const setItemSelector = (0,
|
6573
|
+
const setItemSelector = (0, import_react41.useCallback)(
|
6283
6574
|
(newItemSelector) => {
|
6284
6575
|
dispatch({
|
6285
6576
|
type: "setUi",
|
@@ -6288,9 +6579,9 @@ var Outline = () => {
|
|
6288
6579
|
},
|
6289
6580
|
[]
|
6290
6581
|
);
|
6291
|
-
const Wrapper = (0,
|
6292
|
-
return /* @__PURE__ */ (0,
|
6293
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
6582
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.outline || "div", [overrides]);
|
6583
|
+
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: [
|
6584
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6294
6585
|
LayerTree,
|
6295
6586
|
{
|
6296
6587
|
config,
|
@@ -6303,7 +6594,7 @@ var Outline = () => {
|
|
6303
6594
|
),
|
6304
6595
|
Object.entries(findZonesForArea(data, "root")).map(
|
6305
6596
|
([zoneKey, zone]) => {
|
6306
|
-
return /* @__PURE__ */ (0,
|
6597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6307
6598
|
LayerTree,
|
6308
6599
|
{
|
6309
6600
|
config,
|
@@ -6402,19 +6693,19 @@ function usePuckHistory({
|
|
6402
6693
|
|
6403
6694
|
// lib/use-history-store.ts
|
6404
6695
|
init_react_import();
|
6405
|
-
var
|
6696
|
+
var import_react42 = require("react");
|
6406
6697
|
var import_use_debounce3 = require("use-debounce");
|
6407
6698
|
var EMPTY_HISTORY_INDEX = 0;
|
6408
6699
|
function useHistoryStore(initialHistory) {
|
6409
6700
|
var _a, _b;
|
6410
|
-
const [histories, setHistories] = (0,
|
6701
|
+
const [histories, setHistories] = (0, import_react42.useState)(
|
6411
6702
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6412
6703
|
);
|
6413
6704
|
const updateHistories = (histories2) => {
|
6414
6705
|
setHistories(histories2);
|
6415
6706
|
setIndex(histories2.length - 1);
|
6416
6707
|
};
|
6417
|
-
const [index, setIndex] = (0,
|
6708
|
+
const [index, setIndex] = (0, import_react42.useState)(
|
6418
6709
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6419
6710
|
);
|
6420
6711
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6574,22 +6865,22 @@ var getBox = function getBox2(el) {
|
|
6574
6865
|
};
|
6575
6866
|
|
6576
6867
|
// components/Puck/components/Canvas/index.tsx
|
6577
|
-
var
|
6868
|
+
var import_react44 = require("react");
|
6578
6869
|
|
6579
6870
|
// components/ViewportControls/index.tsx
|
6580
6871
|
init_react_import();
|
6581
|
-
var
|
6872
|
+
var import_react43 = require("react");
|
6582
6873
|
|
6583
6874
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6584
6875
|
init_react_import();
|
6585
6876
|
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
6877
|
|
6587
6878
|
// components/ViewportControls/index.tsx
|
6588
|
-
var
|
6879
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
6589
6880
|
var icons = {
|
6590
|
-
Smartphone: /* @__PURE__ */ (0,
|
6591
|
-
Tablet: /* @__PURE__ */ (0,
|
6592
|
-
Monitor: /* @__PURE__ */ (0,
|
6881
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
|
6882
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
|
6883
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
|
6593
6884
|
};
|
6594
6885
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6595
6886
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6601,11 +6892,11 @@ var ViewportButton = ({
|
|
6601
6892
|
onClick
|
6602
6893
|
}) => {
|
6603
6894
|
const { state } = useAppContext();
|
6604
|
-
const [isActive, setIsActive] = (0,
|
6605
|
-
(0,
|
6895
|
+
const [isActive, setIsActive] = (0, import_react43.useState)(false);
|
6896
|
+
(0, import_react43.useEffect)(() => {
|
6606
6897
|
setIsActive(width === state.ui.viewports.current.width);
|
6607
6898
|
}, [width, state.ui.viewports.current.width]);
|
6608
|
-
return /* @__PURE__ */ (0,
|
6899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6609
6900
|
IconButton,
|
6610
6901
|
{
|
6611
6902
|
title,
|
@@ -6614,7 +6905,7 @@ var ViewportButton = ({
|
|
6614
6905
|
e.stopPropagation();
|
6615
6906
|
onClick({ width, height });
|
6616
6907
|
},
|
6617
|
-
children: /* @__PURE__ */ (0,
|
6908
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
|
6618
6909
|
}
|
6619
6910
|
) });
|
6620
6911
|
};
|
@@ -6638,7 +6929,7 @@ var ViewportControls = ({
|
|
6638
6929
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6639
6930
|
(option) => option.value === autoZoom
|
6640
6931
|
);
|
6641
|
-
const zoomOptions = (0,
|
6932
|
+
const zoomOptions = (0, import_react43.useMemo)(
|
6642
6933
|
() => [
|
6643
6934
|
...defaultZoomOptions,
|
6644
6935
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6650,8 +6941,8 @@ var ViewportControls = ({
|
|
6650
6941
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
6651
6942
|
[autoZoom]
|
6652
6943
|
);
|
6653
|
-
return /* @__PURE__ */ (0,
|
6654
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
6944
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
|
6945
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6655
6946
|
ViewportButton,
|
6656
6947
|
{
|
6657
6948
|
height: viewport.height,
|
@@ -6662,8 +6953,8 @@ var ViewportControls = ({
|
|
6662
6953
|
},
|
6663
6954
|
i
|
6664
6955
|
)),
|
6665
|
-
/* @__PURE__ */ (0,
|
6666
|
-
/* @__PURE__ */ (0,
|
6956
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
6957
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6667
6958
|
IconButton,
|
6668
6959
|
{
|
6669
6960
|
title: "Zoom viewport out",
|
@@ -6677,10 +6968,10 @@ var ViewportControls = ({
|
|
6677
6968
|
)].value
|
6678
6969
|
);
|
6679
6970
|
},
|
6680
|
-
children: /* @__PURE__ */ (0,
|
6971
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
|
6681
6972
|
}
|
6682
6973
|
),
|
6683
|
-
/* @__PURE__ */ (0,
|
6974
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6684
6975
|
IconButton,
|
6685
6976
|
{
|
6686
6977
|
title: "Zoom viewport in",
|
@@ -6694,11 +6985,11 @@ var ViewportControls = ({
|
|
6694
6985
|
)].value
|
6695
6986
|
);
|
6696
6987
|
},
|
6697
|
-
children: /* @__PURE__ */ (0,
|
6988
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
|
6698
6989
|
}
|
6699
6990
|
),
|
6700
|
-
/* @__PURE__ */ (0,
|
6701
|
-
/* @__PURE__ */ (0,
|
6991
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
6992
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6702
6993
|
"select",
|
6703
6994
|
{
|
6704
6995
|
className: getClassName25("zoomSelect"),
|
@@ -6706,7 +6997,7 @@ var ViewportControls = ({
|
|
6706
6997
|
onChange: (e) => {
|
6707
6998
|
onZoom(parseFloat(e.currentTarget.value));
|
6708
6999
|
},
|
6709
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
7000
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6710
7001
|
"option",
|
6711
7002
|
{
|
6712
7003
|
value: option.value,
|
@@ -6754,24 +7045,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6754
7045
|
};
|
6755
7046
|
|
6756
7047
|
// components/Puck/components/Canvas/index.tsx
|
6757
|
-
var
|
7048
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
6758
7049
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6759
7050
|
var ZOOM_ON_CHANGE = true;
|
6760
7051
|
var Canvas = () => {
|
6761
7052
|
const { status, iframe } = useAppContext();
|
6762
7053
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6763
7054
|
const { ui } = state;
|
6764
|
-
const frameRef = (0,
|
6765
|
-
const [showTransition, setShowTransition] = (0,
|
6766
|
-
const defaultRender = (0,
|
6767
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
7055
|
+
const frameRef = (0, import_react44.useRef)(null);
|
7056
|
+
const [showTransition, setShowTransition] = (0, import_react44.useState)(false);
|
7057
|
+
const defaultRender = (0, import_react44.useMemo)(() => {
|
7058
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
6768
7059
|
return PuckDefault;
|
6769
7060
|
}, []);
|
6770
|
-
const CustomPreview = (0,
|
7061
|
+
const CustomPreview = (0, import_react44.useMemo)(
|
6771
7062
|
() => overrides.preview || defaultRender,
|
6772
7063
|
[overrides]
|
6773
7064
|
);
|
6774
|
-
const getFrameDimensions = (0,
|
7065
|
+
const getFrameDimensions = (0, import_react44.useCallback)(() => {
|
6775
7066
|
if (frameRef.current) {
|
6776
7067
|
const frame = frameRef.current;
|
6777
7068
|
const box = getBox(frame);
|
@@ -6779,7 +7070,7 @@ var Canvas = () => {
|
|
6779
7070
|
}
|
6780
7071
|
return { width: 0, height: 0 };
|
6781
7072
|
}, [frameRef]);
|
6782
|
-
const resetAutoZoom = (0,
|
7073
|
+
const resetAutoZoom = (0, import_react44.useCallback)(
|
6783
7074
|
(ui2 = state.ui) => {
|
6784
7075
|
if (frameRef.current) {
|
6785
7076
|
setZoomConfig(
|
@@ -6789,11 +7080,11 @@ var Canvas = () => {
|
|
6789
7080
|
},
|
6790
7081
|
[frameRef, zoomConfig, state.ui]
|
6791
7082
|
);
|
6792
|
-
(0,
|
7083
|
+
(0, import_react44.useEffect)(() => {
|
6793
7084
|
setShowTransition(false);
|
6794
7085
|
resetAutoZoom();
|
6795
7086
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6796
|
-
(0,
|
7087
|
+
(0, import_react44.useEffect)(() => {
|
6797
7088
|
const { height: frameHeight } = getFrameDimensions();
|
6798
7089
|
if (ui.viewports.current.height === "auto") {
|
6799
7090
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6801,13 +7092,13 @@ var Canvas = () => {
|
|
6801
7092
|
}));
|
6802
7093
|
}
|
6803
7094
|
}, [zoomConfig.zoom]);
|
6804
|
-
(0,
|
7095
|
+
(0, import_react44.useEffect)(() => {
|
6805
7096
|
if (ZOOM_ON_CHANGE) {
|
6806
7097
|
setShowTransition(true);
|
6807
7098
|
resetAutoZoom(ui);
|
6808
7099
|
}
|
6809
7100
|
}, [ui.viewports.current.width]);
|
6810
|
-
(0,
|
7101
|
+
(0, import_react44.useEffect)(() => {
|
6811
7102
|
const cb = () => {
|
6812
7103
|
setShowTransition(false);
|
6813
7104
|
resetAutoZoom();
|
@@ -6817,13 +7108,13 @@ var Canvas = () => {
|
|
6817
7108
|
window.removeEventListener("resize", cb);
|
6818
7109
|
};
|
6819
7110
|
}, []);
|
6820
|
-
const [showLoader, setShowLoader] = (0,
|
6821
|
-
(0,
|
7111
|
+
const [showLoader, setShowLoader] = (0, import_react44.useState)(false);
|
7112
|
+
(0, import_react44.useEffect)(() => {
|
6822
7113
|
setTimeout(() => {
|
6823
7114
|
setShowLoader(true);
|
6824
7115
|
}, 500);
|
6825
7116
|
}, []);
|
6826
|
-
return /* @__PURE__ */ (0,
|
7117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
6827
7118
|
"div",
|
6828
7119
|
{
|
6829
7120
|
className: getClassName26({
|
@@ -6836,7 +7127,7 @@ var Canvas = () => {
|
|
6836
7127
|
recordHistory: true
|
6837
7128
|
}),
|
6838
7129
|
children: [
|
6839
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
7130
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
6840
7131
|
ViewportControls,
|
6841
7132
|
{
|
6842
7133
|
autoZoom: zoomConfig.autoZoom,
|
@@ -6862,8 +7153,8 @@ var Canvas = () => {
|
|
6862
7153
|
}
|
6863
7154
|
}
|
6864
7155
|
) }),
|
6865
|
-
/* @__PURE__ */ (0,
|
6866
|
-
/* @__PURE__ */ (0,
|
7156
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7157
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
6867
7158
|
"div",
|
6868
7159
|
{
|
6869
7160
|
className: getClassName26("root"),
|
@@ -6884,10 +7175,10 @@ var Canvas = () => {
|
|
6884
7175
|
})
|
6885
7176
|
);
|
6886
7177
|
},
|
6887
|
-
children: /* @__PURE__ */ (0,
|
7178
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview2, {}) })
|
6888
7179
|
}
|
6889
7180
|
),
|
6890
|
-
/* @__PURE__ */ (0,
|
7181
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
6891
7182
|
] })
|
6892
7183
|
]
|
6893
7184
|
}
|
@@ -6896,7 +7187,7 @@ var Canvas = () => {
|
|
6896
7187
|
|
6897
7188
|
// lib/use-loaded-overrides.ts
|
6898
7189
|
init_react_import();
|
6899
|
-
var
|
7190
|
+
var import_react45 = require("react");
|
6900
7191
|
|
6901
7192
|
// lib/load-overrides.ts
|
6902
7193
|
init_react_import();
|
@@ -6935,26 +7226,26 @@ var useLoadedOverrides = ({
|
|
6935
7226
|
overrides,
|
6936
7227
|
plugins
|
6937
7228
|
}) => {
|
6938
|
-
return (0,
|
7229
|
+
return (0, import_react45.useMemo)(() => {
|
6939
7230
|
return loadOverrides({ overrides, plugins });
|
6940
7231
|
}, [plugins, overrides]);
|
6941
7232
|
};
|
6942
7233
|
|
6943
7234
|
// components/DefaultOverride/index.tsx
|
6944
7235
|
init_react_import();
|
6945
|
-
var
|
6946
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
7236
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7237
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
6947
7238
|
|
6948
7239
|
// lib/use-inject-css.ts
|
6949
7240
|
init_react_import();
|
6950
|
-
var
|
7241
|
+
var import_react46 = require("react");
|
6951
7242
|
var styles = ``;
|
6952
7243
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6953
|
-
const [el, setEl] = (0,
|
6954
|
-
(0,
|
7244
|
+
const [el, setEl] = (0, import_react46.useState)();
|
7245
|
+
(0, import_react46.useEffect)(() => {
|
6955
7246
|
setEl(document.createElement("style"));
|
6956
7247
|
}, []);
|
6957
|
-
(0,
|
7248
|
+
(0, import_react46.useEffect)(() => {
|
6958
7249
|
var _a;
|
6959
7250
|
if (!el || typeof window === "undefined") {
|
6960
7251
|
return;
|
@@ -6974,10 +7265,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
6974
7265
|
|
6975
7266
|
// lib/use-preview-mode-hotkeys.ts
|
6976
7267
|
init_react_import();
|
6977
|
-
var
|
7268
|
+
var import_react47 = require("react");
|
6978
7269
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
6979
7270
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
6980
|
-
const toggleInteractive = (0,
|
7271
|
+
const toggleInteractive = (0, import_react47.useCallback)(() => {
|
6981
7272
|
dispatch({
|
6982
7273
|
type: "setUi",
|
6983
7274
|
ui: (ui) => ({
|
@@ -7000,7 +7291,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
|
7000
7291
|
};
|
7001
7292
|
|
7002
7293
|
// components/Puck/index.tsx
|
7003
|
-
var
|
7294
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
7004
7295
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
7005
7296
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
7006
7297
|
function Puck({
|
@@ -7029,7 +7320,7 @@ function Puck({
|
|
7029
7320
|
waitForStyles: true
|
7030
7321
|
}, _iframe);
|
7031
7322
|
useInjectGlobalCss(iframe.enabled);
|
7032
|
-
const [generatedAppState] = (0,
|
7323
|
+
const [generatedAppState] = (0, import_react48.useState)(() => {
|
7033
7324
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7034
7325
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7035
7326
|
let clientUiState = {};
|
@@ -7101,14 +7392,14 @@ function Puck({
|
|
7101
7392
|
histories,
|
7102
7393
|
index: initialHistoryIndex
|
7103
7394
|
});
|
7104
|
-
const [reducer] = (0,
|
7395
|
+
const [reducer] = (0, import_react48.useState)(
|
7105
7396
|
() => createReducer({
|
7106
7397
|
config,
|
7107
7398
|
record: historyStore.record,
|
7108
7399
|
onAction
|
7109
7400
|
})
|
7110
7401
|
);
|
7111
|
-
const [appState, dispatch] = (0,
|
7402
|
+
const [appState, dispatch] = (0, import_react48.useReducer)(
|
7112
7403
|
reducer,
|
7113
7404
|
flushZones(initialAppState)
|
7114
7405
|
);
|
@@ -7119,14 +7410,14 @@ function Puck({
|
|
7119
7410
|
historyStore,
|
7120
7411
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7121
7412
|
});
|
7122
|
-
const [menuOpen, setMenuOpen] = (0,
|
7413
|
+
const [menuOpen, setMenuOpen] = (0, import_react48.useState)(false);
|
7123
7414
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7124
7415
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7125
|
-
(0,
|
7416
|
+
(0, import_react48.useEffect)(() => {
|
7126
7417
|
if (onChange) onChange(data);
|
7127
7418
|
}, [data]);
|
7128
7419
|
const rootProps = data.root.props || data.root;
|
7129
|
-
const toggleSidebars = (0,
|
7420
|
+
const toggleSidebars = (0, import_react48.useCallback)(
|
7130
7421
|
(sidebar) => {
|
7131
7422
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7132
7423
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7140,7 +7431,7 @@ function Puck({
|
|
7140
7431
|
},
|
7141
7432
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7142
7433
|
);
|
7143
|
-
(0,
|
7434
|
+
(0, import_react48.useEffect)(() => {
|
7144
7435
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7145
7436
|
dispatch({
|
7146
7437
|
type: "setUi",
|
@@ -7163,7 +7454,7 @@ function Puck({
|
|
7163
7454
|
window.removeEventListener("resize", handleResize);
|
7164
7455
|
};
|
7165
7456
|
}, []);
|
7166
|
-
const defaultHeaderRender = (0,
|
7457
|
+
const defaultHeaderRender = (0, import_react48.useMemo)(() => {
|
7167
7458
|
if (renderHeader) {
|
7168
7459
|
console.warn(
|
7169
7460
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7171,20 +7462,20 @@ function Puck({
|
|
7171
7462
|
const RenderHeader = (_a2) => {
|
7172
7463
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
7173
7464
|
const Comp = renderHeader;
|
7174
|
-
return /* @__PURE__ */ (0,
|
7465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7175
7466
|
};
|
7176
7467
|
return RenderHeader;
|
7177
7468
|
}
|
7178
7469
|
return DefaultOverride;
|
7179
7470
|
}, [renderHeader]);
|
7180
|
-
const defaultHeaderActionsRender = (0,
|
7471
|
+
const defaultHeaderActionsRender = (0, import_react48.useMemo)(() => {
|
7181
7472
|
if (renderHeaderActions) {
|
7182
7473
|
console.warn(
|
7183
7474
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7184
7475
|
);
|
7185
7476
|
const RenderHeader = (props) => {
|
7186
7477
|
const Comp = renderHeaderActions;
|
7187
|
-
return /* @__PURE__ */ (0,
|
7478
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7188
7479
|
};
|
7189
7480
|
return RenderHeader;
|
7190
7481
|
}
|
@@ -7194,27 +7485,27 @@ function Puck({
|
|
7194
7485
|
overrides,
|
7195
7486
|
plugins
|
7196
7487
|
});
|
7197
|
-
const CustomPuck = (0,
|
7488
|
+
const CustomPuck = (0, import_react48.useMemo)(
|
7198
7489
|
() => loadedOverrides.puck || DefaultOverride,
|
7199
7490
|
[loadedOverrides]
|
7200
7491
|
);
|
7201
|
-
const CustomHeader = (0,
|
7492
|
+
const CustomHeader = (0, import_react48.useMemo)(
|
7202
7493
|
() => loadedOverrides.header || defaultHeaderRender,
|
7203
7494
|
[loadedOverrides]
|
7204
7495
|
);
|
7205
|
-
const CustomHeaderActions = (0,
|
7496
|
+
const CustomHeaderActions = (0, import_react48.useMemo)(
|
7206
7497
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7207
7498
|
[loadedOverrides]
|
7208
7499
|
);
|
7209
|
-
const [mounted, setMounted] = (0,
|
7210
|
-
(0,
|
7500
|
+
const [mounted, setMounted] = (0, import_react48.useState)(false);
|
7501
|
+
(0, import_react48.useEffect)(() => {
|
7211
7502
|
setMounted(true);
|
7212
7503
|
}, []);
|
7213
7504
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7214
7505
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7215
7506
|
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7216
|
-
return /* @__PURE__ */ (0,
|
7217
|
-
/* @__PURE__ */ (0,
|
7507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
7508
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7218
7509
|
AppProvider,
|
7219
7510
|
{
|
7220
7511
|
value: {
|
@@ -7236,7 +7527,7 @@ function Puck({
|
|
7236
7527
|
getPermissions: () => ({}),
|
7237
7528
|
refreshPermissions: () => null
|
7238
7529
|
},
|
7239
|
-
children: /* @__PURE__ */ (0,
|
7530
|
+
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
7531
|
"div",
|
7241
7532
|
{
|
7242
7533
|
className: getLayoutClassName({
|
@@ -7245,60 +7536,60 @@ function Puck({
|
|
7245
7536
|
mounted,
|
7246
7537
|
rightSideBarVisible
|
7247
7538
|
}),
|
7248
|
-
children: /* @__PURE__ */ (0,
|
7249
|
-
/* @__PURE__ */ (0,
|
7539
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
7540
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7250
7541
|
CustomHeader,
|
7251
7542
|
{
|
7252
|
-
actions: /* @__PURE__ */ (0,
|
7543
|
+
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
7544
|
Button,
|
7254
7545
|
{
|
7255
7546
|
onClick: () => {
|
7256
7547
|
onPublish && onPublish(data);
|
7257
7548
|
},
|
7258
|
-
icon: /* @__PURE__ */ (0,
|
7549
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7259
7550
|
children: "Publish"
|
7260
7551
|
}
|
7261
7552
|
) }) }),
|
7262
|
-
children: /* @__PURE__ */ (0,
|
7263
|
-
/* @__PURE__ */ (0,
|
7264
|
-
/* @__PURE__ */ (0,
|
7553
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
7554
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
|
7555
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7265
7556
|
"div",
|
7266
7557
|
{
|
7267
7558
|
className: getLayoutClassName("leftSideBarToggle"),
|
7268
|
-
children: /* @__PURE__ */ (0,
|
7559
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7269
7560
|
IconButton,
|
7270
7561
|
{
|
7271
7562
|
onClick: () => {
|
7272
7563
|
toggleSidebars("left");
|
7273
7564
|
},
|
7274
7565
|
title: "Toggle left sidebar",
|
7275
|
-
children: /* @__PURE__ */ (0,
|
7566
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
7276
7567
|
}
|
7277
7568
|
)
|
7278
7569
|
}
|
7279
7570
|
),
|
7280
|
-
/* @__PURE__ */ (0,
|
7571
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7281
7572
|
"div",
|
7282
7573
|
{
|
7283
7574
|
className: getLayoutClassName("rightSideBarToggle"),
|
7284
|
-
children: /* @__PURE__ */ (0,
|
7575
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7285
7576
|
IconButton,
|
7286
7577
|
{
|
7287
7578
|
onClick: () => {
|
7288
7579
|
toggleSidebars("right");
|
7289
7580
|
},
|
7290
7581
|
title: "Toggle right sidebar",
|
7291
|
-
children: /* @__PURE__ */ (0,
|
7582
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
7292
7583
|
}
|
7293
7584
|
)
|
7294
7585
|
}
|
7295
7586
|
)
|
7296
7587
|
] }),
|
7297
|
-
/* @__PURE__ */ (0,
|
7588
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
7298
7589
|
headerTitle || rootProps.title || "Page",
|
7299
|
-
headerPath && /* @__PURE__ */ (0,
|
7590
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
7300
7591
|
" ",
|
7301
|
-
/* @__PURE__ */ (0,
|
7592
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7302
7593
|
"code",
|
7303
7594
|
{
|
7304
7595
|
className: getLayoutClassName("headerPath"),
|
@@ -7307,31 +7598,31 @@ function Puck({
|
|
7307
7598
|
)
|
7308
7599
|
] })
|
7309
7600
|
] }) }),
|
7310
|
-
/* @__PURE__ */ (0,
|
7311
|
-
/* @__PURE__ */ (0,
|
7601
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
|
7602
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7312
7603
|
IconButton,
|
7313
7604
|
{
|
7314
7605
|
onClick: () => {
|
7315
7606
|
return setMenuOpen(!menuOpen);
|
7316
7607
|
},
|
7317
7608
|
title: "Toggle menu bar",
|
7318
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
7609
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
7319
7610
|
}
|
7320
7611
|
) }),
|
7321
|
-
/* @__PURE__ */ (0,
|
7612
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7322
7613
|
MenuBar,
|
7323
7614
|
{
|
7324
7615
|
appState,
|
7325
7616
|
dispatch,
|
7326
7617
|
onPublish,
|
7327
7618
|
menuOpen,
|
7328
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
7619
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7329
7620
|
Button,
|
7330
7621
|
{
|
7331
7622
|
onClick: () => {
|
7332
7623
|
onPublish && onPublish(data);
|
7333
7624
|
},
|
7334
|
-
icon: /* @__PURE__ */ (0,
|
7625
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7335
7626
|
children: "Publish"
|
7336
7627
|
}
|
7337
7628
|
) }),
|
@@ -7342,19 +7633,19 @@ function Puck({
|
|
7342
7633
|
] }) })
|
7343
7634
|
}
|
7344
7635
|
),
|
7345
|
-
/* @__PURE__ */ (0,
|
7346
|
-
/* @__PURE__ */ (0,
|
7347
|
-
/* @__PURE__ */ (0,
|
7636
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7637
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
|
7638
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
|
7348
7639
|
] }),
|
7349
|
-
/* @__PURE__ */ (0,
|
7350
|
-
/* @__PURE__ */ (0,
|
7640
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
|
7641
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7351
7642
|
SidebarSection,
|
7352
7643
|
{
|
7353
7644
|
noPadding: true,
|
7354
7645
|
noBorderTop: true,
|
7355
7646
|
showBreadcrumbs: true,
|
7356
7647
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7357
|
-
children: /* @__PURE__ */ (0,
|
7648
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
|
7358
7649
|
}
|
7359
7650
|
) })
|
7360
7651
|
] })
|
@@ -7362,13 +7653,13 @@ function Puck({
|
|
7362
7653
|
) }) })
|
7363
7654
|
}
|
7364
7655
|
),
|
7365
|
-
/* @__PURE__ */ (0,
|
7656
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7366
7657
|
] });
|
7367
7658
|
}
|
7368
7659
|
Puck.Components = Components;
|
7369
7660
|
Puck.Fields = Fields;
|
7370
7661
|
Puck.Outline = Outline;
|
7371
|
-
Puck.Preview =
|
7662
|
+
Puck.Preview = Preview2;
|
7372
7663
|
|
7373
7664
|
// lib/migrate.ts
|
7374
7665
|
init_react_import();
|