@measured/puck 0.18.0-canary.874ba1b → 0.18.0-canary.99e9ecb
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-EXKSBUY5.mjs → chunk-CHWFBYEM.mjs} +2 -4
- package/dist/index.js +734 -606
- package/dist/index.mjs +548 -417
- package/dist/rsc.js +2 -4
- package/dist/rsc.mjs +1 -1
- package/package.json +1 -1
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,
|
@@ -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,43 +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
|
-
const
|
1579
|
-
|
1580
|
-
|
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,
|
1581
1628
|
{
|
1582
|
-
name:
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
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
|
+
)
|
1599
1655
|
},
|
1600
|
-
|
1656
|
+
subPath
|
1601
1657
|
);
|
1602
1658
|
}) }) })
|
1603
1659
|
]
|
@@ -1607,7 +1663,7 @@ var ArrayField = ({
|
|
1607
1663
|
_arrayId
|
1608
1664
|
);
|
1609
1665
|
}),
|
1610
|
-
!addDisabled && /* @__PURE__ */ (0,
|
1666
|
+
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1611
1667
|
"button",
|
1612
1668
|
{
|
1613
1669
|
type: "button",
|
@@ -1621,7 +1677,7 @@ var ArrayField = ({
|
|
1621
1677
|
const newArrayState = regenerateArrayState(newValue);
|
1622
1678
|
onChange(newValue, mapArrayStateToUi(newArrayState));
|
1623
1679
|
},
|
1624
|
-
children: /* @__PURE__ */ (0,
|
1680
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Plus, { size: 21 })
|
1625
1681
|
}
|
1626
1682
|
)
|
1627
1683
|
]
|
@@ -1635,7 +1691,7 @@ var ArrayField = ({
|
|
1635
1691
|
|
1636
1692
|
// components/AutoField/fields/DefaultField/index.tsx
|
1637
1693
|
init_react_import();
|
1638
|
-
var
|
1694
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
1639
1695
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
1640
1696
|
var DefaultField = ({
|
1641
1697
|
field,
|
@@ -1647,16 +1703,16 @@ var DefaultField = ({
|
|
1647
1703
|
Label: Label2,
|
1648
1704
|
id
|
1649
1705
|
}) => {
|
1650
|
-
return /* @__PURE__ */ (0,
|
1706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1651
1707
|
Label2,
|
1652
1708
|
{
|
1653
1709
|
label: label || name,
|
1654
|
-
icon: /* @__PURE__ */ (0,
|
1655
|
-
field.type === "text" && /* @__PURE__ */ (0,
|
1656
|
-
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 })
|
1657
1713
|
] }),
|
1658
1714
|
readOnly,
|
1659
|
-
children: /* @__PURE__ */ (0,
|
1715
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1660
1716
|
"input",
|
1661
1717
|
{
|
1662
1718
|
className: getClassName6("input"),
|
@@ -1667,7 +1723,14 @@ var DefaultField = ({
|
|
1667
1723
|
value: typeof value === "undefined" ? "" : value.toString(),
|
1668
1724
|
onChange: (e) => {
|
1669
1725
|
if (field.type === "number") {
|
1670
|
-
|
1726
|
+
const numberValue = Number(e.currentTarget.value);
|
1727
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
1728
|
+
return;
|
1729
|
+
}
|
1730
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
1731
|
+
return;
|
1732
|
+
}
|
1733
|
+
onChange(numberValue);
|
1671
1734
|
} else {
|
1672
1735
|
onChange(e.currentTarget.value);
|
1673
1736
|
}
|
@@ -1685,11 +1748,11 @@ var DefaultField = ({
|
|
1685
1748
|
|
1686
1749
|
// components/AutoField/fields/ExternalField/index.tsx
|
1687
1750
|
init_react_import();
|
1688
|
-
var
|
1751
|
+
var import_react16 = require("react");
|
1689
1752
|
|
1690
1753
|
// components/ExternalInput/index.tsx
|
1691
1754
|
init_react_import();
|
1692
|
-
var
|
1755
|
+
var import_react15 = require("react");
|
1693
1756
|
|
1694
1757
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
1695
1758
|
init_react_import();
|
@@ -1697,7 +1760,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
1697
1760
|
|
1698
1761
|
// components/Modal/index.tsx
|
1699
1762
|
init_react_import();
|
1700
|
-
var
|
1763
|
+
var import_react13 = require("react");
|
1701
1764
|
|
1702
1765
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
1703
1766
|
init_react_import();
|
@@ -1705,22 +1768,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1705
1768
|
|
1706
1769
|
// components/Modal/index.tsx
|
1707
1770
|
var import_react_dom = require("react-dom");
|
1708
|
-
var
|
1771
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
1709
1772
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1710
1773
|
var Modal = ({
|
1711
1774
|
children,
|
1712
1775
|
onClose,
|
1713
1776
|
isOpen
|
1714
1777
|
}) => {
|
1715
|
-
const [rootEl, setRootEl] = (0,
|
1716
|
-
(0,
|
1778
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
1779
|
+
(0, import_react13.useEffect)(() => {
|
1717
1780
|
setRootEl(document.getElementById("puck-portal-root"));
|
1718
1781
|
}, []);
|
1719
1782
|
if (!rootEl) {
|
1720
|
-
return /* @__PURE__ */ (0,
|
1783
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
|
1721
1784
|
}
|
1722
1785
|
return (0, import_react_dom.createPortal)(
|
1723
|
-
/* @__PURE__ */ (0,
|
1786
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1724
1787
|
"div",
|
1725
1788
|
{
|
1726
1789
|
className: getClassName7("inner"),
|
@@ -1740,11 +1803,11 @@ init_react_import();
|
|
1740
1803
|
var styles_module_default8 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
|
1741
1804
|
|
1742
1805
|
// components/Heading/index.tsx
|
1743
|
-
var
|
1806
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
1744
1807
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1745
1808
|
var Heading = ({ children, rank, size = "m" }) => {
|
1746
1809
|
const Tag = rank ? `h${rank}` : "span";
|
1747
|
-
return /* @__PURE__ */ (0,
|
1810
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
1748
1811
|
Tag,
|
1749
1812
|
{
|
1750
1813
|
className: getClassName8({
|
@@ -1760,7 +1823,7 @@ init_react_import();
|
|
1760
1823
|
|
1761
1824
|
// components/Button/Button.tsx
|
1762
1825
|
init_react_import();
|
1763
|
-
var
|
1826
|
+
var import_react14 = require("react");
|
1764
1827
|
|
1765
1828
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
1766
1829
|
init_react_import();
|
@@ -1780,7 +1843,7 @@ var filterDataAttrs = (props) => {
|
|
1780
1843
|
};
|
1781
1844
|
|
1782
1845
|
// components/Button/Button.tsx
|
1783
|
-
var
|
1846
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
1784
1847
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1785
1848
|
var Button = (_a) => {
|
1786
1849
|
var _b = _a, {
|
@@ -1810,11 +1873,11 @@ var Button = (_a) => {
|
|
1810
1873
|
"size",
|
1811
1874
|
"loading"
|
1812
1875
|
]);
|
1813
|
-
const [loading, setLoading] = (0,
|
1814
|
-
(0,
|
1876
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
1877
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
1815
1878
|
const ElementType = href ? "a" : type ? "button" : "span";
|
1816
1879
|
const dataAttrs = filterDataAttrs(props);
|
1817
|
-
const el = /* @__PURE__ */ (0,
|
1880
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
1818
1881
|
ElementType,
|
1819
1882
|
__spreadProps(__spreadValues({
|
1820
1883
|
className: getClassName9({
|
@@ -1839,9 +1902,9 @@ var Button = (_a) => {
|
|
1839
1902
|
href
|
1840
1903
|
}, dataAttrs), {
|
1841
1904
|
children: [
|
1842
|
-
icon && /* @__PURE__ */ (0,
|
1905
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
1843
1906
|
children,
|
1844
|
-
loading && /* @__PURE__ */ (0,
|
1907
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 14 }) })
|
1845
1908
|
]
|
1846
1909
|
})
|
1847
1910
|
);
|
@@ -1849,7 +1912,7 @@ var Button = (_a) => {
|
|
1849
1912
|
};
|
1850
1913
|
|
1851
1914
|
// components/ExternalInput/index.tsx
|
1852
|
-
var
|
1915
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
1853
1916
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1854
1917
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1855
1918
|
var dataCache = {};
|
@@ -1866,28 +1929,28 @@ var ExternalInput = ({
|
|
1866
1929
|
mapRow = (val) => val,
|
1867
1930
|
filterFields
|
1868
1931
|
} = field || {};
|
1869
|
-
const [data, setData] = (0,
|
1870
|
-
const [isOpen, setOpen] = (0,
|
1871
|
-
const [isLoading, setIsLoading] = (0,
|
1932
|
+
const [data, setData] = (0, import_react15.useState)([]);
|
1933
|
+
const [isOpen, setOpen] = (0, import_react15.useState)(false);
|
1934
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
|
1872
1935
|
const hasFilterFields = !!filterFields;
|
1873
|
-
const [filters, setFilters] = (0,
|
1874
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
1875
|
-
const mappedData = (0,
|
1936
|
+
const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
|
1937
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
|
1938
|
+
const mappedData = (0, import_react15.useMemo)(() => {
|
1876
1939
|
return data.map(mapRow);
|
1877
1940
|
}, [data]);
|
1878
|
-
const keys = (0,
|
1941
|
+
const keys = (0, import_react15.useMemo)(() => {
|
1879
1942
|
const validKeys = /* @__PURE__ */ new Set();
|
1880
1943
|
for (const item of mappedData) {
|
1881
1944
|
for (const key of Object.keys(item)) {
|
1882
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
1945
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
|
1883
1946
|
validKeys.add(key);
|
1884
1947
|
}
|
1885
1948
|
}
|
1886
1949
|
}
|
1887
1950
|
return Array.from(validKeys);
|
1888
1951
|
}, [mappedData]);
|
1889
|
-
const [searchQuery, setSearchQuery] = (0,
|
1890
|
-
const search = (0,
|
1952
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
1953
|
+
const search = (0, import_react15.useCallback)(
|
1891
1954
|
(query, filters2) => __async(void 0, null, function* () {
|
1892
1955
|
setIsLoading(true);
|
1893
1956
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -1900,18 +1963,18 @@ var ExternalInput = ({
|
|
1900
1963
|
}),
|
1901
1964
|
[id, field]
|
1902
1965
|
);
|
1903
|
-
const Footer = (0,
|
1904
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
1966
|
+
const Footer = (0, import_react15.useCallback)(
|
1967
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
1905
1968
|
props.items.length,
|
1906
1969
|
" result",
|
1907
1970
|
props.items.length === 1 ? "" : "s"
|
1908
1971
|
] }),
|
1909
1972
|
[field.renderFooter]
|
1910
1973
|
);
|
1911
|
-
(0,
|
1974
|
+
(0, import_react15.useEffect)(() => {
|
1912
1975
|
search(searchQuery, filters);
|
1913
1976
|
}, []);
|
1914
|
-
return /* @__PURE__ */ (0,
|
1977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1915
1978
|
"div",
|
1916
1979
|
{
|
1917
1980
|
className: getClassName10({
|
@@ -1921,21 +1984,21 @@ var ExternalInput = ({
|
|
1921
1984
|
}),
|
1922
1985
|
id,
|
1923
1986
|
children: [
|
1924
|
-
/* @__PURE__ */ (0,
|
1925
|
-
/* @__PURE__ */ (0,
|
1987
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("actions"), children: [
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1926
1989
|
"button",
|
1927
1990
|
{
|
1928
1991
|
type: "button",
|
1929
1992
|
onClick: () => setOpen(true),
|
1930
1993
|
className: getClassName10("button"),
|
1931
1994
|
disabled: readOnly,
|
1932
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
1933
|
-
/* @__PURE__ */ (0,
|
1934
|
-
/* @__PURE__ */ (0,
|
1995
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
1996
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: "16" }),
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: field.placeholder })
|
1935
1998
|
] })
|
1936
1999
|
}
|
1937
2000
|
),
|
1938
|
-
value && /* @__PURE__ */ (0,
|
2001
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1939
2002
|
"button",
|
1940
2003
|
{
|
1941
2004
|
type: "button",
|
@@ -1944,11 +2007,11 @@ var ExternalInput = ({
|
|
1944
2007
|
onChange(null);
|
1945
2008
|
},
|
1946
2009
|
disabled: readOnly,
|
1947
|
-
children: /* @__PURE__ */ (0,
|
2010
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LockOpen, { size: 16 })
|
1948
2011
|
}
|
1949
2012
|
)
|
1950
2013
|
] }),
|
1951
|
-
/* @__PURE__ */ (0,
|
2014
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1952
2015
|
"form",
|
1953
2016
|
{
|
1954
2017
|
className: getClassNameModal({
|
@@ -1962,11 +2025,11 @@ var ExternalInput = ({
|
|
1962
2025
|
search(searchQuery, filters);
|
1963
2026
|
},
|
1964
2027
|
children: [
|
1965
|
-
/* @__PURE__ */ (0,
|
1966
|
-
/* @__PURE__ */ (0,
|
1967
|
-
/* @__PURE__ */ (0,
|
1968
|
-
/* @__PURE__ */ (0,
|
1969
|
-
/* @__PURE__ */ (0,
|
2028
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: getClassNameModal("search"), children: [
|
2030
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Search, { size: "18" }) }),
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1970
2033
|
"input",
|
1971
2034
|
{
|
1972
2035
|
className: getClassNameModal("searchInput"),
|
@@ -1981,9 +2044,9 @@ var ExternalInput = ({
|
|
1981
2044
|
}
|
1982
2045
|
)
|
1983
2046
|
] }),
|
1984
|
-
/* @__PURE__ */ (0,
|
1985
|
-
/* @__PURE__ */ (0,
|
1986
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2047
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
2048
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
2049
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1987
2050
|
IconButton,
|
1988
2051
|
{
|
1989
2052
|
title: "Toggle filters",
|
@@ -1992,15 +2055,15 @@ var ExternalInput = ({
|
|
1992
2055
|
e.stopPropagation();
|
1993
2056
|
setFiltersToggled(!filtersToggled);
|
1994
2057
|
},
|
1995
|
-
children: /* @__PURE__ */ (0,
|
2058
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SlidersHorizontal, { size: 20 })
|
1996
2059
|
}
|
1997
2060
|
) })
|
1998
2061
|
] })
|
1999
|
-
] }) : /* @__PURE__ */ (0,
|
2000
|
-
/* @__PURE__ */ (0,
|
2001
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2062
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
2063
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
2064
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
2002
2065
|
const filterField = filterFields[fieldName];
|
2003
|
-
return /* @__PURE__ */ (0,
|
2066
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2004
2067
|
AutoFieldPrivate,
|
2005
2068
|
{
|
2006
2069
|
field: filterField,
|
@@ -2017,9 +2080,9 @@ var ExternalInput = ({
|
|
2017
2080
|
fieldName
|
2018
2081
|
);
|
2019
2082
|
}) }),
|
2020
|
-
/* @__PURE__ */ (0,
|
2021
|
-
/* @__PURE__ */ (0,
|
2022
|
-
/* @__PURE__ */ (0,
|
2083
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
2084
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: getClassNameModal("table"), children: [
|
2085
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2023
2086
|
"th",
|
2024
2087
|
{
|
2025
2088
|
className: getClassNameModal("th"),
|
@@ -2028,8 +2091,8 @@ var ExternalInput = ({
|
|
2028
2091
|
},
|
2029
2092
|
key
|
2030
2093
|
)) }) }),
|
2031
|
-
/* @__PURE__ */ (0,
|
2032
|
-
return /* @__PURE__ */ (0,
|
2094
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
2095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2033
2096
|
"tr",
|
2034
2097
|
{
|
2035
2098
|
style: { whiteSpace: "nowrap" },
|
@@ -2038,16 +2101,16 @@ var ExternalInput = ({
|
|
2038
2101
|
onChange(mapProp(data[i]));
|
2039
2102
|
setOpen(false);
|
2040
2103
|
},
|
2041
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
2104
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
2042
2105
|
},
|
2043
2106
|
i
|
2044
2107
|
);
|
2045
2108
|
}) })
|
2046
2109
|
] }),
|
2047
|
-
/* @__PURE__ */ (0,
|
2110
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 24 }) })
|
2048
2111
|
] })
|
2049
2112
|
] }),
|
2050
|
-
/* @__PURE__ */ (0,
|
2113
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footer, { items: mappedData }) })
|
2051
2114
|
]
|
2052
2115
|
}
|
2053
2116
|
) })
|
@@ -2057,7 +2120,7 @@ var ExternalInput = ({
|
|
2057
2120
|
};
|
2058
2121
|
|
2059
2122
|
// components/AutoField/fields/ExternalField/index.tsx
|
2060
|
-
var
|
2123
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
2061
2124
|
var ExternalField = ({
|
2062
2125
|
field,
|
2063
2126
|
onChange,
|
@@ -2071,7 +2134,7 @@ var ExternalField = ({
|
|
2071
2134
|
var _a, _b, _c;
|
2072
2135
|
const validField = field;
|
2073
2136
|
const deprecatedField = field;
|
2074
|
-
(0,
|
2137
|
+
(0, import_react16.useEffect)(() => {
|
2075
2138
|
if (deprecatedField.adaptor) {
|
2076
2139
|
console.error(
|
2077
2140
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
@@ -2081,7 +2144,7 @@ var ExternalField = ({
|
|
2081
2144
|
if (field.type !== "external") {
|
2082
2145
|
return null;
|
2083
2146
|
}
|
2084
|
-
return /* @__PURE__ */ (0,
|
2147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
2085
2148
|
ExternalInput,
|
2086
2149
|
{
|
2087
2150
|
name,
|
@@ -2106,7 +2169,7 @@ var ExternalField = ({
|
|
2106
2169
|
|
2107
2170
|
// components/AutoField/fields/RadioField/index.tsx
|
2108
2171
|
init_react_import();
|
2109
|
-
var
|
2172
|
+
var import_react17 = require("react");
|
2110
2173
|
|
2111
2174
|
// lib/safe-json-parse.ts
|
2112
2175
|
init_react_import();
|
@@ -2120,7 +2183,7 @@ var safeJsonParse = (str) => {
|
|
2120
2183
|
};
|
2121
2184
|
|
2122
2185
|
// components/AutoField/fields/RadioField/index.tsx
|
2123
|
-
var
|
2186
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
2124
2187
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
2125
2188
|
var RadioField = ({
|
2126
2189
|
field,
|
@@ -2132,26 +2195,26 @@ var RadioField = ({
|
|
2132
2195
|
label,
|
2133
2196
|
Label: Label2
|
2134
2197
|
}) => {
|
2135
|
-
const flatOptions = (0,
|
2198
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2136
2199
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2137
2200
|
[field]
|
2138
2201
|
);
|
2139
2202
|
if (field.type !== "radio" || !field.options) {
|
2140
2203
|
return null;
|
2141
2204
|
}
|
2142
|
-
return /* @__PURE__ */ (0,
|
2205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2143
2206
|
Label2,
|
2144
2207
|
{
|
2145
|
-
icon: /* @__PURE__ */ (0,
|
2208
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CircleCheckBig, { size: 16 }),
|
2146
2209
|
label: label || name,
|
2147
2210
|
readOnly,
|
2148
2211
|
el: "div",
|
2149
|
-
children: /* @__PURE__ */ (0,
|
2212
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
2150
2213
|
"label",
|
2151
2214
|
{
|
2152
2215
|
className: getClassName11("radio"),
|
2153
2216
|
children: [
|
2154
|
-
/* @__PURE__ */ (0,
|
2217
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2155
2218
|
"input",
|
2156
2219
|
{
|
2157
2220
|
type: "radio",
|
@@ -2171,7 +2234,7 @@ var RadioField = ({
|
|
2171
2234
|
checked: value === option.value
|
2172
2235
|
}
|
2173
2236
|
),
|
2174
|
-
/* @__PURE__ */ (0,
|
2237
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
2175
2238
|
]
|
2176
2239
|
},
|
2177
2240
|
option.label + option.value
|
@@ -2182,8 +2245,8 @@ var RadioField = ({
|
|
2182
2245
|
|
2183
2246
|
// components/AutoField/fields/SelectField/index.tsx
|
2184
2247
|
init_react_import();
|
2185
|
-
var
|
2186
|
-
var
|
2248
|
+
var import_react18 = require("react");
|
2249
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2187
2250
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2188
2251
|
var SelectField = ({
|
2189
2252
|
field,
|
@@ -2195,20 +2258,20 @@ var SelectField = ({
|
|
2195
2258
|
readOnly,
|
2196
2259
|
id
|
2197
2260
|
}) => {
|
2198
|
-
const flatOptions = (0,
|
2261
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2199
2262
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2200
2263
|
[field]
|
2201
2264
|
);
|
2202
2265
|
if (field.type !== "select" || !field.options) {
|
2203
2266
|
return null;
|
2204
2267
|
}
|
2205
|
-
return /* @__PURE__ */ (0,
|
2268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2206
2269
|
Label2,
|
2207
2270
|
{
|
2208
2271
|
label: label || name,
|
2209
|
-
icon: /* @__PURE__ */ (0,
|
2272
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronDown, { size: 16 }),
|
2210
2273
|
readOnly,
|
2211
|
-
children: /* @__PURE__ */ (0,
|
2274
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2212
2275
|
"select",
|
2213
2276
|
{
|
2214
2277
|
id,
|
@@ -2225,7 +2288,7 @@ var SelectField = ({
|
|
2225
2288
|
}
|
2226
2289
|
},
|
2227
2290
|
value,
|
2228
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
2291
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2229
2292
|
"option",
|
2230
2293
|
{
|
2231
2294
|
label: option.label,
|
@@ -2241,7 +2304,7 @@ var SelectField = ({
|
|
2241
2304
|
|
2242
2305
|
// components/AutoField/fields/TextareaField/index.tsx
|
2243
2306
|
init_react_import();
|
2244
|
-
var
|
2307
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
2245
2308
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2246
2309
|
var TextareaField = ({
|
2247
2310
|
onChange,
|
@@ -2252,7 +2315,7 @@ var TextareaField = ({
|
|
2252
2315
|
Label: Label2,
|
2253
2316
|
id
|
2254
2317
|
}) => {
|
2255
|
-
return /* @__PURE__ */ (0,
|
2318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
2256
2319
|
"textarea",
|
2257
2320
|
{
|
2258
2321
|
id,
|
@@ -2279,7 +2342,7 @@ init_react_import();
|
|
2279
2342
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2280
2343
|
|
2281
2344
|
// components/AutoField/fields/ObjectField/index.tsx
|
2282
|
-
var
|
2345
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
2283
2346
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2284
2347
|
var ObjectField = ({
|
2285
2348
|
field,
|
@@ -2291,47 +2354,54 @@ var ObjectField = ({
|
|
2291
2354
|
readOnly,
|
2292
2355
|
id
|
2293
2356
|
}) => {
|
2294
|
-
const {
|
2357
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2295
2358
|
if (field.type !== "object" || !field.objectFields) {
|
2296
2359
|
return null;
|
2297
2360
|
}
|
2298
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2299
2361
|
const data = value || {};
|
2300
|
-
return /* @__PURE__ */ (0,
|
2362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2301
2363
|
Label2,
|
2302
2364
|
{
|
2303
2365
|
label: label || name,
|
2304
|
-
icon: /* @__PURE__ */ (0,
|
2366
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EllipsisVertical, { size: 16 }),
|
2305
2367
|
el: "div",
|
2306
2368
|
readOnly,
|
2307
|
-
children: /* @__PURE__ */ (0,
|
2308
|
-
const subField = field.objectFields[
|
2309
|
-
const
|
2310
|
-
const
|
2311
|
-
const subReadOnly = readOnly ? readOnly :
|
2312
|
-
const label2 = subField.label ||
|
2313
|
-
return /* @__PURE__ */ (0,
|
2314
|
-
|
2369
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
2370
|
+
const subField = field.objectFields[subName];
|
2371
|
+
const subPath = `${name}.${subName}`;
|
2372
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2373
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2374
|
+
const label2 = subField.label || subName;
|
2375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2376
|
+
NestedFieldProvider,
|
2315
2377
|
{
|
2316
|
-
name:
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2378
|
+
name: localName || id,
|
2379
|
+
subName,
|
2380
|
+
readOnlyFields,
|
2381
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2382
|
+
AutoFieldPrivate,
|
2383
|
+
{
|
2384
|
+
name: subPath,
|
2385
|
+
label: subPath,
|
2386
|
+
id: `${id}_${subName}`,
|
2387
|
+
readOnly: subReadOnly,
|
2388
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2389
|
+
label: label2
|
2390
|
+
// May be used by custom fields
|
2329
2391
|
}),
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2392
|
+
value: data[subName],
|
2393
|
+
onChange: (val, ui) => {
|
2394
|
+
onChange(
|
2395
|
+
__spreadProps(__spreadValues({}, data), {
|
2396
|
+
[subName]: val
|
2397
|
+
}),
|
2398
|
+
ui
|
2399
|
+
);
|
2400
|
+
}
|
2401
|
+
}
|
2402
|
+
)
|
2333
2403
|
},
|
2334
|
-
|
2404
|
+
subPath
|
2335
2405
|
);
|
2336
2406
|
}) }) })
|
2337
2407
|
}
|
@@ -2340,7 +2410,7 @@ var ObjectField = ({
|
|
2340
2410
|
|
2341
2411
|
// lib/use-safe-id.ts
|
2342
2412
|
init_react_import();
|
2343
|
-
var
|
2413
|
+
var import_react19 = __toESM(require("react"));
|
2344
2414
|
|
2345
2415
|
// lib/generate-id.ts
|
2346
2416
|
init_react_import();
|
@@ -2349,15 +2419,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
2349
2419
|
|
2350
2420
|
// lib/use-safe-id.ts
|
2351
2421
|
var useSafeId = () => {
|
2352
|
-
if (typeof
|
2353
|
-
return
|
2422
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
2423
|
+
return import_react19.default.useId();
|
2354
2424
|
}
|
2355
|
-
const [id] = (0,
|
2425
|
+
const [id] = (0, import_react19.useState)(generateId());
|
2356
2426
|
return id;
|
2357
2427
|
};
|
2358
2428
|
|
2359
2429
|
// components/AutoField/index.tsx
|
2360
|
-
var
|
2430
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
2361
2431
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2362
2432
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2363
2433
|
var FieldLabel = ({
|
@@ -2369,16 +2439,16 @@ var FieldLabel = ({
|
|
2369
2439
|
className
|
2370
2440
|
}) => {
|
2371
2441
|
const El = el;
|
2372
|
-
return /* @__PURE__ */ (0,
|
2373
|
-
/* @__PURE__ */ (0,
|
2374
|
-
icon ? /* @__PURE__ */ (0,
|
2442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(El, { className, children: [
|
2443
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName15("label"), children: [
|
2444
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {}),
|
2375
2445
|
label,
|
2376
|
-
readOnly && /* @__PURE__ */ (0,
|
2446
|
+
readOnly && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Lock, { size: "12" }) })
|
2377
2447
|
] }),
|
2378
2448
|
children
|
2379
2449
|
] });
|
2380
2450
|
};
|
2381
|
-
var
|
2451
|
+
var FieldLabelInternal = ({
|
2382
2452
|
children,
|
2383
2453
|
icon,
|
2384
2454
|
label,
|
@@ -2386,14 +2456,14 @@ var FieldLabelInternal2 = ({
|
|
2386
2456
|
readOnly
|
2387
2457
|
}) => {
|
2388
2458
|
const { overrides } = useAppContext();
|
2389
|
-
const Wrapper = (0,
|
2459
|
+
const Wrapper = (0, import_react20.useMemo)(
|
2390
2460
|
() => overrides.fieldLabel || FieldLabel,
|
2391
2461
|
[overrides]
|
2392
2462
|
);
|
2393
2463
|
if (!label) {
|
2394
|
-
return /* @__PURE__ */ (0,
|
2464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
2395
2465
|
}
|
2396
|
-
return /* @__PURE__ */ (0,
|
2466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2397
2467
|
Wrapper,
|
2398
2468
|
{
|
2399
2469
|
label,
|
@@ -2407,8 +2477,9 @@ var FieldLabelInternal2 = ({
|
|
2407
2477
|
};
|
2408
2478
|
function AutoFieldInternal(props) {
|
2409
2479
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2410
|
-
const { dispatch, overrides } = useAppContext();
|
2411
|
-
const
|
2480
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2481
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
2482
|
+
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2412
2483
|
const field = props.field;
|
2413
2484
|
const label = field.label;
|
2414
2485
|
const defaultId = useSafeId();
|
@@ -2439,7 +2510,7 @@ function AutoFieldInternal(props) {
|
|
2439
2510
|
Label: Label2,
|
2440
2511
|
id: resolvedId
|
2441
2512
|
});
|
2442
|
-
const onFocus = (0,
|
2513
|
+
const onFocus = (0, import_react20.useCallback)(
|
2443
2514
|
(e) => {
|
2444
2515
|
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
2445
2516
|
e.stopPropagation();
|
@@ -2453,7 +2524,7 @@ function AutoFieldInternal(props) {
|
|
2453
2524
|
},
|
2454
2525
|
[mergedProps.name]
|
2455
2526
|
);
|
2456
|
-
const onBlur = (0,
|
2527
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
2457
2528
|
if ("name" in e.target) {
|
2458
2529
|
dispatch({
|
2459
2530
|
type: "setUi",
|
@@ -2468,27 +2539,36 @@ function AutoFieldInternal(props) {
|
|
2468
2539
|
return null;
|
2469
2540
|
}
|
2470
2541
|
const CustomField = field.render;
|
2471
|
-
return /* @__PURE__ */ (0,
|
2542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
|
2472
2543
|
}
|
2473
2544
|
const children = defaultFields[field.type](mergedProps);
|
2474
2545
|
const Render2 = render[field.type];
|
2475
|
-
return /* @__PURE__ */ (0,
|
2476
|
-
|
2546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2547
|
+
NestedFieldContext.Provider,
|
2477
2548
|
{
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2481
|
-
onClick: (e) => {
|
2482
|
-
e.stopPropagation();
|
2549
|
+
value: {
|
2550
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2551
|
+
localName: nestedFieldContext.localName
|
2483
2552
|
},
|
2484
|
-
children: /* @__PURE__ */ (0,
|
2553
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2554
|
+
"div",
|
2555
|
+
{
|
2556
|
+
className: getClassNameWrapper(),
|
2557
|
+
onFocus,
|
2558
|
+
onBlur,
|
2559
|
+
onClick: (e) => {
|
2560
|
+
e.stopPropagation();
|
2561
|
+
},
|
2562
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2563
|
+
}
|
2564
|
+
)
|
2485
2565
|
}
|
2486
2566
|
);
|
2487
2567
|
}
|
2488
2568
|
function AutoFieldPrivate(props) {
|
2489
2569
|
const { state } = useAppContext();
|
2490
2570
|
const { value, onChange } = props;
|
2491
|
-
const [localValue, setLocalValue] = (0,
|
2571
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
2492
2572
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
2493
2573
|
(val, ui) => {
|
2494
2574
|
onChange(val, ui);
|
@@ -2496,11 +2576,11 @@ function AutoFieldPrivate(props) {
|
|
2496
2576
|
50,
|
2497
2577
|
{ leading: true }
|
2498
2578
|
);
|
2499
|
-
const onChangeLocal = (0,
|
2579
|
+
const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
|
2500
2580
|
setLocalValue(val);
|
2501
2581
|
onChangeDb(val, ui);
|
2502
2582
|
}, []);
|
2503
|
-
(0,
|
2583
|
+
(0, import_react20.useEffect)(() => {
|
2504
2584
|
if (state.ui.field.focus !== props.name) {
|
2505
2585
|
setLocalValue(value);
|
2506
2586
|
}
|
@@ -2509,11 +2589,11 @@ function AutoFieldPrivate(props) {
|
|
2509
2589
|
value: localValue,
|
2510
2590
|
onChange: onChangeLocal
|
2511
2591
|
};
|
2512
|
-
return /* @__PURE__ */ (0,
|
2592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2513
2593
|
}
|
2514
2594
|
function AutoField(props) {
|
2515
|
-
const DefaultLabel = (0,
|
2516
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
2595
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
2596
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2517
2597
|
"div",
|
2518
2598
|
__spreadProps(__spreadValues({}, labelProps), {
|
2519
2599
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2521,7 +2601,7 @@ function AutoField(props) {
|
|
2521
2601
|
);
|
2522
2602
|
return DefaultLabel2;
|
2523
2603
|
}, [props.readOnly]);
|
2524
|
-
return /* @__PURE__ */ (0,
|
2604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2525
2605
|
}
|
2526
2606
|
|
2527
2607
|
// components/Drawer/index.tsx
|
@@ -2532,21 +2612,21 @@ init_react_import();
|
|
2532
2612
|
var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
|
2533
2613
|
|
2534
2614
|
// components/Drawer/index.tsx
|
2535
|
-
var
|
2615
|
+
var import_react32 = require("react");
|
2536
2616
|
|
2537
2617
|
// components/DragDropContext/index.tsx
|
2538
2618
|
init_react_import();
|
2539
|
-
var
|
2540
|
-
var
|
2619
|
+
var import_react30 = require("@dnd-kit/react");
|
2620
|
+
var import_react31 = require("react");
|
2541
2621
|
var import_dom = require("@dnd-kit/dom");
|
2542
2622
|
|
2543
2623
|
// components/DropZone/index.tsx
|
2544
2624
|
init_react_import();
|
2545
|
-
var
|
2625
|
+
var import_react29 = require("react");
|
2546
2626
|
|
2547
2627
|
// components/DraggableComponent/index.tsx
|
2548
2628
|
init_react_import();
|
2549
|
-
var
|
2629
|
+
var import_react23 = require("react");
|
2550
2630
|
|
2551
2631
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2552
2632
|
init_react_import();
|
@@ -2911,11 +2991,11 @@ function getDeepScrollPosition(element) {
|
|
2911
2991
|
|
2912
2992
|
// components/DropZone/context.tsx
|
2913
2993
|
init_react_import();
|
2914
|
-
var
|
2994
|
+
var import_react21 = require("react");
|
2915
2995
|
var import_zustand = require("zustand");
|
2916
|
-
var
|
2917
|
-
var dropZoneContext = (0,
|
2918
|
-
var ZoneStoreContext = (0,
|
2996
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2997
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2998
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
2919
2999
|
(0, import_zustand.createStore)(() => ({
|
2920
3000
|
zoneDepthIndex: {},
|
2921
3001
|
nextZoneDepthIndex: {},
|
@@ -2929,25 +3009,25 @@ var ZoneStoreProvider = ({
|
|
2929
3009
|
children,
|
2930
3010
|
store
|
2931
3011
|
}) => {
|
2932
|
-
return /* @__PURE__ */ (0,
|
3012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
2933
3013
|
};
|
2934
3014
|
var DropZoneProvider = ({
|
2935
3015
|
children,
|
2936
3016
|
value
|
2937
3017
|
}) => {
|
2938
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
2939
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
3018
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3019
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
2940
3020
|
{}
|
2941
3021
|
);
|
2942
|
-
const [activeZones, setActiveZones] = (0,
|
3022
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
2943
3023
|
const { dispatch } = useAppContext();
|
2944
|
-
const registerZoneArea = (0,
|
3024
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
2945
3025
|
(area) => {
|
2946
3026
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2947
3027
|
},
|
2948
3028
|
[setAreasWithZones]
|
2949
3029
|
);
|
2950
|
-
const registerZone = (0,
|
3030
|
+
const registerZone = (0, import_react21.useCallback)(
|
2951
3031
|
(zoneCompound) => {
|
2952
3032
|
if (!dispatch) {
|
2953
3033
|
return;
|
@@ -2960,7 +3040,7 @@ var DropZoneProvider = ({
|
|
2960
3040
|
},
|
2961
3041
|
[setActiveZones, dispatch]
|
2962
3042
|
);
|
2963
|
-
const unregisterZone = (0,
|
3043
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
2964
3044
|
(zoneCompound) => {
|
2965
3045
|
if (!dispatch) {
|
2966
3046
|
return;
|
@@ -2975,7 +3055,7 @@ var DropZoneProvider = ({
|
|
2975
3055
|
},
|
2976
3056
|
[setActiveZones, dispatch]
|
2977
3057
|
);
|
2978
|
-
const memoValue = (0,
|
3058
|
+
const memoValue = (0, import_react21.useMemo)(
|
2979
3059
|
() => __spreadValues({
|
2980
3060
|
hoveringComponent,
|
2981
3061
|
setHoveringComponent,
|
@@ -2987,16 +3067,16 @@ var DropZoneProvider = ({
|
|
2987
3067
|
}, value),
|
2988
3068
|
[value, hoveringComponent, areasWithZones, activeZones]
|
2989
3069
|
);
|
2990
|
-
return /* @__PURE__ */ (0,
|
3070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
2991
3071
|
};
|
2992
3072
|
|
2993
3073
|
// lib/use-context-store.ts
|
2994
3074
|
init_react_import();
|
2995
|
-
var
|
3075
|
+
var import_react22 = require("react");
|
2996
3076
|
var import_zustand2 = require("zustand");
|
2997
3077
|
var import_shallow = require("zustand/react/shallow");
|
2998
3078
|
function useContextStore(context, selector) {
|
2999
|
-
const store = (0,
|
3079
|
+
const store = (0, import_react22.useContext)(context);
|
3000
3080
|
if (!store) {
|
3001
3081
|
throw new Error("useContextStore must be used inside context");
|
3002
3082
|
}
|
@@ -3004,7 +3084,7 @@ function useContextStore(context, selector) {
|
|
3004
3084
|
}
|
3005
3085
|
|
3006
3086
|
// components/DraggableComponent/index.tsx
|
3007
|
-
var
|
3087
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
3008
3088
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
3009
3089
|
var DEBUG2 = false;
|
3010
3090
|
var space = 8;
|
@@ -3015,12 +3095,12 @@ var DefaultActionBar = ({
|
|
3015
3095
|
label,
|
3016
3096
|
children,
|
3017
3097
|
parentAction
|
3018
|
-
}) => /* @__PURE__ */ (0,
|
3019
|
-
/* @__PURE__ */ (0,
|
3098
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar, { children: [
|
3099
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar.Group, { children: [
|
3020
3100
|
parentAction,
|
3021
|
-
label && /* @__PURE__ */ (0,
|
3101
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Label, { label })
|
3022
3102
|
] }),
|
3023
|
-
/* @__PURE__ */ (0,
|
3103
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Group, { children })
|
3024
3104
|
] });
|
3025
3105
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
3026
3106
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -3055,9 +3135,9 @@ var DraggableComponent = ({
|
|
3055
3135
|
iframe,
|
3056
3136
|
state
|
3057
3137
|
} = useAppContext();
|
3058
|
-
const ctx = (0,
|
3059
|
-
const [localZones, setLocalZones] = (0,
|
3060
|
-
const registerLocalZone = (0,
|
3138
|
+
const ctx = (0, import_react23.useContext)(dropZoneContext);
|
3139
|
+
const [localZones, setLocalZones] = (0, import_react23.useState)({});
|
3140
|
+
const registerLocalZone = (0, import_react23.useCallback)(
|
3061
3141
|
(zoneCompound2, active) => {
|
3062
3142
|
var _a;
|
3063
3143
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -3067,7 +3147,7 @@ var DraggableComponent = ({
|
|
3067
3147
|
},
|
3068
3148
|
[setLocalZones]
|
3069
3149
|
);
|
3070
|
-
const unregisterLocalZone = (0,
|
3150
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
3071
3151
|
(zoneCompound2) => {
|
3072
3152
|
var _a;
|
3073
3153
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -3081,8 +3161,8 @@ var DraggableComponent = ({
|
|
3081
3161
|
);
|
3082
3162
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
3083
3163
|
const { path = [] } = ctx || {};
|
3084
|
-
const [canDrag, setCanDrag] = (0,
|
3085
|
-
(0,
|
3164
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3165
|
+
(0, import_react23.useEffect)(() => {
|
3086
3166
|
var _a;
|
3087
3167
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
3088
3168
|
if (item) {
|
@@ -3098,7 +3178,7 @@ var DraggableComponent = ({
|
|
3098
3178
|
);
|
3099
3179
|
const canCollide = canDrag || userIsDragging;
|
3100
3180
|
const disabled = !isEnabled || !canCollide;
|
3101
|
-
const [dragAxis, setDragAxis] = (0,
|
3181
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
3102
3182
|
const { ref: sortableRef, status } = useSortableSafe({
|
3103
3183
|
id,
|
3104
3184
|
index,
|
@@ -3124,8 +3204,8 @@ var DraggableComponent = ({
|
|
3124
3204
|
}
|
3125
3205
|
});
|
3126
3206
|
const thisIsDragging = status === "dragging";
|
3127
|
-
const ref = (0,
|
3128
|
-
const refSetter = (0,
|
3207
|
+
const ref = (0, import_react23.useRef)(null);
|
3208
|
+
const refSetter = (0, import_react23.useCallback)(
|
3129
3209
|
(el) => {
|
3130
3210
|
sortableRef(el);
|
3131
3211
|
if (el) {
|
@@ -3134,14 +3214,14 @@ var DraggableComponent = ({
|
|
3134
3214
|
},
|
3135
3215
|
[sortableRef]
|
3136
3216
|
);
|
3137
|
-
const [portalEl, setPortalEl] = (0,
|
3138
|
-
(0,
|
3217
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3218
|
+
(0, import_react23.useEffect)(() => {
|
3139
3219
|
var _a, _b, _c;
|
3140
3220
|
setPortalEl(
|
3141
3221
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
3142
3222
|
);
|
3143
3223
|
}, [iframe.enabled, ref.current]);
|
3144
|
-
const getStyle = (0,
|
3224
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3145
3225
|
var _a, _b, _c;
|
3146
3226
|
if (!ref.current) return;
|
3147
3227
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3161,11 +3241,11 @@ var DraggableComponent = ({
|
|
3161
3241
|
};
|
3162
3242
|
return style2;
|
3163
3243
|
}, [ref.current]);
|
3164
|
-
const [style, setStyle] = (0,
|
3165
|
-
const sync = (0,
|
3244
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3245
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3166
3246
|
setStyle(getStyle());
|
3167
3247
|
}, [ref.current, iframe]);
|
3168
|
-
(0,
|
3248
|
+
(0, import_react23.useEffect)(() => {
|
3169
3249
|
if (ref.current) {
|
3170
3250
|
const observer = new ResizeObserver(sync);
|
3171
3251
|
observer.observe(ref.current);
|
@@ -3174,7 +3254,7 @@ var DraggableComponent = ({
|
|
3174
3254
|
};
|
3175
3255
|
}
|
3176
3256
|
}, [ref.current]);
|
3177
|
-
(0,
|
3257
|
+
(0, import_react23.useEffect)(() => {
|
3178
3258
|
if (isSelected) {
|
3179
3259
|
ctx == null ? void 0 : ctx.registerPath({
|
3180
3260
|
index,
|
@@ -3182,14 +3262,14 @@ var DraggableComponent = ({
|
|
3182
3262
|
});
|
3183
3263
|
}
|
3184
3264
|
}, [isSelected]);
|
3185
|
-
const CustomActionBar = (0,
|
3265
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3186
3266
|
() => overrides.actionBar || DefaultActionBar,
|
3187
3267
|
[overrides.actionBar]
|
3188
3268
|
);
|
3189
3269
|
const permissions = getPermissions({
|
3190
3270
|
item: selectedItem
|
3191
3271
|
});
|
3192
|
-
const onClick = (0,
|
3272
|
+
const onClick = (0, import_react23.useCallback)(
|
3193
3273
|
(e) => {
|
3194
3274
|
e.stopPropagation();
|
3195
3275
|
dispatch({
|
@@ -3201,7 +3281,7 @@ var DraggableComponent = ({
|
|
3201
3281
|
},
|
3202
3282
|
[index, zoneCompound, id]
|
3203
3283
|
);
|
3204
|
-
const onSelectParent = (0,
|
3284
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3205
3285
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3206
3286
|
return;
|
3207
3287
|
}
|
@@ -3219,23 +3299,23 @@ var DraggableComponent = ({
|
|
3219
3299
|
}
|
3220
3300
|
});
|
3221
3301
|
}, [ctx, path]);
|
3222
|
-
const onDuplicate = (0,
|
3302
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3223
3303
|
dispatch({
|
3224
3304
|
type: "duplicate",
|
3225
3305
|
sourceIndex: index,
|
3226
3306
|
sourceZone: zoneCompound
|
3227
3307
|
});
|
3228
3308
|
}, [index, zoneCompound]);
|
3229
|
-
const onDelete = (0,
|
3309
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3230
3310
|
dispatch({
|
3231
3311
|
type: "remove",
|
3232
3312
|
index,
|
3233
3313
|
zone: zoneCompound
|
3234
3314
|
});
|
3235
3315
|
}, [index, zoneCompound]);
|
3236
|
-
const [hover, setHover] = (0,
|
3316
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3237
3317
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3238
|
-
(0,
|
3318
|
+
(0, import_react23.useEffect)(() => {
|
3239
3319
|
if (!ref.current) {
|
3240
3320
|
return;
|
3241
3321
|
}
|
@@ -3285,7 +3365,7 @@ var DraggableComponent = ({
|
|
3285
3365
|
thisIsDragging,
|
3286
3366
|
inDroppableZone
|
3287
3367
|
]);
|
3288
|
-
(0,
|
3368
|
+
(0, import_react23.useEffect)(() => {
|
3289
3369
|
if (ref.current && disabled) {
|
3290
3370
|
ref.current.setAttribute("data-puck-disabled", "");
|
3291
3371
|
return () => {
|
@@ -3294,8 +3374,8 @@ var DraggableComponent = ({
|
|
3294
3374
|
};
|
3295
3375
|
}
|
3296
3376
|
}, [disabled, ref]);
|
3297
|
-
const [isVisible, setIsVisible] = (0,
|
3298
|
-
(0,
|
3377
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3378
|
+
(0, import_react23.useEffect)(() => {
|
3299
3379
|
sync();
|
3300
3380
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3301
3381
|
setIsVisible(true);
|
@@ -3303,7 +3383,7 @@ var DraggableComponent = ({
|
|
3303
3383
|
setIsVisible(false);
|
3304
3384
|
}
|
3305
3385
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3306
|
-
const syncActionsPosition = (0,
|
3386
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3307
3387
|
(el) => {
|
3308
3388
|
if (el) {
|
3309
3389
|
const view = el.ownerDocument.defaultView;
|
@@ -3320,7 +3400,7 @@ var DraggableComponent = ({
|
|
3320
3400
|
},
|
3321
3401
|
[zoomConfig]
|
3322
3402
|
);
|
3323
|
-
(0,
|
3403
|
+
(0, import_react23.useEffect)(() => {
|
3324
3404
|
if (userDragAxis) {
|
3325
3405
|
setDragAxis(userDragAxis);
|
3326
3406
|
return;
|
@@ -3334,8 +3414,8 @@ var DraggableComponent = ({
|
|
3334
3414
|
}
|
3335
3415
|
setDragAxis(autoDragAxis);
|
3336
3416
|
}, [ref, userDragAxis, autoDragAxis]);
|
3337
|
-
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0,
|
3338
|
-
return /* @__PURE__ */ (0,
|
3417
|
+
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CornerLeftUp, { size: 16 }) });
|
3418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3339
3419
|
DropZoneProvider,
|
3340
3420
|
{
|
3341
3421
|
value: __spreadProps(__spreadValues({}, ctx), {
|
@@ -3349,7 +3429,7 @@ var DraggableComponent = ({
|
|
3349
3429
|
}),
|
3350
3430
|
children: [
|
3351
3431
|
isVisible && (0, import_react_dom2.createPortal)(
|
3352
|
-
/* @__PURE__ */ (0,
|
3432
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3353
3433
|
"div",
|
3354
3434
|
{
|
3355
3435
|
className: getClassName16({
|
@@ -3361,15 +3441,15 @@ var DraggableComponent = ({
|
|
3361
3441
|
"data-puck-overlay": true,
|
3362
3442
|
children: [
|
3363
3443
|
debug,
|
3364
|
-
isLoading && /* @__PURE__ */ (0,
|
3365
|
-
/* @__PURE__ */ (0,
|
3444
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {}) }),
|
3445
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3366
3446
|
"div",
|
3367
3447
|
{
|
3368
3448
|
className: getClassName16("actionsOverlay"),
|
3369
3449
|
style: {
|
3370
3450
|
top: actionsOverlayTop / zoomConfig.zoom
|
3371
3451
|
},
|
3372
|
-
children: /* @__PURE__ */ (0,
|
3452
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3373
3453
|
"div",
|
3374
3454
|
{
|
3375
3455
|
className: getClassName16("actions"),
|
@@ -3381,14 +3461,14 @@ var DraggableComponent = ({
|
|
3381
3461
|
paddingRight: actionsSide
|
3382
3462
|
},
|
3383
3463
|
ref: syncActionsPosition,
|
3384
|
-
children: /* @__PURE__ */ (0,
|
3464
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3385
3465
|
CustomActionBar,
|
3386
3466
|
{
|
3387
3467
|
parentAction,
|
3388
3468
|
label: DEBUG2 ? id : label,
|
3389
3469
|
children: [
|
3390
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
3391
|
-
permissions.delete && /* @__PURE__ */ (0,
|
3470
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Copy, { size: 16 }) }),
|
3471
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Trash, { size: 16 }) })
|
3392
3472
|
]
|
3393
3473
|
}
|
3394
3474
|
)
|
@@ -3396,7 +3476,7 @@ var DraggableComponent = ({
|
|
3396
3476
|
)
|
3397
3477
|
}
|
3398
3478
|
),
|
3399
|
-
/* @__PURE__ */ (0,
|
3479
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("overlay") })
|
3400
3480
|
]
|
3401
3481
|
}
|
3402
3482
|
),
|
@@ -3414,14 +3494,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
3414
3494
|
|
3415
3495
|
// components/DropZone/lib/use-min-empty-height.ts
|
3416
3496
|
init_react_import();
|
3417
|
-
var
|
3497
|
+
var import_react24 = require("react");
|
3418
3498
|
var useMinEmptyHeight = ({
|
3419
3499
|
zoneCompound,
|
3420
3500
|
userMinEmptyHeight,
|
3421
3501
|
ref
|
3422
3502
|
}) => {
|
3423
|
-
const [prevHeight, setPrevHeight] = (0,
|
3424
|
-
const [isAnimating, setIsAnimating] = (0,
|
3503
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3504
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3425
3505
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3426
3506
|
var _a, _b;
|
3427
3507
|
return {
|
@@ -3429,7 +3509,7 @@ var useMinEmptyHeight = ({
|
|
3429
3509
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3430
3510
|
};
|
3431
3511
|
});
|
3432
|
-
(0,
|
3512
|
+
(0, import_react24.useEffect)(() => {
|
3433
3513
|
if (draggedItem && ref.current) {
|
3434
3514
|
if (isZone) {
|
3435
3515
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3463,15 +3543,15 @@ function assignRefs(refs, node) {
|
|
3463
3543
|
|
3464
3544
|
// components/DropZone/lib/use-content-with-preview.ts
|
3465
3545
|
init_react_import();
|
3466
|
-
var
|
3546
|
+
var import_react27 = require("react");
|
3467
3547
|
|
3468
3548
|
// lib/dnd/use-rendered-callback.ts
|
3469
3549
|
init_react_import();
|
3470
|
-
var
|
3471
|
-
var
|
3550
|
+
var import_react25 = require("@dnd-kit/react");
|
3551
|
+
var import_react26 = require("react");
|
3472
3552
|
function useRenderedCallback(callback, deps) {
|
3473
|
-
const manager = (0,
|
3474
|
-
return (0,
|
3553
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3554
|
+
return (0, import_react26.useCallback)(
|
3475
3555
|
(...args) => __async(this, null, function* () {
|
3476
3556
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
3477
3557
|
return callback(...args);
|
@@ -3501,7 +3581,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3501
3581
|
};
|
3502
3582
|
}
|
3503
3583
|
);
|
3504
|
-
const [contentWithPreview, setContentWithPreview] = (0,
|
3584
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3505
3585
|
const updateContent = useRenderedCallback(
|
3506
3586
|
(content2, preview2) => {
|
3507
3587
|
if (preview2) {
|
@@ -3536,7 +3616,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3536
3616
|
},
|
3537
3617
|
[draggedItemId, previewExists]
|
3538
3618
|
);
|
3539
|
-
(0,
|
3619
|
+
(0, import_react27.useEffect)(() => {
|
3540
3620
|
updateContent(content, preview);
|
3541
3621
|
}, [content, preview]);
|
3542
3622
|
return contentWithPreview;
|
@@ -3544,16 +3624,16 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3544
3624
|
|
3545
3625
|
// components/DropZone/lib/use-drag-axis.ts
|
3546
3626
|
init_react_import();
|
3547
|
-
var
|
3627
|
+
var import_react28 = require("react");
|
3548
3628
|
var GRID_DRAG_AXIS = "dynamic";
|
3549
3629
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3550
3630
|
var DEFAULT_DRAG_AXIS = "y";
|
3551
3631
|
var useDragAxis = (ref, collisionAxis) => {
|
3552
3632
|
const { status } = useAppContext();
|
3553
|
-
const [dragAxis, setDragAxis] = (0,
|
3633
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3554
3634
|
collisionAxis || DEFAULT_DRAG_AXIS
|
3555
3635
|
);
|
3556
|
-
const calculateDragAxis = (0,
|
3636
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3557
3637
|
if (ref.current) {
|
3558
3638
|
const computedStyle = window.getComputedStyle(ref.current);
|
3559
3639
|
if (computedStyle.display === "grid") {
|
@@ -3565,7 +3645,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
3565
3645
|
}
|
3566
3646
|
}
|
3567
3647
|
}, [ref.current]);
|
3568
|
-
(0,
|
3648
|
+
(0, import_react28.useEffect)(() => {
|
3569
3649
|
const onViewportChange = () => {
|
3570
3650
|
calculateDragAxis();
|
3571
3651
|
};
|
@@ -3574,17 +3654,17 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
3574
3654
|
window.removeEventListener("viewportchange", onViewportChange);
|
3575
3655
|
};
|
3576
3656
|
}, []);
|
3577
|
-
(0,
|
3657
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
3578
3658
|
return [dragAxis, calculateDragAxis];
|
3579
3659
|
};
|
3580
3660
|
|
3581
3661
|
// components/DropZone/index.tsx
|
3582
|
-
var
|
3662
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
3583
3663
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3584
3664
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3585
3665
|
var RENDER_DEBUG = false;
|
3586
|
-
var DropZoneEdit = (0,
|
3587
|
-
function
|
3666
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
3667
|
+
function DropZoneEditInternal({
|
3588
3668
|
zone,
|
3589
3669
|
allow,
|
3590
3670
|
disallow,
|
@@ -3594,7 +3674,7 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3594
3674
|
collisionAxis
|
3595
3675
|
}, userRef) {
|
3596
3676
|
const appContext2 = useAppContext();
|
3597
|
-
const ctx = (0,
|
3677
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3598
3678
|
const {
|
3599
3679
|
// These all need setting via context
|
3600
3680
|
data,
|
@@ -3632,12 +3712,12 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3632
3712
|
};
|
3633
3713
|
});
|
3634
3714
|
const { itemSelector } = appContext2.state.ui;
|
3635
|
-
(0,
|
3715
|
+
(0, import_react29.useEffect)(() => {
|
3636
3716
|
if (areaId && registerZoneArea) {
|
3637
3717
|
registerZoneArea(areaId);
|
3638
3718
|
}
|
3639
3719
|
}, [areaId]);
|
3640
|
-
(0,
|
3720
|
+
(0, import_react29.useEffect)(() => {
|
3641
3721
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3642
3722
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3643
3723
|
}
|
@@ -3647,14 +3727,14 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3647
3727
|
}
|
3648
3728
|
};
|
3649
3729
|
}, []);
|
3650
|
-
const content = (0,
|
3730
|
+
const content = (0, import_react29.useMemo)(() => {
|
3651
3731
|
if (areaId && zone !== rootDroppableId) {
|
3652
3732
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3653
3733
|
}
|
3654
3734
|
return data.content || [];
|
3655
3735
|
}, [data, zoneCompound]);
|
3656
|
-
const ref = (0,
|
3657
|
-
const acceptsTarget = (0,
|
3736
|
+
const ref = (0, import_react29.useRef)(null);
|
3737
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
3658
3738
|
(componentType) => {
|
3659
3739
|
if (!componentType) {
|
3660
3740
|
return true;
|
@@ -3676,7 +3756,7 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3676
3756
|
},
|
3677
3757
|
[allow, disallow]
|
3678
3758
|
);
|
3679
|
-
(0,
|
3759
|
+
(0, import_react29.useEffect)(() => {
|
3680
3760
|
if (registerLocalZone) {
|
3681
3761
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3682
3762
|
}
|
@@ -3718,7 +3798,7 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3718
3798
|
userMinEmptyHeight,
|
3719
3799
|
ref
|
3720
3800
|
});
|
3721
|
-
return /* @__PURE__ */ (0,
|
3801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3722
3802
|
"div",
|
3723
3803
|
{
|
3724
3804
|
className: `${getClassName17({
|
@@ -3745,7 +3825,7 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3745
3825
|
var _a, _b, _c, _d, _e;
|
3746
3826
|
const componentId = item.props.id;
|
3747
3827
|
const puckProps = {
|
3748
|
-
renderDropZone:
|
3828
|
+
renderDropZone: (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props)),
|
3749
3829
|
isEditing: true,
|
3750
3830
|
dragRef: null
|
3751
3831
|
};
|
@@ -3755,7 +3835,7 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3755
3835
|
// DEPRECATED
|
3756
3836
|
});
|
3757
3837
|
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3758
|
-
let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ (0,
|
3838
|
+
let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
3759
3839
|
"No configuration for ",
|
3760
3840
|
item.type
|
3761
3841
|
] });
|
@@ -3764,18 +3844,18 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3764
3844
|
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3765
3845
|
if (item.type === "preview" && preview) {
|
3766
3846
|
let Preview4 = function() {
|
3767
|
-
return /* @__PURE__ */ (0,
|
3847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3768
3848
|
};
|
3769
3849
|
var Preview3 = Preview4;
|
3770
3850
|
componentType = preview.componentType;
|
3771
3851
|
label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
|
3772
3852
|
Render2 = Preview4;
|
3773
3853
|
}
|
3774
|
-
return /* @__PURE__ */ (0,
|
3854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3775
3855
|
DropZoneProvider,
|
3776
3856
|
{
|
3777
3857
|
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3778
|
-
children: /* @__PURE__ */ (0,
|
3858
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3779
3859
|
DraggableComponent,
|
3780
3860
|
{
|
3781
3861
|
id: componentId,
|
@@ -3790,14 +3870,14 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3790
3870
|
autoDragAxis: dragAxis,
|
3791
3871
|
userDragAxis: collisionAxis,
|
3792
3872
|
inDroppableZone: acceptsTarget(draggedComponentType),
|
3793
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0,
|
3873
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3794
3874
|
Render2,
|
3795
3875
|
__spreadProps(__spreadValues({}, defaultedProps), {
|
3796
3876
|
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3797
3877
|
dragRef
|
3798
3878
|
})
|
3799
3879
|
})
|
3800
|
-
) : /* @__PURE__ */ (0,
|
3880
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3801
3881
|
}
|
3802
3882
|
)
|
3803
3883
|
},
|
@@ -3808,13 +3888,13 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3808
3888
|
);
|
3809
3889
|
}
|
3810
3890
|
);
|
3811
|
-
var DropZoneRender = (0,
|
3812
|
-
function
|
3813
|
-
const ctx = (0,
|
3891
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
3892
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3893
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3814
3894
|
const { data, areaId = "root", config } = ctx || {};
|
3815
3895
|
let zoneCompound = rootDroppableId;
|
3816
3896
|
let content = (data == null ? void 0 : data.content) || [];
|
3817
|
-
(0,
|
3897
|
+
(0, import_react29.useEffect)(() => {
|
3818
3898
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3819
3899
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3820
3900
|
}
|
@@ -3831,10 +3911,10 @@ var DropZoneRender = (0, import_react28.forwardRef)(
|
|
3831
3911
|
zoneCompound = `${areaId}:${zone}`;
|
3832
3912
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3833
3913
|
}
|
3834
|
-
return /* @__PURE__ */ (0,
|
3914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
3835
3915
|
const Component = config.components[item.type];
|
3836
3916
|
if (Component) {
|
3837
|
-
return /* @__PURE__ */ (0,
|
3917
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3838
3918
|
DropZoneProvider,
|
3839
3919
|
{
|
3840
3920
|
value: {
|
@@ -3844,10 +3924,12 @@ var DropZoneRender = (0, import_react28.forwardRef)(
|
|
3844
3924
|
depth: 1,
|
3845
3925
|
path: []
|
3846
3926
|
},
|
3847
|
-
children: /* @__PURE__ */ (0,
|
3927
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3848
3928
|
Component.render,
|
3849
3929
|
__spreadProps(__spreadValues({}, item.props), {
|
3850
|
-
puck: {
|
3930
|
+
puck: {
|
3931
|
+
renderDropZone: (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props))
|
3932
|
+
}
|
3851
3933
|
})
|
3852
3934
|
)
|
3853
3935
|
},
|
@@ -3858,13 +3940,13 @@ var DropZoneRender = (0, import_react28.forwardRef)(
|
|
3858
3940
|
}) });
|
3859
3941
|
}
|
3860
3942
|
);
|
3861
|
-
var DropZone = (0,
|
3943
|
+
var DropZone = (0, import_react29.forwardRef)(
|
3862
3944
|
function DropZone2(props, ref) {
|
3863
|
-
const ctx = (0,
|
3945
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3864
3946
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3865
|
-
return /* @__PURE__ */ (0,
|
3947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3866
3948
|
}
|
3867
|
-
return /* @__PURE__ */ (0,
|
3949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3868
3950
|
}
|
3869
3951
|
);
|
3870
3952
|
|
@@ -3922,6 +4004,48 @@ var getFrame = () => {
|
|
3922
4004
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3923
4005
|
};
|
3924
4006
|
|
4007
|
+
// lib/global-position.ts
|
4008
|
+
init_react_import();
|
4009
|
+
var GlobalPosition = class {
|
4010
|
+
constructor(target, original) {
|
4011
|
+
this.scaleFactor = 1;
|
4012
|
+
this.frameEl = null;
|
4013
|
+
this.frameRect = null;
|
4014
|
+
var _a;
|
4015
|
+
this.target = target;
|
4016
|
+
this.original = original;
|
4017
|
+
this.frameEl = document.querySelector("iframe");
|
4018
|
+
if (this.frameEl) {
|
4019
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
4020
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4021
|
+
}
|
4022
|
+
}
|
4023
|
+
get x() {
|
4024
|
+
return this.original.x;
|
4025
|
+
}
|
4026
|
+
get y() {
|
4027
|
+
return this.original.y;
|
4028
|
+
}
|
4029
|
+
get global() {
|
4030
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
4031
|
+
return {
|
4032
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
4033
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
4034
|
+
};
|
4035
|
+
}
|
4036
|
+
return this.original;
|
4037
|
+
}
|
4038
|
+
get frame() {
|
4039
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
4040
|
+
return {
|
4041
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
4042
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
4043
|
+
};
|
4044
|
+
}
|
4045
|
+
return this.original;
|
4046
|
+
}
|
4047
|
+
};
|
4048
|
+
|
3925
4049
|
// lib/dnd/NestedDroppablePlugin.ts
|
3926
4050
|
var depthSort = (candidates) => {
|
3927
4051
|
return candidates.sort((a, b) => {
|
@@ -3951,10 +4075,12 @@ var getZoneId2 = (candidate) => {
|
|
3951
4075
|
}
|
3952
4076
|
return id;
|
3953
4077
|
};
|
3954
|
-
var getPointerCollisions = (position, manager
|
3955
|
-
var _a;
|
4078
|
+
var getPointerCollisions = (position, manager) => {
|
3956
4079
|
const candidates = [];
|
3957
|
-
let elements = ownerDocument.elementsFromPoint(
|
4080
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
4081
|
+
position.x,
|
4082
|
+
position.y
|
4083
|
+
);
|
3958
4084
|
const previewFrame = elements.find(
|
3959
4085
|
(el) => el.getAttribute("data-puck-preview")
|
3960
4086
|
);
|
@@ -3963,17 +4089,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3963
4089
|
elements = [drawer];
|
3964
4090
|
}
|
3965
4091
|
if (previewFrame) {
|
3966
|
-
const
|
3967
|
-
if (
|
3968
|
-
|
3969
|
-
const frame = getFrame();
|
3970
|
-
if (frame) {
|
3971
|
-
const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
3972
|
-
elements = frame.elementsFromPoint(
|
3973
|
-
(position.x - rect.left) / scaleFactor,
|
3974
|
-
(position.y - rect.top) / scaleFactor
|
3975
|
-
);
|
3976
|
-
}
|
4092
|
+
const frame = getFrame();
|
4093
|
+
if (frame) {
|
4094
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
3977
4095
|
}
|
3978
4096
|
}
|
3979
4097
|
if (elements) {
|
@@ -3990,9 +4108,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3990
4108
|
}
|
3991
4109
|
return candidates;
|
3992
4110
|
};
|
3993
|
-
var findDeepestCandidate = (position, manager
|
4111
|
+
var findDeepestCandidate = (position, manager) => {
|
3994
4112
|
var _a;
|
3995
|
-
const candidates = getPointerCollisions(position, manager
|
4113
|
+
const candidates = getPointerCollisions(position, manager);
|
3996
4114
|
if (candidates.length > 0) {
|
3997
4115
|
const sortedCandidates = depthSort(candidates);
|
3998
4116
|
const draggable = manager.dragOperation.source;
|
@@ -4045,22 +4163,18 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
4045
4163
|
}
|
4046
4164
|
const cleanupEffect = (0, import_state.effects)(() => {
|
4047
4165
|
const handleMove = (event) => {
|
4048
|
-
const
|
4166
|
+
const target = event.originalTarget || event.target;
|
4167
|
+
const position = new GlobalPosition(target, {
|
4049
4168
|
x: event.clientX,
|
4050
4169
|
y: event.clientY
|
4051
|
-
};
|
4052
|
-
const target = event.originalTarget || event.target;
|
4053
|
-
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
4170
|
+
});
|
4054
4171
|
const elements = document.elementsFromPoint(
|
4055
|
-
|
4056
|
-
|
4172
|
+
position.global.x,
|
4173
|
+
position.global.y
|
4057
4174
|
);
|
4058
4175
|
const overEl = elements.some((el) => el.id === id);
|
4059
4176
|
if (overEl) {
|
4060
|
-
onChange(
|
4061
|
-
findDeepestCandidate(position, manager, ownerDocument),
|
4062
|
-
manager
|
4063
|
-
);
|
4177
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
4064
4178
|
}
|
4065
4179
|
};
|
4066
4180
|
const handleMoveThrottled = throttle(handleMove, 50);
|
@@ -4741,14 +4855,14 @@ function patchWindow(window2) {
|
|
4741
4855
|
|
4742
4856
|
// components/DragDropContext/index.tsx
|
4743
4857
|
var import_zustand3 = require("zustand");
|
4744
|
-
var
|
4858
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
4745
4859
|
var DEBUG3 = false;
|
4746
|
-
var dragListenerContext = (0,
|
4860
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
4747
4861
|
dragListeners: {}
|
4748
4862
|
});
|
4749
4863
|
function useDragListener(type, fn, deps = []) {
|
4750
|
-
const { setDragListeners } = (0,
|
4751
|
-
(0,
|
4864
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
4865
|
+
(0, import_react31.useEffect)(() => {
|
4752
4866
|
if (setDragListeners) {
|
4753
4867
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4754
4868
|
[type]: [...old[type] || [], fn]
|
@@ -4758,8 +4872,8 @@ function useDragListener(type, fn, deps = []) {
|
|
4758
4872
|
}
|
4759
4873
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4760
4874
|
var useTempDisableFallback = (timeout3) => {
|
4761
|
-
const lastFallbackDisable = (0,
|
4762
|
-
return (0,
|
4875
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
4876
|
+
return (0, import_react31.useCallback)((manager) => {
|
4763
4877
|
collisionStore.setState({ fallbackEnabled: false });
|
4764
4878
|
const fallbackId = generateId();
|
4765
4879
|
lastFallbackDisable.current = fallbackId;
|
@@ -4776,11 +4890,11 @@ var DragDropContextClient = ({
|
|
4776
4890
|
disableAutoScroll
|
4777
4891
|
}) => {
|
4778
4892
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4779
|
-
const id = (0,
|
4893
|
+
const id = (0, import_react31.useId)();
|
4780
4894
|
const { data } = state;
|
4781
|
-
const debouncedParamsRef = (0,
|
4895
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
4782
4896
|
const tempDisableFallback = useTempDisableFallback(100);
|
4783
|
-
const [zoneStore] = (0,
|
4897
|
+
const [zoneStore] = (0, import_react31.useState)(
|
4784
4898
|
() => (0, import_zustand3.createStore)(() => ({
|
4785
4899
|
zoneDepthIndex: {},
|
4786
4900
|
nextZoneDepthIndex: {},
|
@@ -4790,7 +4904,7 @@ var DragDropContextClient = ({
|
|
4790
4904
|
previewIndex: {}
|
4791
4905
|
}))
|
4792
4906
|
);
|
4793
|
-
const getChanged2 = (0,
|
4907
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
4794
4908
|
(params, id2) => {
|
4795
4909
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4796
4910
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -4811,7 +4925,7 @@ var DragDropContextClient = ({
|
|
4811
4925
|
},
|
4812
4926
|
[zoneStore]
|
4813
4927
|
);
|
4814
|
-
const setDeepestAndCollide = (0,
|
4928
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
4815
4929
|
(params, manager) => {
|
4816
4930
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4817
4931
|
if (!zoneChanged && !areaChanged) return;
|
@@ -4835,7 +4949,7 @@ var DragDropContextClient = ({
|
|
4835
4949
|
setDeepestDb.cancel();
|
4836
4950
|
debouncedParamsRef.current = null;
|
4837
4951
|
};
|
4838
|
-
(0,
|
4952
|
+
(0, import_react31.useEffect)(() => {
|
4839
4953
|
if (DEBUG3) {
|
4840
4954
|
zoneStore.subscribe(
|
4841
4955
|
(s) => {
|
@@ -4849,7 +4963,7 @@ var DragDropContextClient = ({
|
|
4849
4963
|
);
|
4850
4964
|
}
|
4851
4965
|
}, []);
|
4852
|
-
const [plugins] = (0,
|
4966
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
4853
4967
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
4854
4968
|
createNestedDroppablePlugin(
|
4855
4969
|
{
|
@@ -4896,7 +5010,7 @@ var DragDropContextClient = ({
|
|
4896
5010
|
id
|
4897
5011
|
)
|
4898
5012
|
]);
|
4899
|
-
const [sensors] = (0,
|
5013
|
+
const [sensors] = (0, import_react31.useState)(() => [
|
4900
5014
|
PointerSensor.configure({
|
4901
5015
|
activationConstraints(event, source) {
|
4902
5016
|
var _a;
|
@@ -4915,10 +5029,10 @@ var DragDropContextClient = ({
|
|
4915
5029
|
}
|
4916
5030
|
})
|
4917
5031
|
]);
|
4918
|
-
const [dragListeners, setDragListeners] = (0,
|
4919
|
-
const [pathData, setPathData] = (0,
|
4920
|
-
const dragMode = (0,
|
4921
|
-
const registerPath = (0,
|
5032
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
5033
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
5034
|
+
const dragMode = (0, import_react31.useRef)(null);
|
5035
|
+
const registerPath = (0, import_react31.useCallback)(
|
4922
5036
|
(selector) => {
|
4923
5037
|
const item = getItem(selector, data);
|
4924
5038
|
if (!item) {
|
@@ -4940,16 +5054,16 @@ var DragDropContextClient = ({
|
|
4940
5054
|
},
|
4941
5055
|
[data, setPathData]
|
4942
5056
|
);
|
4943
|
-
const initialSelector = (0,
|
4944
|
-
return /* @__PURE__ */ (0,
|
5057
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5058
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4945
5059
|
dragListenerContext.Provider,
|
4946
5060
|
{
|
4947
5061
|
value: {
|
4948
5062
|
dragListeners,
|
4949
5063
|
setDragListeners
|
4950
5064
|
},
|
4951
|
-
children: /* @__PURE__ */ (0,
|
4952
|
-
|
5065
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5066
|
+
import_react30.DragDropProvider,
|
4953
5067
|
{
|
4954
5068
|
plugins,
|
4955
5069
|
sensors,
|
@@ -5126,7 +5240,7 @@ var DragDropContextClient = ({
|
|
5126
5240
|
initialSelector.current = void 0;
|
5127
5241
|
zoneStore.setState({ draggedItem: event.operation.source });
|
5128
5242
|
},
|
5129
|
-
children: /* @__PURE__ */ (0,
|
5243
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5130
5244
|
DropZoneProvider,
|
5131
5245
|
{
|
5132
5246
|
value: {
|
@@ -5155,11 +5269,11 @@ var DragDropContext = ({
|
|
5155
5269
|
if (status === "LOADING") {
|
5156
5270
|
return children;
|
5157
5271
|
}
|
5158
|
-
return /* @__PURE__ */ (0,
|
5272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
5159
5273
|
};
|
5160
5274
|
|
5161
5275
|
// components/Drawer/index.tsx
|
5162
|
-
var
|
5276
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
5163
5277
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
5164
5278
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
5165
5279
|
var DrawerItemInner = ({
|
@@ -5169,11 +5283,11 @@ var DrawerItemInner = ({
|
|
5169
5283
|
dragRef,
|
5170
5284
|
isDragDisabled
|
5171
5285
|
}) => {
|
5172
|
-
const CustomInner = (0,
|
5173
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
5286
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5287
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5174
5288
|
[children]
|
5175
5289
|
);
|
5176
|
-
return /* @__PURE__ */ (0,
|
5290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5177
5291
|
"div",
|
5178
5292
|
{
|
5179
5293
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -5181,9 +5295,9 @@ var DrawerItemInner = ({
|
|
5181
5295
|
onMouseDown: (e) => e.preventDefault(),
|
5182
5296
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
5183
5297
|
"data-puck-drawer-item": true,
|
5184
|
-
children: /* @__PURE__ */ (0,
|
5185
|
-
/* @__PURE__ */ (0,
|
5186
|
-
/* @__PURE__ */ (0,
|
5298
|
+
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: [
|
5299
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
5300
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragIcon, {}) })
|
5187
5301
|
] }) }) })
|
5188
5302
|
}
|
5189
5303
|
);
|
@@ -5200,9 +5314,9 @@ var DrawerItemDraggable = ({
|
|
5200
5314
|
data: { type: "drawer", componentType: name },
|
5201
5315
|
disabled: isDragDisabled
|
5202
5316
|
});
|
5203
|
-
return /* @__PURE__ */ (0,
|
5204
|
-
/* @__PURE__ */ (0,
|
5205
|
-
/* @__PURE__ */ (0,
|
5317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName18("draggable"), children: [
|
5318
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DrawerItemInner, { name, label, children }) }),
|
5319
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5206
5320
|
DrawerItemInner,
|
5207
5321
|
{
|
5208
5322
|
name,
|
@@ -5223,7 +5337,7 @@ var DrawerItem = ({
|
|
5223
5337
|
isDragDisabled
|
5224
5338
|
}) => {
|
5225
5339
|
const resolvedId = id || name;
|
5226
|
-
const [dynamicId, setDynamicId] = (0,
|
5340
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5227
5341
|
if (typeof index !== "undefined") {
|
5228
5342
|
console.error(
|
5229
5343
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5236,7 +5350,7 @@ var DrawerItem = ({
|
|
5236
5350
|
},
|
5237
5351
|
[resolvedId]
|
5238
5352
|
);
|
5239
|
-
return /* @__PURE__ */ (0,
|
5353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5240
5354
|
DrawerItemDraggable,
|
5241
5355
|
{
|
5242
5356
|
name,
|
@@ -5262,14 +5376,14 @@ var Drawer = ({
|
|
5262
5376
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5263
5377
|
);
|
5264
5378
|
}
|
5265
|
-
const
|
5379
|
+
const id = (0, import_react32.useId)();
|
5266
5380
|
const { ref } = useDroppableSafe({
|
5267
5381
|
id,
|
5268
5382
|
type: "void",
|
5269
5383
|
collisionPriority: 0
|
5270
5384
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
5271
5385
|
});
|
5272
|
-
return /* @__PURE__ */ (0,
|
5386
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5273
5387
|
"div",
|
5274
5388
|
{
|
5275
5389
|
className: getClassName18(),
|
@@ -5284,7 +5398,7 @@ Drawer.Item = DrawerItem;
|
|
5284
5398
|
|
5285
5399
|
// components/Puck/index.tsx
|
5286
5400
|
init_react_import();
|
5287
|
-
var
|
5401
|
+
var import_react48 = require("react");
|
5288
5402
|
|
5289
5403
|
// components/SidebarSection/index.tsx
|
5290
5404
|
init_react_import();
|
@@ -5295,7 +5409,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
5295
5409
|
|
5296
5410
|
// lib/use-breadcrumbs.ts
|
5297
5411
|
init_react_import();
|
5298
|
-
var
|
5412
|
+
var import_react33 = require("react");
|
5299
5413
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5300
5414
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5301
5415
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5345,8 +5459,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5345
5459
|
state: { data },
|
5346
5460
|
selectedItem
|
5347
5461
|
} = useAppContext();
|
5348
|
-
const dzContext = (0,
|
5349
|
-
return (0,
|
5462
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5463
|
+
return (0, import_react33.useMemo)(() => {
|
5350
5464
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5351
5465
|
selectedItem,
|
5352
5466
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5360,7 +5474,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
5360
5474
|
};
|
5361
5475
|
|
5362
5476
|
// components/SidebarSection/index.tsx
|
5363
|
-
var
|
5477
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
5364
5478
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5365
5479
|
var SidebarSection = ({
|
5366
5480
|
children,
|
@@ -5373,15 +5487,15 @@ var SidebarSection = ({
|
|
5373
5487
|
}) => {
|
5374
5488
|
const { setUi } = useAppContext();
|
5375
5489
|
const breadcrumbs = useBreadcrumbs(1);
|
5376
|
-
return /* @__PURE__ */ (0,
|
5490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
5377
5491
|
"div",
|
5378
5492
|
{
|
5379
5493
|
className: getClassName19({ noBorderTop, noPadding }),
|
5380
5494
|
style: { background },
|
5381
5495
|
children: [
|
5382
|
-
/* @__PURE__ */ (0,
|
5383
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
5384
|
-
/* @__PURE__ */ (0,
|
5496
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
5497
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
5498
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5385
5499
|
"button",
|
5386
5500
|
{
|
5387
5501
|
type: "button",
|
@@ -5390,12 +5504,12 @@ var SidebarSection = ({
|
|
5390
5504
|
children: breadcrumb.label
|
5391
5505
|
}
|
5392
5506
|
),
|
5393
|
-
/* @__PURE__ */ (0,
|
5507
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
|
5394
5508
|
] }, i)) : null,
|
5395
|
-
/* @__PURE__ */ (0,
|
5509
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
5396
5510
|
] }) }),
|
5397
|
-
/* @__PURE__ */ (0,
|
5398
|
-
isLoading && /* @__PURE__ */ (0,
|
5511
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
|
5512
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
|
5399
5513
|
]
|
5400
5514
|
}
|
5401
5515
|
);
|
@@ -5426,7 +5540,7 @@ init_react_import();
|
|
5426
5540
|
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" };
|
5427
5541
|
|
5428
5542
|
// components/MenuBar/index.tsx
|
5429
|
-
var
|
5543
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
5430
5544
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5431
5545
|
function MenuBar({
|
5432
5546
|
appState,
|
@@ -5440,7 +5554,7 @@ function MenuBar({
|
|
5440
5554
|
history: { back, forward, historyStore }
|
5441
5555
|
} = useAppContext();
|
5442
5556
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5443
|
-
return /* @__PURE__ */ (0,
|
5557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
5444
5558
|
"div",
|
5445
5559
|
{
|
5446
5560
|
className: getClassName20({ menuOpen }),
|
@@ -5454,12 +5568,12 @@ function MenuBar({
|
|
5454
5568
|
setMenuOpen(false);
|
5455
5569
|
}
|
5456
5570
|
},
|
5457
|
-
children: /* @__PURE__ */ (0,
|
5458
|
-
/* @__PURE__ */ (0,
|
5459
|
-
/* @__PURE__ */ (0,
|
5460
|
-
/* @__PURE__ */ (0,
|
5571
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
|
5572
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
|
5573
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
|
5574
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
|
5461
5575
|
] }),
|
5462
|
-
/* @__PURE__ */ (0,
|
5576
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
5463
5577
|
state: appState,
|
5464
5578
|
dispatch
|
5465
5579
|
}) })
|
@@ -5480,15 +5594,15 @@ init_react_import();
|
|
5480
5594
|
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" };
|
5481
5595
|
|
5482
5596
|
// components/Puck/components/Fields/index.tsx
|
5483
|
-
var
|
5597
|
+
var import_react35 = require("react");
|
5484
5598
|
|
5485
5599
|
// lib/use-parent.ts
|
5486
5600
|
init_react_import();
|
5487
|
-
var
|
5601
|
+
var import_react34 = require("react");
|
5488
5602
|
var useParent = (itemSelector) => {
|
5489
5603
|
var _a;
|
5490
5604
|
const { selectedItem, state } = useAppContext();
|
5491
|
-
const { pathData } = (0,
|
5605
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5492
5606
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
5493
5607
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5494
5608
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -5497,7 +5611,7 @@ var useParent = (itemSelector) => {
|
|
5497
5611
|
};
|
5498
5612
|
|
5499
5613
|
// components/Puck/components/Fields/index.tsx
|
5500
|
-
var
|
5614
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
5501
5615
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5502
5616
|
var defaultPageFields = {
|
5503
5617
|
title: { type: "text" }
|
@@ -5505,7 +5619,7 @@ var defaultPageFields = {
|
|
5505
5619
|
var DefaultFields = ({
|
5506
5620
|
children
|
5507
5621
|
}) => {
|
5508
|
-
return /* @__PURE__ */ (0,
|
5622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5509
5623
|
};
|
5510
5624
|
var useResolvedFields = () => {
|
5511
5625
|
var _a, _b;
|
@@ -5514,20 +5628,20 @@ var useResolvedFields = () => {
|
|
5514
5628
|
const { data } = state;
|
5515
5629
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5516
5630
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5517
|
-
const defaultFields = (0,
|
5631
|
+
const defaultFields = (0, import_react35.useMemo)(
|
5518
5632
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5519
5633
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5520
5634
|
);
|
5521
5635
|
const rootProps = data.root.props || data.root;
|
5522
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5523
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5524
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5636
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react35.useState)({});
|
5637
|
+
const [resolvedFields, setResolvedFields] = (0, import_react35.useState)(defaultFields);
|
5638
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react35.useState)(false);
|
5525
5639
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5526
5640
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5527
5641
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5528
5642
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5529
5643
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5530
|
-
const resolveFields = (0,
|
5644
|
+
const resolveFields = (0, import_react35.useCallback)(
|
5531
5645
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5532
5646
|
var _a2;
|
5533
5647
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5563,19 +5677,33 @@ var useResolvedFields = () => {
|
|
5563
5677
|
lastData
|
5564
5678
|
});
|
5565
5679
|
}),
|
5566
|
-
[data, config, componentData, selectedItem, resolvedFields, state]
|
5680
|
+
[data, config, componentData, selectedItem, resolvedFields, state, parent]
|
5567
5681
|
);
|
5568
|
-
(0,
|
5569
|
-
|
5570
|
-
|
5571
|
-
|
5572
|
-
|
5573
|
-
|
5574
|
-
|
5575
|
-
|
5576
|
-
|
5682
|
+
const [hasParent, setHasParent] = (0, import_react35.useState)(false);
|
5683
|
+
(0, import_react35.useEffect)(() => {
|
5684
|
+
setHasParent(!!parent);
|
5685
|
+
}, [parent]);
|
5686
|
+
(0, import_react35.useEffect)(() => {
|
5687
|
+
var _a2;
|
5688
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || hasParent) {
|
5689
|
+
if (hasResolver) {
|
5690
|
+
setFieldsLoading(true);
|
5691
|
+
resolveFields(defaultFields).then((fields) => {
|
5692
|
+
setResolvedFields(fields || {});
|
5693
|
+
setFieldsLoading(false);
|
5694
|
+
});
|
5695
|
+
} else {
|
5696
|
+
setResolvedFields(defaultFields);
|
5697
|
+
}
|
5577
5698
|
}
|
5578
|
-
}, [
|
5699
|
+
}, [
|
5700
|
+
data,
|
5701
|
+
defaultFields,
|
5702
|
+
state.ui.itemSelector,
|
5703
|
+
selectedItem,
|
5704
|
+
hasResolver,
|
5705
|
+
hasParent
|
5706
|
+
]);
|
5579
5707
|
return [resolvedFields, fieldsLoading];
|
5580
5708
|
};
|
5581
5709
|
var Fields = () => {
|
@@ -5596,8 +5724,8 @@ var Fields = () => {
|
|
5596
5724
|
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;
|
5597
5725
|
const isLoading = fieldsResolving || componentResolving;
|
5598
5726
|
const rootProps = data.root.props || data.root;
|
5599
|
-
const Wrapper = (0,
|
5600
|
-
return /* @__PURE__ */ (0,
|
5727
|
+
const Wrapper = (0, import_react35.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5728
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5601
5729
|
"form",
|
5602
5730
|
{
|
5603
5731
|
className: getClassName21(),
|
@@ -5605,7 +5733,7 @@ var Fields = () => {
|
|
5605
5733
|
e.preventDefault();
|
5606
5734
|
},
|
5607
5735
|
children: [
|
5608
|
-
/* @__PURE__ */ (0,
|
5736
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5609
5737
|
const field = fields[fieldName];
|
5610
5738
|
if (!(field == null ? void 0 : field.type)) return null;
|
5611
5739
|
const onChange = (value, updatedUi) => {
|
@@ -5676,7 +5804,7 @@ var Fields = () => {
|
|
5676
5804
|
item: selectedItem
|
5677
5805
|
});
|
5678
5806
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5679
|
-
return /* @__PURE__ */ (0,
|
5807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5680
5808
|
AutoFieldPrivate,
|
5681
5809
|
{
|
5682
5810
|
field,
|
@@ -5694,7 +5822,7 @@ var Fields = () => {
|
|
5694
5822
|
root: true
|
5695
5823
|
});
|
5696
5824
|
const id = `root_${field.type}_${fieldName}`;
|
5697
|
-
return /* @__PURE__ */ (0,
|
5825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5698
5826
|
AutoFieldPrivate,
|
5699
5827
|
{
|
5700
5828
|
field,
|
@@ -5708,7 +5836,7 @@ var Fields = () => {
|
|
5708
5836
|
);
|
5709
5837
|
}
|
5710
5838
|
}) }),
|
5711
|
-
isLoading && /* @__PURE__ */ (0,
|
5839
|
+
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 }) }) })
|
5712
5840
|
]
|
5713
5841
|
}
|
5714
5842
|
);
|
@@ -5719,7 +5847,7 @@ init_react_import();
|
|
5719
5847
|
|
5720
5848
|
// lib/use-component-list.tsx
|
5721
5849
|
init_react_import();
|
5722
|
-
var
|
5850
|
+
var import_react36 = require("react");
|
5723
5851
|
|
5724
5852
|
// components/ComponentList/index.tsx
|
5725
5853
|
init_react_import();
|
@@ -5729,7 +5857,7 @@ init_react_import();
|
|
5729
5857
|
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" };
|
5730
5858
|
|
5731
5859
|
// components/ComponentList/index.tsx
|
5732
|
-
var
|
5860
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
5733
5861
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5734
5862
|
var ComponentListItem = ({
|
5735
5863
|
name,
|
@@ -5739,7 +5867,7 @@ var ComponentListItem = ({
|
|
5739
5867
|
const canInsert = getPermissions({
|
5740
5868
|
type: name
|
5741
5869
|
}).insert;
|
5742
|
-
return /* @__PURE__ */ (0,
|
5870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5743
5871
|
};
|
5744
5872
|
var ComponentList = ({
|
5745
5873
|
children,
|
@@ -5748,8 +5876,8 @@ var ComponentList = ({
|
|
5748
5876
|
}) => {
|
5749
5877
|
const { config, state, setUi } = useAppContext();
|
5750
5878
|
const { expanded = true } = state.ui.componentList[id] || {};
|
5751
|
-
return /* @__PURE__ */ (0,
|
5752
|
-
title && /* @__PURE__ */ (0,
|
5879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
5880
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
5753
5881
|
"button",
|
5754
5882
|
{
|
5755
5883
|
type: "button",
|
@@ -5763,14 +5891,14 @@ var ComponentList = ({
|
|
5763
5891
|
}),
|
5764
5892
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5765
5893
|
children: [
|
5766
|
-
/* @__PURE__ */ (0,
|
5767
|
-
/* @__PURE__ */ (0,
|
5894
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
|
5895
|
+
/* @__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 }) })
|
5768
5896
|
]
|
5769
5897
|
}
|
5770
5898
|
),
|
5771
|
-
/* @__PURE__ */ (0,
|
5899
|
+
/* @__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) => {
|
5772
5900
|
var _a;
|
5773
|
-
return /* @__PURE__ */ (0,
|
5901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
5774
5902
|
ComponentListItem,
|
5775
5903
|
{
|
5776
5904
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5784,10 +5912,10 @@ var ComponentList = ({
|
|
5784
5912
|
ComponentList.Item = ComponentListItem;
|
5785
5913
|
|
5786
5914
|
// lib/use-component-list.tsx
|
5787
|
-
var
|
5915
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5788
5916
|
var useComponentList = (config, ui) => {
|
5789
|
-
const [componentList, setComponentList] = (0,
|
5790
|
-
(0,
|
5917
|
+
const [componentList, setComponentList] = (0, import_react36.useState)();
|
5918
|
+
(0, import_react36.useEffect)(() => {
|
5791
5919
|
var _a, _b, _c;
|
5792
5920
|
if (Object.keys(ui.componentList).length > 0) {
|
5793
5921
|
const matchedComponents = [];
|
@@ -5797,7 +5925,7 @@ var useComponentList = (config, ui) => {
|
|
5797
5925
|
if (category.visible === false || !category.components) {
|
5798
5926
|
return null;
|
5799
5927
|
}
|
5800
|
-
return /* @__PURE__ */ (0,
|
5928
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5801
5929
|
ComponentList,
|
5802
5930
|
{
|
5803
5931
|
id: categoryKey,
|
@@ -5806,7 +5934,7 @@ var useComponentList = (config, ui) => {
|
|
5806
5934
|
var _a2;
|
5807
5935
|
matchedComponents.push(componentName);
|
5808
5936
|
const componentConf = config.components[componentName] || {};
|
5809
|
-
return /* @__PURE__ */ (0,
|
5937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5810
5938
|
ComponentList.Item,
|
5811
5939
|
{
|
5812
5940
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5826,7 +5954,7 @@ var useComponentList = (config, ui) => {
|
|
5826
5954
|
);
|
5827
5955
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5828
5956
|
_componentList.push(
|
5829
|
-
/* @__PURE__ */ (0,
|
5957
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5830
5958
|
ComponentList,
|
5831
5959
|
{
|
5832
5960
|
id: "other",
|
@@ -5834,7 +5962,7 @@ var useComponentList = (config, ui) => {
|
|
5834
5962
|
children: remainingComponents.map((componentName, i) => {
|
5835
5963
|
var _a2;
|
5836
5964
|
const componentConf = config.components[componentName] || {};
|
5837
|
-
return /* @__PURE__ */ (0,
|
5965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5838
5966
|
ComponentList.Item,
|
5839
5967
|
{
|
5840
5968
|
name: componentName,
|
@@ -5856,25 +5984,25 @@ var useComponentList = (config, ui) => {
|
|
5856
5984
|
};
|
5857
5985
|
|
5858
5986
|
// components/Puck/components/Components/index.tsx
|
5859
|
-
var
|
5860
|
-
var
|
5987
|
+
var import_react37 = require("react");
|
5988
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5861
5989
|
var Components = () => {
|
5862
5990
|
const { config, state, overrides } = useAppContext();
|
5863
5991
|
const componentList = useComponentList(config, state.ui);
|
5864
|
-
const Wrapper = (0,
|
5865
|
-
return /* @__PURE__ */ (0,
|
5992
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.components || "div", [overrides]);
|
5993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
5866
5994
|
};
|
5867
5995
|
|
5868
5996
|
// components/Puck/components/Preview/index.tsx
|
5869
5997
|
init_react_import();
|
5870
|
-
var
|
5998
|
+
var import_react39 = require("react");
|
5871
5999
|
|
5872
6000
|
// components/AutoFrame/index.tsx
|
5873
6001
|
init_react_import();
|
5874
|
-
var
|
6002
|
+
var import_react38 = require("react");
|
5875
6003
|
var import_object_hash = __toESM(require("object-hash"));
|
5876
6004
|
var import_react_dom3 = require("react-dom");
|
5877
|
-
var
|
6005
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
5878
6006
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5879
6007
|
var collectStyles = (doc) => {
|
5880
6008
|
const collected = [];
|
@@ -5917,7 +6045,7 @@ var CopyHostStyles = ({
|
|
5917
6045
|
onStylesLoaded = () => null
|
5918
6046
|
}) => {
|
5919
6047
|
const { document: doc, window: win } = useFrame();
|
5920
|
-
(0,
|
6048
|
+
(0, import_react38.useEffect)(() => {
|
5921
6049
|
if (!win || !doc) {
|
5922
6050
|
return () => {
|
5923
6051
|
};
|
@@ -6074,10 +6202,10 @@ var CopyHostStyles = ({
|
|
6074
6202
|
observer.disconnect();
|
6075
6203
|
};
|
6076
6204
|
}, []);
|
6077
|
-
return /* @__PURE__ */ (0,
|
6205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6078
6206
|
};
|
6079
|
-
var autoFrameContext = (0,
|
6080
|
-
var useFrame = () => (0,
|
6207
|
+
var autoFrameContext = (0, import_react38.createContext)({});
|
6208
|
+
var useFrame = () => (0, import_react38.useContext)(autoFrameContext);
|
6081
6209
|
function AutoFrame(_a) {
|
6082
6210
|
var _b = _a, {
|
6083
6211
|
children,
|
@@ -6094,10 +6222,10 @@ function AutoFrame(_a) {
|
|
6094
6222
|
"onStylesLoaded",
|
6095
6223
|
"frameRef"
|
6096
6224
|
]);
|
6097
|
-
const [loaded, setLoaded] = (0,
|
6098
|
-
const [ctx, setCtx] = (0,
|
6099
|
-
const [mountTarget, setMountTarget] = (0,
|
6100
|
-
(0,
|
6225
|
+
const [loaded, setLoaded] = (0, import_react38.useState)(false);
|
6226
|
+
const [ctx, setCtx] = (0, import_react38.useState)({});
|
6227
|
+
const [mountTarget, setMountTarget] = (0, import_react38.useState)();
|
6228
|
+
(0, import_react38.useEffect)(() => {
|
6101
6229
|
var _a2;
|
6102
6230
|
if (frameRef.current) {
|
6103
6231
|
setCtx({
|
@@ -6109,7 +6237,7 @@ function AutoFrame(_a) {
|
|
6109
6237
|
);
|
6110
6238
|
}
|
6111
6239
|
}, [frameRef, loaded]);
|
6112
|
-
return /* @__PURE__ */ (0,
|
6240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
6113
6241
|
"iframe",
|
6114
6242
|
__spreadProps(__spreadValues({}, props), {
|
6115
6243
|
className,
|
@@ -6119,7 +6247,7 @@ function AutoFrame(_a) {
|
|
6119
6247
|
onLoad: () => {
|
6120
6248
|
setLoaded(true);
|
6121
6249
|
},
|
6122
|
-
children: /* @__PURE__ */ (0,
|
6250
|
+
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) }) })
|
6123
6251
|
})
|
6124
6252
|
);
|
6125
6253
|
}
|
@@ -6132,7 +6260,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
|
|
6132
6260
|
|
6133
6261
|
// components/Render/index.tsx
|
6134
6262
|
init_react_import();
|
6135
|
-
var
|
6263
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
6136
6264
|
function Render({
|
6137
6265
|
config,
|
6138
6266
|
data
|
@@ -6145,7 +6273,7 @@ function Render({
|
|
6145
6273
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
6146
6274
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
6147
6275
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
6148
|
-
return /* @__PURE__ */ (0,
|
6276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6149
6277
|
DropZoneProvider,
|
6150
6278
|
{
|
6151
6279
|
value: {
|
@@ -6155,7 +6283,7 @@ function Render({
|
|
6155
6283
|
depth: 0,
|
6156
6284
|
path: []
|
6157
6285
|
},
|
6158
|
-
children: /* @__PURE__ */ (0,
|
6286
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6159
6287
|
config.root.render,
|
6160
6288
|
__spreadProps(__spreadValues({}, rootProps), {
|
6161
6289
|
puck: {
|
@@ -6165,13 +6293,13 @@ function Render({
|
|
6165
6293
|
title,
|
6166
6294
|
editMode: false,
|
6167
6295
|
id: "puck-root",
|
6168
|
-
children: /* @__PURE__ */ (0,
|
6296
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6169
6297
|
})
|
6170
6298
|
)
|
6171
6299
|
}
|
6172
6300
|
);
|
6173
6301
|
}
|
6174
|
-
return /* @__PURE__ */ (0,
|
6302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6175
6303
|
DropZoneProvider,
|
6176
6304
|
{
|
6177
6305
|
value: {
|
@@ -6181,17 +6309,17 @@ function Render({
|
|
6181
6309
|
depth: 0,
|
6182
6310
|
path: []
|
6183
6311
|
},
|
6184
|
-
children: /* @__PURE__ */ (0,
|
6312
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6185
6313
|
}
|
6186
6314
|
);
|
6187
6315
|
}
|
6188
6316
|
|
6189
6317
|
// components/Puck/components/Preview/index.tsx
|
6190
|
-
var
|
6318
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
6191
6319
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6192
6320
|
var useBubbleIframeEvents = (ref) => {
|
6193
6321
|
const { status } = useAppContext();
|
6194
|
-
(0,
|
6322
|
+
(0, import_react39.useEffect)(() => {
|
6195
6323
|
var _a;
|
6196
6324
|
if (ref.current && status === "READY") {
|
6197
6325
|
const iframe = ref.current;
|
@@ -6230,20 +6358,20 @@ var useBubbleIframeEvents = (ref) => {
|
|
6230
6358
|
};
|
6231
6359
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6232
6360
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6233
|
-
const Page = (0,
|
6361
|
+
const Page = (0, import_react39.useCallback)(
|
6234
6362
|
(pageProps) => {
|
6235
6363
|
var _a, _b;
|
6236
6364
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
6237
6365
|
id: "puck-root"
|
6238
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
6366
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
6239
6367
|
},
|
6240
6368
|
[config.root]
|
6241
6369
|
);
|
6242
|
-
const Frame = (0,
|
6370
|
+
const Frame = (0, import_react39.useMemo)(() => overrides.iframe, [overrides]);
|
6243
6371
|
const rootProps = state.data.root.props || state.data.root;
|
6244
|
-
const ref = (0,
|
6372
|
+
const ref = (0, import_react39.useRef)(null);
|
6245
6373
|
useBubbleIframeEvents(ref);
|
6246
|
-
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0,
|
6374
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6247
6375
|
Page,
|
6248
6376
|
__spreadProps(__spreadValues({}, rootProps), {
|
6249
6377
|
puck: {
|
@@ -6252,10 +6380,10 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6252
6380
|
dragRef: null
|
6253
6381
|
},
|
6254
6382
|
editMode: true,
|
6255
|
-
children: /* @__PURE__ */ (0,
|
6383
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
6256
6384
|
})
|
6257
|
-
) : /* @__PURE__ */ (0,
|
6258
|
-
return /* @__PURE__ */ (0,
|
6385
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
|
6386
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6259
6387
|
"div",
|
6260
6388
|
{
|
6261
6389
|
className: getClassName23(),
|
@@ -6264,7 +6392,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6264
6392
|
onClick: () => {
|
6265
6393
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
6266
6394
|
},
|
6267
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
6395
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6268
6396
|
AutoFrame_default,
|
6269
6397
|
{
|
6270
6398
|
id: "preview-frame",
|
@@ -6274,14 +6402,14 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6274
6402
|
setStatus("READY");
|
6275
6403
|
},
|
6276
6404
|
frameRef: ref,
|
6277
|
-
children: /* @__PURE__ */ (0,
|
6405
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
6278
6406
|
if (Frame) {
|
6279
|
-
return /* @__PURE__ */ (0,
|
6407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
6280
6408
|
}
|
6281
6409
|
return inner;
|
6282
6410
|
} })
|
6283
6411
|
}
|
6284
|
-
) : /* @__PURE__ */ (0,
|
6412
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6285
6413
|
"div",
|
6286
6414
|
{
|
6287
6415
|
id: "preview-frame",
|
@@ -6338,7 +6466,7 @@ var scrollIntoView = (el) => {
|
|
6338
6466
|
};
|
6339
6467
|
|
6340
6468
|
// components/LayerTree/index.tsx
|
6341
|
-
var
|
6469
|
+
var import_react40 = require("react");
|
6342
6470
|
|
6343
6471
|
// lib/is-child-of-zone.ts
|
6344
6472
|
init_react_import();
|
@@ -6371,7 +6499,7 @@ var onScrollEnd = (frame, cb) => {
|
|
6371
6499
|
};
|
6372
6500
|
|
6373
6501
|
// components/LayerTree/index.tsx
|
6374
|
-
var
|
6502
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6375
6503
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6376
6504
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6377
6505
|
var LayerTree = ({
|
@@ -6384,15 +6512,15 @@ var LayerTree = ({
|
|
6384
6512
|
label
|
6385
6513
|
}) => {
|
6386
6514
|
const zones = data.zones || {};
|
6387
|
-
const ctx = (0,
|
6388
|
-
return /* @__PURE__ */ (0,
|
6389
|
-
label && /* @__PURE__ */ (0,
|
6390
|
-
/* @__PURE__ */ (0,
|
6515
|
+
const ctx = (0, import_react40.useContext)(dropZoneContext);
|
6516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6517
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6518
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
6391
6519
|
" ",
|
6392
6520
|
label
|
6393
6521
|
] }),
|
6394
|
-
/* @__PURE__ */ (0,
|
6395
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
6522
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
|
6523
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
6396
6524
|
zoneContent.map((item, i) => {
|
6397
6525
|
var _a;
|
6398
6526
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6405,7 +6533,7 @@ var LayerTree = ({
|
|
6405
6533
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
6406
6534
|
const componentConfig = config.components[item.type];
|
6407
6535
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
6408
|
-
return /* @__PURE__ */ (0,
|
6536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6409
6537
|
"li",
|
6410
6538
|
{
|
6411
6539
|
className: getClassNameLayer({
|
@@ -6415,7 +6543,7 @@ var LayerTree = ({
|
|
6415
6543
|
childIsSelected
|
6416
6544
|
}),
|
6417
6545
|
children: [
|
6418
|
-
/* @__PURE__ */ (0,
|
6546
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6419
6547
|
"button",
|
6420
6548
|
{
|
6421
6549
|
type: "button",
|
@@ -6454,22 +6582,22 @@ var LayerTree = ({
|
|
6454
6582
|
setHoveringComponent(null);
|
6455
6583
|
},
|
6456
6584
|
children: [
|
6457
|
-
containsZone && /* @__PURE__ */ (0,
|
6585
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6458
6586
|
"div",
|
6459
6587
|
{
|
6460
6588
|
className: getClassNameLayer("chevron"),
|
6461
6589
|
title: isSelected ? "Collapse" : "Expand",
|
6462
|
-
children: /* @__PURE__ */ (0,
|
6590
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
6463
6591
|
}
|
6464
6592
|
),
|
6465
|
-
/* @__PURE__ */ (0,
|
6466
|
-
/* @__PURE__ */ (0,
|
6467
|
-
/* @__PURE__ */ (0,
|
6593
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
6594
|
+
/* @__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" }) }),
|
6595
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
6468
6596
|
] })
|
6469
6597
|
]
|
6470
6598
|
}
|
6471
6599
|
) }),
|
6472
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
6600
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6473
6601
|
LayerTree,
|
6474
6602
|
{
|
6475
6603
|
config,
|
@@ -6491,13 +6619,13 @@ var LayerTree = ({
|
|
6491
6619
|
};
|
6492
6620
|
|
6493
6621
|
// components/Puck/components/Outline/index.tsx
|
6494
|
-
var
|
6495
|
-
var
|
6622
|
+
var import_react41 = require("react");
|
6623
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6496
6624
|
var Outline = () => {
|
6497
6625
|
const { dispatch, state, overrides, config } = useAppContext();
|
6498
6626
|
const { data, ui } = state;
|
6499
6627
|
const { itemSelector } = ui;
|
6500
|
-
const setItemSelector = (0,
|
6628
|
+
const setItemSelector = (0, import_react41.useCallback)(
|
6501
6629
|
(newItemSelector) => {
|
6502
6630
|
dispatch({
|
6503
6631
|
type: "setUi",
|
@@ -6506,9 +6634,9 @@ var Outline = () => {
|
|
6506
6634
|
},
|
6507
6635
|
[]
|
6508
6636
|
);
|
6509
|
-
const Wrapper = (0,
|
6510
|
-
return /* @__PURE__ */ (0,
|
6511
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
6637
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.outline || "div", [overrides]);
|
6638
|
+
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: [
|
6639
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6512
6640
|
LayerTree,
|
6513
6641
|
{
|
6514
6642
|
config,
|
@@ -6521,7 +6649,7 @@ var Outline = () => {
|
|
6521
6649
|
),
|
6522
6650
|
Object.entries(findZonesForArea(data, "root")).map(
|
6523
6651
|
([zoneKey, zone]) => {
|
6524
|
-
return /* @__PURE__ */ (0,
|
6652
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6525
6653
|
LayerTree,
|
6526
6654
|
{
|
6527
6655
|
config,
|
@@ -6620,19 +6748,19 @@ function usePuckHistory({
|
|
6620
6748
|
|
6621
6749
|
// lib/use-history-store.ts
|
6622
6750
|
init_react_import();
|
6623
|
-
var
|
6751
|
+
var import_react42 = require("react");
|
6624
6752
|
var import_use_debounce3 = require("use-debounce");
|
6625
6753
|
var EMPTY_HISTORY_INDEX = 0;
|
6626
6754
|
function useHistoryStore(initialHistory) {
|
6627
6755
|
var _a, _b;
|
6628
|
-
const [histories, setHistories] = (0,
|
6756
|
+
const [histories, setHistories] = (0, import_react42.useState)(
|
6629
6757
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6630
6758
|
);
|
6631
6759
|
const updateHistories = (histories2) => {
|
6632
6760
|
setHistories(histories2);
|
6633
6761
|
setIndex(histories2.length - 1);
|
6634
6762
|
};
|
6635
|
-
const [index, setIndex] = (0,
|
6763
|
+
const [index, setIndex] = (0, import_react42.useState)(
|
6636
6764
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6637
6765
|
);
|
6638
6766
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6792,22 +6920,22 @@ var getBox = function getBox2(el) {
|
|
6792
6920
|
};
|
6793
6921
|
|
6794
6922
|
// components/Puck/components/Canvas/index.tsx
|
6795
|
-
var
|
6923
|
+
var import_react44 = require("react");
|
6796
6924
|
|
6797
6925
|
// components/ViewportControls/index.tsx
|
6798
6926
|
init_react_import();
|
6799
|
-
var
|
6927
|
+
var import_react43 = require("react");
|
6800
6928
|
|
6801
6929
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6802
6930
|
init_react_import();
|
6803
6931
|
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" };
|
6804
6932
|
|
6805
6933
|
// components/ViewportControls/index.tsx
|
6806
|
-
var
|
6934
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
6807
6935
|
var icons = {
|
6808
|
-
Smartphone: /* @__PURE__ */ (0,
|
6809
|
-
Tablet: /* @__PURE__ */ (0,
|
6810
|
-
Monitor: /* @__PURE__ */ (0,
|
6936
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
|
6937
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
|
6938
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
|
6811
6939
|
};
|
6812
6940
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6813
6941
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6819,11 +6947,11 @@ var ViewportButton = ({
|
|
6819
6947
|
onClick
|
6820
6948
|
}) => {
|
6821
6949
|
const { state } = useAppContext();
|
6822
|
-
const [isActive, setIsActive] = (0,
|
6823
|
-
(0,
|
6950
|
+
const [isActive, setIsActive] = (0, import_react43.useState)(false);
|
6951
|
+
(0, import_react43.useEffect)(() => {
|
6824
6952
|
setIsActive(width === state.ui.viewports.current.width);
|
6825
6953
|
}, [width, state.ui.viewports.current.width]);
|
6826
|
-
return /* @__PURE__ */ (0,
|
6954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6827
6955
|
IconButton,
|
6828
6956
|
{
|
6829
6957
|
title,
|
@@ -6832,7 +6960,7 @@ var ViewportButton = ({
|
|
6832
6960
|
e.stopPropagation();
|
6833
6961
|
onClick({ width, height });
|
6834
6962
|
},
|
6835
|
-
children: /* @__PURE__ */ (0,
|
6963
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
|
6836
6964
|
}
|
6837
6965
|
) });
|
6838
6966
|
};
|
@@ -6856,7 +6984,7 @@ var ViewportControls = ({
|
|
6856
6984
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6857
6985
|
(option) => option.value === autoZoom
|
6858
6986
|
);
|
6859
|
-
const zoomOptions = (0,
|
6987
|
+
const zoomOptions = (0, import_react43.useMemo)(
|
6860
6988
|
() => [
|
6861
6989
|
...defaultZoomOptions,
|
6862
6990
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6868,8 +6996,8 @@ var ViewportControls = ({
|
|
6868
6996
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
6869
6997
|
[autoZoom]
|
6870
6998
|
);
|
6871
|
-
return /* @__PURE__ */ (0,
|
6872
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
6999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
|
7000
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6873
7001
|
ViewportButton,
|
6874
7002
|
{
|
6875
7003
|
height: viewport.height,
|
@@ -6880,8 +7008,8 @@ var ViewportControls = ({
|
|
6880
7008
|
},
|
6881
7009
|
i
|
6882
7010
|
)),
|
6883
|
-
/* @__PURE__ */ (0,
|
6884
|
-
/* @__PURE__ */ (0,
|
7011
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7012
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6885
7013
|
IconButton,
|
6886
7014
|
{
|
6887
7015
|
title: "Zoom viewport out",
|
@@ -6895,10 +7023,10 @@ var ViewportControls = ({
|
|
6895
7023
|
)].value
|
6896
7024
|
);
|
6897
7025
|
},
|
6898
|
-
children: /* @__PURE__ */ (0,
|
7026
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
|
6899
7027
|
}
|
6900
7028
|
),
|
6901
|
-
/* @__PURE__ */ (0,
|
7029
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6902
7030
|
IconButton,
|
6903
7031
|
{
|
6904
7032
|
title: "Zoom viewport in",
|
@@ -6912,11 +7040,11 @@ var ViewportControls = ({
|
|
6912
7040
|
)].value
|
6913
7041
|
);
|
6914
7042
|
},
|
6915
|
-
children: /* @__PURE__ */ (0,
|
7043
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
|
6916
7044
|
}
|
6917
7045
|
),
|
6918
|
-
/* @__PURE__ */ (0,
|
6919
|
-
/* @__PURE__ */ (0,
|
7046
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7047
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6920
7048
|
"select",
|
6921
7049
|
{
|
6922
7050
|
className: getClassName25("zoomSelect"),
|
@@ -6924,7 +7052,7 @@ var ViewportControls = ({
|
|
6924
7052
|
onChange: (e) => {
|
6925
7053
|
onZoom(parseFloat(e.currentTarget.value));
|
6926
7054
|
},
|
6927
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
7055
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6928
7056
|
"option",
|
6929
7057
|
{
|
6930
7058
|
value: option.value,
|
@@ -6972,24 +7100,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6972
7100
|
};
|
6973
7101
|
|
6974
7102
|
// components/Puck/components/Canvas/index.tsx
|
6975
|
-
var
|
7103
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
6976
7104
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6977
7105
|
var ZOOM_ON_CHANGE = true;
|
6978
7106
|
var Canvas = () => {
|
6979
7107
|
const { status, iframe } = useAppContext();
|
6980
7108
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6981
7109
|
const { ui } = state;
|
6982
|
-
const frameRef = (0,
|
6983
|
-
const [showTransition, setShowTransition] = (0,
|
6984
|
-
const defaultRender = (0,
|
6985
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
7110
|
+
const frameRef = (0, import_react44.useRef)(null);
|
7111
|
+
const [showTransition, setShowTransition] = (0, import_react44.useState)(false);
|
7112
|
+
const defaultRender = (0, import_react44.useMemo)(() => {
|
7113
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
6986
7114
|
return PuckDefault;
|
6987
7115
|
}, []);
|
6988
|
-
const CustomPreview = (0,
|
7116
|
+
const CustomPreview = (0, import_react44.useMemo)(
|
6989
7117
|
() => overrides.preview || defaultRender,
|
6990
7118
|
[overrides]
|
6991
7119
|
);
|
6992
|
-
const getFrameDimensions = (0,
|
7120
|
+
const getFrameDimensions = (0, import_react44.useCallback)(() => {
|
6993
7121
|
if (frameRef.current) {
|
6994
7122
|
const frame = frameRef.current;
|
6995
7123
|
const box = getBox(frame);
|
@@ -6997,7 +7125,7 @@ var Canvas = () => {
|
|
6997
7125
|
}
|
6998
7126
|
return { width: 0, height: 0 };
|
6999
7127
|
}, [frameRef]);
|
7000
|
-
const resetAutoZoom = (0,
|
7128
|
+
const resetAutoZoom = (0, import_react44.useCallback)(
|
7001
7129
|
(ui2 = state.ui) => {
|
7002
7130
|
if (frameRef.current) {
|
7003
7131
|
setZoomConfig(
|
@@ -7007,11 +7135,11 @@ var Canvas = () => {
|
|
7007
7135
|
},
|
7008
7136
|
[frameRef, zoomConfig, state.ui]
|
7009
7137
|
);
|
7010
|
-
(0,
|
7138
|
+
(0, import_react44.useEffect)(() => {
|
7011
7139
|
setShowTransition(false);
|
7012
7140
|
resetAutoZoom();
|
7013
7141
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7014
|
-
(0,
|
7142
|
+
(0, import_react44.useEffect)(() => {
|
7015
7143
|
const { height: frameHeight } = getFrameDimensions();
|
7016
7144
|
if (ui.viewports.current.height === "auto") {
|
7017
7145
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7019,13 +7147,13 @@ var Canvas = () => {
|
|
7019
7147
|
}));
|
7020
7148
|
}
|
7021
7149
|
}, [zoomConfig.zoom]);
|
7022
|
-
(0,
|
7150
|
+
(0, import_react44.useEffect)(() => {
|
7023
7151
|
if (ZOOM_ON_CHANGE) {
|
7024
7152
|
setShowTransition(true);
|
7025
7153
|
resetAutoZoom(ui);
|
7026
7154
|
}
|
7027
7155
|
}, [ui.viewports.current.width]);
|
7028
|
-
(0,
|
7156
|
+
(0, import_react44.useEffect)(() => {
|
7029
7157
|
const cb = () => {
|
7030
7158
|
setShowTransition(false);
|
7031
7159
|
resetAutoZoom();
|
@@ -7035,13 +7163,13 @@ var Canvas = () => {
|
|
7035
7163
|
window.removeEventListener("resize", cb);
|
7036
7164
|
};
|
7037
7165
|
}, []);
|
7038
|
-
const [showLoader, setShowLoader] = (0,
|
7039
|
-
(0,
|
7166
|
+
const [showLoader, setShowLoader] = (0, import_react44.useState)(false);
|
7167
|
+
(0, import_react44.useEffect)(() => {
|
7040
7168
|
setTimeout(() => {
|
7041
7169
|
setShowLoader(true);
|
7042
7170
|
}, 500);
|
7043
7171
|
}, []);
|
7044
|
-
return /* @__PURE__ */ (0,
|
7172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
7045
7173
|
"div",
|
7046
7174
|
{
|
7047
7175
|
className: getClassName26({
|
@@ -7054,7 +7182,7 @@ var Canvas = () => {
|
|
7054
7182
|
recordHistory: true
|
7055
7183
|
}),
|
7056
7184
|
children: [
|
7057
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
7185
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7058
7186
|
ViewportControls,
|
7059
7187
|
{
|
7060
7188
|
autoZoom: zoomConfig.autoZoom,
|
@@ -7080,8 +7208,8 @@ var Canvas = () => {
|
|
7080
7208
|
}
|
7081
7209
|
}
|
7082
7210
|
) }),
|
7083
|
-
/* @__PURE__ */ (0,
|
7084
|
-
/* @__PURE__ */ (0,
|
7211
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7212
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7085
7213
|
"div",
|
7086
7214
|
{
|
7087
7215
|
className: getClassName26("root"),
|
@@ -7102,10 +7230,10 @@ var Canvas = () => {
|
|
7102
7230
|
})
|
7103
7231
|
);
|
7104
7232
|
},
|
7105
|
-
children: /* @__PURE__ */ (0,
|
7233
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview2, {}) })
|
7106
7234
|
}
|
7107
7235
|
),
|
7108
|
-
/* @__PURE__ */ (0,
|
7236
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
7109
7237
|
] })
|
7110
7238
|
]
|
7111
7239
|
}
|
@@ -7114,7 +7242,7 @@ var Canvas = () => {
|
|
7114
7242
|
|
7115
7243
|
// lib/use-loaded-overrides.ts
|
7116
7244
|
init_react_import();
|
7117
|
-
var
|
7245
|
+
var import_react45 = require("react");
|
7118
7246
|
|
7119
7247
|
// lib/load-overrides.ts
|
7120
7248
|
init_react_import();
|
@@ -7153,26 +7281,26 @@ var useLoadedOverrides = ({
|
|
7153
7281
|
overrides,
|
7154
7282
|
plugins
|
7155
7283
|
}) => {
|
7156
|
-
return (0,
|
7284
|
+
return (0, import_react45.useMemo)(() => {
|
7157
7285
|
return loadOverrides({ overrides, plugins });
|
7158
7286
|
}, [plugins, overrides]);
|
7159
7287
|
};
|
7160
7288
|
|
7161
7289
|
// components/DefaultOverride/index.tsx
|
7162
7290
|
init_react_import();
|
7163
|
-
var
|
7164
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
7291
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7292
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
7165
7293
|
|
7166
7294
|
// lib/use-inject-css.ts
|
7167
7295
|
init_react_import();
|
7168
|
-
var
|
7296
|
+
var import_react46 = require("react");
|
7169
7297
|
var styles = ``;
|
7170
7298
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7171
|
-
const [el, setEl] = (0,
|
7172
|
-
(0,
|
7299
|
+
const [el, setEl] = (0, import_react46.useState)();
|
7300
|
+
(0, import_react46.useEffect)(() => {
|
7173
7301
|
setEl(document.createElement("style"));
|
7174
7302
|
}, []);
|
7175
|
-
(0,
|
7303
|
+
(0, import_react46.useEffect)(() => {
|
7176
7304
|
var _a;
|
7177
7305
|
if (!el || typeof window === "undefined") {
|
7178
7306
|
return;
|
@@ -7192,10 +7320,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7192
7320
|
|
7193
7321
|
// lib/use-preview-mode-hotkeys.ts
|
7194
7322
|
init_react_import();
|
7195
|
-
var
|
7323
|
+
var import_react47 = require("react");
|
7196
7324
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7197
7325
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7198
|
-
const toggleInteractive = (0,
|
7326
|
+
const toggleInteractive = (0, import_react47.useCallback)(() => {
|
7199
7327
|
dispatch({
|
7200
7328
|
type: "setUi",
|
7201
7329
|
ui: (ui) => ({
|
@@ -7218,7 +7346,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
|
7218
7346
|
};
|
7219
7347
|
|
7220
7348
|
// components/Puck/index.tsx
|
7221
|
-
var
|
7349
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
7222
7350
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
7223
7351
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
7224
7352
|
function Puck({
|
@@ -7247,7 +7375,7 @@ function Puck({
|
|
7247
7375
|
waitForStyles: true
|
7248
7376
|
}, _iframe);
|
7249
7377
|
useInjectGlobalCss(iframe.enabled);
|
7250
|
-
const [generatedAppState] = (0,
|
7378
|
+
const [generatedAppState] = (0, import_react48.useState)(() => {
|
7251
7379
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7252
7380
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7253
7381
|
let clientUiState = {};
|
@@ -7319,14 +7447,14 @@ function Puck({
|
|
7319
7447
|
histories,
|
7320
7448
|
index: initialHistoryIndex
|
7321
7449
|
});
|
7322
|
-
const [reducer] = (0,
|
7450
|
+
const [reducer] = (0, import_react48.useState)(
|
7323
7451
|
() => createReducer({
|
7324
7452
|
config,
|
7325
7453
|
record: historyStore.record,
|
7326
7454
|
onAction
|
7327
7455
|
})
|
7328
7456
|
);
|
7329
|
-
const [appState, dispatch] = (0,
|
7457
|
+
const [appState, dispatch] = (0, import_react48.useReducer)(
|
7330
7458
|
reducer,
|
7331
7459
|
flushZones(initialAppState)
|
7332
7460
|
);
|
@@ -7337,14 +7465,14 @@ function Puck({
|
|
7337
7465
|
historyStore,
|
7338
7466
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7339
7467
|
});
|
7340
|
-
const [menuOpen, setMenuOpen] = (0,
|
7468
|
+
const [menuOpen, setMenuOpen] = (0, import_react48.useState)(false);
|
7341
7469
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7342
7470
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7343
|
-
(0,
|
7471
|
+
(0, import_react48.useEffect)(() => {
|
7344
7472
|
if (onChange) onChange(data);
|
7345
7473
|
}, [data]);
|
7346
7474
|
const rootProps = data.root.props || data.root;
|
7347
|
-
const toggleSidebars = (0,
|
7475
|
+
const toggleSidebars = (0, import_react48.useCallback)(
|
7348
7476
|
(sidebar) => {
|
7349
7477
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7350
7478
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7358,7 +7486,7 @@ function Puck({
|
|
7358
7486
|
},
|
7359
7487
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7360
7488
|
);
|
7361
|
-
(0,
|
7489
|
+
(0, import_react48.useEffect)(() => {
|
7362
7490
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7363
7491
|
dispatch({
|
7364
7492
|
type: "setUi",
|
@@ -7381,7 +7509,7 @@ function Puck({
|
|
7381
7509
|
window.removeEventListener("resize", handleResize);
|
7382
7510
|
};
|
7383
7511
|
}, []);
|
7384
|
-
const defaultHeaderRender = (0,
|
7512
|
+
const defaultHeaderRender = (0, import_react48.useMemo)(() => {
|
7385
7513
|
if (renderHeader) {
|
7386
7514
|
console.warn(
|
7387
7515
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7389,20 +7517,20 @@ function Puck({
|
|
7389
7517
|
const RenderHeader = (_a2) => {
|
7390
7518
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
7391
7519
|
const Comp = renderHeader;
|
7392
|
-
return /* @__PURE__ */ (0,
|
7520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7393
7521
|
};
|
7394
7522
|
return RenderHeader;
|
7395
7523
|
}
|
7396
7524
|
return DefaultOverride;
|
7397
7525
|
}, [renderHeader]);
|
7398
|
-
const defaultHeaderActionsRender = (0,
|
7526
|
+
const defaultHeaderActionsRender = (0, import_react48.useMemo)(() => {
|
7399
7527
|
if (renderHeaderActions) {
|
7400
7528
|
console.warn(
|
7401
7529
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7402
7530
|
);
|
7403
7531
|
const RenderHeader = (props) => {
|
7404
7532
|
const Comp = renderHeaderActions;
|
7405
|
-
return /* @__PURE__ */ (0,
|
7533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7406
7534
|
};
|
7407
7535
|
return RenderHeader;
|
7408
7536
|
}
|
@@ -7412,27 +7540,27 @@ function Puck({
|
|
7412
7540
|
overrides,
|
7413
7541
|
plugins
|
7414
7542
|
});
|
7415
|
-
const CustomPuck = (0,
|
7543
|
+
const CustomPuck = (0, import_react48.useMemo)(
|
7416
7544
|
() => loadedOverrides.puck || DefaultOverride,
|
7417
7545
|
[loadedOverrides]
|
7418
7546
|
);
|
7419
|
-
const CustomHeader = (0,
|
7547
|
+
const CustomHeader = (0, import_react48.useMemo)(
|
7420
7548
|
() => loadedOverrides.header || defaultHeaderRender,
|
7421
7549
|
[loadedOverrides]
|
7422
7550
|
);
|
7423
|
-
const CustomHeaderActions = (0,
|
7551
|
+
const CustomHeaderActions = (0, import_react48.useMemo)(
|
7424
7552
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7425
7553
|
[loadedOverrides]
|
7426
7554
|
);
|
7427
|
-
const [mounted, setMounted] = (0,
|
7428
|
-
(0,
|
7555
|
+
const [mounted, setMounted] = (0, import_react48.useState)(false);
|
7556
|
+
(0, import_react48.useEffect)(() => {
|
7429
7557
|
setMounted(true);
|
7430
7558
|
}, []);
|
7431
7559
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7432
7560
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7433
7561
|
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7434
|
-
return /* @__PURE__ */ (0,
|
7435
|
-
/* @__PURE__ */ (0,
|
7562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
7563
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7436
7564
|
AppProvider,
|
7437
7565
|
{
|
7438
7566
|
value: {
|
@@ -7454,7 +7582,7 @@ function Puck({
|
|
7454
7582
|
getPermissions: () => ({}),
|
7455
7583
|
refreshPermissions: () => null
|
7456
7584
|
},
|
7457
|
-
children: /* @__PURE__ */ (0,
|
7585
|
+
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)(
|
7458
7586
|
"div",
|
7459
7587
|
{
|
7460
7588
|
className: getLayoutClassName({
|
@@ -7463,60 +7591,60 @@ function Puck({
|
|
7463
7591
|
mounted,
|
7464
7592
|
rightSideBarVisible
|
7465
7593
|
}),
|
7466
|
-
children: /* @__PURE__ */ (0,
|
7467
|
-
/* @__PURE__ */ (0,
|
7594
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
7595
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7468
7596
|
CustomHeader,
|
7469
7597
|
{
|
7470
|
-
actions: /* @__PURE__ */ (0,
|
7598
|
+
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)(
|
7471
7599
|
Button,
|
7472
7600
|
{
|
7473
7601
|
onClick: () => {
|
7474
7602
|
onPublish && onPublish(data);
|
7475
7603
|
},
|
7476
|
-
icon: /* @__PURE__ */ (0,
|
7604
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7477
7605
|
children: "Publish"
|
7478
7606
|
}
|
7479
7607
|
) }) }),
|
7480
|
-
children: /* @__PURE__ */ (0,
|
7481
|
-
/* @__PURE__ */ (0,
|
7482
|
-
/* @__PURE__ */ (0,
|
7608
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
7609
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
|
7610
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7483
7611
|
"div",
|
7484
7612
|
{
|
7485
7613
|
className: getLayoutClassName("leftSideBarToggle"),
|
7486
|
-
children: /* @__PURE__ */ (0,
|
7614
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7487
7615
|
IconButton,
|
7488
7616
|
{
|
7489
7617
|
onClick: () => {
|
7490
7618
|
toggleSidebars("left");
|
7491
7619
|
},
|
7492
7620
|
title: "Toggle left sidebar",
|
7493
|
-
children: /* @__PURE__ */ (0,
|
7621
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
7494
7622
|
}
|
7495
7623
|
)
|
7496
7624
|
}
|
7497
7625
|
),
|
7498
|
-
/* @__PURE__ */ (0,
|
7626
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7499
7627
|
"div",
|
7500
7628
|
{
|
7501
7629
|
className: getLayoutClassName("rightSideBarToggle"),
|
7502
|
-
children: /* @__PURE__ */ (0,
|
7630
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7503
7631
|
IconButton,
|
7504
7632
|
{
|
7505
7633
|
onClick: () => {
|
7506
7634
|
toggleSidebars("right");
|
7507
7635
|
},
|
7508
7636
|
title: "Toggle right sidebar",
|
7509
|
-
children: /* @__PURE__ */ (0,
|
7637
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
7510
7638
|
}
|
7511
7639
|
)
|
7512
7640
|
}
|
7513
7641
|
)
|
7514
7642
|
] }),
|
7515
|
-
/* @__PURE__ */ (0,
|
7643
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
7516
7644
|
headerTitle || rootProps.title || "Page",
|
7517
|
-
headerPath && /* @__PURE__ */ (0,
|
7645
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
7518
7646
|
" ",
|
7519
|
-
/* @__PURE__ */ (0,
|
7647
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7520
7648
|
"code",
|
7521
7649
|
{
|
7522
7650
|
className: getLayoutClassName("headerPath"),
|
@@ -7525,31 +7653,31 @@ function Puck({
|
|
7525
7653
|
)
|
7526
7654
|
] })
|
7527
7655
|
] }) }),
|
7528
|
-
/* @__PURE__ */ (0,
|
7529
|
-
/* @__PURE__ */ (0,
|
7656
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
|
7657
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7530
7658
|
IconButton,
|
7531
7659
|
{
|
7532
7660
|
onClick: () => {
|
7533
7661
|
return setMenuOpen(!menuOpen);
|
7534
7662
|
},
|
7535
7663
|
title: "Toggle menu bar",
|
7536
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
7664
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
7537
7665
|
}
|
7538
7666
|
) }),
|
7539
|
-
/* @__PURE__ */ (0,
|
7667
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7540
7668
|
MenuBar,
|
7541
7669
|
{
|
7542
7670
|
appState,
|
7543
7671
|
dispatch,
|
7544
7672
|
onPublish,
|
7545
7673
|
menuOpen,
|
7546
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
7674
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7547
7675
|
Button,
|
7548
7676
|
{
|
7549
7677
|
onClick: () => {
|
7550
7678
|
onPublish && onPublish(data);
|
7551
7679
|
},
|
7552
|
-
icon: /* @__PURE__ */ (0,
|
7680
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7553
7681
|
children: "Publish"
|
7554
7682
|
}
|
7555
7683
|
) }),
|
@@ -7560,19 +7688,19 @@ function Puck({
|
|
7560
7688
|
] }) })
|
7561
7689
|
}
|
7562
7690
|
),
|
7563
|
-
/* @__PURE__ */ (0,
|
7564
|
-
/* @__PURE__ */ (0,
|
7565
|
-
/* @__PURE__ */ (0,
|
7691
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7692
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
|
7693
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
|
7566
7694
|
] }),
|
7567
|
-
/* @__PURE__ */ (0,
|
7568
|
-
/* @__PURE__ */ (0,
|
7695
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
|
7696
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7569
7697
|
SidebarSection,
|
7570
7698
|
{
|
7571
7699
|
noPadding: true,
|
7572
7700
|
noBorderTop: true,
|
7573
7701
|
showBreadcrumbs: true,
|
7574
7702
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7575
|
-
children: /* @__PURE__ */ (0,
|
7703
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
|
7576
7704
|
}
|
7577
7705
|
) })
|
7578
7706
|
] })
|
@@ -7580,7 +7708,7 @@ function Puck({
|
|
7580
7708
|
) }) })
|
7581
7709
|
}
|
7582
7710
|
),
|
7583
|
-
/* @__PURE__ */ (0,
|
7711
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7584
7712
|
] });
|
7585
7713
|
}
|
7586
7714
|
Puck.Components = Components;
|