@measured/puck 0.18.0-canary.874ba1b → 0.18.0-canary.88863c3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +3 -3
- package/dist/{chunk-EXKSBUY5.mjs → chunk-CHWFBYEM.mjs} +2 -4
- package/dist/index.css +44 -47
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +841 -649
- package/dist/index.mjs +683 -488
- package/dist/rsc.js +2 -4
- package/dist/rsc.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -308,10 +308,10 @@ init_react_import();
|
|
308
308
|
|
309
309
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
310
310
|
init_react_import();
|
311
|
-
var styles_module_default2 = { "InputWrapper": "
|
311
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
|
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,28 +1691,29 @@ 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,
|
1642
1698
|
onChange,
|
1643
1699
|
readOnly,
|
1644
|
-
value,
|
1700
|
+
value: _value,
|
1645
1701
|
name,
|
1646
1702
|
label,
|
1647
1703
|
Label: Label2,
|
1648
1704
|
id
|
1649
1705
|
}) => {
|
1650
|
-
|
1706
|
+
const value = _value;
|
1707
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1651
1708
|
Label2,
|
1652
1709
|
{
|
1653
1710
|
label: label || name,
|
1654
|
-
icon: /* @__PURE__ */ (0,
|
1655
|
-
field.type === "text" && /* @__PURE__ */ (0,
|
1656
|
-
field.type === "number" && /* @__PURE__ */ (0,
|
1711
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
1712
|
+
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Type, { size: 16 }),
|
1713
|
+
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Hash, { size: 16 })
|
1657
1714
|
] }),
|
1658
1715
|
readOnly,
|
1659
|
-
children: /* @__PURE__ */ (0,
|
1716
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1660
1717
|
"input",
|
1661
1718
|
{
|
1662
1719
|
className: getClassName6("input"),
|
@@ -1664,10 +1721,17 @@ var DefaultField = ({
|
|
1664
1721
|
type: field.type,
|
1665
1722
|
title: label || name,
|
1666
1723
|
name,
|
1667
|
-
value:
|
1724
|
+
value: (value == null ? void 0 : value.toString) ? value.toString() : "",
|
1668
1725
|
onChange: (e) => {
|
1669
1726
|
if (field.type === "number") {
|
1670
|
-
|
1727
|
+
const numberValue = Number(e.currentTarget.value);
|
1728
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
1729
|
+
return;
|
1730
|
+
}
|
1731
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
1732
|
+
return;
|
1733
|
+
}
|
1734
|
+
onChange(numberValue);
|
1671
1735
|
} else {
|
1672
1736
|
onChange(e.currentTarget.value);
|
1673
1737
|
}
|
@@ -1685,11 +1749,11 @@ var DefaultField = ({
|
|
1685
1749
|
|
1686
1750
|
// components/AutoField/fields/ExternalField/index.tsx
|
1687
1751
|
init_react_import();
|
1688
|
-
var
|
1752
|
+
var import_react16 = require("react");
|
1689
1753
|
|
1690
1754
|
// components/ExternalInput/index.tsx
|
1691
1755
|
init_react_import();
|
1692
|
-
var
|
1756
|
+
var import_react15 = require("react");
|
1693
1757
|
|
1694
1758
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
1695
1759
|
init_react_import();
|
@@ -1697,7 +1761,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
1697
1761
|
|
1698
1762
|
// components/Modal/index.tsx
|
1699
1763
|
init_react_import();
|
1700
|
-
var
|
1764
|
+
var import_react13 = require("react");
|
1701
1765
|
|
1702
1766
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
1703
1767
|
init_react_import();
|
@@ -1705,22 +1769,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1705
1769
|
|
1706
1770
|
// components/Modal/index.tsx
|
1707
1771
|
var import_react_dom = require("react-dom");
|
1708
|
-
var
|
1772
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
1709
1773
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1710
1774
|
var Modal = ({
|
1711
1775
|
children,
|
1712
1776
|
onClose,
|
1713
1777
|
isOpen
|
1714
1778
|
}) => {
|
1715
|
-
const [rootEl, setRootEl] = (0,
|
1716
|
-
(0,
|
1779
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
1780
|
+
(0, import_react13.useEffect)(() => {
|
1717
1781
|
setRootEl(document.getElementById("puck-portal-root"));
|
1718
1782
|
}, []);
|
1719
1783
|
if (!rootEl) {
|
1720
|
-
return /* @__PURE__ */ (0,
|
1784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
|
1721
1785
|
}
|
1722
1786
|
return (0, import_react_dom.createPortal)(
|
1723
|
-
/* @__PURE__ */ (0,
|
1787
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1724
1788
|
"div",
|
1725
1789
|
{
|
1726
1790
|
className: getClassName7("inner"),
|
@@ -1740,11 +1804,11 @@ init_react_import();
|
|
1740
1804
|
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
1805
|
|
1742
1806
|
// components/Heading/index.tsx
|
1743
|
-
var
|
1807
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
1744
1808
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1745
1809
|
var Heading = ({ children, rank, size = "m" }) => {
|
1746
1810
|
const Tag = rank ? `h${rank}` : "span";
|
1747
|
-
return /* @__PURE__ */ (0,
|
1811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
1748
1812
|
Tag,
|
1749
1813
|
{
|
1750
1814
|
className: getClassName8({
|
@@ -1760,7 +1824,7 @@ init_react_import();
|
|
1760
1824
|
|
1761
1825
|
// components/Button/Button.tsx
|
1762
1826
|
init_react_import();
|
1763
|
-
var
|
1827
|
+
var import_react14 = require("react");
|
1764
1828
|
|
1765
1829
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
1766
1830
|
init_react_import();
|
@@ -1780,7 +1844,7 @@ var filterDataAttrs = (props) => {
|
|
1780
1844
|
};
|
1781
1845
|
|
1782
1846
|
// components/Button/Button.tsx
|
1783
|
-
var
|
1847
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
1784
1848
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1785
1849
|
var Button = (_a) => {
|
1786
1850
|
var _b = _a, {
|
@@ -1810,11 +1874,11 @@ var Button = (_a) => {
|
|
1810
1874
|
"size",
|
1811
1875
|
"loading"
|
1812
1876
|
]);
|
1813
|
-
const [loading, setLoading] = (0,
|
1814
|
-
(0,
|
1877
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
1878
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
1815
1879
|
const ElementType = href ? "a" : type ? "button" : "span";
|
1816
1880
|
const dataAttrs = filterDataAttrs(props);
|
1817
|
-
const el = /* @__PURE__ */ (0,
|
1881
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
1818
1882
|
ElementType,
|
1819
1883
|
__spreadProps(__spreadValues({
|
1820
1884
|
className: getClassName9({
|
@@ -1839,9 +1903,9 @@ var Button = (_a) => {
|
|
1839
1903
|
href
|
1840
1904
|
}, dataAttrs), {
|
1841
1905
|
children: [
|
1842
|
-
icon && /* @__PURE__ */ (0,
|
1906
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
1843
1907
|
children,
|
1844
|
-
loading && /* @__PURE__ */ (0,
|
1908
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 14 }) })
|
1845
1909
|
]
|
1846
1910
|
})
|
1847
1911
|
);
|
@@ -1849,7 +1913,7 @@ var Button = (_a) => {
|
|
1849
1913
|
};
|
1850
1914
|
|
1851
1915
|
// components/ExternalInput/index.tsx
|
1852
|
-
var
|
1916
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
1853
1917
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1854
1918
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1855
1919
|
var dataCache = {};
|
@@ -1866,28 +1930,28 @@ var ExternalInput = ({
|
|
1866
1930
|
mapRow = (val) => val,
|
1867
1931
|
filterFields
|
1868
1932
|
} = field || {};
|
1869
|
-
const [data, setData] = (0,
|
1870
|
-
const [isOpen, setOpen] = (0,
|
1871
|
-
const [isLoading, setIsLoading] = (0,
|
1933
|
+
const [data, setData] = (0, import_react15.useState)([]);
|
1934
|
+
const [isOpen, setOpen] = (0, import_react15.useState)(false);
|
1935
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
|
1872
1936
|
const hasFilterFields = !!filterFields;
|
1873
|
-
const [filters, setFilters] = (0,
|
1874
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
1875
|
-
const mappedData = (0,
|
1937
|
+
const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
|
1938
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
|
1939
|
+
const mappedData = (0, import_react15.useMemo)(() => {
|
1876
1940
|
return data.map(mapRow);
|
1877
1941
|
}, [data]);
|
1878
|
-
const keys = (0,
|
1942
|
+
const keys = (0, import_react15.useMemo)(() => {
|
1879
1943
|
const validKeys = /* @__PURE__ */ new Set();
|
1880
1944
|
for (const item of mappedData) {
|
1881
1945
|
for (const key of Object.keys(item)) {
|
1882
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
1946
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
|
1883
1947
|
validKeys.add(key);
|
1884
1948
|
}
|
1885
1949
|
}
|
1886
1950
|
}
|
1887
1951
|
return Array.from(validKeys);
|
1888
1952
|
}, [mappedData]);
|
1889
|
-
const [searchQuery, setSearchQuery] = (0,
|
1890
|
-
const search = (0,
|
1953
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
1954
|
+
const search = (0, import_react15.useCallback)(
|
1891
1955
|
(query, filters2) => __async(void 0, null, function* () {
|
1892
1956
|
setIsLoading(true);
|
1893
1957
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -1900,18 +1964,18 @@ var ExternalInput = ({
|
|
1900
1964
|
}),
|
1901
1965
|
[id, field]
|
1902
1966
|
);
|
1903
|
-
const Footer = (0,
|
1904
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
1967
|
+
const Footer = (0, import_react15.useCallback)(
|
1968
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
1905
1969
|
props.items.length,
|
1906
1970
|
" result",
|
1907
1971
|
props.items.length === 1 ? "" : "s"
|
1908
1972
|
] }),
|
1909
1973
|
[field.renderFooter]
|
1910
1974
|
);
|
1911
|
-
(0,
|
1975
|
+
(0, import_react15.useEffect)(() => {
|
1912
1976
|
search(searchQuery, filters);
|
1913
1977
|
}, []);
|
1914
|
-
return /* @__PURE__ */ (0,
|
1978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1915
1979
|
"div",
|
1916
1980
|
{
|
1917
1981
|
className: getClassName10({
|
@@ -1921,21 +1985,21 @@ var ExternalInput = ({
|
|
1921
1985
|
}),
|
1922
1986
|
id,
|
1923
1987
|
children: [
|
1924
|
-
/* @__PURE__ */ (0,
|
1925
|
-
/* @__PURE__ */ (0,
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("actions"), children: [
|
1989
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1926
1990
|
"button",
|
1927
1991
|
{
|
1928
1992
|
type: "button",
|
1929
1993
|
onClick: () => setOpen(true),
|
1930
1994
|
className: getClassName10("button"),
|
1931
1995
|
disabled: readOnly,
|
1932
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
1933
|
-
/* @__PURE__ */ (0,
|
1934
|
-
/* @__PURE__ */ (0,
|
1996
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: "16" }),
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: field.placeholder })
|
1935
1999
|
] })
|
1936
2000
|
}
|
1937
2001
|
),
|
1938
|
-
value && /* @__PURE__ */ (0,
|
2002
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1939
2003
|
"button",
|
1940
2004
|
{
|
1941
2005
|
type: "button",
|
@@ -1944,11 +2008,11 @@ var ExternalInput = ({
|
|
1944
2008
|
onChange(null);
|
1945
2009
|
},
|
1946
2010
|
disabled: readOnly,
|
1947
|
-
children: /* @__PURE__ */ (0,
|
2011
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LockOpen, { size: 16 })
|
1948
2012
|
}
|
1949
2013
|
)
|
1950
2014
|
] }),
|
1951
|
-
/* @__PURE__ */ (0,
|
2015
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1952
2016
|
"form",
|
1953
2017
|
{
|
1954
2018
|
className: getClassNameModal({
|
@@ -1962,11 +2026,11 @@ var ExternalInput = ({
|
|
1962
2026
|
search(searchQuery, filters);
|
1963
2027
|
},
|
1964
2028
|
children: [
|
1965
|
-
/* @__PURE__ */ (0,
|
1966
|
-
/* @__PURE__ */ (0,
|
1967
|
-
/* @__PURE__ */ (0,
|
1968
|
-
/* @__PURE__ */ (0,
|
1969
|
-
/* @__PURE__ */ (0,
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
2030
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: getClassNameModal("search"), children: [
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Search, { size: "18" }) }),
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1970
2034
|
"input",
|
1971
2035
|
{
|
1972
2036
|
className: getClassNameModal("searchInput"),
|
@@ -1981,9 +2045,9 @@ var ExternalInput = ({
|
|
1981
2045
|
}
|
1982
2046
|
)
|
1983
2047
|
] }),
|
1984
|
-
/* @__PURE__ */ (0,
|
1985
|
-
/* @__PURE__ */ (0,
|
1986
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2048
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
2049
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
2050
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1987
2051
|
IconButton,
|
1988
2052
|
{
|
1989
2053
|
title: "Toggle filters",
|
@@ -1992,15 +2056,15 @@ var ExternalInput = ({
|
|
1992
2056
|
e.stopPropagation();
|
1993
2057
|
setFiltersToggled(!filtersToggled);
|
1994
2058
|
},
|
1995
|
-
children: /* @__PURE__ */ (0,
|
2059
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SlidersHorizontal, { size: 20 })
|
1996
2060
|
}
|
1997
2061
|
) })
|
1998
2062
|
] })
|
1999
|
-
] }) : /* @__PURE__ */ (0,
|
2000
|
-
/* @__PURE__ */ (0,
|
2001
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2063
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
2064
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
2065
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
2002
2066
|
const filterField = filterFields[fieldName];
|
2003
|
-
return /* @__PURE__ */ (0,
|
2067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2004
2068
|
AutoFieldPrivate,
|
2005
2069
|
{
|
2006
2070
|
field: filterField,
|
@@ -2017,9 +2081,9 @@ var ExternalInput = ({
|
|
2017
2081
|
fieldName
|
2018
2082
|
);
|
2019
2083
|
}) }),
|
2020
|
-
/* @__PURE__ */ (0,
|
2021
|
-
/* @__PURE__ */ (0,
|
2022
|
-
/* @__PURE__ */ (0,
|
2084
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
2085
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: getClassNameModal("table"), children: [
|
2086
|
+
/* @__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
2087
|
"th",
|
2024
2088
|
{
|
2025
2089
|
className: getClassNameModal("th"),
|
@@ -2028,8 +2092,8 @@ var ExternalInput = ({
|
|
2028
2092
|
},
|
2029
2093
|
key
|
2030
2094
|
)) }) }),
|
2031
|
-
/* @__PURE__ */ (0,
|
2032
|
-
return /* @__PURE__ */ (0,
|
2095
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
2096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2033
2097
|
"tr",
|
2034
2098
|
{
|
2035
2099
|
style: { whiteSpace: "nowrap" },
|
@@ -2038,16 +2102,16 @@ var ExternalInput = ({
|
|
2038
2102
|
onChange(mapProp(data[i]));
|
2039
2103
|
setOpen(false);
|
2040
2104
|
},
|
2041
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
2105
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
2042
2106
|
},
|
2043
2107
|
i
|
2044
2108
|
);
|
2045
2109
|
}) })
|
2046
2110
|
] }),
|
2047
|
-
/* @__PURE__ */ (0,
|
2111
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 24 }) })
|
2048
2112
|
] })
|
2049
2113
|
] }),
|
2050
|
-
/* @__PURE__ */ (0,
|
2114
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footer, { items: mappedData }) })
|
2051
2115
|
]
|
2052
2116
|
}
|
2053
2117
|
) })
|
@@ -2057,7 +2121,7 @@ var ExternalInput = ({
|
|
2057
2121
|
};
|
2058
2122
|
|
2059
2123
|
// components/AutoField/fields/ExternalField/index.tsx
|
2060
|
-
var
|
2124
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
2061
2125
|
var ExternalField = ({
|
2062
2126
|
field,
|
2063
2127
|
onChange,
|
@@ -2071,7 +2135,7 @@ var ExternalField = ({
|
|
2071
2135
|
var _a, _b, _c;
|
2072
2136
|
const validField = field;
|
2073
2137
|
const deprecatedField = field;
|
2074
|
-
(0,
|
2138
|
+
(0, import_react16.useEffect)(() => {
|
2075
2139
|
if (deprecatedField.adaptor) {
|
2076
2140
|
console.error(
|
2077
2141
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
@@ -2081,7 +2145,7 @@ var ExternalField = ({
|
|
2081
2145
|
if (field.type !== "external") {
|
2082
2146
|
return null;
|
2083
2147
|
}
|
2084
|
-
return /* @__PURE__ */ (0,
|
2148
|
+
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
2149
|
ExternalInput,
|
2086
2150
|
{
|
2087
2151
|
name,
|
@@ -2106,7 +2170,7 @@ var ExternalField = ({
|
|
2106
2170
|
|
2107
2171
|
// components/AutoField/fields/RadioField/index.tsx
|
2108
2172
|
init_react_import();
|
2109
|
-
var
|
2173
|
+
var import_react17 = require("react");
|
2110
2174
|
|
2111
2175
|
// lib/safe-json-parse.ts
|
2112
2176
|
init_react_import();
|
@@ -2120,7 +2184,7 @@ var safeJsonParse = (str) => {
|
|
2120
2184
|
};
|
2121
2185
|
|
2122
2186
|
// components/AutoField/fields/RadioField/index.tsx
|
2123
|
-
var
|
2187
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
2124
2188
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
2125
2189
|
var RadioField = ({
|
2126
2190
|
field,
|
@@ -2132,26 +2196,26 @@ var RadioField = ({
|
|
2132
2196
|
label,
|
2133
2197
|
Label: Label2
|
2134
2198
|
}) => {
|
2135
|
-
const flatOptions = (0,
|
2199
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2136
2200
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2137
2201
|
[field]
|
2138
2202
|
);
|
2139
2203
|
if (field.type !== "radio" || !field.options) {
|
2140
2204
|
return null;
|
2141
2205
|
}
|
2142
|
-
return /* @__PURE__ */ (0,
|
2206
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2143
2207
|
Label2,
|
2144
2208
|
{
|
2145
|
-
icon: /* @__PURE__ */ (0,
|
2209
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CircleCheckBig, { size: 16 }),
|
2146
2210
|
label: label || name,
|
2147
2211
|
readOnly,
|
2148
2212
|
el: "div",
|
2149
|
-
children: /* @__PURE__ */ (0,
|
2213
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
2150
2214
|
"label",
|
2151
2215
|
{
|
2152
2216
|
className: getClassName11("radio"),
|
2153
2217
|
children: [
|
2154
|
-
/* @__PURE__ */ (0,
|
2218
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2155
2219
|
"input",
|
2156
2220
|
{
|
2157
2221
|
type: "radio",
|
@@ -2171,7 +2235,7 @@ var RadioField = ({
|
|
2171
2235
|
checked: value === option.value
|
2172
2236
|
}
|
2173
2237
|
),
|
2174
|
-
/* @__PURE__ */ (0,
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
2175
2239
|
]
|
2176
2240
|
},
|
2177
2241
|
option.label + option.value
|
@@ -2182,8 +2246,8 @@ var RadioField = ({
|
|
2182
2246
|
|
2183
2247
|
// components/AutoField/fields/SelectField/index.tsx
|
2184
2248
|
init_react_import();
|
2185
|
-
var
|
2186
|
-
var
|
2249
|
+
var import_react18 = require("react");
|
2250
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2187
2251
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2188
2252
|
var SelectField = ({
|
2189
2253
|
field,
|
@@ -2195,20 +2259,20 @@ var SelectField = ({
|
|
2195
2259
|
readOnly,
|
2196
2260
|
id
|
2197
2261
|
}) => {
|
2198
|
-
const flatOptions = (0,
|
2262
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2199
2263
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2200
2264
|
[field]
|
2201
2265
|
);
|
2202
2266
|
if (field.type !== "select" || !field.options) {
|
2203
2267
|
return null;
|
2204
2268
|
}
|
2205
|
-
return /* @__PURE__ */ (0,
|
2269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2206
2270
|
Label2,
|
2207
2271
|
{
|
2208
2272
|
label: label || name,
|
2209
|
-
icon: /* @__PURE__ */ (0,
|
2273
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronDown, { size: 16 }),
|
2210
2274
|
readOnly,
|
2211
|
-
children: /* @__PURE__ */ (0,
|
2275
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2212
2276
|
"select",
|
2213
2277
|
{
|
2214
2278
|
id,
|
@@ -2225,7 +2289,7 @@ var SelectField = ({
|
|
2225
2289
|
}
|
2226
2290
|
},
|
2227
2291
|
value,
|
2228
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
2292
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2229
2293
|
"option",
|
2230
2294
|
{
|
2231
2295
|
label: option.label,
|
@@ -2241,7 +2305,7 @@ var SelectField = ({
|
|
2241
2305
|
|
2242
2306
|
// components/AutoField/fields/TextareaField/index.tsx
|
2243
2307
|
init_react_import();
|
2244
|
-
var
|
2308
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
2245
2309
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2246
2310
|
var TextareaField = ({
|
2247
2311
|
onChange,
|
@@ -2252,7 +2316,7 @@ var TextareaField = ({
|
|
2252
2316
|
Label: Label2,
|
2253
2317
|
id
|
2254
2318
|
}) => {
|
2255
|
-
return /* @__PURE__ */ (0,
|
2319
|
+
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
2320
|
"textarea",
|
2257
2321
|
{
|
2258
2322
|
id,
|
@@ -2279,7 +2343,7 @@ init_react_import();
|
|
2279
2343
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2280
2344
|
|
2281
2345
|
// components/AutoField/fields/ObjectField/index.tsx
|
2282
|
-
var
|
2346
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
2283
2347
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2284
2348
|
var ObjectField = ({
|
2285
2349
|
field,
|
@@ -2291,47 +2355,54 @@ var ObjectField = ({
|
|
2291
2355
|
readOnly,
|
2292
2356
|
id
|
2293
2357
|
}) => {
|
2294
|
-
const {
|
2358
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2295
2359
|
if (field.type !== "object" || !field.objectFields) {
|
2296
2360
|
return null;
|
2297
2361
|
}
|
2298
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2299
2362
|
const data = value || {};
|
2300
|
-
return /* @__PURE__ */ (0,
|
2363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2301
2364
|
Label2,
|
2302
2365
|
{
|
2303
2366
|
label: label || name,
|
2304
|
-
icon: /* @__PURE__ */ (0,
|
2367
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EllipsisVertical, { size: 16 }),
|
2305
2368
|
el: "div",
|
2306
2369
|
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
|
-
|
2370
|
+
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) => {
|
2371
|
+
const subField = field.objectFields[subName];
|
2372
|
+
const subPath = `${name}.${subName}`;
|
2373
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2374
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2375
|
+
const label2 = subField.label || subName;
|
2376
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2377
|
+
NestedFieldProvider,
|
2315
2378
|
{
|
2316
|
-
name:
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2379
|
+
name: localName || id,
|
2380
|
+
subName,
|
2381
|
+
readOnlyFields,
|
2382
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2383
|
+
AutoFieldPrivate,
|
2384
|
+
{
|
2385
|
+
name: subPath,
|
2386
|
+
label: subPath,
|
2387
|
+
id: `${id}_${subName}`,
|
2388
|
+
readOnly: subReadOnly,
|
2389
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2390
|
+
label: label2
|
2391
|
+
// May be used by custom fields
|
2329
2392
|
}),
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2393
|
+
value: data[subName],
|
2394
|
+
onChange: (val, ui) => {
|
2395
|
+
onChange(
|
2396
|
+
__spreadProps(__spreadValues({}, data), {
|
2397
|
+
[subName]: val
|
2398
|
+
}),
|
2399
|
+
ui
|
2400
|
+
);
|
2401
|
+
}
|
2402
|
+
}
|
2403
|
+
)
|
2333
2404
|
},
|
2334
|
-
|
2405
|
+
subPath
|
2335
2406
|
);
|
2336
2407
|
}) }) })
|
2337
2408
|
}
|
@@ -2340,7 +2411,7 @@ var ObjectField = ({
|
|
2340
2411
|
|
2341
2412
|
// lib/use-safe-id.ts
|
2342
2413
|
init_react_import();
|
2343
|
-
var
|
2414
|
+
var import_react19 = __toESM(require("react"));
|
2344
2415
|
|
2345
2416
|
// lib/generate-id.ts
|
2346
2417
|
init_react_import();
|
@@ -2349,15 +2420,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
2349
2420
|
|
2350
2421
|
// lib/use-safe-id.ts
|
2351
2422
|
var useSafeId = () => {
|
2352
|
-
if (typeof
|
2353
|
-
return
|
2423
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
2424
|
+
return import_react19.default.useId();
|
2354
2425
|
}
|
2355
|
-
const [id] = (0,
|
2426
|
+
const [id] = (0, import_react19.useState)(generateId());
|
2356
2427
|
return id;
|
2357
2428
|
};
|
2358
2429
|
|
2359
2430
|
// components/AutoField/index.tsx
|
2360
|
-
var
|
2431
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
2361
2432
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2362
2433
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2363
2434
|
var FieldLabel = ({
|
@@ -2369,16 +2440,16 @@ var FieldLabel = ({
|
|
2369
2440
|
className
|
2370
2441
|
}) => {
|
2371
2442
|
const El = el;
|
2372
|
-
return /* @__PURE__ */ (0,
|
2373
|
-
/* @__PURE__ */ (0,
|
2374
|
-
icon ? /* @__PURE__ */ (0,
|
2443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(El, { className, children: [
|
2444
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName15("label"), children: [
|
2445
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {}),
|
2375
2446
|
label,
|
2376
|
-
readOnly && /* @__PURE__ */ (0,
|
2447
|
+
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
2448
|
] }),
|
2378
2449
|
children
|
2379
2450
|
] });
|
2380
2451
|
};
|
2381
|
-
var
|
2452
|
+
var FieldLabelInternal = ({
|
2382
2453
|
children,
|
2383
2454
|
icon,
|
2384
2455
|
label,
|
@@ -2386,14 +2457,14 @@ var FieldLabelInternal2 = ({
|
|
2386
2457
|
readOnly
|
2387
2458
|
}) => {
|
2388
2459
|
const { overrides } = useAppContext();
|
2389
|
-
const Wrapper = (0,
|
2460
|
+
const Wrapper = (0, import_react20.useMemo)(
|
2390
2461
|
() => overrides.fieldLabel || FieldLabel,
|
2391
2462
|
[overrides]
|
2392
2463
|
);
|
2393
2464
|
if (!label) {
|
2394
|
-
return /* @__PURE__ */ (0,
|
2465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
2395
2466
|
}
|
2396
|
-
return /* @__PURE__ */ (0,
|
2467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2397
2468
|
Wrapper,
|
2398
2469
|
{
|
2399
2470
|
label,
|
@@ -2407,8 +2478,9 @@ var FieldLabelInternal2 = ({
|
|
2407
2478
|
};
|
2408
2479
|
function AutoFieldInternal(props) {
|
2409
2480
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2410
|
-
const { dispatch, overrides } = useAppContext();
|
2411
|
-
const
|
2481
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2482
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
2483
|
+
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2412
2484
|
const field = props.field;
|
2413
2485
|
const label = field.label;
|
2414
2486
|
const defaultId = useSafeId();
|
@@ -2439,7 +2511,7 @@ function AutoFieldInternal(props) {
|
|
2439
2511
|
Label: Label2,
|
2440
2512
|
id: resolvedId
|
2441
2513
|
});
|
2442
|
-
const onFocus = (0,
|
2514
|
+
const onFocus = (0, import_react20.useCallback)(
|
2443
2515
|
(e) => {
|
2444
2516
|
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
2445
2517
|
e.stopPropagation();
|
@@ -2453,7 +2525,7 @@ function AutoFieldInternal(props) {
|
|
2453
2525
|
},
|
2454
2526
|
[mergedProps.name]
|
2455
2527
|
);
|
2456
|
-
const onBlur = (0,
|
2528
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
2457
2529
|
if ("name" in e.target) {
|
2458
2530
|
dispatch({
|
2459
2531
|
type: "setUi",
|
@@ -2468,27 +2540,36 @@ function AutoFieldInternal(props) {
|
|
2468
2540
|
return null;
|
2469
2541
|
}
|
2470
2542
|
const CustomField = field.render;
|
2471
|
-
return /* @__PURE__ */ (0,
|
2543
|
+
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
2544
|
}
|
2473
2545
|
const children = defaultFields[field.type](mergedProps);
|
2474
2546
|
const Render2 = render[field.type];
|
2475
|
-
return /* @__PURE__ */ (0,
|
2476
|
-
|
2547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2548
|
+
NestedFieldContext.Provider,
|
2477
2549
|
{
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2481
|
-
onClick: (e) => {
|
2482
|
-
e.stopPropagation();
|
2550
|
+
value: {
|
2551
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2552
|
+
localName: nestedFieldContext.localName
|
2483
2553
|
},
|
2484
|
-
children: /* @__PURE__ */ (0,
|
2554
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2555
|
+
"div",
|
2556
|
+
{
|
2557
|
+
className: getClassNameWrapper(),
|
2558
|
+
onFocus,
|
2559
|
+
onBlur,
|
2560
|
+
onClick: (e) => {
|
2561
|
+
e.stopPropagation();
|
2562
|
+
},
|
2563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2564
|
+
}
|
2565
|
+
)
|
2485
2566
|
}
|
2486
2567
|
);
|
2487
2568
|
}
|
2488
2569
|
function AutoFieldPrivate(props) {
|
2489
2570
|
const { state } = useAppContext();
|
2490
2571
|
const { value, onChange } = props;
|
2491
|
-
const [localValue, setLocalValue] = (0,
|
2572
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
2492
2573
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
2493
2574
|
(val, ui) => {
|
2494
2575
|
onChange(val, ui);
|
@@ -2496,11 +2577,11 @@ function AutoFieldPrivate(props) {
|
|
2496
2577
|
50,
|
2497
2578
|
{ leading: true }
|
2498
2579
|
);
|
2499
|
-
const onChangeLocal = (0,
|
2580
|
+
const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
|
2500
2581
|
setLocalValue(val);
|
2501
2582
|
onChangeDb(val, ui);
|
2502
2583
|
}, []);
|
2503
|
-
(0,
|
2584
|
+
(0, import_react20.useEffect)(() => {
|
2504
2585
|
if (state.ui.field.focus !== props.name) {
|
2505
2586
|
setLocalValue(value);
|
2506
2587
|
}
|
@@ -2509,11 +2590,11 @@ function AutoFieldPrivate(props) {
|
|
2509
2590
|
value: localValue,
|
2510
2591
|
onChange: onChangeLocal
|
2511
2592
|
};
|
2512
|
-
return /* @__PURE__ */ (0,
|
2593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2513
2594
|
}
|
2514
2595
|
function AutoField(props) {
|
2515
|
-
const DefaultLabel = (0,
|
2516
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
2596
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
2597
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2517
2598
|
"div",
|
2518
2599
|
__spreadProps(__spreadValues({}, labelProps), {
|
2519
2600
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2521,7 +2602,7 @@ function AutoField(props) {
|
|
2521
2602
|
);
|
2522
2603
|
return DefaultLabel2;
|
2523
2604
|
}, [props.readOnly]);
|
2524
|
-
return /* @__PURE__ */ (0,
|
2605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2525
2606
|
}
|
2526
2607
|
|
2527
2608
|
// components/Drawer/index.tsx
|
@@ -2532,21 +2613,21 @@ init_react_import();
|
|
2532
2613
|
var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
|
2533
2614
|
|
2534
2615
|
// components/Drawer/index.tsx
|
2535
|
-
var
|
2616
|
+
var import_react32 = require("react");
|
2536
2617
|
|
2537
2618
|
// components/DragDropContext/index.tsx
|
2538
2619
|
init_react_import();
|
2539
|
-
var
|
2540
|
-
var
|
2620
|
+
var import_react30 = require("@dnd-kit/react");
|
2621
|
+
var import_react31 = require("react");
|
2541
2622
|
var import_dom = require("@dnd-kit/dom");
|
2542
2623
|
|
2543
2624
|
// components/DropZone/index.tsx
|
2544
2625
|
init_react_import();
|
2545
|
-
var
|
2626
|
+
var import_react29 = require("react");
|
2546
2627
|
|
2547
2628
|
// components/DraggableComponent/index.tsx
|
2548
2629
|
init_react_import();
|
2549
|
-
var
|
2630
|
+
var import_react23 = require("react");
|
2550
2631
|
|
2551
2632
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2552
2633
|
init_react_import();
|
@@ -2911,11 +2992,11 @@ function getDeepScrollPosition(element) {
|
|
2911
2992
|
|
2912
2993
|
// components/DropZone/context.tsx
|
2913
2994
|
init_react_import();
|
2914
|
-
var
|
2995
|
+
var import_react21 = require("react");
|
2915
2996
|
var import_zustand = require("zustand");
|
2916
|
-
var
|
2917
|
-
var dropZoneContext = (0,
|
2918
|
-
var ZoneStoreContext = (0,
|
2997
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2998
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2999
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
2919
3000
|
(0, import_zustand.createStore)(() => ({
|
2920
3001
|
zoneDepthIndex: {},
|
2921
3002
|
nextZoneDepthIndex: {},
|
@@ -2929,25 +3010,25 @@ var ZoneStoreProvider = ({
|
|
2929
3010
|
children,
|
2930
3011
|
store
|
2931
3012
|
}) => {
|
2932
|
-
return /* @__PURE__ */ (0,
|
3013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
2933
3014
|
};
|
2934
3015
|
var DropZoneProvider = ({
|
2935
3016
|
children,
|
2936
3017
|
value
|
2937
3018
|
}) => {
|
2938
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
2939
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
3019
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3020
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
2940
3021
|
{}
|
2941
3022
|
);
|
2942
|
-
const [activeZones, setActiveZones] = (0,
|
3023
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
2943
3024
|
const { dispatch } = useAppContext();
|
2944
|
-
const registerZoneArea = (0,
|
3025
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
2945
3026
|
(area) => {
|
2946
3027
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2947
3028
|
},
|
2948
3029
|
[setAreasWithZones]
|
2949
3030
|
);
|
2950
|
-
const registerZone = (0,
|
3031
|
+
const registerZone = (0, import_react21.useCallback)(
|
2951
3032
|
(zoneCompound) => {
|
2952
3033
|
if (!dispatch) {
|
2953
3034
|
return;
|
@@ -2960,7 +3041,7 @@ var DropZoneProvider = ({
|
|
2960
3041
|
},
|
2961
3042
|
[setActiveZones, dispatch]
|
2962
3043
|
);
|
2963
|
-
const unregisterZone = (0,
|
3044
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
2964
3045
|
(zoneCompound) => {
|
2965
3046
|
if (!dispatch) {
|
2966
3047
|
return;
|
@@ -2975,7 +3056,7 @@ var DropZoneProvider = ({
|
|
2975
3056
|
},
|
2976
3057
|
[setActiveZones, dispatch]
|
2977
3058
|
);
|
2978
|
-
const memoValue = (0,
|
3059
|
+
const memoValue = (0, import_react21.useMemo)(
|
2979
3060
|
() => __spreadValues({
|
2980
3061
|
hoveringComponent,
|
2981
3062
|
setHoveringComponent,
|
@@ -2987,16 +3068,16 @@ var DropZoneProvider = ({
|
|
2987
3068
|
}, value),
|
2988
3069
|
[value, hoveringComponent, areasWithZones, activeZones]
|
2989
3070
|
);
|
2990
|
-
return /* @__PURE__ */ (0,
|
3071
|
+
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
3072
|
};
|
2992
3073
|
|
2993
3074
|
// lib/use-context-store.ts
|
2994
3075
|
init_react_import();
|
2995
|
-
var
|
3076
|
+
var import_react22 = require("react");
|
2996
3077
|
var import_zustand2 = require("zustand");
|
2997
3078
|
var import_shallow = require("zustand/react/shallow");
|
2998
3079
|
function useContextStore(context, selector) {
|
2999
|
-
const store = (0,
|
3080
|
+
const store = (0, import_react22.useContext)(context);
|
3000
3081
|
if (!store) {
|
3001
3082
|
throw new Error("useContextStore must be used inside context");
|
3002
3083
|
}
|
@@ -3004,7 +3085,7 @@ function useContextStore(context, selector) {
|
|
3004
3085
|
}
|
3005
3086
|
|
3006
3087
|
// components/DraggableComponent/index.tsx
|
3007
|
-
var
|
3088
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
3008
3089
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
3009
3090
|
var DEBUG2 = false;
|
3010
3091
|
var space = 8;
|
@@ -3015,12 +3096,12 @@ var DefaultActionBar = ({
|
|
3015
3096
|
label,
|
3016
3097
|
children,
|
3017
3098
|
parentAction
|
3018
|
-
}) => /* @__PURE__ */ (0,
|
3019
|
-
/* @__PURE__ */ (0,
|
3099
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar, { children: [
|
3100
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar.Group, { children: [
|
3020
3101
|
parentAction,
|
3021
|
-
label && /* @__PURE__ */ (0,
|
3102
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Label, { label })
|
3022
3103
|
] }),
|
3023
|
-
/* @__PURE__ */ (0,
|
3104
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Group, { children })
|
3024
3105
|
] });
|
3025
3106
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
3026
3107
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -3055,9 +3136,9 @@ var DraggableComponent = ({
|
|
3055
3136
|
iframe,
|
3056
3137
|
state
|
3057
3138
|
} = useAppContext();
|
3058
|
-
const ctx = (0,
|
3059
|
-
const [localZones, setLocalZones] = (0,
|
3060
|
-
const registerLocalZone = (0,
|
3139
|
+
const ctx = (0, import_react23.useContext)(dropZoneContext);
|
3140
|
+
const [localZones, setLocalZones] = (0, import_react23.useState)({});
|
3141
|
+
const registerLocalZone = (0, import_react23.useCallback)(
|
3061
3142
|
(zoneCompound2, active) => {
|
3062
3143
|
var _a;
|
3063
3144
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -3067,7 +3148,7 @@ var DraggableComponent = ({
|
|
3067
3148
|
},
|
3068
3149
|
[setLocalZones]
|
3069
3150
|
);
|
3070
|
-
const unregisterLocalZone = (0,
|
3151
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
3071
3152
|
(zoneCompound2) => {
|
3072
3153
|
var _a;
|
3073
3154
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -3081,8 +3162,8 @@ var DraggableComponent = ({
|
|
3081
3162
|
);
|
3082
3163
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
3083
3164
|
const { path = [] } = ctx || {};
|
3084
|
-
const [canDrag, setCanDrag] = (0,
|
3085
|
-
(0,
|
3165
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3166
|
+
(0, import_react23.useEffect)(() => {
|
3086
3167
|
var _a;
|
3087
3168
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
3088
3169
|
if (item) {
|
@@ -3098,7 +3179,7 @@ var DraggableComponent = ({
|
|
3098
3179
|
);
|
3099
3180
|
const canCollide = canDrag || userIsDragging;
|
3100
3181
|
const disabled = !isEnabled || !canCollide;
|
3101
|
-
const [dragAxis, setDragAxis] = (0,
|
3182
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
3102
3183
|
const { ref: sortableRef, status } = useSortableSafe({
|
3103
3184
|
id,
|
3104
3185
|
index,
|
@@ -3124,8 +3205,8 @@ var DraggableComponent = ({
|
|
3124
3205
|
}
|
3125
3206
|
});
|
3126
3207
|
const thisIsDragging = status === "dragging";
|
3127
|
-
const ref = (0,
|
3128
|
-
const refSetter = (0,
|
3208
|
+
const ref = (0, import_react23.useRef)(null);
|
3209
|
+
const refSetter = (0, import_react23.useCallback)(
|
3129
3210
|
(el) => {
|
3130
3211
|
sortableRef(el);
|
3131
3212
|
if (el) {
|
@@ -3134,14 +3215,14 @@ var DraggableComponent = ({
|
|
3134
3215
|
},
|
3135
3216
|
[sortableRef]
|
3136
3217
|
);
|
3137
|
-
const [portalEl, setPortalEl] = (0,
|
3138
|
-
(0,
|
3218
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3219
|
+
(0, import_react23.useEffect)(() => {
|
3139
3220
|
var _a, _b, _c;
|
3140
3221
|
setPortalEl(
|
3141
3222
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
3142
3223
|
);
|
3143
3224
|
}, [iframe.enabled, ref.current]);
|
3144
|
-
const getStyle = (0,
|
3225
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3145
3226
|
var _a, _b, _c;
|
3146
3227
|
if (!ref.current) return;
|
3147
3228
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3161,11 +3242,11 @@ var DraggableComponent = ({
|
|
3161
3242
|
};
|
3162
3243
|
return style2;
|
3163
3244
|
}, [ref.current]);
|
3164
|
-
const [style, setStyle] = (0,
|
3165
|
-
const sync = (0,
|
3245
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3246
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3166
3247
|
setStyle(getStyle());
|
3167
3248
|
}, [ref.current, iframe]);
|
3168
|
-
(0,
|
3249
|
+
(0, import_react23.useEffect)(() => {
|
3169
3250
|
if (ref.current) {
|
3170
3251
|
const observer = new ResizeObserver(sync);
|
3171
3252
|
observer.observe(ref.current);
|
@@ -3174,22 +3255,28 @@ var DraggableComponent = ({
|
|
3174
3255
|
};
|
3175
3256
|
}
|
3176
3257
|
}, [ref.current]);
|
3177
|
-
(0,
|
3178
|
-
|
3179
|
-
|
3258
|
+
(0, import_react23.useEffect)(() => {
|
3259
|
+
ctx == null ? void 0 : ctx.registerPath(
|
3260
|
+
id,
|
3261
|
+
{
|
3180
3262
|
index,
|
3181
3263
|
zone: zoneCompound
|
3182
|
-
}
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3264
|
+
},
|
3265
|
+
componentType
|
3266
|
+
);
|
3267
|
+
return () => {
|
3268
|
+
var _a;
|
3269
|
+
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3270
|
+
};
|
3271
|
+
}, [id, zoneCompound, index, componentType]);
|
3272
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3186
3273
|
() => overrides.actionBar || DefaultActionBar,
|
3187
3274
|
[overrides.actionBar]
|
3188
3275
|
);
|
3189
3276
|
const permissions = getPermissions({
|
3190
3277
|
item: selectedItem
|
3191
3278
|
});
|
3192
|
-
const onClick = (0,
|
3279
|
+
const onClick = (0, import_react23.useCallback)(
|
3193
3280
|
(e) => {
|
3194
3281
|
e.stopPropagation();
|
3195
3282
|
dispatch({
|
@@ -3201,7 +3288,7 @@ var DraggableComponent = ({
|
|
3201
3288
|
},
|
3202
3289
|
[index, zoneCompound, id]
|
3203
3290
|
);
|
3204
|
-
const onSelectParent = (0,
|
3291
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3205
3292
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3206
3293
|
return;
|
3207
3294
|
}
|
@@ -3219,23 +3306,23 @@ var DraggableComponent = ({
|
|
3219
3306
|
}
|
3220
3307
|
});
|
3221
3308
|
}, [ctx, path]);
|
3222
|
-
const onDuplicate = (0,
|
3309
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3223
3310
|
dispatch({
|
3224
3311
|
type: "duplicate",
|
3225
3312
|
sourceIndex: index,
|
3226
3313
|
sourceZone: zoneCompound
|
3227
3314
|
});
|
3228
3315
|
}, [index, zoneCompound]);
|
3229
|
-
const onDelete = (0,
|
3316
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3230
3317
|
dispatch({
|
3231
3318
|
type: "remove",
|
3232
3319
|
index,
|
3233
3320
|
zone: zoneCompound
|
3234
3321
|
});
|
3235
3322
|
}, [index, zoneCompound]);
|
3236
|
-
const [hover, setHover] = (0,
|
3323
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3237
3324
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3238
|
-
(0,
|
3325
|
+
(0, import_react23.useEffect)(() => {
|
3239
3326
|
if (!ref.current) {
|
3240
3327
|
return;
|
3241
3328
|
}
|
@@ -3285,7 +3372,7 @@ var DraggableComponent = ({
|
|
3285
3372
|
thisIsDragging,
|
3286
3373
|
inDroppableZone
|
3287
3374
|
]);
|
3288
|
-
(0,
|
3375
|
+
(0, import_react23.useEffect)(() => {
|
3289
3376
|
if (ref.current && disabled) {
|
3290
3377
|
ref.current.setAttribute("data-puck-disabled", "");
|
3291
3378
|
return () => {
|
@@ -3294,8 +3381,8 @@ var DraggableComponent = ({
|
|
3294
3381
|
};
|
3295
3382
|
}
|
3296
3383
|
}, [disabled, ref]);
|
3297
|
-
const [isVisible, setIsVisible] = (0,
|
3298
|
-
(0,
|
3384
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3385
|
+
(0, import_react23.useEffect)(() => {
|
3299
3386
|
sync();
|
3300
3387
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3301
3388
|
setIsVisible(true);
|
@@ -3303,7 +3390,7 @@ var DraggableComponent = ({
|
|
3303
3390
|
setIsVisible(false);
|
3304
3391
|
}
|
3305
3392
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3306
|
-
const syncActionsPosition = (0,
|
3393
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3307
3394
|
(el) => {
|
3308
3395
|
if (el) {
|
3309
3396
|
const view = el.ownerDocument.defaultView;
|
@@ -3320,7 +3407,7 @@ var DraggableComponent = ({
|
|
3320
3407
|
},
|
3321
3408
|
[zoomConfig]
|
3322
3409
|
);
|
3323
|
-
(0,
|
3410
|
+
(0, import_react23.useEffect)(() => {
|
3324
3411
|
if (userDragAxis) {
|
3325
3412
|
setDragAxis(userDragAxis);
|
3326
3413
|
return;
|
@@ -3334,8 +3421,8 @@ var DraggableComponent = ({
|
|
3334
3421
|
}
|
3335
3422
|
setDragAxis(autoDragAxis);
|
3336
3423
|
}, [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,
|
3424
|
+
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 }) });
|
3425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3339
3426
|
DropZoneProvider,
|
3340
3427
|
{
|
3341
3428
|
value: __spreadProps(__spreadValues({}, ctx), {
|
@@ -3349,7 +3436,7 @@ var DraggableComponent = ({
|
|
3349
3436
|
}),
|
3350
3437
|
children: [
|
3351
3438
|
isVisible && (0, import_react_dom2.createPortal)(
|
3352
|
-
/* @__PURE__ */ (0,
|
3439
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3353
3440
|
"div",
|
3354
3441
|
{
|
3355
3442
|
className: getClassName16({
|
@@ -3361,15 +3448,15 @@ var DraggableComponent = ({
|
|
3361
3448
|
"data-puck-overlay": true,
|
3362
3449
|
children: [
|
3363
3450
|
debug,
|
3364
|
-
isLoading && /* @__PURE__ */ (0,
|
3365
|
-
/* @__PURE__ */ (0,
|
3451
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {}) }),
|
3452
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3366
3453
|
"div",
|
3367
3454
|
{
|
3368
3455
|
className: getClassName16("actionsOverlay"),
|
3369
3456
|
style: {
|
3370
3457
|
top: actionsOverlayTop / zoomConfig.zoom
|
3371
3458
|
},
|
3372
|
-
children: /* @__PURE__ */ (0,
|
3459
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3373
3460
|
"div",
|
3374
3461
|
{
|
3375
3462
|
className: getClassName16("actions"),
|
@@ -3381,14 +3468,14 @@ var DraggableComponent = ({
|
|
3381
3468
|
paddingRight: actionsSide
|
3382
3469
|
},
|
3383
3470
|
ref: syncActionsPosition,
|
3384
|
-
children: /* @__PURE__ */ (0,
|
3471
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3385
3472
|
CustomActionBar,
|
3386
3473
|
{
|
3387
3474
|
parentAction,
|
3388
3475
|
label: DEBUG2 ? id : label,
|
3389
3476
|
children: [
|
3390
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
3391
|
-
permissions.delete && /* @__PURE__ */ (0,
|
3477
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Copy, { size: 16 }) }),
|
3478
|
+
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
3479
|
]
|
3393
3480
|
}
|
3394
3481
|
)
|
@@ -3396,7 +3483,7 @@ var DraggableComponent = ({
|
|
3396
3483
|
)
|
3397
3484
|
}
|
3398
3485
|
),
|
3399
|
-
/* @__PURE__ */ (0,
|
3486
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("overlay") })
|
3400
3487
|
]
|
3401
3488
|
}
|
3402
3489
|
),
|
@@ -3414,14 +3501,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
3414
3501
|
|
3415
3502
|
// components/DropZone/lib/use-min-empty-height.ts
|
3416
3503
|
init_react_import();
|
3417
|
-
var
|
3504
|
+
var import_react24 = require("react");
|
3418
3505
|
var useMinEmptyHeight = ({
|
3419
3506
|
zoneCompound,
|
3420
3507
|
userMinEmptyHeight,
|
3421
3508
|
ref
|
3422
3509
|
}) => {
|
3423
|
-
const [prevHeight, setPrevHeight] = (0,
|
3424
|
-
const [isAnimating, setIsAnimating] = (0,
|
3510
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3511
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3425
3512
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3426
3513
|
var _a, _b;
|
3427
3514
|
return {
|
@@ -3429,7 +3516,7 @@ var useMinEmptyHeight = ({
|
|
3429
3516
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3430
3517
|
};
|
3431
3518
|
});
|
3432
|
-
(0,
|
3519
|
+
(0, import_react24.useEffect)(() => {
|
3433
3520
|
if (draggedItem && ref.current) {
|
3434
3521
|
if (isZone) {
|
3435
3522
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3463,15 +3550,15 @@ function assignRefs(refs, node) {
|
|
3463
3550
|
|
3464
3551
|
// components/DropZone/lib/use-content-with-preview.ts
|
3465
3552
|
init_react_import();
|
3466
|
-
var
|
3553
|
+
var import_react27 = require("react");
|
3467
3554
|
|
3468
3555
|
// lib/dnd/use-rendered-callback.ts
|
3469
3556
|
init_react_import();
|
3470
|
-
var
|
3471
|
-
var
|
3557
|
+
var import_react25 = require("@dnd-kit/react");
|
3558
|
+
var import_react26 = require("react");
|
3472
3559
|
function useRenderedCallback(callback, deps) {
|
3473
|
-
const manager = (0,
|
3474
|
-
return (0,
|
3560
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3561
|
+
return (0, import_react26.useCallback)(
|
3475
3562
|
(...args) => __async(this, null, function* () {
|
3476
3563
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
3477
3564
|
return callback(...args);
|
@@ -3501,7 +3588,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3501
3588
|
};
|
3502
3589
|
}
|
3503
3590
|
);
|
3504
|
-
const [contentWithPreview, setContentWithPreview] = (0,
|
3591
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3505
3592
|
const updateContent = useRenderedCallback(
|
3506
3593
|
(content2, preview2) => {
|
3507
3594
|
if (preview2) {
|
@@ -3536,7 +3623,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3536
3623
|
},
|
3537
3624
|
[draggedItemId, previewExists]
|
3538
3625
|
);
|
3539
|
-
(0,
|
3626
|
+
(0, import_react27.useEffect)(() => {
|
3540
3627
|
updateContent(content, preview);
|
3541
3628
|
}, [content, preview]);
|
3542
3629
|
return contentWithPreview;
|
@@ -3544,16 +3631,16 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3544
3631
|
|
3545
3632
|
// components/DropZone/lib/use-drag-axis.ts
|
3546
3633
|
init_react_import();
|
3547
|
-
var
|
3634
|
+
var import_react28 = require("react");
|
3548
3635
|
var GRID_DRAG_AXIS = "dynamic";
|
3549
3636
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3550
3637
|
var DEFAULT_DRAG_AXIS = "y";
|
3551
3638
|
var useDragAxis = (ref, collisionAxis) => {
|
3552
3639
|
const { status } = useAppContext();
|
3553
|
-
const [dragAxis, setDragAxis] = (0,
|
3640
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3554
3641
|
collisionAxis || DEFAULT_DRAG_AXIS
|
3555
3642
|
);
|
3556
|
-
const calculateDragAxis = (0,
|
3643
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3557
3644
|
if (ref.current) {
|
3558
3645
|
const computedStyle = window.getComputedStyle(ref.current);
|
3559
3646
|
if (computedStyle.display === "grid") {
|
@@ -3565,7 +3652,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
3565
3652
|
}
|
3566
3653
|
}
|
3567
3654
|
}, [ref.current]);
|
3568
|
-
(0,
|
3655
|
+
(0, import_react28.useEffect)(() => {
|
3569
3656
|
const onViewportChange = () => {
|
3570
3657
|
calculateDragAxis();
|
3571
3658
|
};
|
@@ -3574,17 +3661,18 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
3574
3661
|
window.removeEventListener("viewportchange", onViewportChange);
|
3575
3662
|
};
|
3576
3663
|
}, []);
|
3577
|
-
(0,
|
3664
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
3578
3665
|
return [dragAxis, calculateDragAxis];
|
3579
3666
|
};
|
3580
3667
|
|
3581
3668
|
// components/DropZone/index.tsx
|
3582
|
-
var
|
3669
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
3583
3670
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3584
3671
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3585
3672
|
var RENDER_DEBUG = false;
|
3586
|
-
var
|
3587
|
-
|
3673
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
3674
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
3675
|
+
function DropZoneEditInternal({
|
3588
3676
|
zone,
|
3589
3677
|
allow,
|
3590
3678
|
disallow,
|
@@ -3594,7 +3682,7 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3594
3682
|
collisionAxis
|
3595
3683
|
}, userRef) {
|
3596
3684
|
const appContext2 = useAppContext();
|
3597
|
-
const ctx = (0,
|
3685
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3598
3686
|
const {
|
3599
3687
|
// These all need setting via context
|
3600
3688
|
data,
|
@@ -3632,12 +3720,12 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3632
3720
|
};
|
3633
3721
|
});
|
3634
3722
|
const { itemSelector } = appContext2.state.ui;
|
3635
|
-
(0,
|
3723
|
+
(0, import_react29.useEffect)(() => {
|
3636
3724
|
if (areaId && registerZoneArea) {
|
3637
3725
|
registerZoneArea(areaId);
|
3638
3726
|
}
|
3639
3727
|
}, [areaId]);
|
3640
|
-
(0,
|
3728
|
+
(0, import_react29.useEffect)(() => {
|
3641
3729
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3642
3730
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3643
3731
|
}
|
@@ -3647,14 +3735,14 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3647
3735
|
}
|
3648
3736
|
};
|
3649
3737
|
}, []);
|
3650
|
-
const content = (0,
|
3738
|
+
const content = (0, import_react29.useMemo)(() => {
|
3651
3739
|
if (areaId && zone !== rootDroppableId) {
|
3652
3740
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3653
3741
|
}
|
3654
3742
|
return data.content || [];
|
3655
3743
|
}, [data, zoneCompound]);
|
3656
|
-
const ref = (0,
|
3657
|
-
const acceptsTarget = (0,
|
3744
|
+
const ref = (0, import_react29.useRef)(null);
|
3745
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
3658
3746
|
(componentType) => {
|
3659
3747
|
if (!componentType) {
|
3660
3748
|
return true;
|
@@ -3676,7 +3764,7 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3676
3764
|
},
|
3677
3765
|
[allow, disallow]
|
3678
3766
|
);
|
3679
|
-
(0,
|
3767
|
+
(0, import_react29.useEffect)(() => {
|
3680
3768
|
if (registerLocalZone) {
|
3681
3769
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3682
3770
|
}
|
@@ -3718,7 +3806,7 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3718
3806
|
userMinEmptyHeight,
|
3719
3807
|
ref
|
3720
3808
|
});
|
3721
|
-
return /* @__PURE__ */ (0,
|
3809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3722
3810
|
"div",
|
3723
3811
|
{
|
3724
3812
|
className: `${getClassName17({
|
@@ -3742,10 +3830,10 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3742
3830
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3743
3831
|
}),
|
3744
3832
|
children: contentWithPreview.map((item, i) => {
|
3745
|
-
var _a, _b, _c, _d, _e;
|
3833
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3746
3834
|
const componentId = item.props.id;
|
3747
3835
|
const puckProps = {
|
3748
|
-
renderDropZone:
|
3836
|
+
renderDropZone: DropZoneEditPure,
|
3749
3837
|
isEditing: true,
|
3750
3838
|
dragRef: null
|
3751
3839
|
};
|
@@ -3755,27 +3843,27 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3755
3843
|
// DEPRECATED
|
3756
3844
|
});
|
3757
3845
|
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,
|
3846
|
+
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
3847
|
"No configuration for ",
|
3760
3848
|
item.type
|
3761
3849
|
] });
|
3762
3850
|
const componentConfig = config.components[item.type];
|
3763
3851
|
let componentType = item.type;
|
3764
3852
|
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3765
|
-
if (item.type === "preview"
|
3853
|
+
if (item.type === "preview") {
|
3766
3854
|
let Preview4 = function() {
|
3767
|
-
return /* @__PURE__ */ (0,
|
3855
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3768
3856
|
};
|
3769
3857
|
var Preview3 = Preview4;
|
3770
|
-
componentType = preview.componentType;
|
3771
|
-
label = (
|
3858
|
+
componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
|
3859
|
+
label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
|
3772
3860
|
Render2 = Preview4;
|
3773
3861
|
}
|
3774
|
-
return /* @__PURE__ */ (0,
|
3862
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3775
3863
|
DropZoneProvider,
|
3776
3864
|
{
|
3777
3865
|
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3778
|
-
children: /* @__PURE__ */ (0,
|
3866
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3779
3867
|
DraggableComponent,
|
3780
3868
|
{
|
3781
3869
|
id: componentId,
|
@@ -3783,21 +3871,21 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3783
3871
|
zoneCompound,
|
3784
3872
|
depth: depth + 1,
|
3785
3873
|
index: i,
|
3786
|
-
isLoading: ((
|
3874
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3787
3875
|
isSelected,
|
3788
3876
|
label,
|
3789
3877
|
isEnabled,
|
3790
3878
|
autoDragAxis: dragAxis,
|
3791
3879
|
userDragAxis: collisionAxis,
|
3792
3880
|
inDroppableZone: acceptsTarget(draggedComponentType),
|
3793
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0,
|
3881
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3794
3882
|
Render2,
|
3795
3883
|
__spreadProps(__spreadValues({}, defaultedProps), {
|
3796
3884
|
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3797
3885
|
dragRef
|
3798
3886
|
})
|
3799
3887
|
})
|
3800
|
-
) : /* @__PURE__ */ (0,
|
3888
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3801
3889
|
}
|
3802
3890
|
)
|
3803
3891
|
},
|
@@ -3808,13 +3896,14 @@ var DropZoneEdit = (0, import_react28.forwardRef)(
|
|
3808
3896
|
);
|
3809
3897
|
}
|
3810
3898
|
);
|
3811
|
-
var
|
3812
|
-
|
3813
|
-
|
3899
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
3900
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
3901
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3902
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3814
3903
|
const { data, areaId = "root", config } = ctx || {};
|
3815
3904
|
let zoneCompound = rootDroppableId;
|
3816
3905
|
let content = (data == null ? void 0 : data.content) || [];
|
3817
|
-
(0,
|
3906
|
+
(0, import_react29.useEffect)(() => {
|
3818
3907
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3819
3908
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3820
3909
|
}
|
@@ -3831,10 +3920,10 @@ var DropZoneRender = (0, import_react28.forwardRef)(
|
|
3831
3920
|
zoneCompound = `${areaId}:${zone}`;
|
3832
3921
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3833
3922
|
}
|
3834
|
-
return /* @__PURE__ */ (0,
|
3923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
3835
3924
|
const Component = config.components[item.type];
|
3836
3925
|
if (Component) {
|
3837
|
-
return /* @__PURE__ */ (0,
|
3926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3838
3927
|
DropZoneProvider,
|
3839
3928
|
{
|
3840
3929
|
value: {
|
@@ -3844,10 +3933,12 @@ var DropZoneRender = (0, import_react28.forwardRef)(
|
|
3844
3933
|
depth: 1,
|
3845
3934
|
path: []
|
3846
3935
|
},
|
3847
|
-
children: /* @__PURE__ */ (0,
|
3936
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3848
3937
|
Component.render,
|
3849
3938
|
__spreadProps(__spreadValues({}, item.props), {
|
3850
|
-
puck: {
|
3939
|
+
puck: {
|
3940
|
+
renderDropZone: DropZoneRenderPure
|
3941
|
+
}
|
3851
3942
|
})
|
3852
3943
|
)
|
3853
3944
|
},
|
@@ -3858,13 +3949,13 @@ var DropZoneRender = (0, import_react28.forwardRef)(
|
|
3858
3949
|
}) });
|
3859
3950
|
}
|
3860
3951
|
);
|
3861
|
-
var DropZone = (0,
|
3952
|
+
var DropZone = (0, import_react29.forwardRef)(
|
3862
3953
|
function DropZone2(props, ref) {
|
3863
|
-
const ctx = (0,
|
3954
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3864
3955
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3865
|
-
return /* @__PURE__ */ (0,
|
3956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3866
3957
|
}
|
3867
|
-
return /* @__PURE__ */ (0,
|
3958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3868
3959
|
}
|
3869
3960
|
);
|
3870
3961
|
|
@@ -3922,6 +4013,48 @@ var getFrame = () => {
|
|
3922
4013
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3923
4014
|
};
|
3924
4015
|
|
4016
|
+
// lib/global-position.ts
|
4017
|
+
init_react_import();
|
4018
|
+
var GlobalPosition = class {
|
4019
|
+
constructor(target, original) {
|
4020
|
+
this.scaleFactor = 1;
|
4021
|
+
this.frameEl = null;
|
4022
|
+
this.frameRect = null;
|
4023
|
+
var _a;
|
4024
|
+
this.target = target;
|
4025
|
+
this.original = original;
|
4026
|
+
this.frameEl = document.querySelector("iframe");
|
4027
|
+
if (this.frameEl) {
|
4028
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
4029
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4030
|
+
}
|
4031
|
+
}
|
4032
|
+
get x() {
|
4033
|
+
return this.original.x;
|
4034
|
+
}
|
4035
|
+
get y() {
|
4036
|
+
return this.original.y;
|
4037
|
+
}
|
4038
|
+
get global() {
|
4039
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
4040
|
+
return {
|
4041
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
4042
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
4043
|
+
};
|
4044
|
+
}
|
4045
|
+
return this.original;
|
4046
|
+
}
|
4047
|
+
get frame() {
|
4048
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
4049
|
+
return {
|
4050
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
4051
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
4052
|
+
};
|
4053
|
+
}
|
4054
|
+
return this.original;
|
4055
|
+
}
|
4056
|
+
};
|
4057
|
+
|
3925
4058
|
// lib/dnd/NestedDroppablePlugin.ts
|
3926
4059
|
var depthSort = (candidates) => {
|
3927
4060
|
return candidates.sort((a, b) => {
|
@@ -3951,10 +4084,12 @@ var getZoneId2 = (candidate) => {
|
|
3951
4084
|
}
|
3952
4085
|
return id;
|
3953
4086
|
};
|
3954
|
-
var getPointerCollisions = (position, manager
|
3955
|
-
var _a;
|
4087
|
+
var getPointerCollisions = (position, manager) => {
|
3956
4088
|
const candidates = [];
|
3957
|
-
let elements = ownerDocument.elementsFromPoint(
|
4089
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
4090
|
+
position.x,
|
4091
|
+
position.y
|
4092
|
+
);
|
3958
4093
|
const previewFrame = elements.find(
|
3959
4094
|
(el) => el.getAttribute("data-puck-preview")
|
3960
4095
|
);
|
@@ -3963,17 +4098,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3963
4098
|
elements = [drawer];
|
3964
4099
|
}
|
3965
4100
|
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
|
-
}
|
4101
|
+
const frame = getFrame();
|
4102
|
+
if (frame) {
|
4103
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
3977
4104
|
}
|
3978
4105
|
}
|
3979
4106
|
if (elements) {
|
@@ -3990,9 +4117,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3990
4117
|
}
|
3991
4118
|
return candidates;
|
3992
4119
|
};
|
3993
|
-
var findDeepestCandidate = (position, manager
|
4120
|
+
var findDeepestCandidate = (position, manager) => {
|
3994
4121
|
var _a;
|
3995
|
-
const candidates = getPointerCollisions(position, manager
|
4122
|
+
const candidates = getPointerCollisions(position, manager);
|
3996
4123
|
if (candidates.length > 0) {
|
3997
4124
|
const sortedCandidates = depthSort(candidates);
|
3998
4125
|
const draggable = manager.dragOperation.source;
|
@@ -4045,22 +4172,18 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
4045
4172
|
}
|
4046
4173
|
const cleanupEffect = (0, import_state.effects)(() => {
|
4047
4174
|
const handleMove = (event) => {
|
4048
|
-
const
|
4175
|
+
const target = event.originalTarget || event.target;
|
4176
|
+
const position = new GlobalPosition(target, {
|
4049
4177
|
x: event.clientX,
|
4050
4178
|
y: event.clientY
|
4051
|
-
};
|
4052
|
-
const target = event.originalTarget || event.target;
|
4053
|
-
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
4179
|
+
});
|
4054
4180
|
const elements = document.elementsFromPoint(
|
4055
|
-
|
4056
|
-
|
4181
|
+
position.global.x,
|
4182
|
+
position.global.y
|
4057
4183
|
);
|
4058
4184
|
const overEl = elements.some((el) => el.id === id);
|
4059
4185
|
if (overEl) {
|
4060
|
-
onChange(
|
4061
|
-
findDeepestCandidate(position, manager, ownerDocument),
|
4062
|
-
manager
|
4063
|
-
);
|
4186
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
4064
4187
|
}
|
4065
4188
|
};
|
4066
4189
|
const handleMoveThrottled = throttle(handleMove, 50);
|
@@ -4391,6 +4514,11 @@ var reduceUi = (ui, action) => {
|
|
4391
4514
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4392
4515
|
});
|
4393
4516
|
}
|
4517
|
+
if (action.type === "remove") {
|
4518
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4519
|
+
itemSelector: null
|
4520
|
+
});
|
4521
|
+
}
|
4394
4522
|
return ui;
|
4395
4523
|
};
|
4396
4524
|
|
@@ -4641,6 +4769,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
|
|
4641
4769
|
}
|
4642
4770
|
}
|
4643
4771
|
handlePointerUp(event) {
|
4772
|
+
if (!this.source) {
|
4773
|
+
return;
|
4774
|
+
}
|
4644
4775
|
event.preventDefault();
|
4645
4776
|
event.stopPropagation();
|
4646
4777
|
const { status } = this.manager.dragOperation;
|
@@ -4741,14 +4872,14 @@ function patchWindow(window2) {
|
|
4741
4872
|
|
4742
4873
|
// components/DragDropContext/index.tsx
|
4743
4874
|
var import_zustand3 = require("zustand");
|
4744
|
-
var
|
4875
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
4745
4876
|
var DEBUG3 = false;
|
4746
|
-
var dragListenerContext = (0,
|
4877
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
4747
4878
|
dragListeners: {}
|
4748
4879
|
});
|
4749
4880
|
function useDragListener(type, fn, deps = []) {
|
4750
|
-
const { setDragListeners } = (0,
|
4751
|
-
(0,
|
4881
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
4882
|
+
(0, import_react31.useEffect)(() => {
|
4752
4883
|
if (setDragListeners) {
|
4753
4884
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4754
4885
|
[type]: [...old[type] || [], fn]
|
@@ -4758,8 +4889,8 @@ function useDragListener(type, fn, deps = []) {
|
|
4758
4889
|
}
|
4759
4890
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4760
4891
|
var useTempDisableFallback = (timeout3) => {
|
4761
|
-
const lastFallbackDisable = (0,
|
4762
|
-
return (0,
|
4892
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
4893
|
+
return (0, import_react31.useCallback)((manager) => {
|
4763
4894
|
collisionStore.setState({ fallbackEnabled: false });
|
4764
4895
|
const fallbackId = generateId();
|
4765
4896
|
lastFallbackDisable.current = fallbackId;
|
@@ -4776,11 +4907,11 @@ var DragDropContextClient = ({
|
|
4776
4907
|
disableAutoScroll
|
4777
4908
|
}) => {
|
4778
4909
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4779
|
-
const id = (0,
|
4910
|
+
const id = (0, import_react31.useId)();
|
4780
4911
|
const { data } = state;
|
4781
|
-
const debouncedParamsRef = (0,
|
4912
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
4782
4913
|
const tempDisableFallback = useTempDisableFallback(100);
|
4783
|
-
const [zoneStore] = (0,
|
4914
|
+
const [zoneStore] = (0, import_react31.useState)(
|
4784
4915
|
() => (0, import_zustand3.createStore)(() => ({
|
4785
4916
|
zoneDepthIndex: {},
|
4786
4917
|
nextZoneDepthIndex: {},
|
@@ -4790,7 +4921,7 @@ var DragDropContextClient = ({
|
|
4790
4921
|
previewIndex: {}
|
4791
4922
|
}))
|
4792
4923
|
);
|
4793
|
-
const getChanged2 = (0,
|
4924
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
4794
4925
|
(params, id2) => {
|
4795
4926
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4796
4927
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -4811,7 +4942,7 @@ var DragDropContextClient = ({
|
|
4811
4942
|
},
|
4812
4943
|
[zoneStore]
|
4813
4944
|
);
|
4814
|
-
const setDeepestAndCollide = (0,
|
4945
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
4815
4946
|
(params, manager) => {
|
4816
4947
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4817
4948
|
if (!zoneChanged && !areaChanged) return;
|
@@ -4835,7 +4966,7 @@ var DragDropContextClient = ({
|
|
4835
4966
|
setDeepestDb.cancel();
|
4836
4967
|
debouncedParamsRef.current = null;
|
4837
4968
|
};
|
4838
|
-
(0,
|
4969
|
+
(0, import_react31.useEffect)(() => {
|
4839
4970
|
if (DEBUG3) {
|
4840
4971
|
zoneStore.subscribe(
|
4841
4972
|
(s) => {
|
@@ -4849,7 +4980,7 @@ var DragDropContextClient = ({
|
|
4849
4980
|
);
|
4850
4981
|
}
|
4851
4982
|
}, []);
|
4852
|
-
const [plugins] = (0,
|
4983
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
4853
4984
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
4854
4985
|
createNestedDroppablePlugin(
|
4855
4986
|
{
|
@@ -4896,7 +5027,7 @@ var DragDropContextClient = ({
|
|
4896
5027
|
id
|
4897
5028
|
)
|
4898
5029
|
]);
|
4899
|
-
const [sensors] = (0,
|
5030
|
+
const [sensors] = (0, import_react31.useState)(() => [
|
4900
5031
|
PointerSensor.configure({
|
4901
5032
|
activationConstraints(event, source) {
|
4902
5033
|
var _a;
|
@@ -4915,41 +5046,47 @@ var DragDropContextClient = ({
|
|
4915
5046
|
}
|
4916
5047
|
})
|
4917
5048
|
]);
|
4918
|
-
const [dragListeners, setDragListeners] = (0,
|
4919
|
-
const [pathData, setPathData] = (0,
|
4920
|
-
const dragMode = (0,
|
4921
|
-
const registerPath = (0,
|
4922
|
-
(selector) => {
|
4923
|
-
const item = getItem(selector, data);
|
4924
|
-
if (!item) {
|
4925
|
-
return;
|
4926
|
-
}
|
5049
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
5050
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
5051
|
+
const dragMode = (0, import_react31.useRef)(null);
|
5052
|
+
const registerPath = (0, import_react31.useCallback)(
|
5053
|
+
(id2, selector, label) => {
|
4927
5054
|
const [area] = getZoneId(selector.zone);
|
4928
5055
|
setPathData((latestPathData = {}) => {
|
4929
5056
|
const parentPathData = latestPathData[area] || { path: [] };
|
4930
5057
|
return __spreadProps(__spreadValues({}, latestPathData), {
|
4931
|
-
[
|
5058
|
+
[id2]: {
|
4932
5059
|
path: [
|
4933
5060
|
...parentPathData.path,
|
4934
5061
|
...selector.zone ? [selector.zone] : []
|
4935
5062
|
],
|
4936
|
-
label
|
5063
|
+
label
|
4937
5064
|
}
|
4938
5065
|
});
|
4939
5066
|
});
|
4940
5067
|
},
|
4941
5068
|
[data, setPathData]
|
4942
5069
|
);
|
4943
|
-
const
|
4944
|
-
|
5070
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5071
|
+
(id2) => {
|
5072
|
+
setPathData((latestPathData = {}) => {
|
5073
|
+
const newPathData = __spreadValues({}, latestPathData);
|
5074
|
+
delete newPathData[id2];
|
5075
|
+
return newPathData;
|
5076
|
+
});
|
5077
|
+
},
|
5078
|
+
[data, setPathData]
|
5079
|
+
);
|
5080
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4945
5082
|
dragListenerContext.Provider,
|
4946
5083
|
{
|
4947
5084
|
value: {
|
4948
5085
|
dragListeners,
|
4949
5086
|
setDragListeners
|
4950
5087
|
},
|
4951
|
-
children: /* @__PURE__ */ (0,
|
4952
|
-
|
5088
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5089
|
+
import_react30.DragDropProvider,
|
4953
5090
|
{
|
4954
5091
|
plugins,
|
4955
5092
|
sensors,
|
@@ -5126,7 +5263,7 @@ var DragDropContextClient = ({
|
|
5126
5263
|
initialSelector.current = void 0;
|
5127
5264
|
zoneStore.setState({ draggedItem: event.operation.source });
|
5128
5265
|
},
|
5129
|
-
children: /* @__PURE__ */ (0,
|
5266
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5130
5267
|
DropZoneProvider,
|
5131
5268
|
{
|
5132
5269
|
value: {
|
@@ -5136,6 +5273,7 @@ var DragDropContextClient = ({
|
|
5136
5273
|
areaId: "root",
|
5137
5274
|
depth: 0,
|
5138
5275
|
registerPath,
|
5276
|
+
unregisterPath,
|
5139
5277
|
pathData,
|
5140
5278
|
path: []
|
5141
5279
|
},
|
@@ -5155,11 +5293,11 @@ var DragDropContext = ({
|
|
5155
5293
|
if (status === "LOADING") {
|
5156
5294
|
return children;
|
5157
5295
|
}
|
5158
|
-
return /* @__PURE__ */ (0,
|
5296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
5159
5297
|
};
|
5160
5298
|
|
5161
5299
|
// components/Drawer/index.tsx
|
5162
|
-
var
|
5300
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
5163
5301
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
5164
5302
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
5165
5303
|
var DrawerItemInner = ({
|
@@ -5169,11 +5307,11 @@ var DrawerItemInner = ({
|
|
5169
5307
|
dragRef,
|
5170
5308
|
isDragDisabled
|
5171
5309
|
}) => {
|
5172
|
-
const CustomInner = (0,
|
5173
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
5310
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5311
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5174
5312
|
[children]
|
5175
5313
|
);
|
5176
|
-
return /* @__PURE__ */ (0,
|
5314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5177
5315
|
"div",
|
5178
5316
|
{
|
5179
5317
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -5181,9 +5319,9 @@ var DrawerItemInner = ({
|
|
5181
5319
|
onMouseDown: (e) => e.preventDefault(),
|
5182
5320
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
5183
5321
|
"data-puck-drawer-item": true,
|
5184
|
-
children: /* @__PURE__ */ (0,
|
5185
|
-
/* @__PURE__ */ (0,
|
5186
|
-
/* @__PURE__ */ (0,
|
5322
|
+
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: [
|
5323
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
5324
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragIcon, {}) })
|
5187
5325
|
] }) }) })
|
5188
5326
|
}
|
5189
5327
|
);
|
@@ -5200,9 +5338,9 @@ var DrawerItemDraggable = ({
|
|
5200
5338
|
data: { type: "drawer", componentType: name },
|
5201
5339
|
disabled: isDragDisabled
|
5202
5340
|
});
|
5203
|
-
return /* @__PURE__ */ (0,
|
5204
|
-
/* @__PURE__ */ (0,
|
5205
|
-
/* @__PURE__ */ (0,
|
5341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName18("draggable"), children: [
|
5342
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DrawerItemInner, { name, label, children }) }),
|
5343
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5206
5344
|
DrawerItemInner,
|
5207
5345
|
{
|
5208
5346
|
name,
|
@@ -5223,7 +5361,7 @@ var DrawerItem = ({
|
|
5223
5361
|
isDragDisabled
|
5224
5362
|
}) => {
|
5225
5363
|
const resolvedId = id || name;
|
5226
|
-
const [dynamicId, setDynamicId] = (0,
|
5364
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5227
5365
|
if (typeof index !== "undefined") {
|
5228
5366
|
console.error(
|
5229
5367
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5236,7 +5374,7 @@ var DrawerItem = ({
|
|
5236
5374
|
},
|
5237
5375
|
[resolvedId]
|
5238
5376
|
);
|
5239
|
-
return /* @__PURE__ */ (0,
|
5377
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5240
5378
|
DrawerItemDraggable,
|
5241
5379
|
{
|
5242
5380
|
name,
|
@@ -5262,14 +5400,14 @@ var Drawer = ({
|
|
5262
5400
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5263
5401
|
);
|
5264
5402
|
}
|
5265
|
-
const
|
5403
|
+
const id = (0, import_react32.useId)();
|
5266
5404
|
const { ref } = useDroppableSafe({
|
5267
5405
|
id,
|
5268
5406
|
type: "void",
|
5269
5407
|
collisionPriority: 0
|
5270
5408
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
5271
5409
|
});
|
5272
|
-
return /* @__PURE__ */ (0,
|
5410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5273
5411
|
"div",
|
5274
5412
|
{
|
5275
5413
|
className: getClassName18(),
|
@@ -5284,7 +5422,7 @@ Drawer.Item = DrawerItem;
|
|
5284
5422
|
|
5285
5423
|
// components/Puck/index.tsx
|
5286
5424
|
init_react_import();
|
5287
|
-
var
|
5425
|
+
var import_react50 = require("react");
|
5288
5426
|
|
5289
5427
|
// components/SidebarSection/index.tsx
|
5290
5428
|
init_react_import();
|
@@ -5295,7 +5433,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
5295
5433
|
|
5296
5434
|
// lib/use-breadcrumbs.ts
|
5297
5435
|
init_react_import();
|
5298
|
-
var
|
5436
|
+
var import_react33 = require("react");
|
5299
5437
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5300
5438
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5301
5439
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5345,8 +5483,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5345
5483
|
state: { data },
|
5346
5484
|
selectedItem
|
5347
5485
|
} = useAppContext();
|
5348
|
-
const dzContext = (0,
|
5349
|
-
return (0,
|
5486
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5487
|
+
return (0, import_react33.useMemo)(() => {
|
5350
5488
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5351
5489
|
selectedItem,
|
5352
5490
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5360,7 +5498,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
5360
5498
|
};
|
5361
5499
|
|
5362
5500
|
// components/SidebarSection/index.tsx
|
5363
|
-
var
|
5501
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
5364
5502
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5365
5503
|
var SidebarSection = ({
|
5366
5504
|
children,
|
@@ -5373,15 +5511,15 @@ var SidebarSection = ({
|
|
5373
5511
|
}) => {
|
5374
5512
|
const { setUi } = useAppContext();
|
5375
5513
|
const breadcrumbs = useBreadcrumbs(1);
|
5376
|
-
return /* @__PURE__ */ (0,
|
5514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
5377
5515
|
"div",
|
5378
5516
|
{
|
5379
5517
|
className: getClassName19({ noBorderTop, noPadding }),
|
5380
5518
|
style: { background },
|
5381
5519
|
children: [
|
5382
|
-
/* @__PURE__ */ (0,
|
5383
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
5384
|
-
/* @__PURE__ */ (0,
|
5520
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
5521
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
5522
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5385
5523
|
"button",
|
5386
5524
|
{
|
5387
5525
|
type: "button",
|
@@ -5390,12 +5528,12 @@ var SidebarSection = ({
|
|
5390
5528
|
children: breadcrumb.label
|
5391
5529
|
}
|
5392
5530
|
),
|
5393
|
-
/* @__PURE__ */ (0,
|
5531
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
|
5394
5532
|
] }, i)) : null,
|
5395
|
-
/* @__PURE__ */ (0,
|
5533
|
+
/* @__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
5534
|
] }) }),
|
5397
|
-
/* @__PURE__ */ (0,
|
5398
|
-
isLoading && /* @__PURE__ */ (0,
|
5535
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
|
5536
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
|
5399
5537
|
]
|
5400
5538
|
}
|
5401
5539
|
);
|
@@ -5426,7 +5564,7 @@ init_react_import();
|
|
5426
5564
|
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
5565
|
|
5428
5566
|
// components/MenuBar/index.tsx
|
5429
|
-
var
|
5567
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
5430
5568
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5431
5569
|
function MenuBar({
|
5432
5570
|
appState,
|
@@ -5440,7 +5578,7 @@ function MenuBar({
|
|
5440
5578
|
history: { back, forward, historyStore }
|
5441
5579
|
} = useAppContext();
|
5442
5580
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5443
|
-
return /* @__PURE__ */ (0,
|
5581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
5444
5582
|
"div",
|
5445
5583
|
{
|
5446
5584
|
className: getClassName20({ menuOpen }),
|
@@ -5454,12 +5592,12 @@ function MenuBar({
|
|
5454
5592
|
setMenuOpen(false);
|
5455
5593
|
}
|
5456
5594
|
},
|
5457
|
-
children: /* @__PURE__ */ (0,
|
5458
|
-
/* @__PURE__ */ (0,
|
5459
|
-
/* @__PURE__ */ (0,
|
5460
|
-
/* @__PURE__ */ (0,
|
5595
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
|
5596
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
|
5597
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
|
5598
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
|
5461
5599
|
] }),
|
5462
|
-
/* @__PURE__ */ (0,
|
5600
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
5463
5601
|
state: appState,
|
5464
5602
|
dispatch
|
5465
5603
|
}) })
|
@@ -5477,36 +5615,61 @@ init_react_import();
|
|
5477
5615
|
|
5478
5616
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5479
5617
|
init_react_import();
|
5480
|
-
var styles_module_default16 = { "PuckFields": "
|
5618
|
+
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
5481
5619
|
|
5482
5620
|
// components/Puck/components/Fields/index.tsx
|
5483
|
-
var
|
5621
|
+
var import_react37 = require("react");
|
5622
|
+
|
5623
|
+
// lib/use-resolved-fields.ts
|
5624
|
+
init_react_import();
|
5625
|
+
var import_react36 = require("react");
|
5484
5626
|
|
5485
5627
|
// lib/use-parent.ts
|
5486
5628
|
init_react_import();
|
5487
|
-
var
|
5488
|
-
var
|
5629
|
+
var import_react34 = require("react");
|
5630
|
+
var getParent = (itemSelector, pathData, data) => {
|
5489
5631
|
var _a;
|
5490
|
-
|
5491
|
-
const
|
5492
|
-
const
|
5493
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5632
|
+
if (!itemSelector) return null;
|
5633
|
+
const item = getItem(itemSelector, data);
|
5634
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5494
5635
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5495
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5636
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5496
5637
|
return parent || null;
|
5497
5638
|
};
|
5639
|
+
var useGetParent = () => {
|
5640
|
+
const { state } = useAppContext();
|
5641
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5642
|
+
return (0, import_react34.useCallback)(
|
5643
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5644
|
+
[state.ui.itemSelector, pathData, state.data]
|
5645
|
+
);
|
5646
|
+
};
|
5647
|
+
var useParent = () => {
|
5648
|
+
return useGetParent()();
|
5649
|
+
};
|
5498
5650
|
|
5499
|
-
//
|
5500
|
-
|
5501
|
-
var
|
5651
|
+
// lib/use-on-value-change.ts
|
5652
|
+
init_react_import();
|
5653
|
+
var import_react35 = require("react");
|
5654
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5655
|
+
const tracked = (0, import_react35.useRef)(value);
|
5656
|
+
(0, import_react35.useEffect)(() => {
|
5657
|
+
const oldValue = tracked.current;
|
5658
|
+
if (!compare(value, oldValue)) {
|
5659
|
+
tracked.current = value;
|
5660
|
+
onChange(value, oldValue);
|
5661
|
+
}
|
5662
|
+
}, [onChange, compare, value, ...deps]);
|
5663
|
+
}
|
5664
|
+
|
5665
|
+
// lib/selector-is.ts
|
5666
|
+
init_react_import();
|
5667
|
+
var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
|
5668
|
+
|
5669
|
+
// lib/use-resolved-fields.ts
|
5502
5670
|
var defaultPageFields = {
|
5503
5671
|
title: { type: "text" }
|
5504
5672
|
};
|
5505
|
-
var DefaultFields = ({
|
5506
|
-
children
|
5507
|
-
}) => {
|
5508
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
|
5509
|
-
};
|
5510
5673
|
var useResolvedFields = () => {
|
5511
5674
|
var _a, _b;
|
5512
5675
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5514,20 +5677,21 @@ var useResolvedFields = () => {
|
|
5514
5677
|
const { data } = state;
|
5515
5678
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5516
5679
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5517
|
-
const defaultFields = (0,
|
5680
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5518
5681
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5519
5682
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5520
5683
|
);
|
5521
5684
|
const rootProps = data.root.props || data.root;
|
5522
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5523
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5524
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5685
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5686
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
|
5687
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5688
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5525
5689
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5526
5690
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5527
5691
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5528
5692
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5529
5693
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5530
|
-
const resolveFields = (0,
|
5694
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5531
5695
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5532
5696
|
var _a2;
|
5533
5697
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5539,7 +5703,7 @@ var useResolvedFields = () => {
|
|
5539
5703
|
{
|
5540
5704
|
changed,
|
5541
5705
|
fields,
|
5542
|
-
lastFields:
|
5706
|
+
lastFields: lastFields.current,
|
5543
5707
|
lastData,
|
5544
5708
|
appState: state,
|
5545
5709
|
parent
|
@@ -5550,7 +5714,7 @@ var useResolvedFields = () => {
|
|
5550
5714
|
return yield config.root.resolveFields(componentData, {
|
5551
5715
|
changed,
|
5552
5716
|
fields,
|
5553
|
-
lastFields:
|
5717
|
+
lastFields: lastFields.current,
|
5554
5718
|
lastData,
|
5555
5719
|
appState: state,
|
5556
5720
|
parent
|
@@ -5559,26 +5723,56 @@ var useResolvedFields = () => {
|
|
5559
5723
|
return defaultResolveFields(componentData, {
|
5560
5724
|
changed,
|
5561
5725
|
fields,
|
5562
|
-
lastFields:
|
5726
|
+
lastFields: lastFields.current,
|
5563
5727
|
lastData
|
5564
5728
|
});
|
5565
5729
|
}),
|
5566
|
-
[data, config, componentData, selectedItem,
|
5730
|
+
[data, config, componentData, selectedItem, state, parent]
|
5567
5731
|
);
|
5568
|
-
(0,
|
5569
|
-
|
5570
|
-
|
5571
|
-
|
5572
|
-
|
5573
|
-
|
5574
|
-
|
5575
|
-
|
5576
|
-
|
5732
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5733
|
+
var _a2, _b2;
|
5734
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5735
|
+
if (hasResolver) {
|
5736
|
+
setFieldsLoading(true);
|
5737
|
+
resolveFields(defaultFields).then((fields) => {
|
5738
|
+
setResolvedFields(fields || {});
|
5739
|
+
lastFields.current = fields;
|
5740
|
+
setFieldsLoading(false);
|
5741
|
+
});
|
5742
|
+
return;
|
5743
|
+
}
|
5577
5744
|
}
|
5578
|
-
|
5745
|
+
setResolvedFields(defaultFields);
|
5746
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5747
|
+
useOnValueChange(
|
5748
|
+
state.ui.itemSelector,
|
5749
|
+
() => {
|
5750
|
+
lastFields.current = defaultFields;
|
5751
|
+
},
|
5752
|
+
selectorIs
|
5753
|
+
);
|
5754
|
+
useOnValueChange(
|
5755
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5756
|
+
() => {
|
5757
|
+
triggerResolver();
|
5758
|
+
},
|
5759
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5760
|
+
);
|
5761
|
+
(0, import_react36.useEffect)(() => {
|
5762
|
+
triggerResolver();
|
5763
|
+
}, []);
|
5579
5764
|
return [resolvedFields, fieldsLoading];
|
5580
5765
|
};
|
5581
|
-
|
5766
|
+
|
5767
|
+
// components/Puck/components/Fields/index.tsx
|
5768
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
5769
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5770
|
+
var DefaultFields = ({
|
5771
|
+
children
|
5772
|
+
}) => {
|
5773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5774
|
+
};
|
5775
|
+
var Fields = ({ wrapFields = true }) => {
|
5582
5776
|
var _a, _b;
|
5583
5777
|
const {
|
5584
5778
|
selectedItem,
|
@@ -5596,16 +5790,16 @@ var Fields = () => {
|
|
5596
5790
|
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
5791
|
const isLoading = fieldsResolving || componentResolving;
|
5598
5792
|
const rootProps = data.root.props || data.root;
|
5599
|
-
const Wrapper = (0,
|
5600
|
-
return /* @__PURE__ */ (0,
|
5793
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5601
5795
|
"form",
|
5602
5796
|
{
|
5603
|
-
className: getClassName21(),
|
5797
|
+
className: getClassName21({ wrapFields }),
|
5604
5798
|
onSubmit: (e) => {
|
5605
5799
|
e.preventDefault();
|
5606
5800
|
},
|
5607
5801
|
children: [
|
5608
|
-
/* @__PURE__ */ (0,
|
5802
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5609
5803
|
const field = fields[fieldName];
|
5610
5804
|
if (!(field == null ? void 0 : field.type)) return null;
|
5611
5805
|
const onChange = (value, updatedUi) => {
|
@@ -5676,7 +5870,7 @@ var Fields = () => {
|
|
5676
5870
|
item: selectedItem
|
5677
5871
|
});
|
5678
5872
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5679
|
-
return /* @__PURE__ */ (0,
|
5873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5680
5874
|
AutoFieldPrivate,
|
5681
5875
|
{
|
5682
5876
|
field,
|
@@ -5685,16 +5879,15 @@ var Fields = () => {
|
|
5685
5879
|
readOnly: !edit || readOnly[fieldName],
|
5686
5880
|
value: selectedItem.props[fieldName],
|
5687
5881
|
onChange
|
5688
|
-
}
|
5689
|
-
|
5690
|
-
);
|
5882
|
+
}
|
5883
|
+
) }, id);
|
5691
5884
|
} else {
|
5692
5885
|
const readOnly = data.root.readOnly || {};
|
5693
5886
|
const { edit } = getPermissions({
|
5694
5887
|
root: true
|
5695
5888
|
});
|
5696
5889
|
const id = `root_${field.type}_${fieldName}`;
|
5697
|
-
return /* @__PURE__ */ (0,
|
5890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5698
5891
|
AutoFieldPrivate,
|
5699
5892
|
{
|
5700
5893
|
field,
|
@@ -5703,12 +5896,11 @@ var Fields = () => {
|
|
5703
5896
|
readOnly: !edit || readOnly[fieldName],
|
5704
5897
|
value: rootProps[fieldName],
|
5705
5898
|
onChange
|
5706
|
-
}
|
5707
|
-
|
5708
|
-
);
|
5899
|
+
}
|
5900
|
+
) }, id);
|
5709
5901
|
}
|
5710
5902
|
}) }),
|
5711
|
-
isLoading && /* @__PURE__ */ (0,
|
5903
|
+
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
5904
|
]
|
5713
5905
|
}
|
5714
5906
|
);
|
@@ -5719,7 +5911,7 @@ init_react_import();
|
|
5719
5911
|
|
5720
5912
|
// lib/use-component-list.tsx
|
5721
5913
|
init_react_import();
|
5722
|
-
var
|
5914
|
+
var import_react38 = require("react");
|
5723
5915
|
|
5724
5916
|
// components/ComponentList/index.tsx
|
5725
5917
|
init_react_import();
|
@@ -5729,7 +5921,7 @@ init_react_import();
|
|
5729
5921
|
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
5922
|
|
5731
5923
|
// components/ComponentList/index.tsx
|
5732
|
-
var
|
5924
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
5733
5925
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5734
5926
|
var ComponentListItem = ({
|
5735
5927
|
name,
|
@@ -5739,7 +5931,7 @@ var ComponentListItem = ({
|
|
5739
5931
|
const canInsert = getPermissions({
|
5740
5932
|
type: name
|
5741
5933
|
}).insert;
|
5742
|
-
return /* @__PURE__ */ (0,
|
5934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5743
5935
|
};
|
5744
5936
|
var ComponentList = ({
|
5745
5937
|
children,
|
@@ -5748,8 +5940,8 @@ var ComponentList = ({
|
|
5748
5940
|
}) => {
|
5749
5941
|
const { config, state, setUi } = useAppContext();
|
5750
5942
|
const { expanded = true } = state.ui.componentList[id] || {};
|
5751
|
-
return /* @__PURE__ */ (0,
|
5752
|
-
title && /* @__PURE__ */ (0,
|
5943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
5944
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
5753
5945
|
"button",
|
5754
5946
|
{
|
5755
5947
|
type: "button",
|
@@ -5763,14 +5955,14 @@ var ComponentList = ({
|
|
5763
5955
|
}),
|
5764
5956
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5765
5957
|
children: [
|
5766
|
-
/* @__PURE__ */ (0,
|
5767
|
-
/* @__PURE__ */ (0,
|
5958
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
|
5959
|
+
/* @__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
5960
|
]
|
5769
5961
|
}
|
5770
5962
|
),
|
5771
|
-
/* @__PURE__ */ (0,
|
5963
|
+
/* @__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
5964
|
var _a;
|
5773
|
-
return /* @__PURE__ */ (0,
|
5965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
5774
5966
|
ComponentListItem,
|
5775
5967
|
{
|
5776
5968
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5784,10 +5976,10 @@ var ComponentList = ({
|
|
5784
5976
|
ComponentList.Item = ComponentListItem;
|
5785
5977
|
|
5786
5978
|
// lib/use-component-list.tsx
|
5787
|
-
var
|
5979
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5788
5980
|
var useComponentList = (config, ui) => {
|
5789
|
-
const [componentList, setComponentList] = (0,
|
5790
|
-
(0,
|
5981
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
5982
|
+
(0, import_react38.useEffect)(() => {
|
5791
5983
|
var _a, _b, _c;
|
5792
5984
|
if (Object.keys(ui.componentList).length > 0) {
|
5793
5985
|
const matchedComponents = [];
|
@@ -5797,7 +5989,7 @@ var useComponentList = (config, ui) => {
|
|
5797
5989
|
if (category.visible === false || !category.components) {
|
5798
5990
|
return null;
|
5799
5991
|
}
|
5800
|
-
return /* @__PURE__ */ (0,
|
5992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5801
5993
|
ComponentList,
|
5802
5994
|
{
|
5803
5995
|
id: categoryKey,
|
@@ -5806,7 +5998,7 @@ var useComponentList = (config, ui) => {
|
|
5806
5998
|
var _a2;
|
5807
5999
|
matchedComponents.push(componentName);
|
5808
6000
|
const componentConf = config.components[componentName] || {};
|
5809
|
-
return /* @__PURE__ */ (0,
|
6001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5810
6002
|
ComponentList.Item,
|
5811
6003
|
{
|
5812
6004
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5826,7 +6018,7 @@ var useComponentList = (config, ui) => {
|
|
5826
6018
|
);
|
5827
6019
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5828
6020
|
_componentList.push(
|
5829
|
-
/* @__PURE__ */ (0,
|
6021
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5830
6022
|
ComponentList,
|
5831
6023
|
{
|
5832
6024
|
id: "other",
|
@@ -5834,7 +6026,7 @@ var useComponentList = (config, ui) => {
|
|
5834
6026
|
children: remainingComponents.map((componentName, i) => {
|
5835
6027
|
var _a2;
|
5836
6028
|
const componentConf = config.components[componentName] || {};
|
5837
|
-
return /* @__PURE__ */ (0,
|
6029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5838
6030
|
ComponentList.Item,
|
5839
6031
|
{
|
5840
6032
|
name: componentName,
|
@@ -5856,25 +6048,25 @@ var useComponentList = (config, ui) => {
|
|
5856
6048
|
};
|
5857
6049
|
|
5858
6050
|
// components/Puck/components/Components/index.tsx
|
5859
|
-
var
|
5860
|
-
var
|
6051
|
+
var import_react39 = require("react");
|
6052
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5861
6053
|
var Components = () => {
|
5862
6054
|
const { config, state, overrides } = useAppContext();
|
5863
6055
|
const componentList = useComponentList(config, state.ui);
|
5864
|
-
const Wrapper = (0,
|
5865
|
-
return /* @__PURE__ */ (0,
|
6056
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6057
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
5866
6058
|
};
|
5867
6059
|
|
5868
6060
|
// components/Puck/components/Preview/index.tsx
|
5869
6061
|
init_react_import();
|
5870
|
-
var
|
6062
|
+
var import_react41 = require("react");
|
5871
6063
|
|
5872
6064
|
// components/AutoFrame/index.tsx
|
5873
6065
|
init_react_import();
|
5874
|
-
var
|
6066
|
+
var import_react40 = require("react");
|
5875
6067
|
var import_object_hash = __toESM(require("object-hash"));
|
5876
6068
|
var import_react_dom3 = require("react-dom");
|
5877
|
-
var
|
6069
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
5878
6070
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5879
6071
|
var collectStyles = (doc) => {
|
5880
6072
|
const collected = [];
|
@@ -5917,7 +6109,7 @@ var CopyHostStyles = ({
|
|
5917
6109
|
onStylesLoaded = () => null
|
5918
6110
|
}) => {
|
5919
6111
|
const { document: doc, window: win } = useFrame();
|
5920
|
-
(0,
|
6112
|
+
(0, import_react40.useEffect)(() => {
|
5921
6113
|
if (!win || !doc) {
|
5922
6114
|
return () => {
|
5923
6115
|
};
|
@@ -6074,10 +6266,10 @@ var CopyHostStyles = ({
|
|
6074
6266
|
observer.disconnect();
|
6075
6267
|
};
|
6076
6268
|
}, []);
|
6077
|
-
return /* @__PURE__ */ (0,
|
6269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6078
6270
|
};
|
6079
|
-
var autoFrameContext = (0,
|
6080
|
-
var useFrame = () => (0,
|
6271
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6272
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6081
6273
|
function AutoFrame(_a) {
|
6082
6274
|
var _b = _a, {
|
6083
6275
|
children,
|
@@ -6094,10 +6286,10 @@ function AutoFrame(_a) {
|
|
6094
6286
|
"onStylesLoaded",
|
6095
6287
|
"frameRef"
|
6096
6288
|
]);
|
6097
|
-
const [loaded, setLoaded] = (0,
|
6098
|
-
const [ctx, setCtx] = (0,
|
6099
|
-
const [mountTarget, setMountTarget] = (0,
|
6100
|
-
(0,
|
6289
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6290
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6291
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6292
|
+
(0, import_react40.useEffect)(() => {
|
6101
6293
|
var _a2;
|
6102
6294
|
if (frameRef.current) {
|
6103
6295
|
setCtx({
|
@@ -6109,7 +6301,7 @@ function AutoFrame(_a) {
|
|
6109
6301
|
);
|
6110
6302
|
}
|
6111
6303
|
}, [frameRef, loaded]);
|
6112
|
-
return /* @__PURE__ */ (0,
|
6304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
6113
6305
|
"iframe",
|
6114
6306
|
__spreadProps(__spreadValues({}, props), {
|
6115
6307
|
className,
|
@@ -6119,7 +6311,7 @@ function AutoFrame(_a) {
|
|
6119
6311
|
onLoad: () => {
|
6120
6312
|
setLoaded(true);
|
6121
6313
|
},
|
6122
|
-
children: /* @__PURE__ */ (0,
|
6314
|
+
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
6315
|
})
|
6124
6316
|
);
|
6125
6317
|
}
|
@@ -6132,7 +6324,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
|
|
6132
6324
|
|
6133
6325
|
// components/Render/index.tsx
|
6134
6326
|
init_react_import();
|
6135
|
-
var
|
6327
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
6136
6328
|
function Render({
|
6137
6329
|
config,
|
6138
6330
|
data
|
@@ -6145,7 +6337,7 @@ function Render({
|
|
6145
6337
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
6146
6338
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
6147
6339
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
6148
|
-
return /* @__PURE__ */ (0,
|
6340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6149
6341
|
DropZoneProvider,
|
6150
6342
|
{
|
6151
6343
|
value: {
|
@@ -6155,7 +6347,7 @@ function Render({
|
|
6155
6347
|
depth: 0,
|
6156
6348
|
path: []
|
6157
6349
|
},
|
6158
|
-
children: /* @__PURE__ */ (0,
|
6350
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6159
6351
|
config.root.render,
|
6160
6352
|
__spreadProps(__spreadValues({}, rootProps), {
|
6161
6353
|
puck: {
|
@@ -6165,13 +6357,13 @@ function Render({
|
|
6165
6357
|
title,
|
6166
6358
|
editMode: false,
|
6167
6359
|
id: "puck-root",
|
6168
|
-
children: /* @__PURE__ */ (0,
|
6360
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6169
6361
|
})
|
6170
6362
|
)
|
6171
6363
|
}
|
6172
6364
|
);
|
6173
6365
|
}
|
6174
|
-
return /* @__PURE__ */ (0,
|
6366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6175
6367
|
DropZoneProvider,
|
6176
6368
|
{
|
6177
6369
|
value: {
|
@@ -6181,17 +6373,17 @@ function Render({
|
|
6181
6373
|
depth: 0,
|
6182
6374
|
path: []
|
6183
6375
|
},
|
6184
|
-
children: /* @__PURE__ */ (0,
|
6376
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6185
6377
|
}
|
6186
6378
|
);
|
6187
6379
|
}
|
6188
6380
|
|
6189
6381
|
// components/Puck/components/Preview/index.tsx
|
6190
|
-
var
|
6382
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
6191
6383
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6192
6384
|
var useBubbleIframeEvents = (ref) => {
|
6193
6385
|
const { status } = useAppContext();
|
6194
|
-
(0,
|
6386
|
+
(0, import_react41.useEffect)(() => {
|
6195
6387
|
var _a;
|
6196
6388
|
if (ref.current && status === "READY") {
|
6197
6389
|
const iframe = ref.current;
|
@@ -6230,20 +6422,20 @@ var useBubbleIframeEvents = (ref) => {
|
|
6230
6422
|
};
|
6231
6423
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6232
6424
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6233
|
-
const Page = (0,
|
6425
|
+
const Page = (0, import_react41.useCallback)(
|
6234
6426
|
(pageProps) => {
|
6235
6427
|
var _a, _b;
|
6236
6428
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
6237
6429
|
id: "puck-root"
|
6238
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
6430
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
6239
6431
|
},
|
6240
6432
|
[config.root]
|
6241
6433
|
);
|
6242
|
-
const Frame = (0,
|
6434
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6243
6435
|
const rootProps = state.data.root.props || state.data.root;
|
6244
|
-
const ref = (0,
|
6436
|
+
const ref = (0, import_react41.useRef)(null);
|
6245
6437
|
useBubbleIframeEvents(ref);
|
6246
|
-
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0,
|
6438
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6247
6439
|
Page,
|
6248
6440
|
__spreadProps(__spreadValues({}, rootProps), {
|
6249
6441
|
puck: {
|
@@ -6252,10 +6444,10 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6252
6444
|
dragRef: null
|
6253
6445
|
},
|
6254
6446
|
editMode: true,
|
6255
|
-
children: /* @__PURE__ */ (0,
|
6447
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
6256
6448
|
})
|
6257
|
-
) : /* @__PURE__ */ (0,
|
6258
|
-
return /* @__PURE__ */ (0,
|
6449
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
|
6450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6259
6451
|
"div",
|
6260
6452
|
{
|
6261
6453
|
className: getClassName23(),
|
@@ -6264,7 +6456,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6264
6456
|
onClick: () => {
|
6265
6457
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
6266
6458
|
},
|
6267
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
6459
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6268
6460
|
AutoFrame_default,
|
6269
6461
|
{
|
6270
6462
|
id: "preview-frame",
|
@@ -6274,14 +6466,14 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6274
6466
|
setStatus("READY");
|
6275
6467
|
},
|
6276
6468
|
frameRef: ref,
|
6277
|
-
children: /* @__PURE__ */ (0,
|
6469
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
6278
6470
|
if (Frame) {
|
6279
|
-
return /* @__PURE__ */ (0,
|
6471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
6280
6472
|
}
|
6281
6473
|
return inner;
|
6282
6474
|
} })
|
6283
6475
|
}
|
6284
|
-
) : /* @__PURE__ */ (0,
|
6476
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6285
6477
|
"div",
|
6286
6478
|
{
|
6287
6479
|
id: "preview-frame",
|
@@ -6338,7 +6530,7 @@ var scrollIntoView = (el) => {
|
|
6338
6530
|
};
|
6339
6531
|
|
6340
6532
|
// components/LayerTree/index.tsx
|
6341
|
-
var
|
6533
|
+
var import_react42 = require("react");
|
6342
6534
|
|
6343
6535
|
// lib/is-child-of-zone.ts
|
6344
6536
|
init_react_import();
|
@@ -6371,7 +6563,7 @@ var onScrollEnd = (frame, cb) => {
|
|
6371
6563
|
};
|
6372
6564
|
|
6373
6565
|
// components/LayerTree/index.tsx
|
6374
|
-
var
|
6566
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6375
6567
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6376
6568
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6377
6569
|
var LayerTree = ({
|
@@ -6384,15 +6576,15 @@ var LayerTree = ({
|
|
6384
6576
|
label
|
6385
6577
|
}) => {
|
6386
6578
|
const zones = data.zones || {};
|
6387
|
-
const ctx = (0,
|
6388
|
-
return /* @__PURE__ */ (0,
|
6389
|
-
label && /* @__PURE__ */ (0,
|
6390
|
-
/* @__PURE__ */ (0,
|
6579
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6580
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6581
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6582
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
6391
6583
|
" ",
|
6392
6584
|
label
|
6393
6585
|
] }),
|
6394
|
-
/* @__PURE__ */ (0,
|
6395
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
6586
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
|
6587
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
6396
6588
|
zoneContent.map((item, i) => {
|
6397
6589
|
var _a;
|
6398
6590
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6405,7 +6597,7 @@ var LayerTree = ({
|
|
6405
6597
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
6406
6598
|
const componentConfig = config.components[item.type];
|
6407
6599
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
6408
|
-
return /* @__PURE__ */ (0,
|
6600
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6409
6601
|
"li",
|
6410
6602
|
{
|
6411
6603
|
className: getClassNameLayer({
|
@@ -6415,7 +6607,7 @@ var LayerTree = ({
|
|
6415
6607
|
childIsSelected
|
6416
6608
|
}),
|
6417
6609
|
children: [
|
6418
|
-
/* @__PURE__ */ (0,
|
6610
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6419
6611
|
"button",
|
6420
6612
|
{
|
6421
6613
|
type: "button",
|
@@ -6454,22 +6646,22 @@ var LayerTree = ({
|
|
6454
6646
|
setHoveringComponent(null);
|
6455
6647
|
},
|
6456
6648
|
children: [
|
6457
|
-
containsZone && /* @__PURE__ */ (0,
|
6649
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6458
6650
|
"div",
|
6459
6651
|
{
|
6460
6652
|
className: getClassNameLayer("chevron"),
|
6461
6653
|
title: isSelected ? "Collapse" : "Expand",
|
6462
|
-
children: /* @__PURE__ */ (0,
|
6654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
6463
6655
|
}
|
6464
6656
|
),
|
6465
|
-
/* @__PURE__ */ (0,
|
6466
|
-
/* @__PURE__ */ (0,
|
6467
|
-
/* @__PURE__ */ (0,
|
6657
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
6658
|
+
/* @__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" }) }),
|
6659
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
6468
6660
|
] })
|
6469
6661
|
]
|
6470
6662
|
}
|
6471
6663
|
) }),
|
6472
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
6664
|
+
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
6665
|
LayerTree,
|
6474
6666
|
{
|
6475
6667
|
config,
|
@@ -6491,13 +6683,13 @@ var LayerTree = ({
|
|
6491
6683
|
};
|
6492
6684
|
|
6493
6685
|
// components/Puck/components/Outline/index.tsx
|
6494
|
-
var
|
6495
|
-
var
|
6686
|
+
var import_react43 = require("react");
|
6687
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6496
6688
|
var Outline = () => {
|
6497
6689
|
const { dispatch, state, overrides, config } = useAppContext();
|
6498
6690
|
const { data, ui } = state;
|
6499
6691
|
const { itemSelector } = ui;
|
6500
|
-
const setItemSelector = (0,
|
6692
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6501
6693
|
(newItemSelector) => {
|
6502
6694
|
dispatch({
|
6503
6695
|
type: "setUi",
|
@@ -6506,9 +6698,9 @@ var Outline = () => {
|
|
6506
6698
|
},
|
6507
6699
|
[]
|
6508
6700
|
);
|
6509
|
-
const Wrapper = (0,
|
6510
|
-
return /* @__PURE__ */ (0,
|
6511
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
6701
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6702
|
+
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: [
|
6703
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6512
6704
|
LayerTree,
|
6513
6705
|
{
|
6514
6706
|
config,
|
@@ -6521,7 +6713,7 @@ var Outline = () => {
|
|
6521
6713
|
),
|
6522
6714
|
Object.entries(findZonesForArea(data, "root")).map(
|
6523
6715
|
([zoneKey, zone]) => {
|
6524
|
-
return /* @__PURE__ */ (0,
|
6716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6525
6717
|
LayerTree,
|
6526
6718
|
{
|
6527
6719
|
config,
|
@@ -6620,19 +6812,19 @@ function usePuckHistory({
|
|
6620
6812
|
|
6621
6813
|
// lib/use-history-store.ts
|
6622
6814
|
init_react_import();
|
6623
|
-
var
|
6815
|
+
var import_react44 = require("react");
|
6624
6816
|
var import_use_debounce3 = require("use-debounce");
|
6625
6817
|
var EMPTY_HISTORY_INDEX = 0;
|
6626
6818
|
function useHistoryStore(initialHistory) {
|
6627
6819
|
var _a, _b;
|
6628
|
-
const [histories, setHistories] = (0,
|
6820
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6629
6821
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6630
6822
|
);
|
6631
6823
|
const updateHistories = (histories2) => {
|
6632
6824
|
setHistories(histories2);
|
6633
6825
|
setIndex(histories2.length - 1);
|
6634
6826
|
};
|
6635
|
-
const [index, setIndex] = (0,
|
6827
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6636
6828
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6637
6829
|
);
|
6638
6830
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6792,22 +6984,22 @@ var getBox = function getBox2(el) {
|
|
6792
6984
|
};
|
6793
6985
|
|
6794
6986
|
// components/Puck/components/Canvas/index.tsx
|
6795
|
-
var
|
6987
|
+
var import_react46 = require("react");
|
6796
6988
|
|
6797
6989
|
// components/ViewportControls/index.tsx
|
6798
6990
|
init_react_import();
|
6799
|
-
var
|
6991
|
+
var import_react45 = require("react");
|
6800
6992
|
|
6801
6993
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6802
6994
|
init_react_import();
|
6803
6995
|
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
6996
|
|
6805
6997
|
// components/ViewportControls/index.tsx
|
6806
|
-
var
|
6998
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
6807
6999
|
var icons = {
|
6808
|
-
Smartphone: /* @__PURE__ */ (0,
|
6809
|
-
Tablet: /* @__PURE__ */ (0,
|
6810
|
-
Monitor: /* @__PURE__ */ (0,
|
7000
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
|
7001
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
|
7002
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
|
6811
7003
|
};
|
6812
7004
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6813
7005
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6819,11 +7011,11 @@ var ViewportButton = ({
|
|
6819
7011
|
onClick
|
6820
7012
|
}) => {
|
6821
7013
|
const { state } = useAppContext();
|
6822
|
-
const [isActive, setIsActive] = (0,
|
6823
|
-
(0,
|
7014
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7015
|
+
(0, import_react45.useEffect)(() => {
|
6824
7016
|
setIsActive(width === state.ui.viewports.current.width);
|
6825
7017
|
}, [width, state.ui.viewports.current.width]);
|
6826
|
-
return /* @__PURE__ */ (0,
|
7018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6827
7019
|
IconButton,
|
6828
7020
|
{
|
6829
7021
|
title,
|
@@ -6832,7 +7024,7 @@ var ViewportButton = ({
|
|
6832
7024
|
e.stopPropagation();
|
6833
7025
|
onClick({ width, height });
|
6834
7026
|
},
|
6835
|
-
children: /* @__PURE__ */ (0,
|
7027
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
|
6836
7028
|
}
|
6837
7029
|
) });
|
6838
7030
|
};
|
@@ -6856,7 +7048,7 @@ var ViewportControls = ({
|
|
6856
7048
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6857
7049
|
(option) => option.value === autoZoom
|
6858
7050
|
);
|
6859
|
-
const zoomOptions = (0,
|
7051
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
6860
7052
|
() => [
|
6861
7053
|
...defaultZoomOptions,
|
6862
7054
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6868,8 +7060,8 @@ var ViewportControls = ({
|
|
6868
7060
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
6869
7061
|
[autoZoom]
|
6870
7062
|
);
|
6871
|
-
return /* @__PURE__ */ (0,
|
6872
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
7063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
|
7064
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6873
7065
|
ViewportButton,
|
6874
7066
|
{
|
6875
7067
|
height: viewport.height,
|
@@ -6880,8 +7072,8 @@ var ViewportControls = ({
|
|
6880
7072
|
},
|
6881
7073
|
i
|
6882
7074
|
)),
|
6883
|
-
/* @__PURE__ */ (0,
|
6884
|
-
/* @__PURE__ */ (0,
|
7075
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7076
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6885
7077
|
IconButton,
|
6886
7078
|
{
|
6887
7079
|
title: "Zoom viewport out",
|
@@ -6895,10 +7087,10 @@ var ViewportControls = ({
|
|
6895
7087
|
)].value
|
6896
7088
|
);
|
6897
7089
|
},
|
6898
|
-
children: /* @__PURE__ */ (0,
|
7090
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
|
6899
7091
|
}
|
6900
7092
|
),
|
6901
|
-
/* @__PURE__ */ (0,
|
7093
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6902
7094
|
IconButton,
|
6903
7095
|
{
|
6904
7096
|
title: "Zoom viewport in",
|
@@ -6912,11 +7104,11 @@ var ViewportControls = ({
|
|
6912
7104
|
)].value
|
6913
7105
|
);
|
6914
7106
|
},
|
6915
|
-
children: /* @__PURE__ */ (0,
|
7107
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
|
6916
7108
|
}
|
6917
7109
|
),
|
6918
|
-
/* @__PURE__ */ (0,
|
6919
|
-
/* @__PURE__ */ (0,
|
7110
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7111
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6920
7112
|
"select",
|
6921
7113
|
{
|
6922
7114
|
className: getClassName25("zoomSelect"),
|
@@ -6924,7 +7116,7 @@ var ViewportControls = ({
|
|
6924
7116
|
onChange: (e) => {
|
6925
7117
|
onZoom(parseFloat(e.currentTarget.value));
|
6926
7118
|
},
|
6927
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
7119
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6928
7120
|
"option",
|
6929
7121
|
{
|
6930
7122
|
value: option.value,
|
@@ -6972,24 +7164,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6972
7164
|
};
|
6973
7165
|
|
6974
7166
|
// components/Puck/components/Canvas/index.tsx
|
6975
|
-
var
|
7167
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
6976
7168
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6977
7169
|
var ZOOM_ON_CHANGE = true;
|
6978
7170
|
var Canvas = () => {
|
6979
7171
|
const { status, iframe } = useAppContext();
|
6980
7172
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6981
7173
|
const { ui } = state;
|
6982
|
-
const frameRef = (0,
|
6983
|
-
const [showTransition, setShowTransition] = (0,
|
6984
|
-
const defaultRender = (0,
|
6985
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
7174
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7175
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7176
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7177
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
6986
7178
|
return PuckDefault;
|
6987
7179
|
}, []);
|
6988
|
-
const CustomPreview = (0,
|
7180
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
6989
7181
|
() => overrides.preview || defaultRender,
|
6990
7182
|
[overrides]
|
6991
7183
|
);
|
6992
|
-
const getFrameDimensions = (0,
|
7184
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
6993
7185
|
if (frameRef.current) {
|
6994
7186
|
const frame = frameRef.current;
|
6995
7187
|
const box = getBox(frame);
|
@@ -6997,7 +7189,7 @@ var Canvas = () => {
|
|
6997
7189
|
}
|
6998
7190
|
return { width: 0, height: 0 };
|
6999
7191
|
}, [frameRef]);
|
7000
|
-
const resetAutoZoom = (0,
|
7192
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7001
7193
|
(ui2 = state.ui) => {
|
7002
7194
|
if (frameRef.current) {
|
7003
7195
|
setZoomConfig(
|
@@ -7007,11 +7199,11 @@ var Canvas = () => {
|
|
7007
7199
|
},
|
7008
7200
|
[frameRef, zoomConfig, state.ui]
|
7009
7201
|
);
|
7010
|
-
(0,
|
7202
|
+
(0, import_react46.useEffect)(() => {
|
7011
7203
|
setShowTransition(false);
|
7012
7204
|
resetAutoZoom();
|
7013
7205
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7014
|
-
(0,
|
7206
|
+
(0, import_react46.useEffect)(() => {
|
7015
7207
|
const { height: frameHeight } = getFrameDimensions();
|
7016
7208
|
if (ui.viewports.current.height === "auto") {
|
7017
7209
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7019,13 +7211,13 @@ var Canvas = () => {
|
|
7019
7211
|
}));
|
7020
7212
|
}
|
7021
7213
|
}, [zoomConfig.zoom]);
|
7022
|
-
(0,
|
7214
|
+
(0, import_react46.useEffect)(() => {
|
7023
7215
|
if (ZOOM_ON_CHANGE) {
|
7024
7216
|
setShowTransition(true);
|
7025
7217
|
resetAutoZoom(ui);
|
7026
7218
|
}
|
7027
7219
|
}, [ui.viewports.current.width]);
|
7028
|
-
(0,
|
7220
|
+
(0, import_react46.useEffect)(() => {
|
7029
7221
|
const cb = () => {
|
7030
7222
|
setShowTransition(false);
|
7031
7223
|
resetAutoZoom();
|
@@ -7035,13 +7227,13 @@ var Canvas = () => {
|
|
7035
7227
|
window.removeEventListener("resize", cb);
|
7036
7228
|
};
|
7037
7229
|
}, []);
|
7038
|
-
const [showLoader, setShowLoader] = (0,
|
7039
|
-
(0,
|
7230
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7231
|
+
(0, import_react46.useEffect)(() => {
|
7040
7232
|
setTimeout(() => {
|
7041
7233
|
setShowLoader(true);
|
7042
7234
|
}, 500);
|
7043
7235
|
}, []);
|
7044
|
-
return /* @__PURE__ */ (0,
|
7236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
7045
7237
|
"div",
|
7046
7238
|
{
|
7047
7239
|
className: getClassName26({
|
@@ -7054,7 +7246,7 @@ var Canvas = () => {
|
|
7054
7246
|
recordHistory: true
|
7055
7247
|
}),
|
7056
7248
|
children: [
|
7057
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
7249
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7058
7250
|
ViewportControls,
|
7059
7251
|
{
|
7060
7252
|
autoZoom: zoomConfig.autoZoom,
|
@@ -7080,8 +7272,8 @@ var Canvas = () => {
|
|
7080
7272
|
}
|
7081
7273
|
}
|
7082
7274
|
) }),
|
7083
|
-
/* @__PURE__ */ (0,
|
7084
|
-
/* @__PURE__ */ (0,
|
7275
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7276
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7085
7277
|
"div",
|
7086
7278
|
{
|
7087
7279
|
className: getClassName26("root"),
|
@@ -7102,10 +7294,10 @@ var Canvas = () => {
|
|
7102
7294
|
})
|
7103
7295
|
);
|
7104
7296
|
},
|
7105
|
-
children: /* @__PURE__ */ (0,
|
7297
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview2, {}) })
|
7106
7298
|
}
|
7107
7299
|
),
|
7108
|
-
/* @__PURE__ */ (0,
|
7300
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
7109
7301
|
] })
|
7110
7302
|
]
|
7111
7303
|
}
|
@@ -7114,7 +7306,7 @@ var Canvas = () => {
|
|
7114
7306
|
|
7115
7307
|
// lib/use-loaded-overrides.ts
|
7116
7308
|
init_react_import();
|
7117
|
-
var
|
7309
|
+
var import_react47 = require("react");
|
7118
7310
|
|
7119
7311
|
// lib/load-overrides.ts
|
7120
7312
|
init_react_import();
|
@@ -7153,26 +7345,26 @@ var useLoadedOverrides = ({
|
|
7153
7345
|
overrides,
|
7154
7346
|
plugins
|
7155
7347
|
}) => {
|
7156
|
-
return (0,
|
7348
|
+
return (0, import_react47.useMemo)(() => {
|
7157
7349
|
return loadOverrides({ overrides, plugins });
|
7158
7350
|
}, [plugins, overrides]);
|
7159
7351
|
};
|
7160
7352
|
|
7161
7353
|
// components/DefaultOverride/index.tsx
|
7162
7354
|
init_react_import();
|
7163
|
-
var
|
7164
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
7355
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7356
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
7165
7357
|
|
7166
7358
|
// lib/use-inject-css.ts
|
7167
7359
|
init_react_import();
|
7168
|
-
var
|
7360
|
+
var import_react48 = require("react");
|
7169
7361
|
var styles = ``;
|
7170
7362
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7171
|
-
const [el, setEl] = (0,
|
7172
|
-
(0,
|
7363
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7364
|
+
(0, import_react48.useEffect)(() => {
|
7173
7365
|
setEl(document.createElement("style"));
|
7174
7366
|
}, []);
|
7175
|
-
(0,
|
7367
|
+
(0, import_react48.useEffect)(() => {
|
7176
7368
|
var _a;
|
7177
7369
|
if (!el || typeof window === "undefined") {
|
7178
7370
|
return;
|
@@ -7192,10 +7384,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7192
7384
|
|
7193
7385
|
// lib/use-preview-mode-hotkeys.ts
|
7194
7386
|
init_react_import();
|
7195
|
-
var
|
7387
|
+
var import_react49 = require("react");
|
7196
7388
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7197
7389
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7198
|
-
const toggleInteractive = (0,
|
7390
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7199
7391
|
dispatch({
|
7200
7392
|
type: "setUi",
|
7201
7393
|
ui: (ui) => ({
|
@@ -7218,7 +7410,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
|
7218
7410
|
};
|
7219
7411
|
|
7220
7412
|
// components/Puck/index.tsx
|
7221
|
-
var
|
7413
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
7222
7414
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
7223
7415
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
7224
7416
|
function Puck({
|
@@ -7247,7 +7439,7 @@ function Puck({
|
|
7247
7439
|
waitForStyles: true
|
7248
7440
|
}, _iframe);
|
7249
7441
|
useInjectGlobalCss(iframe.enabled);
|
7250
|
-
const [generatedAppState] = (0,
|
7442
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7251
7443
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7252
7444
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7253
7445
|
let clientUiState = {};
|
@@ -7319,14 +7511,14 @@ function Puck({
|
|
7319
7511
|
histories,
|
7320
7512
|
index: initialHistoryIndex
|
7321
7513
|
});
|
7322
|
-
const [reducer] = (0,
|
7514
|
+
const [reducer] = (0, import_react50.useState)(
|
7323
7515
|
() => createReducer({
|
7324
7516
|
config,
|
7325
7517
|
record: historyStore.record,
|
7326
7518
|
onAction
|
7327
7519
|
})
|
7328
7520
|
);
|
7329
|
-
const [appState, dispatch] = (0,
|
7521
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7330
7522
|
reducer,
|
7331
7523
|
flushZones(initialAppState)
|
7332
7524
|
);
|
@@ -7337,14 +7529,14 @@ function Puck({
|
|
7337
7529
|
historyStore,
|
7338
7530
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7339
7531
|
});
|
7340
|
-
const [menuOpen, setMenuOpen] = (0,
|
7532
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7341
7533
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7342
7534
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7343
|
-
(0,
|
7535
|
+
(0, import_react50.useEffect)(() => {
|
7344
7536
|
if (onChange) onChange(data);
|
7345
7537
|
}, [data]);
|
7346
7538
|
const rootProps = data.root.props || data.root;
|
7347
|
-
const toggleSidebars = (0,
|
7539
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7348
7540
|
(sidebar) => {
|
7349
7541
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7350
7542
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7358,7 +7550,7 @@ function Puck({
|
|
7358
7550
|
},
|
7359
7551
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7360
7552
|
);
|
7361
|
-
(0,
|
7553
|
+
(0, import_react50.useEffect)(() => {
|
7362
7554
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7363
7555
|
dispatch({
|
7364
7556
|
type: "setUi",
|
@@ -7381,7 +7573,7 @@ function Puck({
|
|
7381
7573
|
window.removeEventListener("resize", handleResize);
|
7382
7574
|
};
|
7383
7575
|
}, []);
|
7384
|
-
const defaultHeaderRender = (0,
|
7576
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7385
7577
|
if (renderHeader) {
|
7386
7578
|
console.warn(
|
7387
7579
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7389,20 +7581,20 @@ function Puck({
|
|
7389
7581
|
const RenderHeader = (_a2) => {
|
7390
7582
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
7391
7583
|
const Comp = renderHeader;
|
7392
|
-
return /* @__PURE__ */ (0,
|
7584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7393
7585
|
};
|
7394
7586
|
return RenderHeader;
|
7395
7587
|
}
|
7396
7588
|
return DefaultOverride;
|
7397
7589
|
}, [renderHeader]);
|
7398
|
-
const defaultHeaderActionsRender = (0,
|
7590
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7399
7591
|
if (renderHeaderActions) {
|
7400
7592
|
console.warn(
|
7401
7593
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7402
7594
|
);
|
7403
7595
|
const RenderHeader = (props) => {
|
7404
7596
|
const Comp = renderHeaderActions;
|
7405
|
-
return /* @__PURE__ */ (0,
|
7597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7406
7598
|
};
|
7407
7599
|
return RenderHeader;
|
7408
7600
|
}
|
@@ -7412,27 +7604,27 @@ function Puck({
|
|
7412
7604
|
overrides,
|
7413
7605
|
plugins
|
7414
7606
|
});
|
7415
|
-
const CustomPuck = (0,
|
7607
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7416
7608
|
() => loadedOverrides.puck || DefaultOverride,
|
7417
7609
|
[loadedOverrides]
|
7418
7610
|
);
|
7419
|
-
const CustomHeader = (0,
|
7611
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7420
7612
|
() => loadedOverrides.header || defaultHeaderRender,
|
7421
7613
|
[loadedOverrides]
|
7422
7614
|
);
|
7423
|
-
const CustomHeaderActions = (0,
|
7615
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7424
7616
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7425
7617
|
[loadedOverrides]
|
7426
7618
|
);
|
7427
|
-
const [mounted, setMounted] = (0,
|
7428
|
-
(0,
|
7619
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7620
|
+
(0, import_react50.useEffect)(() => {
|
7429
7621
|
setMounted(true);
|
7430
7622
|
}, []);
|
7431
7623
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7432
7624
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7433
7625
|
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7434
|
-
return /* @__PURE__ */ (0,
|
7435
|
-
/* @__PURE__ */ (0,
|
7626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
7627
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7436
7628
|
AppProvider,
|
7437
7629
|
{
|
7438
7630
|
value: {
|
@@ -7454,7 +7646,7 @@ function Puck({
|
|
7454
7646
|
getPermissions: () => ({}),
|
7455
7647
|
refreshPermissions: () => null
|
7456
7648
|
},
|
7457
|
-
children: /* @__PURE__ */ (0,
|
7649
|
+
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
7650
|
"div",
|
7459
7651
|
{
|
7460
7652
|
className: getLayoutClassName({
|
@@ -7463,60 +7655,60 @@ function Puck({
|
|
7463
7655
|
mounted,
|
7464
7656
|
rightSideBarVisible
|
7465
7657
|
}),
|
7466
|
-
children: /* @__PURE__ */ (0,
|
7467
|
-
/* @__PURE__ */ (0,
|
7658
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
7659
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7468
7660
|
CustomHeader,
|
7469
7661
|
{
|
7470
|
-
actions: /* @__PURE__ */ (0,
|
7662
|
+
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
7663
|
Button,
|
7472
7664
|
{
|
7473
7665
|
onClick: () => {
|
7474
7666
|
onPublish && onPublish(data);
|
7475
7667
|
},
|
7476
|
-
icon: /* @__PURE__ */ (0,
|
7668
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7477
7669
|
children: "Publish"
|
7478
7670
|
}
|
7479
7671
|
) }) }),
|
7480
|
-
children: /* @__PURE__ */ (0,
|
7481
|
-
/* @__PURE__ */ (0,
|
7482
|
-
/* @__PURE__ */ (0,
|
7672
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
7673
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
|
7674
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7483
7675
|
"div",
|
7484
7676
|
{
|
7485
7677
|
className: getLayoutClassName("leftSideBarToggle"),
|
7486
|
-
children: /* @__PURE__ */ (0,
|
7678
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7487
7679
|
IconButton,
|
7488
7680
|
{
|
7489
7681
|
onClick: () => {
|
7490
7682
|
toggleSidebars("left");
|
7491
7683
|
},
|
7492
7684
|
title: "Toggle left sidebar",
|
7493
|
-
children: /* @__PURE__ */ (0,
|
7685
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
7494
7686
|
}
|
7495
7687
|
)
|
7496
7688
|
}
|
7497
7689
|
),
|
7498
|
-
/* @__PURE__ */ (0,
|
7690
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7499
7691
|
"div",
|
7500
7692
|
{
|
7501
7693
|
className: getLayoutClassName("rightSideBarToggle"),
|
7502
|
-
children: /* @__PURE__ */ (0,
|
7694
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7503
7695
|
IconButton,
|
7504
7696
|
{
|
7505
7697
|
onClick: () => {
|
7506
7698
|
toggleSidebars("right");
|
7507
7699
|
},
|
7508
7700
|
title: "Toggle right sidebar",
|
7509
|
-
children: /* @__PURE__ */ (0,
|
7701
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
7510
7702
|
}
|
7511
7703
|
)
|
7512
7704
|
}
|
7513
7705
|
)
|
7514
7706
|
] }),
|
7515
|
-
/* @__PURE__ */ (0,
|
7707
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
7516
7708
|
headerTitle || rootProps.title || "Page",
|
7517
|
-
headerPath && /* @__PURE__ */ (0,
|
7709
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
7518
7710
|
" ",
|
7519
|
-
/* @__PURE__ */ (0,
|
7711
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7520
7712
|
"code",
|
7521
7713
|
{
|
7522
7714
|
className: getLayoutClassName("headerPath"),
|
@@ -7525,31 +7717,31 @@ function Puck({
|
|
7525
7717
|
)
|
7526
7718
|
] })
|
7527
7719
|
] }) }),
|
7528
|
-
/* @__PURE__ */ (0,
|
7529
|
-
/* @__PURE__ */ (0,
|
7720
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
|
7721
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7530
7722
|
IconButton,
|
7531
7723
|
{
|
7532
7724
|
onClick: () => {
|
7533
7725
|
return setMenuOpen(!menuOpen);
|
7534
7726
|
},
|
7535
7727
|
title: "Toggle menu bar",
|
7536
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
7728
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
7537
7729
|
}
|
7538
7730
|
) }),
|
7539
|
-
/* @__PURE__ */ (0,
|
7731
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7540
7732
|
MenuBar,
|
7541
7733
|
{
|
7542
7734
|
appState,
|
7543
7735
|
dispatch,
|
7544
7736
|
onPublish,
|
7545
7737
|
menuOpen,
|
7546
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
7738
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7547
7739
|
Button,
|
7548
7740
|
{
|
7549
7741
|
onClick: () => {
|
7550
7742
|
onPublish && onPublish(data);
|
7551
7743
|
},
|
7552
|
-
icon: /* @__PURE__ */ (0,
|
7744
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7553
7745
|
children: "Publish"
|
7554
7746
|
}
|
7555
7747
|
) }),
|
@@ -7560,19 +7752,19 @@ function Puck({
|
|
7560
7752
|
] }) })
|
7561
7753
|
}
|
7562
7754
|
),
|
7563
|
-
/* @__PURE__ */ (0,
|
7564
|
-
/* @__PURE__ */ (0,
|
7565
|
-
/* @__PURE__ */ (0,
|
7755
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7756
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
|
7757
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
|
7566
7758
|
] }),
|
7567
|
-
/* @__PURE__ */ (0,
|
7568
|
-
/* @__PURE__ */ (0,
|
7759
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
|
7760
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7569
7761
|
SidebarSection,
|
7570
7762
|
{
|
7571
7763
|
noPadding: true,
|
7572
7764
|
noBorderTop: true,
|
7573
7765
|
showBreadcrumbs: true,
|
7574
7766
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7575
|
-
children: /* @__PURE__ */ (0,
|
7767
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
|
7576
7768
|
}
|
7577
7769
|
) })
|
7578
7770
|
] })
|
@@ -7580,7 +7772,7 @@ function Puck({
|
|
7580
7772
|
) }) })
|
7581
7773
|
}
|
7582
7774
|
),
|
7583
|
-
/* @__PURE__ */ (0,
|
7775
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7584
7776
|
] });
|
7585
7777
|
}
|
7586
7778
|
Puck.Components = Components;
|