@measured/puck 0.17.1 → 0.17.2-canary.6a8578f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-7IH6SUIT.mjs → chunk-LNGCTWA7.mjs} +2 -4
- package/dist/index.css +12 -14
- package/dist/index.js +624 -503
- package/dist/index.mjs +488 -364
- package/dist/rsc.js +2 -4
- package/dist/rsc.mjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -289,7 +289,7 @@ init_react_import();
|
|
289
289
|
var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
|
290
290
|
|
291
291
|
// components/AutoField/index.tsx
|
292
|
-
var
|
292
|
+
var import_react17 = require("react");
|
293
293
|
|
294
294
|
// components/AutoField/fields/index.tsx
|
295
295
|
init_react_import();
|
@@ -951,13 +951,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
951
951
|
onResolveStart(item);
|
952
952
|
}
|
953
953
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
954
|
-
const { readOnly: existingReadOnly = {} } = item || {};
|
955
|
-
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
956
954
|
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
957
955
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
958
956
|
});
|
959
|
-
if (Object.keys(
|
960
|
-
resolvedItem.readOnly =
|
957
|
+
if (Object.keys(readOnly).length) {
|
958
|
+
resolvedItem.readOnly = readOnly;
|
961
959
|
}
|
962
960
|
cache.lastChange[item.props.id] = {
|
963
961
|
item,
|
@@ -1352,7 +1350,7 @@ var Draggable = ({
|
|
1352
1350
|
};
|
1353
1351
|
|
1354
1352
|
// components/AutoField/fields/ArrayField/index.tsx
|
1355
|
-
var
|
1353
|
+
var import_react9 = require("react");
|
1356
1354
|
|
1357
1355
|
// components/DragIcon/index.tsx
|
1358
1356
|
init_react_import();
|
@@ -1366,19 +1364,64 @@ var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1366
1364
|
var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default5);
|
1367
1365
|
var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
|
1368
1366
|
|
1367
|
+
// components/AutoField/context.tsx
|
1368
|
+
init_react_import();
|
1369
|
+
var import_react8 = require("react");
|
1370
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
1371
|
+
var NestedFieldContext = (0, import_react8.createContext)({});
|
1372
|
+
var useNestedFieldContext = () => {
|
1373
|
+
const context = (0, import_react8.useContext)(NestedFieldContext);
|
1374
|
+
return __spreadProps(__spreadValues({}, context), {
|
1375
|
+
readOnlyFields: context.readOnlyFields || {}
|
1376
|
+
});
|
1377
|
+
};
|
1378
|
+
var NestedFieldProvider = ({
|
1379
|
+
children,
|
1380
|
+
name,
|
1381
|
+
subName,
|
1382
|
+
wildcardName = name,
|
1383
|
+
readOnlyFields
|
1384
|
+
}) => {
|
1385
|
+
const subPath = `${name}.${subName}`;
|
1386
|
+
const wildcardSubPath = `${wildcardName}.${subName}`;
|
1387
|
+
const subReadOnlyFields = (0, import_react8.useMemo)(
|
1388
|
+
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
1389
|
+
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
1390
|
+
if (isLocal) {
|
1391
|
+
const subPathPattern = new RegExp(
|
1392
|
+
`^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
|
1393
|
+
);
|
1394
|
+
const localName = readOnlyKey.replace(subPathPattern, "");
|
1395
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1396
|
+
[localName]: readOnlyFields[readOnlyKey]
|
1397
|
+
});
|
1398
|
+
}
|
1399
|
+
return acc;
|
1400
|
+
}, {}),
|
1401
|
+
[name, subName, wildcardName, readOnlyFields]
|
1402
|
+
);
|
1403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1404
|
+
NestedFieldContext.Provider,
|
1405
|
+
{
|
1406
|
+
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
1407
|
+
children
|
1408
|
+
}
|
1409
|
+
);
|
1410
|
+
};
|
1411
|
+
|
1369
1412
|
// components/DragDropContext/index.tsx
|
1370
1413
|
init_react_import();
|
1371
1414
|
var import_dnd3 = require("@measured/dnd");
|
1372
|
-
var
|
1373
|
-
var DefaultDragDropContext = ({ children }) => /* @__PURE__ */ (0,
|
1415
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
1416
|
+
var DefaultDragDropContext = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children });
|
1374
1417
|
var DragDropContext = (props) => {
|
1375
1418
|
const { status } = useAppContext();
|
1376
1419
|
const El = status !== "LOADING" ? import_dnd3.DragDropContext : DefaultDragDropContext;
|
1377
|
-
return /* @__PURE__ */ (0,
|
1420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(El, __spreadValues({}, props));
|
1378
1421
|
};
|
1379
1422
|
|
1380
1423
|
// components/AutoField/fields/ArrayField/index.tsx
|
1381
|
-
var
|
1424
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
1382
1425
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
1383
1426
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
1384
1427
|
var ArrayField = ({
|
@@ -1389,10 +1432,10 @@ var ArrayField = ({
|
|
1389
1432
|
label,
|
1390
1433
|
readOnly,
|
1391
1434
|
id,
|
1392
|
-
Label = (props) => /* @__PURE__ */ (0,
|
1435
|
+
Label = (props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", __spreadValues({}, props))
|
1393
1436
|
}) => {
|
1394
1437
|
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
1395
|
-
const readOnlyFields =
|
1438
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
1396
1439
|
const value = _value;
|
1397
1440
|
const arrayState = state.ui.arrayState[id] || {
|
1398
1441
|
items: Array.from(value || []).map((item, idx) => {
|
@@ -1403,11 +1446,11 @@ var ArrayField = ({
|
|
1403
1446
|
}),
|
1404
1447
|
openId: ""
|
1405
1448
|
};
|
1406
|
-
const [localState, setLocalState] = (0,
|
1407
|
-
(0,
|
1449
|
+
const [localState, setLocalState] = (0, import_react9.useState)({ arrayState, value });
|
1450
|
+
(0, import_react9.useEffect)(() => {
|
1408
1451
|
setLocalState({ arrayState, value });
|
1409
1452
|
}, [value, state.ui.arrayState[id]]);
|
1410
|
-
const mapArrayStateToUi = (0,
|
1453
|
+
const mapArrayStateToUi = (0, import_react9.useCallback)(
|
1411
1454
|
(partialArrayState) => {
|
1412
1455
|
return {
|
1413
1456
|
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
@@ -1417,13 +1460,13 @@ var ArrayField = ({
|
|
1417
1460
|
},
|
1418
1461
|
[arrayState]
|
1419
1462
|
);
|
1420
|
-
const getHighestIndex = (0,
|
1463
|
+
const getHighestIndex = (0, import_react9.useCallback)(() => {
|
1421
1464
|
return arrayState.items.reduce(
|
1422
1465
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
1423
1466
|
-1
|
1424
1467
|
);
|
1425
1468
|
}, [arrayState]);
|
1426
|
-
const regenerateArrayState = (0,
|
1469
|
+
const regenerateArrayState = (0, import_react9.useCallback)(
|
1427
1470
|
(value2) => {
|
1428
1471
|
let highestIndex = getHighestIndex();
|
1429
1472
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -1442,25 +1485,25 @@ var ArrayField = ({
|
|
1442
1485
|
},
|
1443
1486
|
[arrayState]
|
1444
1487
|
);
|
1445
|
-
(0,
|
1488
|
+
(0, import_react9.useEffect)(() => {
|
1446
1489
|
if (arrayState.items.length > 0) {
|
1447
1490
|
setUi(mapArrayStateToUi(arrayState));
|
1448
1491
|
}
|
1449
1492
|
}, []);
|
1450
|
-
const [hovering, setHovering] = (0,
|
1493
|
+
const [hovering, setHovering] = (0, import_react9.useState)(false);
|
1451
1494
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
1452
1495
|
if (field.type !== "array" || !field.arrayFields) {
|
1453
1496
|
return null;
|
1454
1497
|
}
|
1455
1498
|
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
1456
|
-
return /* @__PURE__ */ (0,
|
1499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1457
1500
|
Label,
|
1458
1501
|
{
|
1459
1502
|
label: label || name,
|
1460
|
-
icon: /* @__PURE__ */ (0,
|
1503
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(List, { size: 16 }),
|
1461
1504
|
el: "div",
|
1462
1505
|
readOnly,
|
1463
|
-
children: /* @__PURE__ */ (0,
|
1506
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1464
1507
|
DragDropContext,
|
1465
1508
|
{
|
1466
1509
|
onDragEnd: (event) => {
|
@@ -1489,8 +1532,8 @@ var ArrayField = ({
|
|
1489
1532
|
});
|
1490
1533
|
}
|
1491
1534
|
},
|
1492
|
-
children: /* @__PURE__ */ (0,
|
1493
|
-
return /* @__PURE__ */ (0,
|
1535
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Droppable, { droppableId: "array", isDropDisabled: readOnly, children: (provided, snapshot) => {
|
1536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
1494
1537
|
"div",
|
1495
1538
|
__spreadProps(__spreadValues({}, provided.droppableProps), {
|
1496
1539
|
ref: provided.innerRef,
|
@@ -1514,7 +1557,7 @@ var ArrayField = ({
|
|
1514
1557
|
localState.arrayState.items.map((item, i) => {
|
1515
1558
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
1516
1559
|
const data = Array.from(localState.value || [])[i] || {};
|
1517
|
-
return /* @__PURE__ */ (0,
|
1560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1518
1561
|
Draggable,
|
1519
1562
|
{
|
1520
1563
|
id: _arrayId,
|
@@ -1525,8 +1568,8 @@ var ArrayField = ({
|
|
1525
1568
|
readOnly
|
1526
1569
|
}),
|
1527
1570
|
isDragDisabled: readOnly || !hovering,
|
1528
|
-
children: () => /* @__PURE__ */ (0,
|
1529
|
-
/* @__PURE__ */ (0,
|
1571
|
+
children: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
1572
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
1530
1573
|
"div",
|
1531
1574
|
{
|
1532
1575
|
onClick: () => {
|
@@ -1547,9 +1590,9 @@ var ArrayField = ({
|
|
1547
1590
|
className: getClassNameItem("summary"),
|
1548
1591
|
children: [
|
1549
1592
|
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
1550
|
-
/* @__PURE__ */ (0,
|
1551
|
-
!readOnly && /* @__PURE__ */ (0,
|
1552
|
-
/* @__PURE__ */ (0,
|
1593
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
1594
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
1595
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1553
1596
|
IconButton,
|
1554
1597
|
{
|
1555
1598
|
type: "button",
|
@@ -1572,10 +1615,10 @@ var ArrayField = ({
|
|
1572
1615
|
);
|
1573
1616
|
},
|
1574
1617
|
title: "Duplicate",
|
1575
|
-
children: /* @__PURE__ */ (0,
|
1618
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Copy, { size: 16 })
|
1576
1619
|
}
|
1577
1620
|
) }),
|
1578
|
-
/* @__PURE__ */ (0,
|
1621
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1579
1622
|
IconButton,
|
1580
1623
|
{
|
1581
1624
|
type: "button",
|
@@ -1598,40 +1641,57 @@ var ArrayField = ({
|
|
1598
1641
|
);
|
1599
1642
|
},
|
1600
1643
|
title: "Delete",
|
1601
|
-
children: /* @__PURE__ */ (0,
|
1644
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Trash, { size: 16 })
|
1602
1645
|
}
|
1603
1646
|
) })
|
1604
1647
|
] }),
|
1605
|
-
/* @__PURE__ */ (0,
|
1648
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DragIcon, {}) })
|
1606
1649
|
] })
|
1607
1650
|
]
|
1608
1651
|
}
|
1609
1652
|
),
|
1610
|
-
/* @__PURE__ */ (0,
|
1611
|
-
(
|
1612
|
-
const subField = field.arrayFields[
|
1613
|
-
const
|
1614
|
-
const
|
1615
|
-
const
|
1616
|
-
|
1617
|
-
|
1653
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
|
1654
|
+
(subName) => {
|
1655
|
+
const subField = field.arrayFields[subName];
|
1656
|
+
const indexName = `${name}[${i}]`;
|
1657
|
+
const subPath = `${indexName}.${subName}`;
|
1658
|
+
const localIndexName = `${localName}[${i}]`;
|
1659
|
+
const localWildcardName = `${localName}[*]`;
|
1660
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
1661
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
1662
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
1663
|
+
const label2 = subField.label || subName;
|
1664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1665
|
+
NestedFieldProvider,
|
1618
1666
|
{
|
1619
|
-
name:
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1667
|
+
name: localIndexName,
|
1668
|
+
wildcardName: localWildcardName,
|
1669
|
+
subName,
|
1670
|
+
readOnlyFields,
|
1671
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1672
|
+
AutoFieldPrivate,
|
1673
|
+
{
|
1674
|
+
name: subPath,
|
1675
|
+
label: label2,
|
1676
|
+
id: `${_arrayId}_${subName}`,
|
1677
|
+
readOnly: subReadOnly,
|
1678
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
1679
|
+
label: label2
|
1680
|
+
// May be used by custom fields
|
1681
|
+
}),
|
1682
|
+
value: data[subName],
|
1683
|
+
onChange: (val, ui) => {
|
1684
|
+
onChange(
|
1685
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
1686
|
+
[subName]: val
|
1687
|
+
})),
|
1688
|
+
ui
|
1689
|
+
);
|
1690
|
+
}
|
1691
|
+
}
|
1692
|
+
)
|
1633
1693
|
},
|
1634
|
-
|
1694
|
+
subPath
|
1635
1695
|
);
|
1636
1696
|
}
|
1637
1697
|
) }) })
|
@@ -1641,7 +1701,7 @@ var ArrayField = ({
|
|
1641
1701
|
);
|
1642
1702
|
}),
|
1643
1703
|
provided.placeholder,
|
1644
|
-
!addDisabled && /* @__PURE__ */ (0,
|
1704
|
+
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1645
1705
|
"button",
|
1646
1706
|
{
|
1647
1707
|
type: "button",
|
@@ -1655,7 +1715,7 @@ var ArrayField = ({
|
|
1655
1715
|
const newArrayState = regenerateArrayState(newValue);
|
1656
1716
|
onChange(newValue, mapArrayStateToUi(newArrayState));
|
1657
1717
|
},
|
1658
|
-
children: /* @__PURE__ */ (0,
|
1718
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Plus, { size: 21 })
|
1659
1719
|
}
|
1660
1720
|
)
|
1661
1721
|
]
|
@@ -1670,7 +1730,7 @@ var ArrayField = ({
|
|
1670
1730
|
|
1671
1731
|
// components/AutoField/fields/DefaultField/index.tsx
|
1672
1732
|
init_react_import();
|
1673
|
-
var
|
1733
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
1674
1734
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
1675
1735
|
var DefaultField = ({
|
1676
1736
|
field,
|
@@ -1682,16 +1742,16 @@ var DefaultField = ({
|
|
1682
1742
|
Label,
|
1683
1743
|
id
|
1684
1744
|
}) => {
|
1685
|
-
return /* @__PURE__ */ (0,
|
1745
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
1686
1746
|
Label,
|
1687
1747
|
{
|
1688
1748
|
label: label || name,
|
1689
|
-
icon: /* @__PURE__ */ (0,
|
1690
|
-
field.type === "text" && /* @__PURE__ */ (0,
|
1691
|
-
field.type === "number" && /* @__PURE__ */ (0,
|
1749
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
1750
|
+
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Type, { size: 16 }),
|
1751
|
+
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Hash, { size: 16 })
|
1692
1752
|
] }),
|
1693
1753
|
readOnly,
|
1694
|
-
children: /* @__PURE__ */ (0,
|
1754
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
1695
1755
|
"input",
|
1696
1756
|
{
|
1697
1757
|
className: getClassName6("input"),
|
@@ -1702,7 +1762,14 @@ var DefaultField = ({
|
|
1702
1762
|
value: typeof value === "undefined" ? "" : value.toString(),
|
1703
1763
|
onChange: (e) => {
|
1704
1764
|
if (field.type === "number") {
|
1705
|
-
|
1765
|
+
const numberValue = Number(e.currentTarget.value);
|
1766
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
1767
|
+
return;
|
1768
|
+
}
|
1769
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
1770
|
+
return;
|
1771
|
+
}
|
1772
|
+
onChange(numberValue);
|
1706
1773
|
} else {
|
1707
1774
|
onChange(e.currentTarget.value);
|
1708
1775
|
}
|
@@ -1720,11 +1787,11 @@ var DefaultField = ({
|
|
1720
1787
|
|
1721
1788
|
// components/AutoField/fields/ExternalField/index.tsx
|
1722
1789
|
init_react_import();
|
1723
|
-
var
|
1790
|
+
var import_react13 = require("react");
|
1724
1791
|
|
1725
1792
|
// components/ExternalInput/index.tsx
|
1726
1793
|
init_react_import();
|
1727
|
-
var
|
1794
|
+
var import_react12 = require("react");
|
1728
1795
|
|
1729
1796
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
1730
1797
|
init_react_import();
|
@@ -1732,7 +1799,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
1732
1799
|
|
1733
1800
|
// components/Modal/index.tsx
|
1734
1801
|
init_react_import();
|
1735
|
-
var
|
1802
|
+
var import_react10 = require("react");
|
1736
1803
|
|
1737
1804
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
1738
1805
|
init_react_import();
|
@@ -1740,22 +1807,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1740
1807
|
|
1741
1808
|
// components/Modal/index.tsx
|
1742
1809
|
var import_react_dom = require("react-dom");
|
1743
|
-
var
|
1810
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
1744
1811
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1745
1812
|
var Modal = ({
|
1746
1813
|
children,
|
1747
1814
|
onClose,
|
1748
1815
|
isOpen
|
1749
1816
|
}) => {
|
1750
|
-
const [rootEl, setRootEl] = (0,
|
1751
|
-
(0,
|
1817
|
+
const [rootEl, setRootEl] = (0, import_react10.useState)(null);
|
1818
|
+
(0, import_react10.useEffect)(() => {
|
1752
1819
|
setRootEl(document.getElementById("puck-portal-root"));
|
1753
1820
|
}, []);
|
1754
1821
|
if (!rootEl) {
|
1755
|
-
return /* @__PURE__ */ (0,
|
1822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", {});
|
1756
1823
|
}
|
1757
1824
|
return (0, import_react_dom.createPortal)(
|
1758
|
-
/* @__PURE__ */ (0,
|
1825
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1759
1826
|
"div",
|
1760
1827
|
{
|
1761
1828
|
className: getClassName7("inner"),
|
@@ -1775,11 +1842,11 @@ init_react_import();
|
|
1775
1842
|
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" };
|
1776
1843
|
|
1777
1844
|
// components/Heading/index.tsx
|
1778
|
-
var
|
1845
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
1779
1846
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1780
1847
|
var Heading = ({ children, rank, size = "m" }) => {
|
1781
1848
|
const Tag = rank ? `h${rank}` : "span";
|
1782
|
-
return /* @__PURE__ */ (0,
|
1849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1783
1850
|
Tag,
|
1784
1851
|
{
|
1785
1852
|
className: getClassName8({
|
@@ -1795,14 +1862,14 @@ init_react_import();
|
|
1795
1862
|
|
1796
1863
|
// components/Button/Button.tsx
|
1797
1864
|
init_react_import();
|
1798
|
-
var
|
1865
|
+
var import_react11 = require("react");
|
1799
1866
|
|
1800
1867
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
1801
1868
|
init_react_import();
|
1802
1869
|
var Button_module_default = { "Button": "_Button_1t64k_1", "Button--medium": "_Button--medium_1t64k_29", "Button--large": "_Button--large_1t64k_37", "Button-icon": "_Button-icon_1t64k_44", "Button--primary": "_Button--primary_1t64k_48", "Button--secondary": "_Button--secondary_1t64k_67", "Button--flush": "_Button--flush_1t64k_84", "Button--disabled": "_Button--disabled_1t64k_88", "Button--fullWidth": "_Button--fullWidth_1t64k_95", "Button-spinner": "_Button-spinner_1t64k_100" };
|
1803
1870
|
|
1804
1871
|
// components/Button/Button.tsx
|
1805
|
-
var
|
1872
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
1806
1873
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1807
1874
|
var Button = ({
|
1808
1875
|
children,
|
@@ -1818,10 +1885,10 @@ var Button = ({
|
|
1818
1885
|
size = "medium",
|
1819
1886
|
loading: loadingProp = false
|
1820
1887
|
}) => {
|
1821
|
-
const [loading, setLoading] = (0,
|
1822
|
-
(0,
|
1888
|
+
const [loading, setLoading] = (0, import_react11.useState)(loadingProp);
|
1889
|
+
(0, import_react11.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
1823
1890
|
const ElementType = href ? "a" : type ? "button" : "span";
|
1824
|
-
const el = /* @__PURE__ */ (0,
|
1891
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
1825
1892
|
ElementType,
|
1826
1893
|
{
|
1827
1894
|
className: getClassName9({
|
@@ -1845,9 +1912,9 @@ var Button = ({
|
|
1845
1912
|
rel: newTab ? "noreferrer" : void 0,
|
1846
1913
|
href,
|
1847
1914
|
children: [
|
1848
|
-
icon && /* @__PURE__ */ (0,
|
1915
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
1849
1916
|
children,
|
1850
|
-
loading && /* @__PURE__ */ (0,
|
1917
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader, { size: 14 }) })
|
1851
1918
|
]
|
1852
1919
|
}
|
1853
1920
|
);
|
@@ -1855,7 +1922,7 @@ var Button = ({
|
|
1855
1922
|
};
|
1856
1923
|
|
1857
1924
|
// components/ExternalInput/index.tsx
|
1858
|
-
var
|
1925
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
1859
1926
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1860
1927
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1861
1928
|
var dataCache = {};
|
@@ -1872,28 +1939,28 @@ var ExternalInput = ({
|
|
1872
1939
|
mapRow = (val) => val,
|
1873
1940
|
filterFields
|
1874
1941
|
} = field || {};
|
1875
|
-
const [data, setData] = (0,
|
1876
|
-
const [isOpen, setOpen] = (0,
|
1877
|
-
const [isLoading, setIsLoading] = (0,
|
1942
|
+
const [data, setData] = (0, import_react12.useState)([]);
|
1943
|
+
const [isOpen, setOpen] = (0, import_react12.useState)(false);
|
1944
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(true);
|
1878
1945
|
const hasFilterFields = !!filterFields;
|
1879
|
-
const [filters, setFilters] = (0,
|
1880
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
1881
|
-
const mappedData = (0,
|
1946
|
+
const [filters, setFilters] = (0, import_react12.useState)(field.initialFilters || {});
|
1947
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react12.useState)(hasFilterFields);
|
1948
|
+
const mappedData = (0, import_react12.useMemo)(() => {
|
1882
1949
|
return data.map(mapRow);
|
1883
1950
|
}, [data]);
|
1884
|
-
const keys = (0,
|
1951
|
+
const keys = (0, import_react12.useMemo)(() => {
|
1885
1952
|
const validKeys = /* @__PURE__ */ new Set();
|
1886
1953
|
for (const item of mappedData) {
|
1887
1954
|
for (const key of Object.keys(item)) {
|
1888
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
1955
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react12.isValidElement)(item[key])) {
|
1889
1956
|
validKeys.add(key);
|
1890
1957
|
}
|
1891
1958
|
}
|
1892
1959
|
}
|
1893
1960
|
return Array.from(validKeys);
|
1894
1961
|
}, [mappedData]);
|
1895
|
-
const [searchQuery, setSearchQuery] = (0,
|
1896
|
-
const search = (0,
|
1962
|
+
const [searchQuery, setSearchQuery] = (0, import_react12.useState)(field.initialQuery || "");
|
1963
|
+
const search = (0, import_react12.useCallback)(
|
1897
1964
|
(query, filters2) => __async(void 0, null, function* () {
|
1898
1965
|
setIsLoading(true);
|
1899
1966
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -1906,18 +1973,18 @@ var ExternalInput = ({
|
|
1906
1973
|
}),
|
1907
1974
|
[id, field]
|
1908
1975
|
);
|
1909
|
-
const Footer = (0,
|
1910
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
1976
|
+
const Footer = (0, import_react12.useCallback)(
|
1977
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
1911
1978
|
props.items.length,
|
1912
1979
|
" result",
|
1913
1980
|
props.items.length === 1 ? "" : "s"
|
1914
1981
|
] }),
|
1915
1982
|
[field.renderFooter]
|
1916
1983
|
);
|
1917
|
-
(0,
|
1984
|
+
(0, import_react12.useEffect)(() => {
|
1918
1985
|
search(searchQuery, filters);
|
1919
1986
|
}, []);
|
1920
|
-
return /* @__PURE__ */ (0,
|
1987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
1921
1988
|
"div",
|
1922
1989
|
{
|
1923
1990
|
className: getClassName10({
|
@@ -1927,21 +1994,21 @@ var ExternalInput = ({
|
|
1927
1994
|
}),
|
1928
1995
|
id,
|
1929
1996
|
children: [
|
1930
|
-
/* @__PURE__ */ (0,
|
1931
|
-
/* @__PURE__ */ (0,
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassName10("actions"), children: [
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
1932
1999
|
"button",
|
1933
2000
|
{
|
1934
2001
|
type: "button",
|
1935
2002
|
onClick: () => setOpen(true),
|
1936
2003
|
className: getClassName10("button"),
|
1937
2004
|
disabled: readOnly,
|
1938
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
1939
|
-
/* @__PURE__ */ (0,
|
1940
|
-
/* @__PURE__ */ (0,
|
2005
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
2006
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Link, { size: "16" }),
|
2007
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: field.placeholder })
|
1941
2008
|
] })
|
1942
2009
|
}
|
1943
2010
|
),
|
1944
|
-
value && /* @__PURE__ */ (0,
|
2011
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
1945
2012
|
"button",
|
1946
2013
|
{
|
1947
2014
|
type: "button",
|
@@ -1950,11 +2017,11 @@ var ExternalInput = ({
|
|
1950
2017
|
onChange(null);
|
1951
2018
|
},
|
1952
2019
|
disabled: readOnly,
|
1953
|
-
children: /* @__PURE__ */ (0,
|
2020
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(LockOpen, { size: 16 })
|
1954
2021
|
}
|
1955
2022
|
)
|
1956
2023
|
] }),
|
1957
|
-
/* @__PURE__ */ (0,
|
2024
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
1958
2025
|
"form",
|
1959
2026
|
{
|
1960
2027
|
className: getClassNameModal({
|
@@ -1968,11 +2035,11 @@ var ExternalInput = ({
|
|
1968
2035
|
search(searchQuery, filters);
|
1969
2036
|
},
|
1970
2037
|
children: [
|
1971
|
-
/* @__PURE__ */ (0,
|
1972
|
-
/* @__PURE__ */ (0,
|
1973
|
-
/* @__PURE__ */ (0,
|
1974
|
-
/* @__PURE__ */ (0,
|
1975
|
-
/* @__PURE__ */ (0,
|
2038
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
2039
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: getClassNameModal("search"), children: [
|
2040
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
2041
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Search, { size: "18" }) }),
|
2042
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
1976
2043
|
"input",
|
1977
2044
|
{
|
1978
2045
|
className: getClassNameModal("searchInput"),
|
@@ -1987,9 +2054,9 @@ var ExternalInput = ({
|
|
1987
2054
|
}
|
1988
2055
|
)
|
1989
2056
|
] }),
|
1990
|
-
/* @__PURE__ */ (0,
|
1991
|
-
/* @__PURE__ */ (0,
|
1992
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2057
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
2058
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
2059
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
1993
2060
|
IconButton,
|
1994
2061
|
{
|
1995
2062
|
title: "Toggle filters",
|
@@ -1998,15 +2065,15 @@ var ExternalInput = ({
|
|
1998
2065
|
e.stopPropagation();
|
1999
2066
|
setFiltersToggled(!filtersToggled);
|
2000
2067
|
},
|
2001
|
-
children: /* @__PURE__ */ (0,
|
2068
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SlidersHorizontal, { size: 20 })
|
2002
2069
|
}
|
2003
2070
|
) })
|
2004
2071
|
] })
|
2005
|
-
] }) : /* @__PURE__ */ (0,
|
2006
|
-
/* @__PURE__ */ (0,
|
2007
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2072
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
2073
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
2074
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
2008
2075
|
const filterField = filterFields[fieldName];
|
2009
|
-
return /* @__PURE__ */ (0,
|
2076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2010
2077
|
AutoFieldPrivate,
|
2011
2078
|
{
|
2012
2079
|
field: filterField,
|
@@ -2023,9 +2090,9 @@ var ExternalInput = ({
|
|
2023
2090
|
fieldName
|
2024
2091
|
);
|
2025
2092
|
}) }),
|
2026
|
-
/* @__PURE__ */ (0,
|
2027
|
-
/* @__PURE__ */ (0,
|
2028
|
-
/* @__PURE__ */ (0,
|
2093
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
2094
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("table", { className: getClassNameModal("table"), children: [
|
2095
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2029
2096
|
"th",
|
2030
2097
|
{
|
2031
2098
|
className: getClassNameModal("th"),
|
@@ -2034,8 +2101,8 @@ var ExternalInput = ({
|
|
2034
2101
|
},
|
2035
2102
|
key
|
2036
2103
|
)) }) }),
|
2037
|
-
/* @__PURE__ */ (0,
|
2038
|
-
return /* @__PURE__ */ (0,
|
2104
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
2105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2039
2106
|
"tr",
|
2040
2107
|
{
|
2041
2108
|
style: { whiteSpace: "nowrap" },
|
@@ -2044,16 +2111,16 @@ var ExternalInput = ({
|
|
2044
2111
|
onChange(mapProp(data[i]));
|
2045
2112
|
setOpen(false);
|
2046
2113
|
},
|
2047
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
2114
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
2048
2115
|
},
|
2049
2116
|
i
|
2050
2117
|
);
|
2051
2118
|
}) })
|
2052
2119
|
] }),
|
2053
|
-
/* @__PURE__ */ (0,
|
2120
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { size: 24 }) })
|
2054
2121
|
] })
|
2055
2122
|
] }),
|
2056
|
-
/* @__PURE__ */ (0,
|
2123
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Footer, { items: mappedData }) })
|
2057
2124
|
]
|
2058
2125
|
}
|
2059
2126
|
) })
|
@@ -2063,7 +2130,7 @@ var ExternalInput = ({
|
|
2063
2130
|
};
|
2064
2131
|
|
2065
2132
|
// components/AutoField/fields/ExternalField/index.tsx
|
2066
|
-
var
|
2133
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2067
2134
|
var ExternalField = ({
|
2068
2135
|
field,
|
2069
2136
|
onChange,
|
@@ -2077,7 +2144,7 @@ var ExternalField = ({
|
|
2077
2144
|
var _a, _b, _c;
|
2078
2145
|
const validField = field;
|
2079
2146
|
const deprecatedField = field;
|
2080
|
-
(0,
|
2147
|
+
(0, import_react13.useEffect)(() => {
|
2081
2148
|
if (deprecatedField.adaptor) {
|
2082
2149
|
console.error(
|
2083
2150
|
"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."
|
@@ -2087,7 +2154,7 @@ var ExternalField = ({
|
|
2087
2154
|
if (field.type !== "external") {
|
2088
2155
|
return null;
|
2089
2156
|
}
|
2090
|
-
return /* @__PURE__ */ (0,
|
2157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2091
2158
|
ExternalInput,
|
2092
2159
|
{
|
2093
2160
|
name,
|
@@ -2112,7 +2179,7 @@ var ExternalField = ({
|
|
2112
2179
|
|
2113
2180
|
// components/AutoField/fields/RadioField/index.tsx
|
2114
2181
|
init_react_import();
|
2115
|
-
var
|
2182
|
+
var import_react14 = require("react");
|
2116
2183
|
|
2117
2184
|
// lib/safe-json-parse.ts
|
2118
2185
|
init_react_import();
|
@@ -2126,7 +2193,7 @@ var safeJsonParse = (str) => {
|
|
2126
2193
|
};
|
2127
2194
|
|
2128
2195
|
// components/AutoField/fields/RadioField/index.tsx
|
2129
|
-
var
|
2196
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
2130
2197
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
2131
2198
|
var RadioField = ({
|
2132
2199
|
field,
|
@@ -2138,26 +2205,26 @@ var RadioField = ({
|
|
2138
2205
|
label,
|
2139
2206
|
Label
|
2140
2207
|
}) => {
|
2141
|
-
const flatOptions = (0,
|
2208
|
+
const flatOptions = (0, import_react14.useMemo)(
|
2142
2209
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2143
2210
|
[field]
|
2144
2211
|
);
|
2145
2212
|
if (field.type !== "radio" || !field.options) {
|
2146
2213
|
return null;
|
2147
2214
|
}
|
2148
|
-
return /* @__PURE__ */ (0,
|
2215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
2149
2216
|
Label,
|
2150
2217
|
{
|
2151
|
-
icon: /* @__PURE__ */ (0,
|
2218
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CircleCheckBig, { size: 16 }),
|
2152
2219
|
label: label || name,
|
2153
2220
|
readOnly,
|
2154
2221
|
el: "div",
|
2155
|
-
children: /* @__PURE__ */ (0,
|
2222
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
2156
2223
|
"label",
|
2157
2224
|
{
|
2158
2225
|
className: getClassName11("radio"),
|
2159
2226
|
children: [
|
2160
|
-
/* @__PURE__ */ (0,
|
2227
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
2161
2228
|
"input",
|
2162
2229
|
{
|
2163
2230
|
type: "radio",
|
@@ -2177,7 +2244,7 @@ var RadioField = ({
|
|
2177
2244
|
checked: value === option.value
|
2178
2245
|
}
|
2179
2246
|
),
|
2180
|
-
/* @__PURE__ */ (0,
|
2247
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
2181
2248
|
]
|
2182
2249
|
},
|
2183
2250
|
option.label + option.value
|
@@ -2188,8 +2255,8 @@ var RadioField = ({
|
|
2188
2255
|
|
2189
2256
|
// components/AutoField/fields/SelectField/index.tsx
|
2190
2257
|
init_react_import();
|
2191
|
-
var
|
2192
|
-
var
|
2258
|
+
var import_react15 = require("react");
|
2259
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
2193
2260
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2194
2261
|
var SelectField = ({
|
2195
2262
|
field,
|
@@ -2201,20 +2268,20 @@ var SelectField = ({
|
|
2201
2268
|
readOnly,
|
2202
2269
|
id
|
2203
2270
|
}) => {
|
2204
|
-
const flatOptions = (0,
|
2271
|
+
const flatOptions = (0, import_react15.useMemo)(
|
2205
2272
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2206
2273
|
[field]
|
2207
2274
|
);
|
2208
2275
|
if (field.type !== "select" || !field.options) {
|
2209
2276
|
return null;
|
2210
2277
|
}
|
2211
|
-
return /* @__PURE__ */ (0,
|
2278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2212
2279
|
Label,
|
2213
2280
|
{
|
2214
2281
|
label: label || name,
|
2215
|
-
icon: /* @__PURE__ */ (0,
|
2282
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChevronDown, { size: 16 }),
|
2216
2283
|
readOnly,
|
2217
|
-
children: /* @__PURE__ */ (0,
|
2284
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2218
2285
|
"select",
|
2219
2286
|
{
|
2220
2287
|
id,
|
@@ -2231,7 +2298,7 @@ var SelectField = ({
|
|
2231
2298
|
}
|
2232
2299
|
},
|
2233
2300
|
value,
|
2234
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
2301
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2235
2302
|
"option",
|
2236
2303
|
{
|
2237
2304
|
label: option.label,
|
@@ -2247,7 +2314,7 @@ var SelectField = ({
|
|
2247
2314
|
|
2248
2315
|
// components/AutoField/fields/TextareaField/index.tsx
|
2249
2316
|
init_react_import();
|
2250
|
-
var
|
2317
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
2251
2318
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2252
2319
|
var TextareaField = ({
|
2253
2320
|
onChange,
|
@@ -2258,7 +2325,7 @@ var TextareaField = ({
|
|
2258
2325
|
Label,
|
2259
2326
|
id
|
2260
2327
|
}) => {
|
2261
|
-
return /* @__PURE__ */ (0,
|
2328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Label, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2262
2329
|
"textarea",
|
2263
2330
|
{
|
2264
2331
|
id,
|
@@ -2285,7 +2352,7 @@ init_react_import();
|
|
2285
2352
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2286
2353
|
|
2287
2354
|
// components/AutoField/fields/ObjectField/index.tsx
|
2288
|
-
var
|
2355
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2289
2356
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2290
2357
|
var ObjectField = ({
|
2291
2358
|
field,
|
@@ -2297,43 +2364,54 @@ var ObjectField = ({
|
|
2297
2364
|
readOnly,
|
2298
2365
|
id
|
2299
2366
|
}) => {
|
2300
|
-
const {
|
2367
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2301
2368
|
if (field.type !== "object" || !field.objectFields) {
|
2302
2369
|
return null;
|
2303
2370
|
}
|
2304
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2305
2371
|
const data = value || {};
|
2306
|
-
return /* @__PURE__ */ (0,
|
2372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
2307
2373
|
Label,
|
2308
2374
|
{
|
2309
2375
|
label: label || name,
|
2310
|
-
icon: /* @__PURE__ */ (0,
|
2376
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EllipsisVertical, { size: 16 }),
|
2311
2377
|
el: "div",
|
2312
2378
|
readOnly,
|
2313
|
-
children: /* @__PURE__ */ (0,
|
2314
|
-
const subField = field.objectFields[
|
2315
|
-
const
|
2316
|
-
const
|
2317
|
-
const subReadOnly = readOnly ? readOnly :
|
2318
|
-
|
2319
|
-
|
2379
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
2380
|
+
const subField = field.objectFields[subName];
|
2381
|
+
const subPath = `${name}.${subName}`;
|
2382
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2383
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2384
|
+
const label2 = subField.label || subName;
|
2385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
2386
|
+
NestedFieldProvider,
|
2320
2387
|
{
|
2321
|
-
name:
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2388
|
+
name: localName || id,
|
2389
|
+
subName,
|
2390
|
+
readOnlyFields,
|
2391
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
2392
|
+
AutoFieldPrivate,
|
2393
|
+
{
|
2394
|
+
name: subPath,
|
2395
|
+
label: subPath,
|
2396
|
+
id: `${id}_${subName}`,
|
2397
|
+
readOnly: subReadOnly,
|
2398
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2399
|
+
label: label2
|
2400
|
+
// May be used by custom fields
|
2331
2401
|
}),
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2402
|
+
value: data[subName],
|
2403
|
+
onChange: (val, ui) => {
|
2404
|
+
onChange(
|
2405
|
+
__spreadProps(__spreadValues({}, data), {
|
2406
|
+
[subName]: val
|
2407
|
+
}),
|
2408
|
+
ui
|
2409
|
+
);
|
2410
|
+
}
|
2411
|
+
}
|
2412
|
+
)
|
2335
2413
|
},
|
2336
|
-
|
2414
|
+
subPath
|
2337
2415
|
);
|
2338
2416
|
}) }) })
|
2339
2417
|
}
|
@@ -2342,7 +2420,7 @@ var ObjectField = ({
|
|
2342
2420
|
|
2343
2421
|
// lib/use-safe-id.ts
|
2344
2422
|
init_react_import();
|
2345
|
-
var
|
2423
|
+
var import_react16 = __toESM(require("react"));
|
2346
2424
|
|
2347
2425
|
// lib/generate-id.ts
|
2348
2426
|
init_react_import();
|
@@ -2351,15 +2429,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
2351
2429
|
|
2352
2430
|
// lib/use-safe-id.ts
|
2353
2431
|
var useSafeId = () => {
|
2354
|
-
if (typeof
|
2355
|
-
return
|
2432
|
+
if (typeof import_react16.default.useId !== "undefined") {
|
2433
|
+
return import_react16.default.useId();
|
2356
2434
|
}
|
2357
|
-
const [id] = (0,
|
2435
|
+
const [id] = (0, import_react16.useState)(generateId());
|
2358
2436
|
return id;
|
2359
2437
|
};
|
2360
2438
|
|
2361
2439
|
// components/AutoField/index.tsx
|
2362
|
-
var
|
2440
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
2363
2441
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2364
2442
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2365
2443
|
var FieldLabel = ({
|
@@ -2371,16 +2449,16 @@ var FieldLabel = ({
|
|
2371
2449
|
className
|
2372
2450
|
}) => {
|
2373
2451
|
const El = el;
|
2374
|
-
return /* @__PURE__ */ (0,
|
2375
|
-
/* @__PURE__ */ (0,
|
2376
|
-
icon ? /* @__PURE__ */ (0,
|
2452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(El, { className, children: [
|
2453
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: getClassName15("label"), children: [
|
2454
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, {}),
|
2377
2455
|
label,
|
2378
|
-
readOnly && /* @__PURE__ */ (0,
|
2456
|
+
readOnly && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Lock, { size: "12" }) })
|
2379
2457
|
] }),
|
2380
2458
|
children
|
2381
2459
|
] });
|
2382
2460
|
};
|
2383
|
-
var
|
2461
|
+
var FieldLabelInternal = ({
|
2384
2462
|
children,
|
2385
2463
|
icon,
|
2386
2464
|
label,
|
@@ -2388,14 +2466,14 @@ var FieldLabelInternal2 = ({
|
|
2388
2466
|
readOnly
|
2389
2467
|
}) => {
|
2390
2468
|
const { overrides } = useAppContext();
|
2391
|
-
const Wrapper = (0,
|
2469
|
+
const Wrapper = (0, import_react17.useMemo)(
|
2392
2470
|
() => overrides.fieldLabel || FieldLabel,
|
2393
2471
|
[overrides]
|
2394
2472
|
);
|
2395
2473
|
if (!label) {
|
2396
|
-
return /* @__PURE__ */ (0,
|
2474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
|
2397
2475
|
}
|
2398
|
-
return /* @__PURE__ */ (0,
|
2476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
2399
2477
|
Wrapper,
|
2400
2478
|
{
|
2401
2479
|
label,
|
@@ -2409,8 +2487,9 @@ var FieldLabelInternal2 = ({
|
|
2409
2487
|
};
|
2410
2488
|
function AutoFieldInternal(props) {
|
2411
2489
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2412
|
-
const { dispatch, overrides } = useAppContext();
|
2413
|
-
const
|
2490
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2491
|
+
const nestedFieldContext = (0, import_react17.useContext)(NestedFieldContext);
|
2492
|
+
const { id, Label = FieldLabelInternal } = props;
|
2414
2493
|
const field = props.field;
|
2415
2494
|
const label = field.label;
|
2416
2495
|
const defaultId = useSafeId();
|
@@ -2441,7 +2520,7 @@ function AutoFieldInternal(props) {
|
|
2441
2520
|
Label,
|
2442
2521
|
id: resolvedId
|
2443
2522
|
});
|
2444
|
-
const onFocus = (0,
|
2523
|
+
const onFocus = (0, import_react17.useCallback)(
|
2445
2524
|
(e) => {
|
2446
2525
|
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
2447
2526
|
e.stopPropagation();
|
@@ -2455,7 +2534,7 @@ function AutoFieldInternal(props) {
|
|
2455
2534
|
},
|
2456
2535
|
[mergedProps.name]
|
2457
2536
|
);
|
2458
|
-
const onBlur = (0,
|
2537
|
+
const onBlur = (0, import_react17.useCallback)((e) => {
|
2459
2538
|
if ("name" in e.target) {
|
2460
2539
|
dispatch({
|
2461
2540
|
type: "setUi",
|
@@ -2470,27 +2549,36 @@ function AutoFieldInternal(props) {
|
|
2470
2549
|
return null;
|
2471
2550
|
}
|
2472
2551
|
const CustomField = field.render;
|
2473
|
-
return /* @__PURE__ */ (0,
|
2552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
|
2474
2553
|
}
|
2475
2554
|
const children = defaultFields[field.type](mergedProps);
|
2476
2555
|
const Render2 = render[field.type];
|
2477
|
-
return /* @__PURE__ */ (0,
|
2478
|
-
|
2556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
2557
|
+
NestedFieldContext.Provider,
|
2479
2558
|
{
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
onClick: (e) => {
|
2484
|
-
e.stopPropagation();
|
2559
|
+
value: {
|
2560
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2561
|
+
localName: nestedFieldContext.localName
|
2485
2562
|
},
|
2486
|
-
children: /* @__PURE__ */ (0,
|
2563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
2564
|
+
"div",
|
2565
|
+
{
|
2566
|
+
className: getClassNameWrapper(),
|
2567
|
+
onFocus,
|
2568
|
+
onBlur,
|
2569
|
+
onClick: (e) => {
|
2570
|
+
e.stopPropagation();
|
2571
|
+
},
|
2572
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2573
|
+
}
|
2574
|
+
)
|
2487
2575
|
}
|
2488
2576
|
);
|
2489
2577
|
}
|
2490
2578
|
function AutoFieldPrivate(props) {
|
2491
2579
|
const { state } = useAppContext();
|
2492
2580
|
const { value, onChange } = props;
|
2493
|
-
const [localValue, setLocalValue] = (0,
|
2581
|
+
const [localValue, setLocalValue] = (0, import_react17.useState)(value);
|
2494
2582
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
2495
2583
|
(val, ui) => {
|
2496
2584
|
onChange(val, ui);
|
@@ -2498,11 +2586,11 @@ function AutoFieldPrivate(props) {
|
|
2498
2586
|
50,
|
2499
2587
|
{ leading: true }
|
2500
2588
|
);
|
2501
|
-
const onChangeLocal = (0,
|
2589
|
+
const onChangeLocal = (0, import_react17.useCallback)((val, ui) => {
|
2502
2590
|
setLocalValue(val);
|
2503
2591
|
onChangeDb(val, ui);
|
2504
2592
|
}, []);
|
2505
|
-
(0,
|
2593
|
+
(0, import_react17.useEffect)(() => {
|
2506
2594
|
if (state.ui.field.focus !== props.name) {
|
2507
2595
|
setLocalValue(value);
|
2508
2596
|
}
|
@@ -2511,11 +2599,11 @@ function AutoFieldPrivate(props) {
|
|
2511
2599
|
value: localValue,
|
2512
2600
|
onChange: onChangeLocal
|
2513
2601
|
};
|
2514
|
-
return /* @__PURE__ */ (0,
|
2602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2515
2603
|
}
|
2516
2604
|
function AutoField(props) {
|
2517
|
-
const DefaultLabel = (0,
|
2518
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
2605
|
+
const DefaultLabel = (0, import_react17.useMemo)(() => {
|
2606
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
2519
2607
|
"div",
|
2520
2608
|
__spreadProps(__spreadValues({}, labelProps), {
|
2521
2609
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2523,7 +2611,7 @@ function AutoField(props) {
|
|
2523
2611
|
);
|
2524
2612
|
return DefaultLabel2;
|
2525
2613
|
}, [props.readOnly]);
|
2526
|
-
return /* @__PURE__ */ (0,
|
2614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2527
2615
|
}
|
2528
2616
|
|
2529
2617
|
// components/Drawer/index.tsx
|
@@ -2534,11 +2622,11 @@ init_react_import();
|
|
2534
2622
|
var styles_module_default10 = { "Drawer": "_Drawer_1oa7v_1", "DrawerItem--disabled": "_DrawerItem--disabled_1oa7v_5", "DrawerItem-draggable": "_DrawerItem-draggable_1oa7v_5", "DrawerItem-default": "_DrawerItem-default_1oa7v_11", "DrawerItem-draggableWrapper": "_DrawerItem-draggableWrapper_1oa7v_11", "DrawerItem": "_DrawerItem_1oa7v_5", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_1oa7v_36", "DrawerItem-name": "_DrawerItem-name_1oa7v_54" };
|
2535
2623
|
|
2536
2624
|
// components/Drawer/index.tsx
|
2537
|
-
var
|
2538
|
-
var
|
2625
|
+
var import_react18 = require("react");
|
2626
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
2539
2627
|
var getClassName16 = get_class_name_factory_default("Drawer", styles_module_default10);
|
2540
2628
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
2541
|
-
var drawerContext = (0,
|
2629
|
+
var drawerContext = (0, import_react18.createContext)({
|
2542
2630
|
droppableId: ""
|
2543
2631
|
});
|
2544
2632
|
var DrawerDraggable = ({
|
@@ -2547,7 +2635,7 @@ var DrawerDraggable = ({
|
|
2547
2635
|
index,
|
2548
2636
|
isDragDisabled
|
2549
2637
|
}) => {
|
2550
|
-
return /* @__PURE__ */ (0,
|
2638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
2551
2639
|
Draggable,
|
2552
2640
|
{
|
2553
2641
|
id,
|
@@ -2569,21 +2657,21 @@ var DrawerItem = ({
|
|
2569
2657
|
index,
|
2570
2658
|
isDragDisabled
|
2571
2659
|
}) => {
|
2572
|
-
const ctx = (0,
|
2660
|
+
const ctx = (0, import_react18.useContext)(drawerContext);
|
2573
2661
|
const resolvedId = `${ctx.droppableId}::${id || name}`;
|
2574
|
-
const CustomInner = (0,
|
2575
|
-
() => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ (0,
|
2662
|
+
const CustomInner = (0, import_react18.useMemo)(
|
2663
|
+
() => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
2576
2664
|
[children]
|
2577
2665
|
);
|
2578
|
-
return /* @__PURE__ */ (0,
|
2666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
2579
2667
|
DrawerDraggable,
|
2580
2668
|
{
|
2581
2669
|
id: resolvedId,
|
2582
2670
|
index,
|
2583
2671
|
isDragDisabled,
|
2584
|
-
children: /* @__PURE__ */ (0,
|
2585
|
-
/* @__PURE__ */ (0,
|
2586
|
-
/* @__PURE__ */ (0,
|
2672
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
|
2673
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
2674
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DragIcon, { isDragDisabled }) })
|
2587
2675
|
] }) }) })
|
2588
2676
|
}
|
2589
2677
|
);
|
@@ -2594,7 +2682,7 @@ var Drawer = ({
|
|
2594
2682
|
direction = "vertical"
|
2595
2683
|
}) => {
|
2596
2684
|
const droppableId = `component-list:${_droppableId}`;
|
2597
|
-
return /* @__PURE__ */ (0,
|
2685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(drawerContext.Provider, { value: { droppableId }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Droppable, { droppableId, isDropDisabled: true, direction, children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
2598
2686
|
"div",
|
2599
2687
|
__spreadProps(__spreadValues({}, provided.droppableProps), {
|
2600
2688
|
ref: provided.innerRef,
|
@@ -2603,7 +2691,7 @@ var Drawer = ({
|
|
2603
2691
|
}),
|
2604
2692
|
children: [
|
2605
2693
|
children,
|
2606
|
-
/* @__PURE__ */ (0,
|
2694
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { display: "none" }, children: provided.placeholder })
|
2607
2695
|
]
|
2608
2696
|
})
|
2609
2697
|
) }) });
|
@@ -2612,11 +2700,11 @@ Drawer.Item = DrawerItem;
|
|
2612
2700
|
|
2613
2701
|
// components/DropZone/index.tsx
|
2614
2702
|
init_react_import();
|
2615
|
-
var
|
2703
|
+
var import_react22 = require("react");
|
2616
2704
|
|
2617
2705
|
// components/DraggableComponent/index.tsx
|
2618
2706
|
init_react_import();
|
2619
|
-
var
|
2707
|
+
var import_react20 = require("react");
|
2620
2708
|
var import_dnd4 = require("@measured/dnd");
|
2621
2709
|
|
2622
2710
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -2625,10 +2713,10 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1bhad
|
|
2625
2713
|
|
2626
2714
|
// lib/use-modifier-held.ts
|
2627
2715
|
init_react_import();
|
2628
|
-
var
|
2716
|
+
var import_react19 = require("react");
|
2629
2717
|
var useModifierHeld = (modifier) => {
|
2630
|
-
const [modifierHeld, setModifierHeld] = (0,
|
2631
|
-
(0,
|
2718
|
+
const [modifierHeld, setModifierHeld] = (0, import_react19.useState)(false);
|
2719
|
+
(0, import_react19.useEffect)(() => {
|
2632
2720
|
function downHandler({ key }) {
|
2633
2721
|
if (key === modifier) {
|
2634
2722
|
setModifierHeld(true);
|
@@ -2662,7 +2750,7 @@ var isIos = () => [
|
|
2662
2750
|
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
2663
2751
|
|
2664
2752
|
// components/DraggableComponent/index.tsx
|
2665
|
-
var
|
2753
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
2666
2754
|
var getClassName17 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2667
2755
|
var space = 8;
|
2668
2756
|
var actionsOverlayTop = space * 6.5;
|
@@ -2671,7 +2759,7 @@ var actionsRight = space;
|
|
2671
2759
|
var DefaultActionBar = ({
|
2672
2760
|
label,
|
2673
2761
|
children
|
2674
|
-
}) => /* @__PURE__ */ (0,
|
2762
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar, { label, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar.Group, { children }) });
|
2675
2763
|
var DraggableComponent = ({
|
2676
2764
|
children,
|
2677
2765
|
id,
|
@@ -2697,28 +2785,28 @@ var DraggableComponent = ({
|
|
2697
2785
|
const { zoomConfig, status, overrides, selectedItem, getPermissions } = useAppContext();
|
2698
2786
|
const isModifierHeld = useModifierHeld("Alt");
|
2699
2787
|
const El = status !== "LOADING" ? import_dnd4.Draggable : DefaultDraggable;
|
2700
|
-
(0,
|
2701
|
-
const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0,
|
2702
|
-
(0,
|
2788
|
+
(0, import_react20.useEffect)(onMount, []);
|
2789
|
+
const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0, import_react20.useState)(false);
|
2790
|
+
(0, import_react20.useEffect)(() => {
|
2703
2791
|
if (isIos()) {
|
2704
2792
|
setDisableSecondaryAnimation(true);
|
2705
2793
|
}
|
2706
2794
|
}, []);
|
2707
|
-
const CustomActionBar = (0,
|
2795
|
+
const CustomActionBar = (0, import_react20.useMemo)(
|
2708
2796
|
() => overrides.actionBar || DefaultActionBar,
|
2709
2797
|
[overrides.actionBar]
|
2710
2798
|
);
|
2711
2799
|
const permissions = getPermissions({
|
2712
2800
|
item: selectedItem
|
2713
2801
|
});
|
2714
|
-
return /* @__PURE__ */ (0,
|
2802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
2715
2803
|
El,
|
2716
2804
|
{
|
2717
2805
|
draggableId: id,
|
2718
2806
|
index,
|
2719
2807
|
isDragDisabled,
|
2720
2808
|
disableSecondaryAnimation,
|
2721
|
-
children: (provided, snapshot) => /* @__PURE__ */ (0,
|
2809
|
+
children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
2722
2810
|
"div",
|
2723
2811
|
__spreadProps(__spreadValues(__spreadValues({
|
2724
2812
|
ref: provided.innerRef
|
@@ -2741,15 +2829,15 @@ var DraggableComponent = ({
|
|
2741
2829
|
onClick,
|
2742
2830
|
children: [
|
2743
2831
|
debug,
|
2744
|
-
isLoading && /* @__PURE__ */ (0,
|
2745
|
-
isSelected && /* @__PURE__ */ (0,
|
2832
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName17("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Loader, {}) }),
|
2833
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
2746
2834
|
"div",
|
2747
2835
|
{
|
2748
2836
|
className: getClassName17("actionsOverlay"),
|
2749
2837
|
style: {
|
2750
2838
|
top: actionsOverlayTop / zoomConfig.zoom
|
2751
2839
|
},
|
2752
|
-
children: /* @__PURE__ */ (0,
|
2840
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
2753
2841
|
"div",
|
2754
2842
|
{
|
2755
2843
|
className: getClassName17("actions"),
|
@@ -2758,16 +2846,16 @@ var DraggableComponent = ({
|
|
2758
2846
|
top: actionsTop / zoomConfig.zoom,
|
2759
2847
|
right: actionsRight / zoomConfig.zoom
|
2760
2848
|
},
|
2761
|
-
children: /* @__PURE__ */ (0,
|
2762
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
2763
|
-
permissions.delete && /* @__PURE__ */ (0,
|
2849
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(CustomActionBar, { label, children: [
|
2850
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Copy, { size: 16 }) }),
|
2851
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Trash, { size: 16 }) })
|
2764
2852
|
] })
|
2765
2853
|
}
|
2766
2854
|
)
|
2767
2855
|
}
|
2768
2856
|
),
|
2769
|
-
/* @__PURE__ */ (0,
|
2770
|
-
/* @__PURE__ */ (0,
|
2857
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName17("overlay") }),
|
2858
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName17("contents"), children })
|
2771
2859
|
]
|
2772
2860
|
})
|
2773
2861
|
)
|
@@ -2782,7 +2870,7 @@ var styles_module_default12 = { "DropZone": "_DropZone_djoti_1", "DropZone-conte
|
|
2782
2870
|
|
2783
2871
|
// components/DropZone/context.tsx
|
2784
2872
|
init_react_import();
|
2785
|
-
var
|
2873
|
+
var import_react21 = require("react");
|
2786
2874
|
var import_use_debounce2 = require("use-debounce");
|
2787
2875
|
|
2788
2876
|
// lib/get-zone-id.ts
|
@@ -2798,30 +2886,30 @@ var getZoneId = (zoneCompound) => {
|
|
2798
2886
|
};
|
2799
2887
|
|
2800
2888
|
// components/DropZone/context.tsx
|
2801
|
-
var
|
2802
|
-
var dropZoneContext = (0,
|
2889
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
2890
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2803
2891
|
var DropZoneProvider = ({
|
2804
2892
|
children,
|
2805
2893
|
value
|
2806
2894
|
}) => {
|
2807
|
-
const [hoveringArea, setHoveringArea] = (0,
|
2808
|
-
const [hoveringZone, setHoveringZone] = (0,
|
2895
|
+
const [hoveringArea, setHoveringArea] = (0, import_react21.useState)(null);
|
2896
|
+
const [hoveringZone, setHoveringZone] = (0, import_react21.useState)(
|
2809
2897
|
rootDroppableId
|
2810
2898
|
);
|
2811
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
2899
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
2812
2900
|
const [hoveringAreaDb] = (0, import_use_debounce2.useDebounce)(hoveringArea, 75, { leading: false });
|
2813
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
2901
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
2814
2902
|
{}
|
2815
2903
|
);
|
2816
|
-
const [activeZones, setActiveZones] = (0,
|
2904
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
2817
2905
|
const { dispatch = null } = value ? value : {};
|
2818
|
-
const registerZoneArea = (0,
|
2906
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
2819
2907
|
(area) => {
|
2820
2908
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2821
2909
|
},
|
2822
2910
|
[setAreasWithZones]
|
2823
2911
|
);
|
2824
|
-
const registerZone = (0,
|
2912
|
+
const registerZone = (0, import_react21.useCallback)(
|
2825
2913
|
(zoneCompound) => {
|
2826
2914
|
if (!dispatch) {
|
2827
2915
|
return;
|
@@ -2834,7 +2922,7 @@ var DropZoneProvider = ({
|
|
2834
2922
|
},
|
2835
2923
|
[setActiveZones, dispatch]
|
2836
2924
|
);
|
2837
|
-
const unregisterZone = (0,
|
2925
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
2838
2926
|
(zoneCompound) => {
|
2839
2927
|
if (!dispatch) {
|
2840
2928
|
return;
|
@@ -2849,8 +2937,8 @@ var DropZoneProvider = ({
|
|
2849
2937
|
},
|
2850
2938
|
[setActiveZones, dispatch]
|
2851
2939
|
);
|
2852
|
-
const [pathData, setPathData] = (0,
|
2853
|
-
const registerPath = (0,
|
2940
|
+
const [pathData, setPathData] = (0, import_react21.useState)();
|
2941
|
+
const registerPath = (0, import_react21.useCallback)(
|
2854
2942
|
(selector) => {
|
2855
2943
|
if (!(value == null ? void 0 : value.data)) {
|
2856
2944
|
return;
|
@@ -2875,8 +2963,8 @@ var DropZoneProvider = ({
|
|
2875
2963
|
},
|
2876
2964
|
[value, setPathData]
|
2877
2965
|
);
|
2878
|
-
const [zoneWillDrag, setZoneWillDrag] = (0,
|
2879
|
-
return /* @__PURE__ */ (0,
|
2966
|
+
const [zoneWillDrag, setZoneWillDrag] = (0, import_react21.useState)("");
|
2967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: value && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
2880
2968
|
dropZoneContext.Provider,
|
2881
2969
|
{
|
2882
2970
|
value: __spreadValues({
|
@@ -2902,12 +2990,12 @@ var DropZoneProvider = ({
|
|
2902
2990
|
};
|
2903
2991
|
|
2904
2992
|
// components/DropZone/index.tsx
|
2905
|
-
var
|
2993
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
2906
2994
|
var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
|
2907
2995
|
function DropZoneEdit({ zone, allow, disallow, style }) {
|
2908
2996
|
var _a;
|
2909
2997
|
const appContext2 = useAppContext();
|
2910
|
-
const ctx = (0,
|
2998
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
2911
2999
|
const {
|
2912
3000
|
// These all need setting via context
|
2913
3001
|
data,
|
@@ -2926,12 +3014,12 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2926
3014
|
} = ctx || {};
|
2927
3015
|
let content = data.content || [];
|
2928
3016
|
let zoneCompound = rootDroppableId;
|
2929
|
-
(0,
|
3017
|
+
(0, import_react22.useEffect)(() => {
|
2930
3018
|
if (areaId && registerZoneArea) {
|
2931
3019
|
registerZoneArea(areaId);
|
2932
3020
|
}
|
2933
3021
|
}, [areaId]);
|
2934
|
-
(0,
|
3022
|
+
(0, import_react22.useEffect)(() => {
|
2935
3023
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
2936
3024
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
2937
3025
|
}
|
@@ -2957,7 +3045,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2957
3045
|
const draggingOverArea = userIsDragging && zoneArea === draggedSourceArea;
|
2958
3046
|
const draggingNewComponent = draggedSourceId == null ? void 0 : draggedSourceId.startsWith("component-list");
|
2959
3047
|
if (!(ctx == null ? void 0 : ctx.config) || !ctx.setHoveringArea || !ctx.setHoveringZone || !ctx.setHoveringComponent || !ctx.setItemSelector || !ctx.registerPath || !ctx.dispatch) {
|
2960
|
-
return /* @__PURE__ */ (0,
|
3048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: "DropZone requires context to work." });
|
2961
3049
|
}
|
2962
3050
|
const {
|
2963
3051
|
hoveringArea = "root",
|
@@ -2998,7 +3086,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2998
3086
|
}
|
2999
3087
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3000
3088
|
const isAreaSelected = selectedItem && zoneArea === selectedItem.props.id;
|
3001
|
-
return /* @__PURE__ */ (0,
|
3089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3002
3090
|
"div",
|
3003
3091
|
{
|
3004
3092
|
className: getClassName18({
|
@@ -3015,14 +3103,14 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3015
3103
|
onMouseUp: () => {
|
3016
3104
|
setZoneWillDrag("");
|
3017
3105
|
},
|
3018
|
-
children: /* @__PURE__ */ (0,
|
3106
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3019
3107
|
Droppable,
|
3020
3108
|
{
|
3021
3109
|
droppableId: zoneCompound,
|
3022
3110
|
direction: "vertical",
|
3023
3111
|
isDropDisabled: !isEnabled,
|
3024
3112
|
children: (provided, snapshot) => {
|
3025
|
-
return /* @__PURE__ */ (0,
|
3113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
3026
3114
|
"div",
|
3027
3115
|
__spreadProps(__spreadValues({}, (provided || { droppableProps: {} }).droppableProps), {
|
3028
3116
|
className: getClassName18("content"),
|
@@ -3052,7 +3140,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3052
3140
|
"draggable-"
|
3053
3141
|
)[1] === componentId;
|
3054
3142
|
const containsZone = areasWithZones ? areasWithZones[componentId] : false;
|
3055
|
-
const Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ (0,
|
3143
|
+
const Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
3056
3144
|
"No configuration for ",
|
3057
3145
|
item.type
|
3058
3146
|
] });
|
@@ -3064,19 +3152,19 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3064
3152
|
appContext2.state.data
|
3065
3153
|
)
|
3066
3154
|
}).drag;
|
3067
|
-
return /* @__PURE__ */ (0,
|
3155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
3068
3156
|
"div",
|
3069
3157
|
{
|
3070
3158
|
className: getClassName18("item"),
|
3071
3159
|
style: { zIndex: isDragging ? 1 : void 0 },
|
3072
3160
|
children: [
|
3073
|
-
/* @__PURE__ */ (0,
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3074
3162
|
DropZoneProvider,
|
3075
3163
|
{
|
3076
3164
|
value: __spreadProps(__spreadValues({}, ctx), {
|
3077
3165
|
areaId: componentId
|
3078
3166
|
}),
|
3079
|
-
children: /* @__PURE__ */ (0,
|
3167
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3080
3168
|
DraggableComponent,
|
3081
3169
|
{
|
3082
3170
|
label,
|
@@ -3144,12 +3232,12 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3144
3232
|
style: {
|
3145
3233
|
pointerEvents: userIsDragging && draggingNewComponent ? "all" : void 0
|
3146
3234
|
},
|
3147
|
-
children: /* @__PURE__ */ (0,
|
3235
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName18("renderWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3148
3236
|
}
|
3149
3237
|
)
|
3150
3238
|
}
|
3151
3239
|
),
|
3152
|
-
userIsDragging && /* @__PURE__ */ (0,
|
3240
|
+
userIsDragging && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3153
3241
|
"div",
|
3154
3242
|
{
|
3155
3243
|
className: getClassName18("hitbox"),
|
@@ -3166,7 +3254,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3166
3254
|
);
|
3167
3255
|
}),
|
3168
3256
|
provided == null ? void 0 : provided.placeholder,
|
3169
|
-
(snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ (0,
|
3257
|
+
(snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3170
3258
|
"div",
|
3171
3259
|
{
|
3172
3260
|
"data-puck-placeholder": true,
|
@@ -3187,7 +3275,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3187
3275
|
);
|
3188
3276
|
}
|
3189
3277
|
function DropZoneRender({ zone }) {
|
3190
|
-
const ctx = (0,
|
3278
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
3191
3279
|
const { data, areaId = "root", config } = ctx || {};
|
3192
3280
|
let zoneCompound = rootDroppableId;
|
3193
3281
|
let content = (data == null ? void 0 : data.content) || [];
|
@@ -3198,14 +3286,14 @@ function DropZoneRender({ zone }) {
|
|
3198
3286
|
zoneCompound = `${areaId}:${zone}`;
|
3199
3287
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3200
3288
|
}
|
3201
|
-
return /* @__PURE__ */ (0,
|
3289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: content.map((item) => {
|
3202
3290
|
const Component = config.components[item.type];
|
3203
3291
|
if (Component) {
|
3204
|
-
return /* @__PURE__ */ (0,
|
3292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3205
3293
|
DropZoneProvider,
|
3206
3294
|
{
|
3207
3295
|
value: { data, config, areaId: item.props.id },
|
3208
|
-
children: /* @__PURE__ */ (0,
|
3296
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3209
3297
|
Component.render,
|
3210
3298
|
__spreadProps(__spreadValues({}, item.props), {
|
3211
3299
|
puck: { renderDropZone: DropZone }
|
@@ -3219,35 +3307,35 @@ function DropZoneRender({ zone }) {
|
|
3219
3307
|
}) });
|
3220
3308
|
}
|
3221
3309
|
function DropZone(props) {
|
3222
|
-
const ctx = (0,
|
3310
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
3223
3311
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3224
|
-
return /* @__PURE__ */ (0,
|
3312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadValues({}, props));
|
3225
3313
|
}
|
3226
|
-
return /* @__PURE__ */ (0,
|
3314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender, __spreadValues({}, props));
|
3227
3315
|
}
|
3228
3316
|
|
3229
3317
|
// components/Puck/index.tsx
|
3230
3318
|
init_react_import();
|
3231
|
-
var
|
3319
|
+
var import_react37 = require("react");
|
3232
3320
|
|
3233
3321
|
// lib/use-placeholder-style.ts
|
3234
3322
|
init_react_import();
|
3235
|
-
var
|
3323
|
+
var import_react23 = require("react");
|
3236
3324
|
|
3237
3325
|
// lib/get-frame.ts
|
3238
3326
|
init_react_import();
|
3239
3327
|
var getFrame = () => {
|
3240
|
-
let
|
3241
|
-
if ((
|
3242
|
-
|
3328
|
+
let frameEl = document.querySelector("#preview-frame");
|
3329
|
+
if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
|
3330
|
+
return frameEl.contentDocument || document;
|
3243
3331
|
}
|
3244
|
-
return
|
3332
|
+
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3245
3333
|
};
|
3246
3334
|
|
3247
3335
|
// lib/use-placeholder-style.ts
|
3248
3336
|
var usePlaceholderStyle = () => {
|
3249
3337
|
const queryAttr = "data-rfd-drag-handle-draggable-id";
|
3250
|
-
const [placeholderStyle, setPlaceholderStyle] = (0,
|
3338
|
+
const [placeholderStyle, setPlaceholderStyle] = (0, import_react23.useState)();
|
3251
3339
|
const onDragStartOrUpdate = (draggedItem) => {
|
3252
3340
|
var _a;
|
3253
3341
|
const draggableId = draggedItem.draggableId;
|
@@ -3300,7 +3388,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
3300
3388
|
|
3301
3389
|
// lib/use-breadcrumbs.ts
|
3302
3390
|
init_react_import();
|
3303
|
-
var
|
3391
|
+
var import_react24 = require("react");
|
3304
3392
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
3305
3393
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
3306
3394
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -3350,8 +3438,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
3350
3438
|
state: { data },
|
3351
3439
|
selectedItem
|
3352
3440
|
} = useAppContext();
|
3353
|
-
const dzContext = (0,
|
3354
|
-
return (0,
|
3441
|
+
const dzContext = (0, import_react24.useContext)(dropZoneContext);
|
3442
|
+
return (0, import_react24.useMemo)(() => {
|
3355
3443
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
3356
3444
|
selectedItem,
|
3357
3445
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -3365,7 +3453,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
3365
3453
|
};
|
3366
3454
|
|
3367
3455
|
// components/SidebarSection/index.tsx
|
3368
|
-
var
|
3456
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
3369
3457
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
3370
3458
|
var SidebarSection = ({
|
3371
3459
|
children,
|
@@ -3378,15 +3466,15 @@ var SidebarSection = ({
|
|
3378
3466
|
}) => {
|
3379
3467
|
const { setUi } = useAppContext();
|
3380
3468
|
const breadcrumbs = useBreadcrumbs(1);
|
3381
|
-
return /* @__PURE__ */ (0,
|
3469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
3382
3470
|
"div",
|
3383
3471
|
{
|
3384
3472
|
className: getClassName19({ noBorderTop, noPadding }),
|
3385
3473
|
style: { background },
|
3386
3474
|
children: [
|
3387
|
-
/* @__PURE__ */ (0,
|
3388
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
3389
|
-
/* @__PURE__ */ (0,
|
3475
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
3476
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
3477
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
3390
3478
|
"button",
|
3391
3479
|
{
|
3392
3480
|
type: "button",
|
@@ -3395,12 +3483,12 @@ var SidebarSection = ({
|
|
3395
3483
|
children: breadcrumb.label
|
3396
3484
|
}
|
3397
3485
|
),
|
3398
|
-
/* @__PURE__ */ (0,
|
3486
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChevronRight, { size: 16 })
|
3399
3487
|
] }, i)) : null,
|
3400
|
-
/* @__PURE__ */ (0,
|
3488
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
3401
3489
|
] }) }),
|
3402
|
-
/* @__PURE__ */ (0,
|
3403
|
-
isLoading && /* @__PURE__ */ (0,
|
3490
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("content"), children }),
|
3491
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Loader, { size: 32 }) })
|
3404
3492
|
]
|
3405
3493
|
}
|
3406
3494
|
);
|
@@ -3603,6 +3691,9 @@ function reduceData(data, action, config) {
|
|
3603
3691
|
});
|
3604
3692
|
}
|
3605
3693
|
if (action.type === "move") {
|
3694
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
3695
|
+
return data;
|
3696
|
+
}
|
3606
3697
|
const newData = setupZone(
|
3607
3698
|
setupZone(data, action.sourceZone),
|
3608
3699
|
action.destinationZone
|
@@ -3781,7 +3872,7 @@ init_react_import();
|
|
3781
3872
|
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" };
|
3782
3873
|
|
3783
3874
|
// components/MenuBar/index.tsx
|
3784
|
-
var
|
3875
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
3785
3876
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
3786
3877
|
function MenuBar({
|
3787
3878
|
appState,
|
@@ -3795,7 +3886,7 @@ function MenuBar({
|
|
3795
3886
|
history: { back, forward, historyStore }
|
3796
3887
|
} = useAppContext();
|
3797
3888
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
3798
|
-
return /* @__PURE__ */ (0,
|
3889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
3799
3890
|
"div",
|
3800
3891
|
{
|
3801
3892
|
className: getClassName20({ menuOpen }),
|
@@ -3809,12 +3900,12 @@ function MenuBar({
|
|
3809
3900
|
setMenuOpen(false);
|
3810
3901
|
}
|
3811
3902
|
},
|
3812
|
-
children: /* @__PURE__ */ (0,
|
3813
|
-
/* @__PURE__ */ (0,
|
3814
|
-
/* @__PURE__ */ (0,
|
3815
|
-
/* @__PURE__ */ (0,
|
3903
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName20("inner"), children: [
|
3904
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName20("history"), children: [
|
3905
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Undo2, { size: 21 }) }),
|
3906
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Redo2, { size: 21 }) })
|
3816
3907
|
] }),
|
3817
|
-
/* @__PURE__ */ (0,
|
3908
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
3818
3909
|
state: appState,
|
3819
3910
|
dispatch
|
3820
3911
|
}) })
|
@@ -3835,15 +3926,15 @@ init_react_import();
|
|
3835
3926
|
var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
|
3836
3927
|
|
3837
3928
|
// components/Puck/components/Fields/index.tsx
|
3838
|
-
var
|
3929
|
+
var import_react26 = require("react");
|
3839
3930
|
|
3840
3931
|
// lib/use-parent.ts
|
3841
3932
|
init_react_import();
|
3842
|
-
var
|
3933
|
+
var import_react25 = require("react");
|
3843
3934
|
var useParent = (itemSelector) => {
|
3844
3935
|
var _a;
|
3845
3936
|
const { selectedItem, state } = useAppContext();
|
3846
|
-
const { pathData } = (0,
|
3937
|
+
const { pathData } = (0, import_react25.useContext)(dropZoneContext) || {};
|
3847
3938
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
3848
3939
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
3849
3940
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -3852,7 +3943,7 @@ var useParent = (itemSelector) => {
|
|
3852
3943
|
};
|
3853
3944
|
|
3854
3945
|
// components/Puck/components/Fields/index.tsx
|
3855
|
-
var
|
3946
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
3856
3947
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
3857
3948
|
var defaultPageFields = {
|
3858
3949
|
title: { type: "text" }
|
@@ -3860,7 +3951,7 @@ var defaultPageFields = {
|
|
3860
3951
|
var DefaultFields = ({
|
3861
3952
|
children
|
3862
3953
|
}) => {
|
3863
|
-
return /* @__PURE__ */ (0,
|
3954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_jsx_runtime28.Fragment, { children });
|
3864
3955
|
};
|
3865
3956
|
var useResolvedFields = () => {
|
3866
3957
|
var _a, _b;
|
@@ -3869,20 +3960,20 @@ var useResolvedFields = () => {
|
|
3869
3960
|
const { data } = state;
|
3870
3961
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
3871
3962
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
3872
|
-
const defaultFields = (0,
|
3963
|
+
const defaultFields = (0, import_react26.useMemo)(
|
3873
3964
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
3874
3965
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
3875
3966
|
);
|
3876
3967
|
const rootProps = data.root.props || data.root;
|
3877
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
3878
|
-
const [resolvedFields, setResolvedFields] = (0,
|
3879
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
3968
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react26.useState)({});
|
3969
|
+
const [resolvedFields, setResolvedFields] = (0, import_react26.useState)(defaultFields);
|
3970
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react26.useState)(false);
|
3880
3971
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
3881
3972
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
3882
3973
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
3883
3974
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
3884
3975
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
3885
|
-
const resolveFields = (0,
|
3976
|
+
const resolveFields = (0, import_react26.useCallback)(
|
3886
3977
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
3887
3978
|
var _a2;
|
3888
3979
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -3920,7 +4011,7 @@ var useResolvedFields = () => {
|
|
3920
4011
|
}),
|
3921
4012
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
3922
4013
|
);
|
3923
|
-
(0,
|
4014
|
+
(0, import_react26.useEffect)(() => {
|
3924
4015
|
if (hasResolver) {
|
3925
4016
|
setFieldsLoading(true);
|
3926
4017
|
resolveFields(defaultFields).then((fields) => {
|
@@ -3951,8 +4042,8 @@ var Fields = () => {
|
|
3951
4042
|
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;
|
3952
4043
|
const isLoading = fieldsResolving || componentResolving;
|
3953
4044
|
const rootProps = data.root.props || data.root;
|
3954
|
-
const Wrapper = (0,
|
3955
|
-
return /* @__PURE__ */ (0,
|
4045
|
+
const Wrapper = (0, import_react26.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
4046
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
3956
4047
|
"form",
|
3957
4048
|
{
|
3958
4049
|
className: getClassName21(),
|
@@ -3960,7 +4051,7 @@ var Fields = () => {
|
|
3960
4051
|
e.preventDefault();
|
3961
4052
|
},
|
3962
4053
|
children: [
|
3963
|
-
/* @__PURE__ */ (0,
|
4054
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
3964
4055
|
const field = fields[fieldName];
|
3965
4056
|
if (!(field == null ? void 0 : field.type)) return null;
|
3966
4057
|
const onChange = (value, updatedUi) => {
|
@@ -4031,7 +4122,7 @@ var Fields = () => {
|
|
4031
4122
|
item: selectedItem
|
4032
4123
|
});
|
4033
4124
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
4034
|
-
return /* @__PURE__ */ (0,
|
4125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
4035
4126
|
AutoFieldPrivate,
|
4036
4127
|
{
|
4037
4128
|
field,
|
@@ -4049,7 +4140,7 @@ var Fields = () => {
|
|
4049
4140
|
root: true
|
4050
4141
|
});
|
4051
4142
|
const id = `root_${field.type}_${fieldName}`;
|
4052
|
-
return /* @__PURE__ */ (0,
|
4143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
4053
4144
|
AutoFieldPrivate,
|
4054
4145
|
{
|
4055
4146
|
field,
|
@@ -4063,7 +4154,7 @@ var Fields = () => {
|
|
4063
4154
|
);
|
4064
4155
|
}
|
4065
4156
|
}) }),
|
4066
|
-
isLoading && /* @__PURE__ */ (0,
|
4157
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 16 }) }) })
|
4067
4158
|
]
|
4068
4159
|
}
|
4069
4160
|
);
|
@@ -4074,7 +4165,7 @@ init_react_import();
|
|
4074
4165
|
|
4075
4166
|
// lib/use-component-list.tsx
|
4076
4167
|
init_react_import();
|
4077
|
-
var
|
4168
|
+
var import_react27 = require("react");
|
4078
4169
|
|
4079
4170
|
// components/ComponentList/index.tsx
|
4080
4171
|
init_react_import();
|
@@ -4084,7 +4175,7 @@ init_react_import();
|
|
4084
4175
|
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" };
|
4085
4176
|
|
4086
4177
|
// components/ComponentList/index.tsx
|
4087
|
-
var
|
4178
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
4088
4179
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
4089
4180
|
var ComponentListItem = ({
|
4090
4181
|
name,
|
@@ -4095,7 +4186,7 @@ var ComponentListItem = ({
|
|
4095
4186
|
const canInsert = getPermissions({
|
4096
4187
|
type: name
|
4097
4188
|
}).insert;
|
4098
|
-
return /* @__PURE__ */ (0,
|
4189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
4099
4190
|
Drawer.Item,
|
4100
4191
|
{
|
4101
4192
|
label,
|
@@ -4113,8 +4204,8 @@ var ComponentList = ({
|
|
4113
4204
|
}) => {
|
4114
4205
|
const { config, state, setUi } = useAppContext();
|
4115
4206
|
const { expanded = true } = state.ui.componentList[id] || {};
|
4116
|
-
return /* @__PURE__ */ (0,
|
4117
|
-
title && /* @__PURE__ */ (0,
|
4207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
4208
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
4118
4209
|
"button",
|
4119
4210
|
{
|
4120
4211
|
type: "button",
|
@@ -4128,14 +4219,14 @@ var ComponentList = ({
|
|
4128
4219
|
}),
|
4129
4220
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
4130
4221
|
children: [
|
4131
|
-
/* @__PURE__ */ (0,
|
4132
|
-
/* @__PURE__ */ (0,
|
4222
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: title }),
|
4223
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronDown, { size: 12 }) })
|
4133
4224
|
]
|
4134
4225
|
}
|
4135
4226
|
),
|
4136
|
-
/* @__PURE__ */ (0,
|
4227
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Drawer, { droppableId: title, children: children || Object.keys(config.components).map((componentKey, i) => {
|
4137
4228
|
var _a;
|
4138
|
-
return /* @__PURE__ */ (0,
|
4229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
4139
4230
|
ComponentListItem,
|
4140
4231
|
{
|
4141
4232
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -4150,10 +4241,10 @@ var ComponentList = ({
|
|
4150
4241
|
ComponentList.Item = ComponentListItem;
|
4151
4242
|
|
4152
4243
|
// lib/use-component-list.tsx
|
4153
|
-
var
|
4244
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
4154
4245
|
var useComponentList = (config, ui) => {
|
4155
|
-
const [componentList, setComponentList] = (0,
|
4156
|
-
(0,
|
4246
|
+
const [componentList, setComponentList] = (0, import_react27.useState)();
|
4247
|
+
(0, import_react27.useEffect)(() => {
|
4157
4248
|
var _a, _b, _c;
|
4158
4249
|
if (Object.keys(ui.componentList).length > 0) {
|
4159
4250
|
const matchedComponents = [];
|
@@ -4163,7 +4254,7 @@ var useComponentList = (config, ui) => {
|
|
4163
4254
|
if (category.visible === false || !category.components) {
|
4164
4255
|
return null;
|
4165
4256
|
}
|
4166
|
-
return /* @__PURE__ */ (0,
|
4257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4167
4258
|
ComponentList,
|
4168
4259
|
{
|
4169
4260
|
id: categoryKey,
|
@@ -4172,7 +4263,7 @@ var useComponentList = (config, ui) => {
|
|
4172
4263
|
var _a2;
|
4173
4264
|
matchedComponents.push(componentName);
|
4174
4265
|
const componentConf = config.components[componentName] || {};
|
4175
|
-
return /* @__PURE__ */ (0,
|
4266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4176
4267
|
ComponentList.Item,
|
4177
4268
|
{
|
4178
4269
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -4192,7 +4283,7 @@ var useComponentList = (config, ui) => {
|
|
4192
4283
|
);
|
4193
4284
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
4194
4285
|
_componentList.push(
|
4195
|
-
/* @__PURE__ */ (0,
|
4286
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4196
4287
|
ComponentList,
|
4197
4288
|
{
|
4198
4289
|
id: "other",
|
@@ -4200,7 +4291,7 @@ var useComponentList = (config, ui) => {
|
|
4200
4291
|
children: remainingComponents.map((componentName, i) => {
|
4201
4292
|
var _a2;
|
4202
4293
|
const componentConf = config.components[componentName] || {};
|
4203
|
-
return /* @__PURE__ */ (0,
|
4294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4204
4295
|
ComponentList.Item,
|
4205
4296
|
{
|
4206
4297
|
name: componentName,
|
@@ -4222,25 +4313,25 @@ var useComponentList = (config, ui) => {
|
|
4222
4313
|
};
|
4223
4314
|
|
4224
4315
|
// components/Puck/components/Components/index.tsx
|
4225
|
-
var
|
4226
|
-
var
|
4316
|
+
var import_react28 = require("react");
|
4317
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
4227
4318
|
var Components = () => {
|
4228
4319
|
const { config, state, overrides } = useAppContext();
|
4229
4320
|
const componentList = useComponentList(config, state.ui);
|
4230
|
-
const Wrapper = (0,
|
4231
|
-
return /* @__PURE__ */ (0,
|
4321
|
+
const Wrapper = (0, import_react28.useMemo)(() => overrides.components || "div", [overrides]);
|
4322
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComponentList, { id: "all" }) });
|
4232
4323
|
};
|
4233
4324
|
|
4234
4325
|
// components/Puck/components/Preview/index.tsx
|
4235
4326
|
init_react_import();
|
4236
|
-
var
|
4327
|
+
var import_react30 = require("react");
|
4237
4328
|
|
4238
4329
|
// components/AutoFrame/index.tsx
|
4239
4330
|
init_react_import();
|
4240
|
-
var
|
4331
|
+
var import_react29 = require("react");
|
4241
4332
|
var import_object_hash = __toESM(require("object-hash"));
|
4242
4333
|
var import_react_dom2 = require("react-dom");
|
4243
|
-
var
|
4334
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
4244
4335
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
4245
4336
|
var collectStyles = (doc) => {
|
4246
4337
|
const collected = [];
|
@@ -4283,7 +4374,7 @@ var CopyHostStyles = ({
|
|
4283
4374
|
onStylesLoaded = () => null
|
4284
4375
|
}) => {
|
4285
4376
|
const { document: doc, window: win } = useFrame();
|
4286
|
-
(0,
|
4377
|
+
(0, import_react29.useEffect)(() => {
|
4287
4378
|
if (!win || !doc) {
|
4288
4379
|
return () => {
|
4289
4380
|
};
|
@@ -4440,10 +4531,10 @@ var CopyHostStyles = ({
|
|
4440
4531
|
observer.disconnect();
|
4441
4532
|
};
|
4442
4533
|
}, []);
|
4443
|
-
return /* @__PURE__ */ (0,
|
4534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
|
4444
4535
|
};
|
4445
|
-
var autoFrameContext = (0,
|
4446
|
-
var useFrame = () => (0,
|
4536
|
+
var autoFrameContext = (0, import_react29.createContext)({});
|
4537
|
+
var useFrame = () => (0, import_react29.useContext)(autoFrameContext);
|
4447
4538
|
function AutoFrame(_a) {
|
4448
4539
|
var _b = _a, {
|
4449
4540
|
children,
|
@@ -4458,11 +4549,11 @@ function AutoFrame(_a) {
|
|
4458
4549
|
"id",
|
4459
4550
|
"onStylesLoaded"
|
4460
4551
|
]);
|
4461
|
-
const [loaded, setLoaded] = (0,
|
4462
|
-
const [ctx, setCtx] = (0,
|
4463
|
-
const ref = (0,
|
4464
|
-
const [mountTarget, setMountTarget] = (0,
|
4465
|
-
(0,
|
4552
|
+
const [loaded, setLoaded] = (0, import_react29.useState)(false);
|
4553
|
+
const [ctx, setCtx] = (0, import_react29.useState)({});
|
4554
|
+
const ref = (0, import_react29.useRef)(null);
|
4555
|
+
const [mountTarget, setMountTarget] = (0, import_react29.useState)();
|
4556
|
+
(0, import_react29.useEffect)(() => {
|
4466
4557
|
var _a2;
|
4467
4558
|
if (ref.current) {
|
4468
4559
|
setCtx({
|
@@ -4472,7 +4563,7 @@ function AutoFrame(_a) {
|
|
4472
4563
|
setMountTarget((_a2 = ref.current.contentDocument) == null ? void 0 : _a2.getElementById("frame-root"));
|
4473
4564
|
}
|
4474
4565
|
}, [ref, loaded]);
|
4475
|
-
return /* @__PURE__ */ (0,
|
4566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
4476
4567
|
"iframe",
|
4477
4568
|
__spreadProps(__spreadValues({}, props), {
|
4478
4569
|
className,
|
@@ -4482,7 +4573,7 @@ function AutoFrame(_a) {
|
|
4482
4573
|
onLoad: () => {
|
4483
4574
|
setLoaded(true);
|
4484
4575
|
},
|
4485
|
-
children: /* @__PURE__ */ (0,
|
4576
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(CopyHostStyles, { debug, onStylesLoaded, children: (0, import_react_dom2.createPortal)(children, mountTarget) }) })
|
4486
4577
|
})
|
4487
4578
|
);
|
4488
4579
|
}
|
@@ -4494,22 +4585,22 @@ init_react_import();
|
|
4494
4585
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
|
4495
4586
|
|
4496
4587
|
// components/Puck/components/Preview/index.tsx
|
4497
|
-
var
|
4588
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
4498
4589
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
4499
4590
|
var Preview = ({ id = "puck-preview" }) => {
|
4500
4591
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
4501
|
-
const Page = (0,
|
4592
|
+
const Page = (0, import_react30.useCallback)(
|
4502
4593
|
(pageProps) => {
|
4503
4594
|
var _a, _b;
|
4504
4595
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
4505
4596
|
id: "puck-root"
|
4506
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
4597
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
4507
4598
|
},
|
4508
4599
|
[config.root]
|
4509
4600
|
);
|
4510
|
-
const Frame = (0,
|
4601
|
+
const Frame = (0, import_react30.useMemo)(() => overrides.iframe, [overrides]);
|
4511
4602
|
const rootProps = state.data.root.props || state.data.root;
|
4512
|
-
return /* @__PURE__ */ (0,
|
4603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4513
4604
|
"div",
|
4514
4605
|
{
|
4515
4606
|
className: getClassName23(),
|
@@ -4517,7 +4608,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4517
4608
|
onClick: () => {
|
4518
4609
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
4519
4610
|
},
|
4520
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
4611
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4521
4612
|
AutoFrame_default,
|
4522
4613
|
{
|
4523
4614
|
id: "preview-frame",
|
@@ -4526,27 +4617,27 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4526
4617
|
onStylesLoaded: () => {
|
4527
4618
|
setStatus("READY");
|
4528
4619
|
},
|
4529
|
-
children: /* @__PURE__ */ (0,
|
4530
|
-
const inner = /* @__PURE__ */ (0,
|
4620
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
4621
|
+
const inner = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4531
4622
|
Page,
|
4532
4623
|
__spreadProps(__spreadValues({}, rootProps), {
|
4533
4624
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4534
4625
|
editMode: true,
|
4535
|
-
children: /* @__PURE__ */ (0,
|
4626
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
4536
4627
|
})
|
4537
4628
|
);
|
4538
4629
|
if (Frame) {
|
4539
|
-
return /* @__PURE__ */ (0,
|
4630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
4540
4631
|
}
|
4541
4632
|
return inner;
|
4542
4633
|
} })
|
4543
4634
|
}
|
4544
|
-
) : /* @__PURE__ */ (0,
|
4635
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4545
4636
|
Page,
|
4546
4637
|
__spreadProps(__spreadValues({}, rootProps), {
|
4547
4638
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4548
4639
|
editMode: true,
|
4549
|
-
children: /* @__PURE__ */ (0,
|
4640
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
4550
4641
|
})
|
4551
4642
|
) })
|
4552
4643
|
}
|
@@ -4596,7 +4687,7 @@ var scrollIntoView = (el) => {
|
|
4596
4687
|
};
|
4597
4688
|
|
4598
4689
|
// components/LayerTree/index.tsx
|
4599
|
-
var
|
4690
|
+
var import_react31 = require("react");
|
4600
4691
|
|
4601
4692
|
// lib/is-child-of-zone.ts
|
4602
4693
|
init_react_import();
|
@@ -4610,7 +4701,7 @@ var isChildOfZone = (item, maybeChild, ctx) => {
|
|
4610
4701
|
};
|
4611
4702
|
|
4612
4703
|
// components/LayerTree/index.tsx
|
4613
|
-
var
|
4704
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
4614
4705
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
4615
4706
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
4616
4707
|
var LayerTree = ({
|
@@ -4623,15 +4714,15 @@ var LayerTree = ({
|
|
4623
4714
|
label
|
4624
4715
|
}) => {
|
4625
4716
|
const zones = data.zones || {};
|
4626
|
-
const ctx = (0,
|
4627
|
-
return /* @__PURE__ */ (0,
|
4628
|
-
label && /* @__PURE__ */ (0,
|
4629
|
-
/* @__PURE__ */ (0,
|
4717
|
+
const ctx = (0, import_react31.useContext)(dropZoneContext);
|
4718
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
4719
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
4720
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
4630
4721
|
" ",
|
4631
4722
|
label
|
4632
4723
|
] }),
|
4633
|
-
/* @__PURE__ */ (0,
|
4634
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
4724
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
|
4725
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
4635
4726
|
zoneContent.map((item, i) => {
|
4636
4727
|
var _a;
|
4637
4728
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -4649,7 +4740,7 @@ var LayerTree = ({
|
|
4649
4740
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
4650
4741
|
const componentConfig = config.components[item.type];
|
4651
4742
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
4652
|
-
return /* @__PURE__ */ (0,
|
4743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
4653
4744
|
"li",
|
4654
4745
|
{
|
4655
4746
|
className: getClassNameLayer({
|
@@ -4659,7 +4750,7 @@ var LayerTree = ({
|
|
4659
4750
|
childIsSelected
|
4660
4751
|
}),
|
4661
4752
|
children: [
|
4662
|
-
/* @__PURE__ */ (0,
|
4753
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
4663
4754
|
"button",
|
4664
4755
|
{
|
4665
4756
|
type: "button",
|
@@ -4692,22 +4783,22 @@ var LayerTree = ({
|
|
4692
4783
|
setHoveringComponent(null);
|
4693
4784
|
},
|
4694
4785
|
children: [
|
4695
|
-
containsZone && /* @__PURE__ */ (0,
|
4786
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
4696
4787
|
"div",
|
4697
4788
|
{
|
4698
4789
|
className: getClassNameLayer("chevron"),
|
4699
4790
|
title: isSelected ? "Collapse" : "Expand",
|
4700
|
-
children: /* @__PURE__ */ (0,
|
4791
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
4701
4792
|
}
|
4702
4793
|
),
|
4703
|
-
/* @__PURE__ */ (0,
|
4704
|
-
/* @__PURE__ */ (0,
|
4705
|
-
/* @__PURE__ */ (0,
|
4794
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
4795
|
+
/* @__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" }) }),
|
4796
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
4706
4797
|
] })
|
4707
4798
|
]
|
4708
4799
|
}
|
4709
4800
|
) }),
|
4710
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
4801
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
4711
4802
|
LayerTree,
|
4712
4803
|
{
|
4713
4804
|
config,
|
@@ -4729,13 +4820,13 @@ var LayerTree = ({
|
|
4729
4820
|
};
|
4730
4821
|
|
4731
4822
|
// components/Puck/components/Outline/index.tsx
|
4732
|
-
var
|
4733
|
-
var
|
4823
|
+
var import_react32 = require("react");
|
4824
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
4734
4825
|
var Outline = () => {
|
4735
4826
|
const { dispatch, state, overrides, config } = useAppContext();
|
4736
4827
|
const { data, ui } = state;
|
4737
4828
|
const { itemSelector } = ui;
|
4738
|
-
const setItemSelector = (0,
|
4829
|
+
const setItemSelector = (0, import_react32.useCallback)(
|
4739
4830
|
(newItemSelector) => {
|
4740
4831
|
dispatch({
|
4741
4832
|
type: "setUi",
|
@@ -4744,9 +4835,9 @@ var Outline = () => {
|
|
4744
4835
|
},
|
4745
4836
|
[]
|
4746
4837
|
);
|
4747
|
-
const Wrapper = (0,
|
4748
|
-
return /* @__PURE__ */ (0,
|
4749
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
4838
|
+
const Wrapper = (0, import_react32.useMemo)(() => overrides.outline || "div", [overrides]);
|
4839
|
+
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: [
|
4840
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4750
4841
|
LayerTree,
|
4751
4842
|
{
|
4752
4843
|
config,
|
@@ -4759,7 +4850,7 @@ var Outline = () => {
|
|
4759
4850
|
),
|
4760
4851
|
Object.entries(findZonesForArea(data, "root")).map(
|
4761
4852
|
([zoneKey, zone]) => {
|
4762
|
-
return /* @__PURE__ */ (0,
|
4853
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4763
4854
|
LayerTree,
|
4764
4855
|
{
|
4765
4856
|
config,
|
@@ -4783,7 +4874,8 @@ var import_react_hotkeys_hook = require("react-hotkeys-hook");
|
|
4783
4874
|
function usePuckHistory({
|
4784
4875
|
dispatch,
|
4785
4876
|
initialAppState,
|
4786
|
-
historyStore
|
4877
|
+
historyStore,
|
4878
|
+
iframeEnabled
|
4787
4879
|
}) {
|
4788
4880
|
const back = () => {
|
4789
4881
|
var _a;
|
@@ -4801,6 +4893,16 @@ function usePuckHistory({
|
|
4801
4893
|
historyStore.forward();
|
4802
4894
|
}
|
4803
4895
|
};
|
4896
|
+
const backIframe = () => {
|
4897
|
+
if (iframeEnabled) {
|
4898
|
+
back();
|
4899
|
+
}
|
4900
|
+
};
|
4901
|
+
const forwardIframe = () => {
|
4902
|
+
if (iframeEnabled) {
|
4903
|
+
forward();
|
4904
|
+
}
|
4905
|
+
};
|
4804
4906
|
const setHistories = (histories) => {
|
4805
4907
|
var _a;
|
4806
4908
|
dispatch({
|
@@ -4819,9 +4921,23 @@ function usePuckHistory({
|
|
4819
4921
|
historyStore.setHistoryIndex(index);
|
4820
4922
|
}
|
4821
4923
|
};
|
4924
|
+
const frame = getFrame();
|
4925
|
+
const resolvedFrame = frame !== document ? frame : void 0;
|
4822
4926
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+z", back, { preventDefault: true });
|
4823
4927
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+shift+z", forward, { preventDefault: true });
|
4824
4928
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+y", forward, { preventDefault: true });
|
4929
|
+
(0, import_react_hotkeys_hook.useHotkeys)("meta+z", backIframe, {
|
4930
|
+
preventDefault: true,
|
4931
|
+
document: resolvedFrame
|
4932
|
+
});
|
4933
|
+
(0, import_react_hotkeys_hook.useHotkeys)("meta+shift+z", forwardIframe, {
|
4934
|
+
preventDefault: true,
|
4935
|
+
document: resolvedFrame
|
4936
|
+
});
|
4937
|
+
(0, import_react_hotkeys_hook.useHotkeys)("meta+y", forwardIframe, {
|
4938
|
+
preventDefault: true,
|
4939
|
+
document: resolvedFrame
|
4940
|
+
});
|
4825
4941
|
return {
|
4826
4942
|
back,
|
4827
4943
|
forward,
|
@@ -4833,19 +4949,19 @@ function usePuckHistory({
|
|
4833
4949
|
|
4834
4950
|
// lib/use-history-store.ts
|
4835
4951
|
init_react_import();
|
4836
|
-
var
|
4952
|
+
var import_react33 = require("react");
|
4837
4953
|
var import_use_debounce3 = require("use-debounce");
|
4838
4954
|
var EMPTY_HISTORY_INDEX = 0;
|
4839
4955
|
function useHistoryStore(initialHistory) {
|
4840
4956
|
var _a, _b;
|
4841
|
-
const [histories, setHistories] = (0,
|
4957
|
+
const [histories, setHistories] = (0, import_react33.useState)(
|
4842
4958
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
4843
4959
|
);
|
4844
4960
|
const updateHistories = (histories2) => {
|
4845
4961
|
setHistories(histories2);
|
4846
4962
|
setIndex(histories2.length - 1);
|
4847
4963
|
};
|
4848
|
-
const [index, setIndex] = (0,
|
4964
|
+
const [index, setIndex] = (0, import_react33.useState)(
|
4849
4965
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
4850
4966
|
);
|
4851
4967
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -5005,22 +5121,22 @@ var getBox = function getBox2(el) {
|
|
5005
5121
|
};
|
5006
5122
|
|
5007
5123
|
// components/Puck/components/Canvas/index.tsx
|
5008
|
-
var
|
5124
|
+
var import_react35 = require("react");
|
5009
5125
|
|
5010
5126
|
// components/ViewportControls/index.tsx
|
5011
5127
|
init_react_import();
|
5012
|
-
var
|
5128
|
+
var import_react34 = require("react");
|
5013
5129
|
|
5014
5130
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
5015
5131
|
init_react_import();
|
5016
5132
|
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" };
|
5017
5133
|
|
5018
5134
|
// components/ViewportControls/index.tsx
|
5019
|
-
var
|
5135
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
5020
5136
|
var icons = {
|
5021
|
-
Smartphone: /* @__PURE__ */ (0,
|
5022
|
-
Tablet: /* @__PURE__ */ (0,
|
5023
|
-
Monitor: /* @__PURE__ */ (0,
|
5137
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
|
5138
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
|
5139
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
|
5024
5140
|
};
|
5025
5141
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
5026
5142
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -5032,11 +5148,11 @@ var ViewportButton = ({
|
|
5032
5148
|
onClick
|
5033
5149
|
}) => {
|
5034
5150
|
const { state } = useAppContext();
|
5035
|
-
const [isActive, setIsActive] = (0,
|
5036
|
-
(0,
|
5151
|
+
const [isActive, setIsActive] = (0, import_react34.useState)(false);
|
5152
|
+
(0, import_react34.useEffect)(() => {
|
5037
5153
|
setIsActive(width === state.ui.viewports.current.width);
|
5038
5154
|
}, [width, state.ui.viewports.current.width]);
|
5039
|
-
return /* @__PURE__ */ (0,
|
5155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5040
5156
|
IconButton,
|
5041
5157
|
{
|
5042
5158
|
title,
|
@@ -5045,7 +5161,7 @@ var ViewportButton = ({
|
|
5045
5161
|
e.stopPropagation();
|
5046
5162
|
onClick({ width, height });
|
5047
5163
|
},
|
5048
|
-
children: /* @__PURE__ */ (0,
|
5164
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
|
5049
5165
|
}
|
5050
5166
|
) });
|
5051
5167
|
};
|
@@ -5069,7 +5185,7 @@ var ViewportControls = ({
|
|
5069
5185
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
5070
5186
|
(option) => option.value === autoZoom
|
5071
5187
|
);
|
5072
|
-
const zoomOptions = (0,
|
5188
|
+
const zoomOptions = (0, import_react34.useMemo)(
|
5073
5189
|
() => [
|
5074
5190
|
...defaultZoomOptions,
|
5075
5191
|
...defaultsContainAutoZoom ? [] : [
|
@@ -5081,8 +5197,8 @@ var ViewportControls = ({
|
|
5081
5197
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
5082
5198
|
[autoZoom]
|
5083
5199
|
);
|
5084
|
-
return /* @__PURE__ */ (0,
|
5085
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
5200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
|
5201
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5086
5202
|
ViewportButton,
|
5087
5203
|
{
|
5088
5204
|
height: viewport.height,
|
@@ -5093,8 +5209,8 @@ var ViewportControls = ({
|
|
5093
5209
|
},
|
5094
5210
|
i
|
5095
5211
|
)),
|
5096
|
-
/* @__PURE__ */ (0,
|
5097
|
-
/* @__PURE__ */ (0,
|
5212
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
5213
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5098
5214
|
IconButton,
|
5099
5215
|
{
|
5100
5216
|
title: "Zoom viewport out",
|
@@ -5108,10 +5224,10 @@ var ViewportControls = ({
|
|
5108
5224
|
)].value
|
5109
5225
|
);
|
5110
5226
|
},
|
5111
|
-
children: /* @__PURE__ */ (0,
|
5227
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
|
5112
5228
|
}
|
5113
5229
|
),
|
5114
|
-
/* @__PURE__ */ (0,
|
5230
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5115
5231
|
IconButton,
|
5116
5232
|
{
|
5117
5233
|
title: "Zoom viewport in",
|
@@ -5125,11 +5241,11 @@ var ViewportControls = ({
|
|
5125
5241
|
)].value
|
5126
5242
|
);
|
5127
5243
|
},
|
5128
|
-
children: /* @__PURE__ */ (0,
|
5244
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
|
5129
5245
|
}
|
5130
5246
|
),
|
5131
|
-
/* @__PURE__ */ (0,
|
5132
|
-
/* @__PURE__ */ (0,
|
5247
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
5248
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5133
5249
|
"select",
|
5134
5250
|
{
|
5135
5251
|
className: getClassName25("zoomSelect"),
|
@@ -5137,7 +5253,7 @@ var ViewportControls = ({
|
|
5137
5253
|
onChange: (e) => {
|
5138
5254
|
onZoom(parseFloat(e.currentTarget.value));
|
5139
5255
|
},
|
5140
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
5256
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5141
5257
|
"option",
|
5142
5258
|
{
|
5143
5259
|
value: option.value,
|
@@ -5152,7 +5268,7 @@ var ViewportControls = ({
|
|
5152
5268
|
|
5153
5269
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
5154
5270
|
init_react_import();
|
5155
|
-
var styles_module_default21 = { "PuckCanvas": "
|
5271
|
+
var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
|
5156
5272
|
|
5157
5273
|
// lib/get-zoom-config.ts
|
5158
5274
|
init_react_import();
|
@@ -5185,24 +5301,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
5185
5301
|
};
|
5186
5302
|
|
5187
5303
|
// components/Puck/components/Canvas/index.tsx
|
5188
|
-
var
|
5304
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
5189
5305
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
5190
5306
|
var ZOOM_ON_CHANGE = true;
|
5191
5307
|
var Canvas = () => {
|
5192
5308
|
const { status, iframe } = useAppContext();
|
5193
5309
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
5194
5310
|
const { ui } = state;
|
5195
|
-
const frameRef = (0,
|
5196
|
-
const [showTransition, setShowTransition] = (0,
|
5197
|
-
const defaultRender = (0,
|
5198
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
5311
|
+
const frameRef = (0, import_react35.useRef)(null);
|
5312
|
+
const [showTransition, setShowTransition] = (0, import_react35.useState)(false);
|
5313
|
+
const defaultRender = (0, import_react35.useMemo)(() => {
|
5314
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
5199
5315
|
return PuckDefault;
|
5200
5316
|
}, []);
|
5201
|
-
const CustomPreview = (0,
|
5317
|
+
const CustomPreview = (0, import_react35.useMemo)(
|
5202
5318
|
() => overrides.preview || defaultRender,
|
5203
5319
|
[overrides]
|
5204
5320
|
);
|
5205
|
-
const getFrameDimensions = (0,
|
5321
|
+
const getFrameDimensions = (0, import_react35.useCallback)(() => {
|
5206
5322
|
if (frameRef.current) {
|
5207
5323
|
const frame = frameRef.current;
|
5208
5324
|
const box = getBox(frame);
|
@@ -5210,7 +5326,7 @@ var Canvas = () => {
|
|
5210
5326
|
}
|
5211
5327
|
return { width: 0, height: 0 };
|
5212
5328
|
}, [frameRef]);
|
5213
|
-
const resetAutoZoom = (0,
|
5329
|
+
const resetAutoZoom = (0, import_react35.useCallback)(
|
5214
5330
|
(ui2 = state.ui) => {
|
5215
5331
|
if (frameRef.current) {
|
5216
5332
|
setZoomConfig(
|
@@ -5220,11 +5336,11 @@ var Canvas = () => {
|
|
5220
5336
|
},
|
5221
5337
|
[frameRef, zoomConfig, state.ui]
|
5222
5338
|
);
|
5223
|
-
(0,
|
5339
|
+
(0, import_react35.useEffect)(() => {
|
5224
5340
|
setShowTransition(false);
|
5225
5341
|
resetAutoZoom();
|
5226
5342
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
5227
|
-
(0,
|
5343
|
+
(0, import_react35.useEffect)(() => {
|
5228
5344
|
const { height: frameHeight } = getFrameDimensions();
|
5229
5345
|
if (ui.viewports.current.height === "auto") {
|
5230
5346
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -5232,13 +5348,13 @@ var Canvas = () => {
|
|
5232
5348
|
}));
|
5233
5349
|
}
|
5234
5350
|
}, [zoomConfig.zoom]);
|
5235
|
-
(0,
|
5351
|
+
(0, import_react35.useEffect)(() => {
|
5236
5352
|
if (ZOOM_ON_CHANGE) {
|
5237
5353
|
setShowTransition(true);
|
5238
5354
|
resetAutoZoom(ui);
|
5239
5355
|
}
|
5240
5356
|
}, [ui.viewports.current.width]);
|
5241
|
-
(0,
|
5357
|
+
(0, import_react35.useEffect)(() => {
|
5242
5358
|
const observer = new ResizeObserver(() => {
|
5243
5359
|
setShowTransition(false);
|
5244
5360
|
resetAutoZoom();
|
@@ -5250,13 +5366,13 @@ var Canvas = () => {
|
|
5250
5366
|
observer.disconnect();
|
5251
5367
|
};
|
5252
5368
|
}, []);
|
5253
|
-
const [showLoader, setShowLoader] = (0,
|
5254
|
-
(0,
|
5369
|
+
const [showLoader, setShowLoader] = (0, import_react35.useState)(false);
|
5370
|
+
(0, import_react35.useEffect)(() => {
|
5255
5371
|
setTimeout(() => {
|
5256
5372
|
setShowLoader(true);
|
5257
5373
|
}, 500);
|
5258
5374
|
}, []);
|
5259
|
-
return /* @__PURE__ */ (0,
|
5375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
5260
5376
|
"div",
|
5261
5377
|
{
|
5262
5378
|
className: getClassName26({
|
@@ -5269,7 +5385,7 @@ var Canvas = () => {
|
|
5269
5385
|
recordHistory: true
|
5270
5386
|
}),
|
5271
5387
|
children: [
|
5272
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
5388
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
5273
5389
|
ViewportControls,
|
5274
5390
|
{
|
5275
5391
|
autoZoom: zoomConfig.autoZoom,
|
@@ -5294,8 +5410,8 @@ var Canvas = () => {
|
|
5294
5410
|
}
|
5295
5411
|
}
|
5296
5412
|
) }),
|
5297
|
-
/* @__PURE__ */ (0,
|
5298
|
-
/* @__PURE__ */ (0,
|
5413
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
5414
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
5299
5415
|
"div",
|
5300
5416
|
{
|
5301
5417
|
className: getClassName26("root"),
|
@@ -5307,10 +5423,10 @@ var Canvas = () => {
|
|
5307
5423
|
overflow: iframe.enabled ? void 0 : "auto"
|
5308
5424
|
},
|
5309
5425
|
suppressHydrationWarning: true,
|
5310
|
-
children: /* @__PURE__ */ (0,
|
5426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview, {}) })
|
5311
5427
|
}
|
5312
5428
|
),
|
5313
|
-
/* @__PURE__ */ (0,
|
5429
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
5314
5430
|
] })
|
5315
5431
|
]
|
5316
5432
|
}
|
@@ -5354,7 +5470,7 @@ var insertComponent = (componentType, zone, index, {
|
|
5354
5470
|
|
5355
5471
|
// lib/use-loaded-overrides.ts
|
5356
5472
|
init_react_import();
|
5357
|
-
var
|
5473
|
+
var import_react36 = require("react");
|
5358
5474
|
|
5359
5475
|
// lib/load-overrides.ts
|
5360
5476
|
init_react_import();
|
@@ -5393,18 +5509,18 @@ var useLoadedOverrides = ({
|
|
5393
5509
|
overrides,
|
5394
5510
|
plugins
|
5395
5511
|
}) => {
|
5396
|
-
return (0,
|
5512
|
+
return (0, import_react36.useMemo)(() => {
|
5397
5513
|
return loadOverrides({ overrides, plugins });
|
5398
5514
|
}, [plugins, overrides]);
|
5399
5515
|
};
|
5400
5516
|
|
5401
5517
|
// components/DefaultOverride/index.tsx
|
5402
5518
|
init_react_import();
|
5403
|
-
var
|
5404
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
5519
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
5520
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
5405
5521
|
|
5406
5522
|
// components/Puck/index.tsx
|
5407
|
-
var
|
5523
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
5408
5524
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
5409
5525
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
5410
5526
|
function Puck({
|
@@ -5427,13 +5543,13 @@ function Puck({
|
|
5427
5543
|
dnd,
|
5428
5544
|
initialHistory: _initialHistory
|
5429
5545
|
}) {
|
5430
|
-
var _a;
|
5546
|
+
var _a, _b;
|
5431
5547
|
const iframe = __spreadValues({
|
5432
5548
|
enabled: true,
|
5433
5549
|
waitForStyles: true
|
5434
5550
|
}, _iframe);
|
5435
|
-
const [generatedAppState] = (0,
|
5436
|
-
var _a2,
|
5551
|
+
const [generatedAppState] = (0, import_react37.useState)(() => {
|
5552
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
5437
5553
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
5438
5554
|
let clientUiState = {};
|
5439
5555
|
if (typeof window !== "undefined") {
|
@@ -5453,7 +5569,7 @@ function Puck({
|
|
5453
5569
|
clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
|
5454
5570
|
viewports: __spreadProps(__spreadValues({}, initial.viewports), {
|
5455
5571
|
current: __spreadProps(__spreadValues({}, initial.viewports.current), {
|
5456
|
-
height: ((
|
5572
|
+
height: ((_b2 = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b2.height) || ((_c = viewports[closestViewport]) == null ? void 0 : _c.height) || "auto",
|
5457
5573
|
width: ((_e = (_d = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _d.current) == null ? void 0 : _e.width) || ((_f = viewports[closestViewport]) == null ? void 0 : _f.width)
|
5458
5574
|
})
|
5459
5575
|
})
|
@@ -5504,22 +5620,27 @@ function Puck({
|
|
5504
5620
|
histories,
|
5505
5621
|
index: initialHistoryIndex
|
5506
5622
|
});
|
5507
|
-
const [reducer] = (0,
|
5623
|
+
const [reducer] = (0, import_react37.useState)(
|
5508
5624
|
() => createReducer({
|
5509
5625
|
config,
|
5510
5626
|
record: historyStore.record,
|
5511
5627
|
onAction
|
5512
5628
|
})
|
5513
5629
|
);
|
5514
|
-
const [appState, dispatch] = (0,
|
5630
|
+
const [appState, dispatch] = (0, import_react37.useReducer)(
|
5515
5631
|
reducer,
|
5516
5632
|
flushZones(initialAppState)
|
5517
5633
|
);
|
5518
5634
|
const { data, ui } = appState;
|
5519
|
-
const history = usePuckHistory({
|
5520
|
-
|
5635
|
+
const history = usePuckHistory({
|
5636
|
+
dispatch,
|
5637
|
+
initialAppState,
|
5638
|
+
historyStore,
|
5639
|
+
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
5640
|
+
});
|
5641
|
+
const [menuOpen, setMenuOpen] = (0, import_react37.useState)(false);
|
5521
5642
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
5522
|
-
const setItemSelector = (0,
|
5643
|
+
const setItemSelector = (0, import_react37.useCallback)(
|
5523
5644
|
(newItemSelector) => {
|
5524
5645
|
if (newItemSelector === itemSelector) return;
|
5525
5646
|
dispatch({
|
@@ -5531,13 +5652,13 @@ function Puck({
|
|
5531
5652
|
[itemSelector]
|
5532
5653
|
);
|
5533
5654
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
5534
|
-
(0,
|
5655
|
+
(0, import_react37.useEffect)(() => {
|
5535
5656
|
if (onChange) onChange(data);
|
5536
5657
|
}, [data]);
|
5537
5658
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
5538
|
-
const [draggedItem, setDraggedItem] = (0,
|
5659
|
+
const [draggedItem, setDraggedItem] = (0, import_react37.useState)();
|
5539
5660
|
const rootProps = data.root.props || data.root;
|
5540
|
-
const toggleSidebars = (0,
|
5661
|
+
const toggleSidebars = (0, import_react37.useCallback)(
|
5541
5662
|
(sidebar) => {
|
5542
5663
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
5543
5664
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -5551,7 +5672,7 @@ function Puck({
|
|
5551
5672
|
},
|
5552
5673
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
5553
5674
|
);
|
5554
|
-
(0,
|
5675
|
+
(0, import_react37.useEffect)(() => {
|
5555
5676
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
5556
5677
|
dispatch({
|
5557
5678
|
type: "setUi",
|
@@ -5574,28 +5695,28 @@ function Puck({
|
|
5574
5695
|
window.removeEventListener("resize", handleResize);
|
5575
5696
|
};
|
5576
5697
|
}, []);
|
5577
|
-
const defaultHeaderRender = (0,
|
5698
|
+
const defaultHeaderRender = (0, import_react37.useMemo)(() => {
|
5578
5699
|
if (renderHeader) {
|
5579
5700
|
console.warn(
|
5580
5701
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
5581
5702
|
);
|
5582
5703
|
const RenderHeader = (_a2) => {
|
5583
|
-
var
|
5704
|
+
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
5584
5705
|
const Comp = renderHeader;
|
5585
|
-
return /* @__PURE__ */ (0,
|
5706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
5586
5707
|
};
|
5587
5708
|
return RenderHeader;
|
5588
5709
|
}
|
5589
5710
|
return DefaultOverride;
|
5590
5711
|
}, [renderHeader]);
|
5591
|
-
const defaultHeaderActionsRender = (0,
|
5712
|
+
const defaultHeaderActionsRender = (0, import_react37.useMemo)(() => {
|
5592
5713
|
if (renderHeaderActions) {
|
5593
5714
|
console.warn(
|
5594
5715
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
5595
5716
|
);
|
5596
5717
|
const RenderHeader = (props) => {
|
5597
5718
|
const Comp = renderHeaderActions;
|
5598
|
-
return /* @__PURE__ */ (0,
|
5719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
5599
5720
|
};
|
5600
5721
|
return RenderHeader;
|
5601
5722
|
}
|
@@ -5605,26 +5726,26 @@ function Puck({
|
|
5605
5726
|
overrides,
|
5606
5727
|
plugins
|
5607
5728
|
});
|
5608
|
-
const CustomPuck = (0,
|
5729
|
+
const CustomPuck = (0, import_react37.useMemo)(
|
5609
5730
|
() => loadedOverrides.puck || DefaultOverride,
|
5610
5731
|
[loadedOverrides]
|
5611
5732
|
);
|
5612
|
-
const CustomHeader = (0,
|
5733
|
+
const CustomHeader = (0, import_react37.useMemo)(
|
5613
5734
|
() => loadedOverrides.header || defaultHeaderRender,
|
5614
5735
|
[loadedOverrides]
|
5615
5736
|
);
|
5616
|
-
const CustomHeaderActions = (0,
|
5737
|
+
const CustomHeaderActions = (0, import_react37.useMemo)(
|
5617
5738
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
5618
5739
|
[loadedOverrides]
|
5619
5740
|
);
|
5620
|
-
const [mounted, setMounted] = (0,
|
5621
|
-
(0,
|
5741
|
+
const [mounted, setMounted] = (0, import_react37.useState)(false);
|
5742
|
+
(0, import_react37.useEffect)(() => {
|
5622
5743
|
setMounted(true);
|
5623
5744
|
}, []);
|
5624
5745
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
5625
|
-
const selectedComponentLabel = selectedItem ? (
|
5626
|
-
return /* @__PURE__ */ (0,
|
5627
|
-
/* @__PURE__ */ (0,
|
5746
|
+
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
5747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
5748
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5628
5749
|
AppProvider,
|
5629
5750
|
{
|
5630
5751
|
value: {
|
@@ -5646,7 +5767,7 @@ function Puck({
|
|
5646
5767
|
getPermissions: () => ({}),
|
5647
5768
|
refreshPermissions: () => null
|
5648
5769
|
},
|
5649
|
-
children: /* @__PURE__ */ (0,
|
5770
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(appContext.Consumer, { children: ({ resolveData }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5650
5771
|
DragDropContext,
|
5651
5772
|
{
|
5652
5773
|
autoScrollerOptions: { disabled: dnd == null ? void 0 : dnd.disableAutoScroll },
|
@@ -5698,7 +5819,7 @@ function Puck({
|
|
5698
5819
|
});
|
5699
5820
|
}
|
5700
5821
|
},
|
5701
|
-
children: /* @__PURE__ */ (0,
|
5822
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5702
5823
|
DropZoneProvider,
|
5703
5824
|
{
|
5704
5825
|
value: {
|
@@ -5712,7 +5833,7 @@ function Puck({
|
|
5712
5833
|
mode: "edit",
|
5713
5834
|
areaId: "root"
|
5714
5835
|
},
|
5715
|
-
children: /* @__PURE__ */ (0,
|
5836
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5716
5837
|
"div",
|
5717
5838
|
{
|
5718
5839
|
className: getLayoutClassName({
|
@@ -5721,58 +5842,58 @@ function Puck({
|
|
5721
5842
|
mounted,
|
5722
5843
|
rightSideBarVisible
|
5723
5844
|
}),
|
5724
|
-
children: /* @__PURE__ */ (0,
|
5725
|
-
/* @__PURE__ */ (0,
|
5845
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
5846
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5726
5847
|
CustomHeader,
|
5727
5848
|
{
|
5728
|
-
actions: /* @__PURE__ */ (0,
|
5849
|
+
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)(
|
5729
5850
|
Button,
|
5730
5851
|
{
|
5731
5852
|
onClick: () => {
|
5732
5853
|
onPublish && onPublish(data);
|
5733
5854
|
},
|
5734
|
-
icon: /* @__PURE__ */ (0,
|
5855
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
5735
5856
|
children: "Publish"
|
5736
5857
|
}
|
5737
5858
|
) }) }),
|
5738
|
-
children: /* @__PURE__ */ (0,
|
5739
|
-
/* @__PURE__ */ (0,
|
5859
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
5860
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
5740
5861
|
"div",
|
5741
5862
|
{
|
5742
5863
|
className: getLayoutClassName("headerToggle"),
|
5743
5864
|
children: [
|
5744
|
-
/* @__PURE__ */ (0,
|
5865
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5745
5866
|
"div",
|
5746
5867
|
{
|
5747
5868
|
className: getLayoutClassName(
|
5748
5869
|
"leftSideBarToggle"
|
5749
5870
|
),
|
5750
|
-
children: /* @__PURE__ */ (0,
|
5871
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5751
5872
|
IconButton,
|
5752
5873
|
{
|
5753
5874
|
onClick: () => {
|
5754
5875
|
toggleSidebars("left");
|
5755
5876
|
},
|
5756
5877
|
title: "Toggle left sidebar",
|
5757
|
-
children: /* @__PURE__ */ (0,
|
5878
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
5758
5879
|
}
|
5759
5880
|
)
|
5760
5881
|
}
|
5761
5882
|
),
|
5762
|
-
/* @__PURE__ */ (0,
|
5883
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5763
5884
|
"div",
|
5764
5885
|
{
|
5765
5886
|
className: getLayoutClassName(
|
5766
5887
|
"rightSideBarToggle"
|
5767
5888
|
),
|
5768
|
-
children: /* @__PURE__ */ (0,
|
5889
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5769
5890
|
IconButton,
|
5770
5891
|
{
|
5771
5892
|
onClick: () => {
|
5772
5893
|
toggleSidebars("right");
|
5773
5894
|
},
|
5774
5895
|
title: "Toggle right sidebar",
|
5775
|
-
children: /* @__PURE__ */ (0,
|
5896
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
5776
5897
|
}
|
5777
5898
|
)
|
5778
5899
|
}
|
@@ -5780,15 +5901,15 @@ function Puck({
|
|
5780
5901
|
]
|
5781
5902
|
}
|
5782
5903
|
),
|
5783
|
-
/* @__PURE__ */ (0,
|
5904
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5784
5905
|
"div",
|
5785
5906
|
{
|
5786
5907
|
className: getLayoutClassName("headerTitle"),
|
5787
|
-
children: /* @__PURE__ */ (0,
|
5908
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
5788
5909
|
headerTitle || rootProps.title || "Page",
|
5789
|
-
headerPath && /* @__PURE__ */ (0,
|
5910
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
5790
5911
|
" ",
|
5791
|
-
/* @__PURE__ */ (0,
|
5912
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5792
5913
|
"code",
|
5793
5914
|
{
|
5794
5915
|
className: getLayoutClassName(
|
@@ -5801,41 +5922,41 @@ function Puck({
|
|
5801
5922
|
] })
|
5802
5923
|
}
|
5803
5924
|
),
|
5804
|
-
/* @__PURE__ */ (0,
|
5925
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
5805
5926
|
"div",
|
5806
5927
|
{
|
5807
5928
|
className: getLayoutClassName("headerTools"),
|
5808
5929
|
children: [
|
5809
|
-
/* @__PURE__ */ (0,
|
5930
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5810
5931
|
"div",
|
5811
5932
|
{
|
5812
5933
|
className: getLayoutClassName("menuButton"),
|
5813
|
-
children: /* @__PURE__ */ (0,
|
5934
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5814
5935
|
IconButton,
|
5815
5936
|
{
|
5816
5937
|
onClick: () => {
|
5817
5938
|
return setMenuOpen(!menuOpen);
|
5818
5939
|
},
|
5819
5940
|
title: "Toggle menu bar",
|
5820
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
5941
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
5821
5942
|
}
|
5822
5943
|
)
|
5823
5944
|
}
|
5824
5945
|
),
|
5825
|
-
/* @__PURE__ */ (0,
|
5946
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5826
5947
|
MenuBar,
|
5827
5948
|
{
|
5828
5949
|
appState,
|
5829
5950
|
dispatch,
|
5830
5951
|
onPublish,
|
5831
5952
|
menuOpen,
|
5832
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
5953
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5833
5954
|
Button,
|
5834
5955
|
{
|
5835
5956
|
onClick: () => {
|
5836
5957
|
onPublish && onPublish(data);
|
5837
5958
|
},
|
5838
|
-
icon: /* @__PURE__ */ (0,
|
5959
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
5839
5960
|
children: "Publish"
|
5840
5961
|
}
|
5841
5962
|
) }),
|
@@ -5848,19 +5969,19 @@ function Puck({
|
|
5848
5969
|
] }) })
|
5849
5970
|
}
|
5850
5971
|
),
|
5851
|
-
/* @__PURE__ */ (0,
|
5852
|
-
/* @__PURE__ */ (0,
|
5853
|
-
/* @__PURE__ */ (0,
|
5972
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
5973
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
|
5974
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
|
5854
5975
|
] }),
|
5855
|
-
/* @__PURE__ */ (0,
|
5856
|
-
/* @__PURE__ */ (0,
|
5976
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
|
5977
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5857
5978
|
SidebarSection,
|
5858
5979
|
{
|
5859
5980
|
noPadding: true,
|
5860
5981
|
noBorderTop: true,
|
5861
5982
|
showBreadcrumbs: true,
|
5862
5983
|
title: selectedItem ? selectedComponentLabel : "Page",
|
5863
|
-
children: /* @__PURE__ */ (0,
|
5984
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
|
5864
5985
|
}
|
5865
5986
|
) })
|
5866
5987
|
] })
|
@@ -5872,7 +5993,7 @@ function Puck({
|
|
5872
5993
|
) })
|
5873
5994
|
}
|
5874
5995
|
),
|
5875
|
-
/* @__PURE__ */ (0,
|
5996
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
5876
5997
|
] });
|
5877
5998
|
}
|
5878
5999
|
Puck.Components = Components;
|
@@ -5882,7 +6003,7 @@ Puck.Preview = Preview;
|
|
5882
6003
|
|
5883
6004
|
// components/Render/index.tsx
|
5884
6005
|
init_react_import();
|
5885
|
-
var
|
6006
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
5886
6007
|
function Render({
|
5887
6008
|
config,
|
5888
6009
|
data
|
@@ -5895,7 +6016,7 @@ function Render({
|
|
5895
6016
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
5896
6017
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
5897
6018
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5898
|
-
return /* @__PURE__ */ (0,
|
6019
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
5899
6020
|
config.root.render,
|
5900
6021
|
__spreadProps(__spreadValues({}, rootProps), {
|
5901
6022
|
puck: {
|
@@ -5905,11 +6026,11 @@ function Render({
|
|
5905
6026
|
title,
|
5906
6027
|
editMode: false,
|
5907
6028
|
id: "puck-root",
|
5908
|
-
children: /* @__PURE__ */ (0,
|
6029
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DropZone, { zone: rootDroppableId })
|
5909
6030
|
})
|
5910
6031
|
) });
|
5911
6032
|
}
|
5912
|
-
return /* @__PURE__ */ (0,
|
6033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DropZone, { zone: rootDroppableId }) });
|
5913
6034
|
}
|
5914
6035
|
|
5915
6036
|
// lib/migrate.ts
|