@measured/puck 0.17.1 → 0.17.2-canary.66b30db
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 +648 -513
- package/dist/index.mjs +512 -374
- 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;
|
@@ -3918,19 +4009,33 @@ var useResolvedFields = () => {
|
|
3918
4009
|
lastData
|
3919
4010
|
});
|
3920
4011
|
}),
|
3921
|
-
[data, config, componentData, selectedItem, resolvedFields, state]
|
4012
|
+
[data, config, componentData, selectedItem, resolvedFields, state, parent]
|
3922
4013
|
);
|
3923
|
-
(0,
|
3924
|
-
|
3925
|
-
|
3926
|
-
|
3927
|
-
|
3928
|
-
|
3929
|
-
|
3930
|
-
|
3931
|
-
|
4014
|
+
const [hasParent, setHasParent] = (0, import_react26.useState)(false);
|
4015
|
+
(0, import_react26.useEffect)(() => {
|
4016
|
+
setHasParent(!!parent);
|
4017
|
+
}, [parent]);
|
4018
|
+
(0, import_react26.useEffect)(() => {
|
4019
|
+
var _a2;
|
4020
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || hasParent) {
|
4021
|
+
if (hasResolver) {
|
4022
|
+
setFieldsLoading(true);
|
4023
|
+
resolveFields(defaultFields).then((fields) => {
|
4024
|
+
setResolvedFields(fields || {});
|
4025
|
+
setFieldsLoading(false);
|
4026
|
+
});
|
4027
|
+
} else {
|
4028
|
+
setResolvedFields(defaultFields);
|
4029
|
+
}
|
3932
4030
|
}
|
3933
|
-
}, [
|
4031
|
+
}, [
|
4032
|
+
data,
|
4033
|
+
defaultFields,
|
4034
|
+
state.ui.itemSelector,
|
4035
|
+
selectedItem,
|
4036
|
+
hasResolver,
|
4037
|
+
hasParent
|
4038
|
+
]);
|
3934
4039
|
return [resolvedFields, fieldsLoading];
|
3935
4040
|
};
|
3936
4041
|
var Fields = () => {
|
@@ -3951,8 +4056,8 @@ var Fields = () => {
|
|
3951
4056
|
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
4057
|
const isLoading = fieldsResolving || componentResolving;
|
3953
4058
|
const rootProps = data.root.props || data.root;
|
3954
|
-
const Wrapper = (0,
|
3955
|
-
return /* @__PURE__ */ (0,
|
4059
|
+
const Wrapper = (0, import_react26.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
4060
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
3956
4061
|
"form",
|
3957
4062
|
{
|
3958
4063
|
className: getClassName21(),
|
@@ -3960,7 +4065,7 @@ var Fields = () => {
|
|
3960
4065
|
e.preventDefault();
|
3961
4066
|
},
|
3962
4067
|
children: [
|
3963
|
-
/* @__PURE__ */ (0,
|
4068
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
3964
4069
|
const field = fields[fieldName];
|
3965
4070
|
if (!(field == null ? void 0 : field.type)) return null;
|
3966
4071
|
const onChange = (value, updatedUi) => {
|
@@ -4031,7 +4136,7 @@ var Fields = () => {
|
|
4031
4136
|
item: selectedItem
|
4032
4137
|
});
|
4033
4138
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
4034
|
-
return /* @__PURE__ */ (0,
|
4139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
4035
4140
|
AutoFieldPrivate,
|
4036
4141
|
{
|
4037
4142
|
field,
|
@@ -4049,7 +4154,7 @@ var Fields = () => {
|
|
4049
4154
|
root: true
|
4050
4155
|
});
|
4051
4156
|
const id = `root_${field.type}_${fieldName}`;
|
4052
|
-
return /* @__PURE__ */ (0,
|
4157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
4053
4158
|
AutoFieldPrivate,
|
4054
4159
|
{
|
4055
4160
|
field,
|
@@ -4063,7 +4168,7 @@ var Fields = () => {
|
|
4063
4168
|
);
|
4064
4169
|
}
|
4065
4170
|
}) }),
|
4066
|
-
isLoading && /* @__PURE__ */ (0,
|
4171
|
+
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
4172
|
]
|
4068
4173
|
}
|
4069
4174
|
);
|
@@ -4074,7 +4179,7 @@ init_react_import();
|
|
4074
4179
|
|
4075
4180
|
// lib/use-component-list.tsx
|
4076
4181
|
init_react_import();
|
4077
|
-
var
|
4182
|
+
var import_react27 = require("react");
|
4078
4183
|
|
4079
4184
|
// components/ComponentList/index.tsx
|
4080
4185
|
init_react_import();
|
@@ -4084,7 +4189,7 @@ init_react_import();
|
|
4084
4189
|
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
4190
|
|
4086
4191
|
// components/ComponentList/index.tsx
|
4087
|
-
var
|
4192
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
4088
4193
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
4089
4194
|
var ComponentListItem = ({
|
4090
4195
|
name,
|
@@ -4095,7 +4200,7 @@ var ComponentListItem = ({
|
|
4095
4200
|
const canInsert = getPermissions({
|
4096
4201
|
type: name
|
4097
4202
|
}).insert;
|
4098
|
-
return /* @__PURE__ */ (0,
|
4203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
4099
4204
|
Drawer.Item,
|
4100
4205
|
{
|
4101
4206
|
label,
|
@@ -4113,8 +4218,8 @@ var ComponentList = ({
|
|
4113
4218
|
}) => {
|
4114
4219
|
const { config, state, setUi } = useAppContext();
|
4115
4220
|
const { expanded = true } = state.ui.componentList[id] || {};
|
4116
|
-
return /* @__PURE__ */ (0,
|
4117
|
-
title && /* @__PURE__ */ (0,
|
4221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
4222
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
4118
4223
|
"button",
|
4119
4224
|
{
|
4120
4225
|
type: "button",
|
@@ -4128,14 +4233,14 @@ var ComponentList = ({
|
|
4128
4233
|
}),
|
4129
4234
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
4130
4235
|
children: [
|
4131
|
-
/* @__PURE__ */ (0,
|
4132
|
-
/* @__PURE__ */ (0,
|
4236
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: title }),
|
4237
|
+
/* @__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
4238
|
]
|
4134
4239
|
}
|
4135
4240
|
),
|
4136
|
-
/* @__PURE__ */ (0,
|
4241
|
+
/* @__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
4242
|
var _a;
|
4138
|
-
return /* @__PURE__ */ (0,
|
4243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
4139
4244
|
ComponentListItem,
|
4140
4245
|
{
|
4141
4246
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -4150,10 +4255,10 @@ var ComponentList = ({
|
|
4150
4255
|
ComponentList.Item = ComponentListItem;
|
4151
4256
|
|
4152
4257
|
// lib/use-component-list.tsx
|
4153
|
-
var
|
4258
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
4154
4259
|
var useComponentList = (config, ui) => {
|
4155
|
-
const [componentList, setComponentList] = (0,
|
4156
|
-
(0,
|
4260
|
+
const [componentList, setComponentList] = (0, import_react27.useState)();
|
4261
|
+
(0, import_react27.useEffect)(() => {
|
4157
4262
|
var _a, _b, _c;
|
4158
4263
|
if (Object.keys(ui.componentList).length > 0) {
|
4159
4264
|
const matchedComponents = [];
|
@@ -4163,7 +4268,7 @@ var useComponentList = (config, ui) => {
|
|
4163
4268
|
if (category.visible === false || !category.components) {
|
4164
4269
|
return null;
|
4165
4270
|
}
|
4166
|
-
return /* @__PURE__ */ (0,
|
4271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4167
4272
|
ComponentList,
|
4168
4273
|
{
|
4169
4274
|
id: categoryKey,
|
@@ -4172,7 +4277,7 @@ var useComponentList = (config, ui) => {
|
|
4172
4277
|
var _a2;
|
4173
4278
|
matchedComponents.push(componentName);
|
4174
4279
|
const componentConf = config.components[componentName] || {};
|
4175
|
-
return /* @__PURE__ */ (0,
|
4280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4176
4281
|
ComponentList.Item,
|
4177
4282
|
{
|
4178
4283
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -4192,7 +4297,7 @@ var useComponentList = (config, ui) => {
|
|
4192
4297
|
);
|
4193
4298
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
4194
4299
|
_componentList.push(
|
4195
|
-
/* @__PURE__ */ (0,
|
4300
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4196
4301
|
ComponentList,
|
4197
4302
|
{
|
4198
4303
|
id: "other",
|
@@ -4200,7 +4305,7 @@ var useComponentList = (config, ui) => {
|
|
4200
4305
|
children: remainingComponents.map((componentName, i) => {
|
4201
4306
|
var _a2;
|
4202
4307
|
const componentConf = config.components[componentName] || {};
|
4203
|
-
return /* @__PURE__ */ (0,
|
4308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4204
4309
|
ComponentList.Item,
|
4205
4310
|
{
|
4206
4311
|
name: componentName,
|
@@ -4222,25 +4327,25 @@ var useComponentList = (config, ui) => {
|
|
4222
4327
|
};
|
4223
4328
|
|
4224
4329
|
// components/Puck/components/Components/index.tsx
|
4225
|
-
var
|
4226
|
-
var
|
4330
|
+
var import_react28 = require("react");
|
4331
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
4227
4332
|
var Components = () => {
|
4228
4333
|
const { config, state, overrides } = useAppContext();
|
4229
4334
|
const componentList = useComponentList(config, state.ui);
|
4230
|
-
const Wrapper = (0,
|
4231
|
-
return /* @__PURE__ */ (0,
|
4335
|
+
const Wrapper = (0, import_react28.useMemo)(() => overrides.components || "div", [overrides]);
|
4336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComponentList, { id: "all" }) });
|
4232
4337
|
};
|
4233
4338
|
|
4234
4339
|
// components/Puck/components/Preview/index.tsx
|
4235
4340
|
init_react_import();
|
4236
|
-
var
|
4341
|
+
var import_react30 = require("react");
|
4237
4342
|
|
4238
4343
|
// components/AutoFrame/index.tsx
|
4239
4344
|
init_react_import();
|
4240
|
-
var
|
4345
|
+
var import_react29 = require("react");
|
4241
4346
|
var import_object_hash = __toESM(require("object-hash"));
|
4242
4347
|
var import_react_dom2 = require("react-dom");
|
4243
|
-
var
|
4348
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
4244
4349
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
4245
4350
|
var collectStyles = (doc) => {
|
4246
4351
|
const collected = [];
|
@@ -4283,7 +4388,7 @@ var CopyHostStyles = ({
|
|
4283
4388
|
onStylesLoaded = () => null
|
4284
4389
|
}) => {
|
4285
4390
|
const { document: doc, window: win } = useFrame();
|
4286
|
-
(0,
|
4391
|
+
(0, import_react29.useEffect)(() => {
|
4287
4392
|
if (!win || !doc) {
|
4288
4393
|
return () => {
|
4289
4394
|
};
|
@@ -4440,10 +4545,10 @@ var CopyHostStyles = ({
|
|
4440
4545
|
observer.disconnect();
|
4441
4546
|
};
|
4442
4547
|
}, []);
|
4443
|
-
return /* @__PURE__ */ (0,
|
4548
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
|
4444
4549
|
};
|
4445
|
-
var autoFrameContext = (0,
|
4446
|
-
var useFrame = () => (0,
|
4550
|
+
var autoFrameContext = (0, import_react29.createContext)({});
|
4551
|
+
var useFrame = () => (0, import_react29.useContext)(autoFrameContext);
|
4447
4552
|
function AutoFrame(_a) {
|
4448
4553
|
var _b = _a, {
|
4449
4554
|
children,
|
@@ -4458,11 +4563,11 @@ function AutoFrame(_a) {
|
|
4458
4563
|
"id",
|
4459
4564
|
"onStylesLoaded"
|
4460
4565
|
]);
|
4461
|
-
const [loaded, setLoaded] = (0,
|
4462
|
-
const [ctx, setCtx] = (0,
|
4463
|
-
const ref = (0,
|
4464
|
-
const [mountTarget, setMountTarget] = (0,
|
4465
|
-
(0,
|
4566
|
+
const [loaded, setLoaded] = (0, import_react29.useState)(false);
|
4567
|
+
const [ctx, setCtx] = (0, import_react29.useState)({});
|
4568
|
+
const ref = (0, import_react29.useRef)(null);
|
4569
|
+
const [mountTarget, setMountTarget] = (0, import_react29.useState)();
|
4570
|
+
(0, import_react29.useEffect)(() => {
|
4466
4571
|
var _a2;
|
4467
4572
|
if (ref.current) {
|
4468
4573
|
setCtx({
|
@@ -4472,7 +4577,7 @@ function AutoFrame(_a) {
|
|
4472
4577
|
setMountTarget((_a2 = ref.current.contentDocument) == null ? void 0 : _a2.getElementById("frame-root"));
|
4473
4578
|
}
|
4474
4579
|
}, [ref, loaded]);
|
4475
|
-
return /* @__PURE__ */ (0,
|
4580
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
4476
4581
|
"iframe",
|
4477
4582
|
__spreadProps(__spreadValues({}, props), {
|
4478
4583
|
className,
|
@@ -4482,7 +4587,7 @@ function AutoFrame(_a) {
|
|
4482
4587
|
onLoad: () => {
|
4483
4588
|
setLoaded(true);
|
4484
4589
|
},
|
4485
|
-
children: /* @__PURE__ */ (0,
|
4590
|
+
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
4591
|
})
|
4487
4592
|
);
|
4488
4593
|
}
|
@@ -4494,22 +4599,22 @@ init_react_import();
|
|
4494
4599
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
|
4495
4600
|
|
4496
4601
|
// components/Puck/components/Preview/index.tsx
|
4497
|
-
var
|
4602
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
4498
4603
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
4499
4604
|
var Preview = ({ id = "puck-preview" }) => {
|
4500
4605
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
4501
|
-
const Page = (0,
|
4606
|
+
const Page = (0, import_react30.useCallback)(
|
4502
4607
|
(pageProps) => {
|
4503
4608
|
var _a, _b;
|
4504
4609
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
4505
4610
|
id: "puck-root"
|
4506
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
4611
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
4507
4612
|
},
|
4508
4613
|
[config.root]
|
4509
4614
|
);
|
4510
|
-
const Frame = (0,
|
4615
|
+
const Frame = (0, import_react30.useMemo)(() => overrides.iframe, [overrides]);
|
4511
4616
|
const rootProps = state.data.root.props || state.data.root;
|
4512
|
-
return /* @__PURE__ */ (0,
|
4617
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4513
4618
|
"div",
|
4514
4619
|
{
|
4515
4620
|
className: getClassName23(),
|
@@ -4517,7 +4622,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4517
4622
|
onClick: () => {
|
4518
4623
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
4519
4624
|
},
|
4520
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
4625
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4521
4626
|
AutoFrame_default,
|
4522
4627
|
{
|
4523
4628
|
id: "preview-frame",
|
@@ -4526,27 +4631,27 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4526
4631
|
onStylesLoaded: () => {
|
4527
4632
|
setStatus("READY");
|
4528
4633
|
},
|
4529
|
-
children: /* @__PURE__ */ (0,
|
4530
|
-
const inner = /* @__PURE__ */ (0,
|
4634
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
4635
|
+
const inner = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4531
4636
|
Page,
|
4532
4637
|
__spreadProps(__spreadValues({}, rootProps), {
|
4533
4638
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4534
4639
|
editMode: true,
|
4535
|
-
children: /* @__PURE__ */ (0,
|
4640
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
4536
4641
|
})
|
4537
4642
|
);
|
4538
4643
|
if (Frame) {
|
4539
|
-
return /* @__PURE__ */ (0,
|
4644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
4540
4645
|
}
|
4541
4646
|
return inner;
|
4542
4647
|
} })
|
4543
4648
|
}
|
4544
|
-
) : /* @__PURE__ */ (0,
|
4649
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4545
4650
|
Page,
|
4546
4651
|
__spreadProps(__spreadValues({}, rootProps), {
|
4547
4652
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4548
4653
|
editMode: true,
|
4549
|
-
children: /* @__PURE__ */ (0,
|
4654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
4550
4655
|
})
|
4551
4656
|
) })
|
4552
4657
|
}
|
@@ -4596,7 +4701,7 @@ var scrollIntoView = (el) => {
|
|
4596
4701
|
};
|
4597
4702
|
|
4598
4703
|
// components/LayerTree/index.tsx
|
4599
|
-
var
|
4704
|
+
var import_react31 = require("react");
|
4600
4705
|
|
4601
4706
|
// lib/is-child-of-zone.ts
|
4602
4707
|
init_react_import();
|
@@ -4610,7 +4715,7 @@ var isChildOfZone = (item, maybeChild, ctx) => {
|
|
4610
4715
|
};
|
4611
4716
|
|
4612
4717
|
// components/LayerTree/index.tsx
|
4613
|
-
var
|
4718
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
4614
4719
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
4615
4720
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
4616
4721
|
var LayerTree = ({
|
@@ -4623,15 +4728,15 @@ var LayerTree = ({
|
|
4623
4728
|
label
|
4624
4729
|
}) => {
|
4625
4730
|
const zones = data.zones || {};
|
4626
|
-
const ctx = (0,
|
4627
|
-
return /* @__PURE__ */ (0,
|
4628
|
-
label && /* @__PURE__ */ (0,
|
4629
|
-
/* @__PURE__ */ (0,
|
4731
|
+
const ctx = (0, import_react31.useContext)(dropZoneContext);
|
4732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
4733
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
4734
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
4630
4735
|
" ",
|
4631
4736
|
label
|
4632
4737
|
] }),
|
4633
|
-
/* @__PURE__ */ (0,
|
4634
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
4738
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
|
4739
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
4635
4740
|
zoneContent.map((item, i) => {
|
4636
4741
|
var _a;
|
4637
4742
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -4649,7 +4754,7 @@ var LayerTree = ({
|
|
4649
4754
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
4650
4755
|
const componentConfig = config.components[item.type];
|
4651
4756
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
4652
|
-
return /* @__PURE__ */ (0,
|
4757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
4653
4758
|
"li",
|
4654
4759
|
{
|
4655
4760
|
className: getClassNameLayer({
|
@@ -4659,7 +4764,7 @@ var LayerTree = ({
|
|
4659
4764
|
childIsSelected
|
4660
4765
|
}),
|
4661
4766
|
children: [
|
4662
|
-
/* @__PURE__ */ (0,
|
4767
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
4663
4768
|
"button",
|
4664
4769
|
{
|
4665
4770
|
type: "button",
|
@@ -4692,22 +4797,22 @@ var LayerTree = ({
|
|
4692
4797
|
setHoveringComponent(null);
|
4693
4798
|
},
|
4694
4799
|
children: [
|
4695
|
-
containsZone && /* @__PURE__ */ (0,
|
4800
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
4696
4801
|
"div",
|
4697
4802
|
{
|
4698
4803
|
className: getClassNameLayer("chevron"),
|
4699
4804
|
title: isSelected ? "Collapse" : "Expand",
|
4700
|
-
children: /* @__PURE__ */ (0,
|
4805
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
4701
4806
|
}
|
4702
4807
|
),
|
4703
|
-
/* @__PURE__ */ (0,
|
4704
|
-
/* @__PURE__ */ (0,
|
4705
|
-
/* @__PURE__ */ (0,
|
4808
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
4809
|
+
/* @__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" }) }),
|
4810
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
4706
4811
|
] })
|
4707
4812
|
]
|
4708
4813
|
}
|
4709
4814
|
) }),
|
4710
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
4815
|
+
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
4816
|
LayerTree,
|
4712
4817
|
{
|
4713
4818
|
config,
|
@@ -4729,13 +4834,13 @@ var LayerTree = ({
|
|
4729
4834
|
};
|
4730
4835
|
|
4731
4836
|
// components/Puck/components/Outline/index.tsx
|
4732
|
-
var
|
4733
|
-
var
|
4837
|
+
var import_react32 = require("react");
|
4838
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
4734
4839
|
var Outline = () => {
|
4735
4840
|
const { dispatch, state, overrides, config } = useAppContext();
|
4736
4841
|
const { data, ui } = state;
|
4737
4842
|
const { itemSelector } = ui;
|
4738
|
-
const setItemSelector = (0,
|
4843
|
+
const setItemSelector = (0, import_react32.useCallback)(
|
4739
4844
|
(newItemSelector) => {
|
4740
4845
|
dispatch({
|
4741
4846
|
type: "setUi",
|
@@ -4744,9 +4849,9 @@ var Outline = () => {
|
|
4744
4849
|
},
|
4745
4850
|
[]
|
4746
4851
|
);
|
4747
|
-
const Wrapper = (0,
|
4748
|
-
return /* @__PURE__ */ (0,
|
4749
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
4852
|
+
const Wrapper = (0, import_react32.useMemo)(() => overrides.outline || "div", [overrides]);
|
4853
|
+
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: [
|
4854
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4750
4855
|
LayerTree,
|
4751
4856
|
{
|
4752
4857
|
config,
|
@@ -4759,7 +4864,7 @@ var Outline = () => {
|
|
4759
4864
|
),
|
4760
4865
|
Object.entries(findZonesForArea(data, "root")).map(
|
4761
4866
|
([zoneKey, zone]) => {
|
4762
|
-
return /* @__PURE__ */ (0,
|
4867
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4763
4868
|
LayerTree,
|
4764
4869
|
{
|
4765
4870
|
config,
|
@@ -4783,7 +4888,8 @@ var import_react_hotkeys_hook = require("react-hotkeys-hook");
|
|
4783
4888
|
function usePuckHistory({
|
4784
4889
|
dispatch,
|
4785
4890
|
initialAppState,
|
4786
|
-
historyStore
|
4891
|
+
historyStore,
|
4892
|
+
iframeEnabled
|
4787
4893
|
}) {
|
4788
4894
|
const back = () => {
|
4789
4895
|
var _a;
|
@@ -4801,6 +4907,16 @@ function usePuckHistory({
|
|
4801
4907
|
historyStore.forward();
|
4802
4908
|
}
|
4803
4909
|
};
|
4910
|
+
const backIframe = () => {
|
4911
|
+
if (iframeEnabled) {
|
4912
|
+
back();
|
4913
|
+
}
|
4914
|
+
};
|
4915
|
+
const forwardIframe = () => {
|
4916
|
+
if (iframeEnabled) {
|
4917
|
+
forward();
|
4918
|
+
}
|
4919
|
+
};
|
4804
4920
|
const setHistories = (histories) => {
|
4805
4921
|
var _a;
|
4806
4922
|
dispatch({
|
@@ -4819,9 +4935,23 @@ function usePuckHistory({
|
|
4819
4935
|
historyStore.setHistoryIndex(index);
|
4820
4936
|
}
|
4821
4937
|
};
|
4938
|
+
const frame = getFrame();
|
4939
|
+
const resolvedFrame = frame !== document ? frame : void 0;
|
4822
4940
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+z", back, { preventDefault: true });
|
4823
4941
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+shift+z", forward, { preventDefault: true });
|
4824
4942
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+y", forward, { preventDefault: true });
|
4943
|
+
(0, import_react_hotkeys_hook.useHotkeys)("meta+z", backIframe, {
|
4944
|
+
preventDefault: true,
|
4945
|
+
document: resolvedFrame
|
4946
|
+
});
|
4947
|
+
(0, import_react_hotkeys_hook.useHotkeys)("meta+shift+z", forwardIframe, {
|
4948
|
+
preventDefault: true,
|
4949
|
+
document: resolvedFrame
|
4950
|
+
});
|
4951
|
+
(0, import_react_hotkeys_hook.useHotkeys)("meta+y", forwardIframe, {
|
4952
|
+
preventDefault: true,
|
4953
|
+
document: resolvedFrame
|
4954
|
+
});
|
4825
4955
|
return {
|
4826
4956
|
back,
|
4827
4957
|
forward,
|
@@ -4833,19 +4963,19 @@ function usePuckHistory({
|
|
4833
4963
|
|
4834
4964
|
// lib/use-history-store.ts
|
4835
4965
|
init_react_import();
|
4836
|
-
var
|
4966
|
+
var import_react33 = require("react");
|
4837
4967
|
var import_use_debounce3 = require("use-debounce");
|
4838
4968
|
var EMPTY_HISTORY_INDEX = 0;
|
4839
4969
|
function useHistoryStore(initialHistory) {
|
4840
4970
|
var _a, _b;
|
4841
|
-
const [histories, setHistories] = (0,
|
4971
|
+
const [histories, setHistories] = (0, import_react33.useState)(
|
4842
4972
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
4843
4973
|
);
|
4844
4974
|
const updateHistories = (histories2) => {
|
4845
4975
|
setHistories(histories2);
|
4846
4976
|
setIndex(histories2.length - 1);
|
4847
4977
|
};
|
4848
|
-
const [index, setIndex] = (0,
|
4978
|
+
const [index, setIndex] = (0, import_react33.useState)(
|
4849
4979
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
4850
4980
|
);
|
4851
4981
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -5005,22 +5135,22 @@ var getBox = function getBox2(el) {
|
|
5005
5135
|
};
|
5006
5136
|
|
5007
5137
|
// components/Puck/components/Canvas/index.tsx
|
5008
|
-
var
|
5138
|
+
var import_react35 = require("react");
|
5009
5139
|
|
5010
5140
|
// components/ViewportControls/index.tsx
|
5011
5141
|
init_react_import();
|
5012
|
-
var
|
5142
|
+
var import_react34 = require("react");
|
5013
5143
|
|
5014
5144
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
5015
5145
|
init_react_import();
|
5016
5146
|
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
5147
|
|
5018
5148
|
// components/ViewportControls/index.tsx
|
5019
|
-
var
|
5149
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
5020
5150
|
var icons = {
|
5021
|
-
Smartphone: /* @__PURE__ */ (0,
|
5022
|
-
Tablet: /* @__PURE__ */ (0,
|
5023
|
-
Monitor: /* @__PURE__ */ (0,
|
5151
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
|
5152
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
|
5153
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
|
5024
5154
|
};
|
5025
5155
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
5026
5156
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -5032,11 +5162,11 @@ var ViewportButton = ({
|
|
5032
5162
|
onClick
|
5033
5163
|
}) => {
|
5034
5164
|
const { state } = useAppContext();
|
5035
|
-
const [isActive, setIsActive] = (0,
|
5036
|
-
(0,
|
5165
|
+
const [isActive, setIsActive] = (0, import_react34.useState)(false);
|
5166
|
+
(0, import_react34.useEffect)(() => {
|
5037
5167
|
setIsActive(width === state.ui.viewports.current.width);
|
5038
5168
|
}, [width, state.ui.viewports.current.width]);
|
5039
|
-
return /* @__PURE__ */ (0,
|
5169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5040
5170
|
IconButton,
|
5041
5171
|
{
|
5042
5172
|
title,
|
@@ -5045,7 +5175,7 @@ var ViewportButton = ({
|
|
5045
5175
|
e.stopPropagation();
|
5046
5176
|
onClick({ width, height });
|
5047
5177
|
},
|
5048
|
-
children: /* @__PURE__ */ (0,
|
5178
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
|
5049
5179
|
}
|
5050
5180
|
) });
|
5051
5181
|
};
|
@@ -5069,7 +5199,7 @@ var ViewportControls = ({
|
|
5069
5199
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
5070
5200
|
(option) => option.value === autoZoom
|
5071
5201
|
);
|
5072
|
-
const zoomOptions = (0,
|
5202
|
+
const zoomOptions = (0, import_react34.useMemo)(
|
5073
5203
|
() => [
|
5074
5204
|
...defaultZoomOptions,
|
5075
5205
|
...defaultsContainAutoZoom ? [] : [
|
@@ -5081,8 +5211,8 @@ var ViewportControls = ({
|
|
5081
5211
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
5082
5212
|
[autoZoom]
|
5083
5213
|
);
|
5084
|
-
return /* @__PURE__ */ (0,
|
5085
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
5214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
|
5215
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5086
5216
|
ViewportButton,
|
5087
5217
|
{
|
5088
5218
|
height: viewport.height,
|
@@ -5093,8 +5223,8 @@ var ViewportControls = ({
|
|
5093
5223
|
},
|
5094
5224
|
i
|
5095
5225
|
)),
|
5096
|
-
/* @__PURE__ */ (0,
|
5097
|
-
/* @__PURE__ */ (0,
|
5226
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
5227
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5098
5228
|
IconButton,
|
5099
5229
|
{
|
5100
5230
|
title: "Zoom viewport out",
|
@@ -5108,10 +5238,10 @@ var ViewportControls = ({
|
|
5108
5238
|
)].value
|
5109
5239
|
);
|
5110
5240
|
},
|
5111
|
-
children: /* @__PURE__ */ (0,
|
5241
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
|
5112
5242
|
}
|
5113
5243
|
),
|
5114
|
-
/* @__PURE__ */ (0,
|
5244
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5115
5245
|
IconButton,
|
5116
5246
|
{
|
5117
5247
|
title: "Zoom viewport in",
|
@@ -5125,11 +5255,11 @@ var ViewportControls = ({
|
|
5125
5255
|
)].value
|
5126
5256
|
);
|
5127
5257
|
},
|
5128
|
-
children: /* @__PURE__ */ (0,
|
5258
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
|
5129
5259
|
}
|
5130
5260
|
),
|
5131
|
-
/* @__PURE__ */ (0,
|
5132
|
-
/* @__PURE__ */ (0,
|
5261
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
5262
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5133
5263
|
"select",
|
5134
5264
|
{
|
5135
5265
|
className: getClassName25("zoomSelect"),
|
@@ -5137,7 +5267,7 @@ var ViewportControls = ({
|
|
5137
5267
|
onChange: (e) => {
|
5138
5268
|
onZoom(parseFloat(e.currentTarget.value));
|
5139
5269
|
},
|
5140
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
5270
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5141
5271
|
"option",
|
5142
5272
|
{
|
5143
5273
|
value: option.value,
|
@@ -5152,7 +5282,7 @@ var ViewportControls = ({
|
|
5152
5282
|
|
5153
5283
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
5154
5284
|
init_react_import();
|
5155
|
-
var styles_module_default21 = { "PuckCanvas": "
|
5285
|
+
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
5286
|
|
5157
5287
|
// lib/get-zoom-config.ts
|
5158
5288
|
init_react_import();
|
@@ -5185,24 +5315,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
5185
5315
|
};
|
5186
5316
|
|
5187
5317
|
// components/Puck/components/Canvas/index.tsx
|
5188
|
-
var
|
5318
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
5189
5319
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
5190
5320
|
var ZOOM_ON_CHANGE = true;
|
5191
5321
|
var Canvas = () => {
|
5192
5322
|
const { status, iframe } = useAppContext();
|
5193
5323
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
5194
5324
|
const { ui } = state;
|
5195
|
-
const frameRef = (0,
|
5196
|
-
const [showTransition, setShowTransition] = (0,
|
5197
|
-
const defaultRender = (0,
|
5198
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
5325
|
+
const frameRef = (0, import_react35.useRef)(null);
|
5326
|
+
const [showTransition, setShowTransition] = (0, import_react35.useState)(false);
|
5327
|
+
const defaultRender = (0, import_react35.useMemo)(() => {
|
5328
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
5199
5329
|
return PuckDefault;
|
5200
5330
|
}, []);
|
5201
|
-
const CustomPreview = (0,
|
5331
|
+
const CustomPreview = (0, import_react35.useMemo)(
|
5202
5332
|
() => overrides.preview || defaultRender,
|
5203
5333
|
[overrides]
|
5204
5334
|
);
|
5205
|
-
const getFrameDimensions = (0,
|
5335
|
+
const getFrameDimensions = (0, import_react35.useCallback)(() => {
|
5206
5336
|
if (frameRef.current) {
|
5207
5337
|
const frame = frameRef.current;
|
5208
5338
|
const box = getBox(frame);
|
@@ -5210,7 +5340,7 @@ var Canvas = () => {
|
|
5210
5340
|
}
|
5211
5341
|
return { width: 0, height: 0 };
|
5212
5342
|
}, [frameRef]);
|
5213
|
-
const resetAutoZoom = (0,
|
5343
|
+
const resetAutoZoom = (0, import_react35.useCallback)(
|
5214
5344
|
(ui2 = state.ui) => {
|
5215
5345
|
if (frameRef.current) {
|
5216
5346
|
setZoomConfig(
|
@@ -5220,11 +5350,11 @@ var Canvas = () => {
|
|
5220
5350
|
},
|
5221
5351
|
[frameRef, zoomConfig, state.ui]
|
5222
5352
|
);
|
5223
|
-
(0,
|
5353
|
+
(0, import_react35.useEffect)(() => {
|
5224
5354
|
setShowTransition(false);
|
5225
5355
|
resetAutoZoom();
|
5226
5356
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
5227
|
-
(0,
|
5357
|
+
(0, import_react35.useEffect)(() => {
|
5228
5358
|
const { height: frameHeight } = getFrameDimensions();
|
5229
5359
|
if (ui.viewports.current.height === "auto") {
|
5230
5360
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -5232,13 +5362,13 @@ var Canvas = () => {
|
|
5232
5362
|
}));
|
5233
5363
|
}
|
5234
5364
|
}, [zoomConfig.zoom]);
|
5235
|
-
(0,
|
5365
|
+
(0, import_react35.useEffect)(() => {
|
5236
5366
|
if (ZOOM_ON_CHANGE) {
|
5237
5367
|
setShowTransition(true);
|
5238
5368
|
resetAutoZoom(ui);
|
5239
5369
|
}
|
5240
5370
|
}, [ui.viewports.current.width]);
|
5241
|
-
(0,
|
5371
|
+
(0, import_react35.useEffect)(() => {
|
5242
5372
|
const observer = new ResizeObserver(() => {
|
5243
5373
|
setShowTransition(false);
|
5244
5374
|
resetAutoZoom();
|
@@ -5250,13 +5380,13 @@ var Canvas = () => {
|
|
5250
5380
|
observer.disconnect();
|
5251
5381
|
};
|
5252
5382
|
}, []);
|
5253
|
-
const [showLoader, setShowLoader] = (0,
|
5254
|
-
(0,
|
5383
|
+
const [showLoader, setShowLoader] = (0, import_react35.useState)(false);
|
5384
|
+
(0, import_react35.useEffect)(() => {
|
5255
5385
|
setTimeout(() => {
|
5256
5386
|
setShowLoader(true);
|
5257
5387
|
}, 500);
|
5258
5388
|
}, []);
|
5259
|
-
return /* @__PURE__ */ (0,
|
5389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
5260
5390
|
"div",
|
5261
5391
|
{
|
5262
5392
|
className: getClassName26({
|
@@ -5269,7 +5399,7 @@ var Canvas = () => {
|
|
5269
5399
|
recordHistory: true
|
5270
5400
|
}),
|
5271
5401
|
children: [
|
5272
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
5402
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
5273
5403
|
ViewportControls,
|
5274
5404
|
{
|
5275
5405
|
autoZoom: zoomConfig.autoZoom,
|
@@ -5294,8 +5424,8 @@ var Canvas = () => {
|
|
5294
5424
|
}
|
5295
5425
|
}
|
5296
5426
|
) }),
|
5297
|
-
/* @__PURE__ */ (0,
|
5298
|
-
/* @__PURE__ */ (0,
|
5427
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
5428
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
5299
5429
|
"div",
|
5300
5430
|
{
|
5301
5431
|
className: getClassName26("root"),
|
@@ -5307,10 +5437,10 @@ var Canvas = () => {
|
|
5307
5437
|
overflow: iframe.enabled ? void 0 : "auto"
|
5308
5438
|
},
|
5309
5439
|
suppressHydrationWarning: true,
|
5310
|
-
children: /* @__PURE__ */ (0,
|
5440
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview, {}) })
|
5311
5441
|
}
|
5312
5442
|
),
|
5313
|
-
/* @__PURE__ */ (0,
|
5443
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
5314
5444
|
] })
|
5315
5445
|
]
|
5316
5446
|
}
|
@@ -5354,7 +5484,7 @@ var insertComponent = (componentType, zone, index, {
|
|
5354
5484
|
|
5355
5485
|
// lib/use-loaded-overrides.ts
|
5356
5486
|
init_react_import();
|
5357
|
-
var
|
5487
|
+
var import_react36 = require("react");
|
5358
5488
|
|
5359
5489
|
// lib/load-overrides.ts
|
5360
5490
|
init_react_import();
|
@@ -5393,18 +5523,18 @@ var useLoadedOverrides = ({
|
|
5393
5523
|
overrides,
|
5394
5524
|
plugins
|
5395
5525
|
}) => {
|
5396
|
-
return (0,
|
5526
|
+
return (0, import_react36.useMemo)(() => {
|
5397
5527
|
return loadOverrides({ overrides, plugins });
|
5398
5528
|
}, [plugins, overrides]);
|
5399
5529
|
};
|
5400
5530
|
|
5401
5531
|
// components/DefaultOverride/index.tsx
|
5402
5532
|
init_react_import();
|
5403
|
-
var
|
5404
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
5533
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
5534
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
5405
5535
|
|
5406
5536
|
// components/Puck/index.tsx
|
5407
|
-
var
|
5537
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
5408
5538
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
5409
5539
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
5410
5540
|
function Puck({
|
@@ -5427,13 +5557,13 @@ function Puck({
|
|
5427
5557
|
dnd,
|
5428
5558
|
initialHistory: _initialHistory
|
5429
5559
|
}) {
|
5430
|
-
var _a;
|
5560
|
+
var _a, _b;
|
5431
5561
|
const iframe = __spreadValues({
|
5432
5562
|
enabled: true,
|
5433
5563
|
waitForStyles: true
|
5434
5564
|
}, _iframe);
|
5435
|
-
const [generatedAppState] = (0,
|
5436
|
-
var _a2,
|
5565
|
+
const [generatedAppState] = (0, import_react37.useState)(() => {
|
5566
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
5437
5567
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
5438
5568
|
let clientUiState = {};
|
5439
5569
|
if (typeof window !== "undefined") {
|
@@ -5453,7 +5583,7 @@ function Puck({
|
|
5453
5583
|
clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
|
5454
5584
|
viewports: __spreadProps(__spreadValues({}, initial.viewports), {
|
5455
5585
|
current: __spreadProps(__spreadValues({}, initial.viewports.current), {
|
5456
|
-
height: ((
|
5586
|
+
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
5587
|
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
5588
|
})
|
5459
5589
|
})
|
@@ -5504,22 +5634,27 @@ function Puck({
|
|
5504
5634
|
histories,
|
5505
5635
|
index: initialHistoryIndex
|
5506
5636
|
});
|
5507
|
-
const [reducer] = (0,
|
5637
|
+
const [reducer] = (0, import_react37.useState)(
|
5508
5638
|
() => createReducer({
|
5509
5639
|
config,
|
5510
5640
|
record: historyStore.record,
|
5511
5641
|
onAction
|
5512
5642
|
})
|
5513
5643
|
);
|
5514
|
-
const [appState, dispatch] = (0,
|
5644
|
+
const [appState, dispatch] = (0, import_react37.useReducer)(
|
5515
5645
|
reducer,
|
5516
5646
|
flushZones(initialAppState)
|
5517
5647
|
);
|
5518
5648
|
const { data, ui } = appState;
|
5519
|
-
const history = usePuckHistory({
|
5520
|
-
|
5649
|
+
const history = usePuckHistory({
|
5650
|
+
dispatch,
|
5651
|
+
initialAppState,
|
5652
|
+
historyStore,
|
5653
|
+
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
5654
|
+
});
|
5655
|
+
const [menuOpen, setMenuOpen] = (0, import_react37.useState)(false);
|
5521
5656
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
5522
|
-
const setItemSelector = (0,
|
5657
|
+
const setItemSelector = (0, import_react37.useCallback)(
|
5523
5658
|
(newItemSelector) => {
|
5524
5659
|
if (newItemSelector === itemSelector) return;
|
5525
5660
|
dispatch({
|
@@ -5531,13 +5666,13 @@ function Puck({
|
|
5531
5666
|
[itemSelector]
|
5532
5667
|
);
|
5533
5668
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
5534
|
-
(0,
|
5669
|
+
(0, import_react37.useEffect)(() => {
|
5535
5670
|
if (onChange) onChange(data);
|
5536
5671
|
}, [data]);
|
5537
5672
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
5538
|
-
const [draggedItem, setDraggedItem] = (0,
|
5673
|
+
const [draggedItem, setDraggedItem] = (0, import_react37.useState)();
|
5539
5674
|
const rootProps = data.root.props || data.root;
|
5540
|
-
const toggleSidebars = (0,
|
5675
|
+
const toggleSidebars = (0, import_react37.useCallback)(
|
5541
5676
|
(sidebar) => {
|
5542
5677
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
5543
5678
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -5551,7 +5686,7 @@ function Puck({
|
|
5551
5686
|
},
|
5552
5687
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
5553
5688
|
);
|
5554
|
-
(0,
|
5689
|
+
(0, import_react37.useEffect)(() => {
|
5555
5690
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
5556
5691
|
dispatch({
|
5557
5692
|
type: "setUi",
|
@@ -5574,28 +5709,28 @@ function Puck({
|
|
5574
5709
|
window.removeEventListener("resize", handleResize);
|
5575
5710
|
};
|
5576
5711
|
}, []);
|
5577
|
-
const defaultHeaderRender = (0,
|
5712
|
+
const defaultHeaderRender = (0, import_react37.useMemo)(() => {
|
5578
5713
|
if (renderHeader) {
|
5579
5714
|
console.warn(
|
5580
5715
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
5581
5716
|
);
|
5582
5717
|
const RenderHeader = (_a2) => {
|
5583
|
-
var
|
5718
|
+
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
5584
5719
|
const Comp = renderHeader;
|
5585
|
-
return /* @__PURE__ */ (0,
|
5720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
5586
5721
|
};
|
5587
5722
|
return RenderHeader;
|
5588
5723
|
}
|
5589
5724
|
return DefaultOverride;
|
5590
5725
|
}, [renderHeader]);
|
5591
|
-
const defaultHeaderActionsRender = (0,
|
5726
|
+
const defaultHeaderActionsRender = (0, import_react37.useMemo)(() => {
|
5592
5727
|
if (renderHeaderActions) {
|
5593
5728
|
console.warn(
|
5594
5729
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
5595
5730
|
);
|
5596
5731
|
const RenderHeader = (props) => {
|
5597
5732
|
const Comp = renderHeaderActions;
|
5598
|
-
return /* @__PURE__ */ (0,
|
5733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
5599
5734
|
};
|
5600
5735
|
return RenderHeader;
|
5601
5736
|
}
|
@@ -5605,26 +5740,26 @@ function Puck({
|
|
5605
5740
|
overrides,
|
5606
5741
|
plugins
|
5607
5742
|
});
|
5608
|
-
const CustomPuck = (0,
|
5743
|
+
const CustomPuck = (0, import_react37.useMemo)(
|
5609
5744
|
() => loadedOverrides.puck || DefaultOverride,
|
5610
5745
|
[loadedOverrides]
|
5611
5746
|
);
|
5612
|
-
const CustomHeader = (0,
|
5747
|
+
const CustomHeader = (0, import_react37.useMemo)(
|
5613
5748
|
() => loadedOverrides.header || defaultHeaderRender,
|
5614
5749
|
[loadedOverrides]
|
5615
5750
|
);
|
5616
|
-
const CustomHeaderActions = (0,
|
5751
|
+
const CustomHeaderActions = (0, import_react37.useMemo)(
|
5617
5752
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
5618
5753
|
[loadedOverrides]
|
5619
5754
|
);
|
5620
|
-
const [mounted, setMounted] = (0,
|
5621
|
-
(0,
|
5755
|
+
const [mounted, setMounted] = (0, import_react37.useState)(false);
|
5756
|
+
(0, import_react37.useEffect)(() => {
|
5622
5757
|
setMounted(true);
|
5623
5758
|
}, []);
|
5624
5759
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
5625
|
-
const selectedComponentLabel = selectedItem ? (
|
5626
|
-
return /* @__PURE__ */ (0,
|
5627
|
-
/* @__PURE__ */ (0,
|
5760
|
+
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
5761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
5762
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5628
5763
|
AppProvider,
|
5629
5764
|
{
|
5630
5765
|
value: {
|
@@ -5646,7 +5781,7 @@ function Puck({
|
|
5646
5781
|
getPermissions: () => ({}),
|
5647
5782
|
refreshPermissions: () => null
|
5648
5783
|
},
|
5649
|
-
children: /* @__PURE__ */ (0,
|
5784
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(appContext.Consumer, { children: ({ resolveData }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5650
5785
|
DragDropContext,
|
5651
5786
|
{
|
5652
5787
|
autoScrollerOptions: { disabled: dnd == null ? void 0 : dnd.disableAutoScroll },
|
@@ -5698,7 +5833,7 @@ function Puck({
|
|
5698
5833
|
});
|
5699
5834
|
}
|
5700
5835
|
},
|
5701
|
-
children: /* @__PURE__ */ (0,
|
5836
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5702
5837
|
DropZoneProvider,
|
5703
5838
|
{
|
5704
5839
|
value: {
|
@@ -5712,7 +5847,7 @@ function Puck({
|
|
5712
5847
|
mode: "edit",
|
5713
5848
|
areaId: "root"
|
5714
5849
|
},
|
5715
|
-
children: /* @__PURE__ */ (0,
|
5850
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5716
5851
|
"div",
|
5717
5852
|
{
|
5718
5853
|
className: getLayoutClassName({
|
@@ -5721,58 +5856,58 @@ function Puck({
|
|
5721
5856
|
mounted,
|
5722
5857
|
rightSideBarVisible
|
5723
5858
|
}),
|
5724
|
-
children: /* @__PURE__ */ (0,
|
5725
|
-
/* @__PURE__ */ (0,
|
5859
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
5860
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5726
5861
|
CustomHeader,
|
5727
5862
|
{
|
5728
|
-
actions: /* @__PURE__ */ (0,
|
5863
|
+
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
5864
|
Button,
|
5730
5865
|
{
|
5731
5866
|
onClick: () => {
|
5732
5867
|
onPublish && onPublish(data);
|
5733
5868
|
},
|
5734
|
-
icon: /* @__PURE__ */ (0,
|
5869
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
5735
5870
|
children: "Publish"
|
5736
5871
|
}
|
5737
5872
|
) }) }),
|
5738
|
-
children: /* @__PURE__ */ (0,
|
5739
|
-
/* @__PURE__ */ (0,
|
5873
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
5874
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
5740
5875
|
"div",
|
5741
5876
|
{
|
5742
5877
|
className: getLayoutClassName("headerToggle"),
|
5743
5878
|
children: [
|
5744
|
-
/* @__PURE__ */ (0,
|
5879
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5745
5880
|
"div",
|
5746
5881
|
{
|
5747
5882
|
className: getLayoutClassName(
|
5748
5883
|
"leftSideBarToggle"
|
5749
5884
|
),
|
5750
|
-
children: /* @__PURE__ */ (0,
|
5885
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5751
5886
|
IconButton,
|
5752
5887
|
{
|
5753
5888
|
onClick: () => {
|
5754
5889
|
toggleSidebars("left");
|
5755
5890
|
},
|
5756
5891
|
title: "Toggle left sidebar",
|
5757
|
-
children: /* @__PURE__ */ (0,
|
5892
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
5758
5893
|
}
|
5759
5894
|
)
|
5760
5895
|
}
|
5761
5896
|
),
|
5762
|
-
/* @__PURE__ */ (0,
|
5897
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5763
5898
|
"div",
|
5764
5899
|
{
|
5765
5900
|
className: getLayoutClassName(
|
5766
5901
|
"rightSideBarToggle"
|
5767
5902
|
),
|
5768
|
-
children: /* @__PURE__ */ (0,
|
5903
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5769
5904
|
IconButton,
|
5770
5905
|
{
|
5771
5906
|
onClick: () => {
|
5772
5907
|
toggleSidebars("right");
|
5773
5908
|
},
|
5774
5909
|
title: "Toggle right sidebar",
|
5775
|
-
children: /* @__PURE__ */ (0,
|
5910
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
5776
5911
|
}
|
5777
5912
|
)
|
5778
5913
|
}
|
@@ -5780,15 +5915,15 @@ function Puck({
|
|
5780
5915
|
]
|
5781
5916
|
}
|
5782
5917
|
),
|
5783
|
-
/* @__PURE__ */ (0,
|
5918
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5784
5919
|
"div",
|
5785
5920
|
{
|
5786
5921
|
className: getLayoutClassName("headerTitle"),
|
5787
|
-
children: /* @__PURE__ */ (0,
|
5922
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
5788
5923
|
headerTitle || rootProps.title || "Page",
|
5789
|
-
headerPath && /* @__PURE__ */ (0,
|
5924
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
5790
5925
|
" ",
|
5791
|
-
/* @__PURE__ */ (0,
|
5926
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5792
5927
|
"code",
|
5793
5928
|
{
|
5794
5929
|
className: getLayoutClassName(
|
@@ -5801,41 +5936,41 @@ function Puck({
|
|
5801
5936
|
] })
|
5802
5937
|
}
|
5803
5938
|
),
|
5804
|
-
/* @__PURE__ */ (0,
|
5939
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
5805
5940
|
"div",
|
5806
5941
|
{
|
5807
5942
|
className: getLayoutClassName("headerTools"),
|
5808
5943
|
children: [
|
5809
|
-
/* @__PURE__ */ (0,
|
5944
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5810
5945
|
"div",
|
5811
5946
|
{
|
5812
5947
|
className: getLayoutClassName("menuButton"),
|
5813
|
-
children: /* @__PURE__ */ (0,
|
5948
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5814
5949
|
IconButton,
|
5815
5950
|
{
|
5816
5951
|
onClick: () => {
|
5817
5952
|
return setMenuOpen(!menuOpen);
|
5818
5953
|
},
|
5819
5954
|
title: "Toggle menu bar",
|
5820
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
5955
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
5821
5956
|
}
|
5822
5957
|
)
|
5823
5958
|
}
|
5824
5959
|
),
|
5825
|
-
/* @__PURE__ */ (0,
|
5960
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5826
5961
|
MenuBar,
|
5827
5962
|
{
|
5828
5963
|
appState,
|
5829
5964
|
dispatch,
|
5830
5965
|
onPublish,
|
5831
5966
|
menuOpen,
|
5832
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
5967
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5833
5968
|
Button,
|
5834
5969
|
{
|
5835
5970
|
onClick: () => {
|
5836
5971
|
onPublish && onPublish(data);
|
5837
5972
|
},
|
5838
|
-
icon: /* @__PURE__ */ (0,
|
5973
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
5839
5974
|
children: "Publish"
|
5840
5975
|
}
|
5841
5976
|
) }),
|
@@ -5848,19 +5983,19 @@ function Puck({
|
|
5848
5983
|
] }) })
|
5849
5984
|
}
|
5850
5985
|
),
|
5851
|
-
/* @__PURE__ */ (0,
|
5852
|
-
/* @__PURE__ */ (0,
|
5853
|
-
/* @__PURE__ */ (0,
|
5986
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
5987
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
|
5988
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
|
5854
5989
|
] }),
|
5855
|
-
/* @__PURE__ */ (0,
|
5856
|
-
/* @__PURE__ */ (0,
|
5990
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
|
5991
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5857
5992
|
SidebarSection,
|
5858
5993
|
{
|
5859
5994
|
noPadding: true,
|
5860
5995
|
noBorderTop: true,
|
5861
5996
|
showBreadcrumbs: true,
|
5862
5997
|
title: selectedItem ? selectedComponentLabel : "Page",
|
5863
|
-
children: /* @__PURE__ */ (0,
|
5998
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
|
5864
5999
|
}
|
5865
6000
|
) })
|
5866
6001
|
] })
|
@@ -5872,7 +6007,7 @@ function Puck({
|
|
5872
6007
|
) })
|
5873
6008
|
}
|
5874
6009
|
),
|
5875
|
-
/* @__PURE__ */ (0,
|
6010
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
5876
6011
|
] });
|
5877
6012
|
}
|
5878
6013
|
Puck.Components = Components;
|
@@ -5882,7 +6017,7 @@ Puck.Preview = Preview;
|
|
5882
6017
|
|
5883
6018
|
// components/Render/index.tsx
|
5884
6019
|
init_react_import();
|
5885
|
-
var
|
6020
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
5886
6021
|
function Render({
|
5887
6022
|
config,
|
5888
6023
|
data
|
@@ -5895,7 +6030,7 @@ function Render({
|
|
5895
6030
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
5896
6031
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
5897
6032
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5898
|
-
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)(
|
5899
6034
|
config.root.render,
|
5900
6035
|
__spreadProps(__spreadValues({}, rootProps), {
|
5901
6036
|
puck: {
|
@@ -5905,11 +6040,11 @@ function Render({
|
|
5905
6040
|
title,
|
5906
6041
|
editMode: false,
|
5907
6042
|
id: "puck-root",
|
5908
|
-
children: /* @__PURE__ */ (0,
|
6043
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DropZone, { zone: rootDroppableId })
|
5909
6044
|
})
|
5910
6045
|
) });
|
5911
6046
|
}
|
5912
|
-
return /* @__PURE__ */ (0,
|
6047
|
+
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
6048
|
}
|
5914
6049
|
|
5915
6050
|
// lib/migrate.ts
|