@measured/puck 0.17.1 → 0.17.2-canary.98a70fd
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 +616 -502
- package/dist/index.mjs +480 -363
- 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"),
|
@@ -1720,11 +1780,11 @@ var DefaultField = ({
|
|
1720
1780
|
|
1721
1781
|
// components/AutoField/fields/ExternalField/index.tsx
|
1722
1782
|
init_react_import();
|
1723
|
-
var
|
1783
|
+
var import_react13 = require("react");
|
1724
1784
|
|
1725
1785
|
// components/ExternalInput/index.tsx
|
1726
1786
|
init_react_import();
|
1727
|
-
var
|
1787
|
+
var import_react12 = require("react");
|
1728
1788
|
|
1729
1789
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
1730
1790
|
init_react_import();
|
@@ -1732,7 +1792,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
1732
1792
|
|
1733
1793
|
// components/Modal/index.tsx
|
1734
1794
|
init_react_import();
|
1735
|
-
var
|
1795
|
+
var import_react10 = require("react");
|
1736
1796
|
|
1737
1797
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
1738
1798
|
init_react_import();
|
@@ -1740,22 +1800,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1740
1800
|
|
1741
1801
|
// components/Modal/index.tsx
|
1742
1802
|
var import_react_dom = require("react-dom");
|
1743
|
-
var
|
1803
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
1744
1804
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1745
1805
|
var Modal = ({
|
1746
1806
|
children,
|
1747
1807
|
onClose,
|
1748
1808
|
isOpen
|
1749
1809
|
}) => {
|
1750
|
-
const [rootEl, setRootEl] = (0,
|
1751
|
-
(0,
|
1810
|
+
const [rootEl, setRootEl] = (0, import_react10.useState)(null);
|
1811
|
+
(0, import_react10.useEffect)(() => {
|
1752
1812
|
setRootEl(document.getElementById("puck-portal-root"));
|
1753
1813
|
}, []);
|
1754
1814
|
if (!rootEl) {
|
1755
|
-
return /* @__PURE__ */ (0,
|
1815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", {});
|
1756
1816
|
}
|
1757
1817
|
return (0, import_react_dom.createPortal)(
|
1758
|
-
/* @__PURE__ */ (0,
|
1818
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1759
1819
|
"div",
|
1760
1820
|
{
|
1761
1821
|
className: getClassName7("inner"),
|
@@ -1775,11 +1835,11 @@ init_react_import();
|
|
1775
1835
|
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
1836
|
|
1777
1837
|
// components/Heading/index.tsx
|
1778
|
-
var
|
1838
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
1779
1839
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1780
1840
|
var Heading = ({ children, rank, size = "m" }) => {
|
1781
1841
|
const Tag = rank ? `h${rank}` : "span";
|
1782
|
-
return /* @__PURE__ */ (0,
|
1842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1783
1843
|
Tag,
|
1784
1844
|
{
|
1785
1845
|
className: getClassName8({
|
@@ -1795,14 +1855,14 @@ init_react_import();
|
|
1795
1855
|
|
1796
1856
|
// components/Button/Button.tsx
|
1797
1857
|
init_react_import();
|
1798
|
-
var
|
1858
|
+
var import_react11 = require("react");
|
1799
1859
|
|
1800
1860
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
1801
1861
|
init_react_import();
|
1802
1862
|
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
1863
|
|
1804
1864
|
// components/Button/Button.tsx
|
1805
|
-
var
|
1865
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
1806
1866
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1807
1867
|
var Button = ({
|
1808
1868
|
children,
|
@@ -1818,10 +1878,10 @@ var Button = ({
|
|
1818
1878
|
size = "medium",
|
1819
1879
|
loading: loadingProp = false
|
1820
1880
|
}) => {
|
1821
|
-
const [loading, setLoading] = (0,
|
1822
|
-
(0,
|
1881
|
+
const [loading, setLoading] = (0, import_react11.useState)(loadingProp);
|
1882
|
+
(0, import_react11.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
1823
1883
|
const ElementType = href ? "a" : type ? "button" : "span";
|
1824
|
-
const el = /* @__PURE__ */ (0,
|
1884
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
1825
1885
|
ElementType,
|
1826
1886
|
{
|
1827
1887
|
className: getClassName9({
|
@@ -1845,9 +1905,9 @@ var Button = ({
|
|
1845
1905
|
rel: newTab ? "noreferrer" : void 0,
|
1846
1906
|
href,
|
1847
1907
|
children: [
|
1848
|
-
icon && /* @__PURE__ */ (0,
|
1908
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
1849
1909
|
children,
|
1850
|
-
loading && /* @__PURE__ */ (0,
|
1910
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader, { size: 14 }) })
|
1851
1911
|
]
|
1852
1912
|
}
|
1853
1913
|
);
|
@@ -1855,7 +1915,7 @@ var Button = ({
|
|
1855
1915
|
};
|
1856
1916
|
|
1857
1917
|
// components/ExternalInput/index.tsx
|
1858
|
-
var
|
1918
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
1859
1919
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1860
1920
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1861
1921
|
var dataCache = {};
|
@@ -1872,28 +1932,28 @@ var ExternalInput = ({
|
|
1872
1932
|
mapRow = (val) => val,
|
1873
1933
|
filterFields
|
1874
1934
|
} = field || {};
|
1875
|
-
const [data, setData] = (0,
|
1876
|
-
const [isOpen, setOpen] = (0,
|
1877
|
-
const [isLoading, setIsLoading] = (0,
|
1935
|
+
const [data, setData] = (0, import_react12.useState)([]);
|
1936
|
+
const [isOpen, setOpen] = (0, import_react12.useState)(false);
|
1937
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(true);
|
1878
1938
|
const hasFilterFields = !!filterFields;
|
1879
|
-
const [filters, setFilters] = (0,
|
1880
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
1881
|
-
const mappedData = (0,
|
1939
|
+
const [filters, setFilters] = (0, import_react12.useState)(field.initialFilters || {});
|
1940
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react12.useState)(hasFilterFields);
|
1941
|
+
const mappedData = (0, import_react12.useMemo)(() => {
|
1882
1942
|
return data.map(mapRow);
|
1883
1943
|
}, [data]);
|
1884
|
-
const keys = (0,
|
1944
|
+
const keys = (0, import_react12.useMemo)(() => {
|
1885
1945
|
const validKeys = /* @__PURE__ */ new Set();
|
1886
1946
|
for (const item of mappedData) {
|
1887
1947
|
for (const key of Object.keys(item)) {
|
1888
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
1948
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react12.isValidElement)(item[key])) {
|
1889
1949
|
validKeys.add(key);
|
1890
1950
|
}
|
1891
1951
|
}
|
1892
1952
|
}
|
1893
1953
|
return Array.from(validKeys);
|
1894
1954
|
}, [mappedData]);
|
1895
|
-
const [searchQuery, setSearchQuery] = (0,
|
1896
|
-
const search = (0,
|
1955
|
+
const [searchQuery, setSearchQuery] = (0, import_react12.useState)(field.initialQuery || "");
|
1956
|
+
const search = (0, import_react12.useCallback)(
|
1897
1957
|
(query, filters2) => __async(void 0, null, function* () {
|
1898
1958
|
setIsLoading(true);
|
1899
1959
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -1906,18 +1966,18 @@ var ExternalInput = ({
|
|
1906
1966
|
}),
|
1907
1967
|
[id, field]
|
1908
1968
|
);
|
1909
|
-
const Footer = (0,
|
1910
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
1969
|
+
const Footer = (0, import_react12.useCallback)(
|
1970
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
1911
1971
|
props.items.length,
|
1912
1972
|
" result",
|
1913
1973
|
props.items.length === 1 ? "" : "s"
|
1914
1974
|
] }),
|
1915
1975
|
[field.renderFooter]
|
1916
1976
|
);
|
1917
|
-
(0,
|
1977
|
+
(0, import_react12.useEffect)(() => {
|
1918
1978
|
search(searchQuery, filters);
|
1919
1979
|
}, []);
|
1920
|
-
return /* @__PURE__ */ (0,
|
1980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
1921
1981
|
"div",
|
1922
1982
|
{
|
1923
1983
|
className: getClassName10({
|
@@ -1927,21 +1987,21 @@ var ExternalInput = ({
|
|
1927
1987
|
}),
|
1928
1988
|
id,
|
1929
1989
|
children: [
|
1930
|
-
/* @__PURE__ */ (0,
|
1931
|
-
/* @__PURE__ */ (0,
|
1990
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassName10("actions"), children: [
|
1991
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
1932
1992
|
"button",
|
1933
1993
|
{
|
1934
1994
|
type: "button",
|
1935
1995
|
onClick: () => setOpen(true),
|
1936
1996
|
className: getClassName10("button"),
|
1937
1997
|
disabled: readOnly,
|
1938
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
1939
|
-
/* @__PURE__ */ (0,
|
1940
|
-
/* @__PURE__ */ (0,
|
1998
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
1999
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Link, { size: "16" }),
|
2000
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: field.placeholder })
|
1941
2001
|
] })
|
1942
2002
|
}
|
1943
2003
|
),
|
1944
|
-
value && /* @__PURE__ */ (0,
|
2004
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
1945
2005
|
"button",
|
1946
2006
|
{
|
1947
2007
|
type: "button",
|
@@ -1950,11 +2010,11 @@ var ExternalInput = ({
|
|
1950
2010
|
onChange(null);
|
1951
2011
|
},
|
1952
2012
|
disabled: readOnly,
|
1953
|
-
children: /* @__PURE__ */ (0,
|
2013
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(LockOpen, { size: 16 })
|
1954
2014
|
}
|
1955
2015
|
)
|
1956
2016
|
] }),
|
1957
|
-
/* @__PURE__ */ (0,
|
2017
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
1958
2018
|
"form",
|
1959
2019
|
{
|
1960
2020
|
className: getClassNameModal({
|
@@ -1968,11 +2028,11 @@ var ExternalInput = ({
|
|
1968
2028
|
search(searchQuery, filters);
|
1969
2029
|
},
|
1970
2030
|
children: [
|
1971
|
-
/* @__PURE__ */ (0,
|
1972
|
-
/* @__PURE__ */ (0,
|
1973
|
-
/* @__PURE__ */ (0,
|
1974
|
-
/* @__PURE__ */ (0,
|
1975
|
-
/* @__PURE__ */ (0,
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: getClassNameModal("search"), children: [
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
2034
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Search, { size: "18" }) }),
|
2035
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
1976
2036
|
"input",
|
1977
2037
|
{
|
1978
2038
|
className: getClassNameModal("searchInput"),
|
@@ -1987,9 +2047,9 @@ var ExternalInput = ({
|
|
1987
2047
|
}
|
1988
2048
|
)
|
1989
2049
|
] }),
|
1990
|
-
/* @__PURE__ */ (0,
|
1991
|
-
/* @__PURE__ */ (0,
|
1992
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
2052
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
1993
2053
|
IconButton,
|
1994
2054
|
{
|
1995
2055
|
title: "Toggle filters",
|
@@ -1998,15 +2058,15 @@ var ExternalInput = ({
|
|
1998
2058
|
e.stopPropagation();
|
1999
2059
|
setFiltersToggled(!filtersToggled);
|
2000
2060
|
},
|
2001
|
-
children: /* @__PURE__ */ (0,
|
2061
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SlidersHorizontal, { size: 20 })
|
2002
2062
|
}
|
2003
2063
|
) })
|
2004
2064
|
] })
|
2005
|
-
] }) : /* @__PURE__ */ (0,
|
2006
|
-
/* @__PURE__ */ (0,
|
2007
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2065
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
2066
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
2067
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
2008
2068
|
const filterField = filterFields[fieldName];
|
2009
|
-
return /* @__PURE__ */ (0,
|
2069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2010
2070
|
AutoFieldPrivate,
|
2011
2071
|
{
|
2012
2072
|
field: filterField,
|
@@ -2023,9 +2083,9 @@ var ExternalInput = ({
|
|
2023
2083
|
fieldName
|
2024
2084
|
);
|
2025
2085
|
}) }),
|
2026
|
-
/* @__PURE__ */ (0,
|
2027
|
-
/* @__PURE__ */ (0,
|
2028
|
-
/* @__PURE__ */ (0,
|
2086
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
2087
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("table", { className: getClassNameModal("table"), children: [
|
2088
|
+
/* @__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
2089
|
"th",
|
2030
2090
|
{
|
2031
2091
|
className: getClassNameModal("th"),
|
@@ -2034,8 +2094,8 @@ var ExternalInput = ({
|
|
2034
2094
|
},
|
2035
2095
|
key
|
2036
2096
|
)) }) }),
|
2037
|
-
/* @__PURE__ */ (0,
|
2038
|
-
return /* @__PURE__ */ (0,
|
2097
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
2098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2039
2099
|
"tr",
|
2040
2100
|
{
|
2041
2101
|
style: { whiteSpace: "nowrap" },
|
@@ -2044,16 +2104,16 @@ var ExternalInput = ({
|
|
2044
2104
|
onChange(mapProp(data[i]));
|
2045
2105
|
setOpen(false);
|
2046
2106
|
},
|
2047
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
2107
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
2048
2108
|
},
|
2049
2109
|
i
|
2050
2110
|
);
|
2051
2111
|
}) })
|
2052
2112
|
] }),
|
2053
|
-
/* @__PURE__ */ (0,
|
2113
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { size: 24 }) })
|
2054
2114
|
] })
|
2055
2115
|
] }),
|
2056
|
-
/* @__PURE__ */ (0,
|
2116
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Footer, { items: mappedData }) })
|
2057
2117
|
]
|
2058
2118
|
}
|
2059
2119
|
) })
|
@@ -2063,7 +2123,7 @@ var ExternalInput = ({
|
|
2063
2123
|
};
|
2064
2124
|
|
2065
2125
|
// components/AutoField/fields/ExternalField/index.tsx
|
2066
|
-
var
|
2126
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2067
2127
|
var ExternalField = ({
|
2068
2128
|
field,
|
2069
2129
|
onChange,
|
@@ -2077,7 +2137,7 @@ var ExternalField = ({
|
|
2077
2137
|
var _a, _b, _c;
|
2078
2138
|
const validField = field;
|
2079
2139
|
const deprecatedField = field;
|
2080
|
-
(0,
|
2140
|
+
(0, import_react13.useEffect)(() => {
|
2081
2141
|
if (deprecatedField.adaptor) {
|
2082
2142
|
console.error(
|
2083
2143
|
"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 +2147,7 @@ var ExternalField = ({
|
|
2087
2147
|
if (field.type !== "external") {
|
2088
2148
|
return null;
|
2089
2149
|
}
|
2090
|
-
return /* @__PURE__ */ (0,
|
2150
|
+
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
2151
|
ExternalInput,
|
2092
2152
|
{
|
2093
2153
|
name,
|
@@ -2112,7 +2172,7 @@ var ExternalField = ({
|
|
2112
2172
|
|
2113
2173
|
// components/AutoField/fields/RadioField/index.tsx
|
2114
2174
|
init_react_import();
|
2115
|
-
var
|
2175
|
+
var import_react14 = require("react");
|
2116
2176
|
|
2117
2177
|
// lib/safe-json-parse.ts
|
2118
2178
|
init_react_import();
|
@@ -2126,7 +2186,7 @@ var safeJsonParse = (str) => {
|
|
2126
2186
|
};
|
2127
2187
|
|
2128
2188
|
// components/AutoField/fields/RadioField/index.tsx
|
2129
|
-
var
|
2189
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
2130
2190
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
2131
2191
|
var RadioField = ({
|
2132
2192
|
field,
|
@@ -2138,26 +2198,26 @@ var RadioField = ({
|
|
2138
2198
|
label,
|
2139
2199
|
Label
|
2140
2200
|
}) => {
|
2141
|
-
const flatOptions = (0,
|
2201
|
+
const flatOptions = (0, import_react14.useMemo)(
|
2142
2202
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2143
2203
|
[field]
|
2144
2204
|
);
|
2145
2205
|
if (field.type !== "radio" || !field.options) {
|
2146
2206
|
return null;
|
2147
2207
|
}
|
2148
|
-
return /* @__PURE__ */ (0,
|
2208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
2149
2209
|
Label,
|
2150
2210
|
{
|
2151
|
-
icon: /* @__PURE__ */ (0,
|
2211
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CircleCheckBig, { size: 16 }),
|
2152
2212
|
label: label || name,
|
2153
2213
|
readOnly,
|
2154
2214
|
el: "div",
|
2155
|
-
children: /* @__PURE__ */ (0,
|
2215
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
2156
2216
|
"label",
|
2157
2217
|
{
|
2158
2218
|
className: getClassName11("radio"),
|
2159
2219
|
children: [
|
2160
|
-
/* @__PURE__ */ (0,
|
2220
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
2161
2221
|
"input",
|
2162
2222
|
{
|
2163
2223
|
type: "radio",
|
@@ -2177,7 +2237,7 @@ var RadioField = ({
|
|
2177
2237
|
checked: value === option.value
|
2178
2238
|
}
|
2179
2239
|
),
|
2180
|
-
/* @__PURE__ */ (0,
|
2240
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
2181
2241
|
]
|
2182
2242
|
},
|
2183
2243
|
option.label + option.value
|
@@ -2188,8 +2248,8 @@ var RadioField = ({
|
|
2188
2248
|
|
2189
2249
|
// components/AutoField/fields/SelectField/index.tsx
|
2190
2250
|
init_react_import();
|
2191
|
-
var
|
2192
|
-
var
|
2251
|
+
var import_react15 = require("react");
|
2252
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
2193
2253
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2194
2254
|
var SelectField = ({
|
2195
2255
|
field,
|
@@ -2201,20 +2261,20 @@ var SelectField = ({
|
|
2201
2261
|
readOnly,
|
2202
2262
|
id
|
2203
2263
|
}) => {
|
2204
|
-
const flatOptions = (0,
|
2264
|
+
const flatOptions = (0, import_react15.useMemo)(
|
2205
2265
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2206
2266
|
[field]
|
2207
2267
|
);
|
2208
2268
|
if (field.type !== "select" || !field.options) {
|
2209
2269
|
return null;
|
2210
2270
|
}
|
2211
|
-
return /* @__PURE__ */ (0,
|
2271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2212
2272
|
Label,
|
2213
2273
|
{
|
2214
2274
|
label: label || name,
|
2215
|
-
icon: /* @__PURE__ */ (0,
|
2275
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChevronDown, { size: 16 }),
|
2216
2276
|
readOnly,
|
2217
|
-
children: /* @__PURE__ */ (0,
|
2277
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2218
2278
|
"select",
|
2219
2279
|
{
|
2220
2280
|
id,
|
@@ -2231,7 +2291,7 @@ var SelectField = ({
|
|
2231
2291
|
}
|
2232
2292
|
},
|
2233
2293
|
value,
|
2234
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
2294
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2235
2295
|
"option",
|
2236
2296
|
{
|
2237
2297
|
label: option.label,
|
@@ -2247,7 +2307,7 @@ var SelectField = ({
|
|
2247
2307
|
|
2248
2308
|
// components/AutoField/fields/TextareaField/index.tsx
|
2249
2309
|
init_react_import();
|
2250
|
-
var
|
2310
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
2251
2311
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2252
2312
|
var TextareaField = ({
|
2253
2313
|
onChange,
|
@@ -2258,7 +2318,7 @@ var TextareaField = ({
|
|
2258
2318
|
Label,
|
2259
2319
|
id
|
2260
2320
|
}) => {
|
2261
|
-
return /* @__PURE__ */ (0,
|
2321
|
+
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
2322
|
"textarea",
|
2263
2323
|
{
|
2264
2324
|
id,
|
@@ -2285,7 +2345,7 @@ init_react_import();
|
|
2285
2345
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2286
2346
|
|
2287
2347
|
// components/AutoField/fields/ObjectField/index.tsx
|
2288
|
-
var
|
2348
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2289
2349
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2290
2350
|
var ObjectField = ({
|
2291
2351
|
field,
|
@@ -2297,43 +2357,54 @@ var ObjectField = ({
|
|
2297
2357
|
readOnly,
|
2298
2358
|
id
|
2299
2359
|
}) => {
|
2300
|
-
const {
|
2360
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2301
2361
|
if (field.type !== "object" || !field.objectFields) {
|
2302
2362
|
return null;
|
2303
2363
|
}
|
2304
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2305
2364
|
const data = value || {};
|
2306
|
-
return /* @__PURE__ */ (0,
|
2365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
2307
2366
|
Label,
|
2308
2367
|
{
|
2309
2368
|
label: label || name,
|
2310
|
-
icon: /* @__PURE__ */ (0,
|
2369
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EllipsisVertical, { size: 16 }),
|
2311
2370
|
el: "div",
|
2312
2371
|
readOnly,
|
2313
|
-
children: /* @__PURE__ */ (0,
|
2314
|
-
const subField = field.objectFields[
|
2315
|
-
const
|
2316
|
-
const
|
2317
|
-
const subReadOnly = readOnly ? readOnly :
|
2318
|
-
|
2319
|
-
|
2372
|
+
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) => {
|
2373
|
+
const subField = field.objectFields[subName];
|
2374
|
+
const subPath = `${name}.${subName}`;
|
2375
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2376
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2377
|
+
const label2 = subField.label || subName;
|
2378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
2379
|
+
NestedFieldProvider,
|
2320
2380
|
{
|
2321
|
-
name:
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2381
|
+
name: localName || id,
|
2382
|
+
subName,
|
2383
|
+
readOnlyFields,
|
2384
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
2385
|
+
AutoFieldPrivate,
|
2386
|
+
{
|
2387
|
+
name: subPath,
|
2388
|
+
label: subPath,
|
2389
|
+
id: `${id}_${subName}`,
|
2390
|
+
readOnly: subReadOnly,
|
2391
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2392
|
+
label: label2
|
2393
|
+
// May be used by custom fields
|
2331
2394
|
}),
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2395
|
+
value: data[subName],
|
2396
|
+
onChange: (val, ui) => {
|
2397
|
+
onChange(
|
2398
|
+
__spreadProps(__spreadValues({}, data), {
|
2399
|
+
[subName]: val
|
2400
|
+
}),
|
2401
|
+
ui
|
2402
|
+
);
|
2403
|
+
}
|
2404
|
+
}
|
2405
|
+
)
|
2335
2406
|
},
|
2336
|
-
|
2407
|
+
subPath
|
2337
2408
|
);
|
2338
2409
|
}) }) })
|
2339
2410
|
}
|
@@ -2342,7 +2413,7 @@ var ObjectField = ({
|
|
2342
2413
|
|
2343
2414
|
// lib/use-safe-id.ts
|
2344
2415
|
init_react_import();
|
2345
|
-
var
|
2416
|
+
var import_react16 = __toESM(require("react"));
|
2346
2417
|
|
2347
2418
|
// lib/generate-id.ts
|
2348
2419
|
init_react_import();
|
@@ -2351,15 +2422,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
2351
2422
|
|
2352
2423
|
// lib/use-safe-id.ts
|
2353
2424
|
var useSafeId = () => {
|
2354
|
-
if (typeof
|
2355
|
-
return
|
2425
|
+
if (typeof import_react16.default.useId !== "undefined") {
|
2426
|
+
return import_react16.default.useId();
|
2356
2427
|
}
|
2357
|
-
const [id] = (0,
|
2428
|
+
const [id] = (0, import_react16.useState)(generateId());
|
2358
2429
|
return id;
|
2359
2430
|
};
|
2360
2431
|
|
2361
2432
|
// components/AutoField/index.tsx
|
2362
|
-
var
|
2433
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
2363
2434
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2364
2435
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2365
2436
|
var FieldLabel = ({
|
@@ -2371,16 +2442,16 @@ var FieldLabel = ({
|
|
2371
2442
|
className
|
2372
2443
|
}) => {
|
2373
2444
|
const El = el;
|
2374
|
-
return /* @__PURE__ */ (0,
|
2375
|
-
/* @__PURE__ */ (0,
|
2376
|
-
icon ? /* @__PURE__ */ (0,
|
2445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(El, { className, children: [
|
2446
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: getClassName15("label"), children: [
|
2447
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, {}),
|
2377
2448
|
label,
|
2378
|
-
readOnly && /* @__PURE__ */ (0,
|
2449
|
+
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
2450
|
] }),
|
2380
2451
|
children
|
2381
2452
|
] });
|
2382
2453
|
};
|
2383
|
-
var
|
2454
|
+
var FieldLabelInternal = ({
|
2384
2455
|
children,
|
2385
2456
|
icon,
|
2386
2457
|
label,
|
@@ -2388,14 +2459,14 @@ var FieldLabelInternal2 = ({
|
|
2388
2459
|
readOnly
|
2389
2460
|
}) => {
|
2390
2461
|
const { overrides } = useAppContext();
|
2391
|
-
const Wrapper = (0,
|
2462
|
+
const Wrapper = (0, import_react17.useMemo)(
|
2392
2463
|
() => overrides.fieldLabel || FieldLabel,
|
2393
2464
|
[overrides]
|
2394
2465
|
);
|
2395
2466
|
if (!label) {
|
2396
|
-
return /* @__PURE__ */ (0,
|
2467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
|
2397
2468
|
}
|
2398
|
-
return /* @__PURE__ */ (0,
|
2469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
2399
2470
|
Wrapper,
|
2400
2471
|
{
|
2401
2472
|
label,
|
@@ -2409,8 +2480,8 @@ var FieldLabelInternal2 = ({
|
|
2409
2480
|
};
|
2410
2481
|
function AutoFieldInternal(props) {
|
2411
2482
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2412
|
-
const { dispatch, overrides } = useAppContext();
|
2413
|
-
const { id, Label =
|
2483
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2484
|
+
const { id, Label = FieldLabelInternal } = props;
|
2414
2485
|
const field = props.field;
|
2415
2486
|
const label = field.label;
|
2416
2487
|
const defaultId = useSafeId();
|
@@ -2441,7 +2512,7 @@ function AutoFieldInternal(props) {
|
|
2441
2512
|
Label,
|
2442
2513
|
id: resolvedId
|
2443
2514
|
});
|
2444
|
-
const onFocus = (0,
|
2515
|
+
const onFocus = (0, import_react17.useCallback)(
|
2445
2516
|
(e) => {
|
2446
2517
|
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
2447
2518
|
e.stopPropagation();
|
@@ -2455,7 +2526,7 @@ function AutoFieldInternal(props) {
|
|
2455
2526
|
},
|
2456
2527
|
[mergedProps.name]
|
2457
2528
|
);
|
2458
|
-
const onBlur = (0,
|
2529
|
+
const onBlur = (0, import_react17.useCallback)((e) => {
|
2459
2530
|
if ("name" in e.target) {
|
2460
2531
|
dispatch({
|
2461
2532
|
type: "setUi",
|
@@ -2470,27 +2541,37 @@ function AutoFieldInternal(props) {
|
|
2470
2541
|
return null;
|
2471
2542
|
}
|
2472
2543
|
const CustomField = field.render;
|
2473
|
-
return /* @__PURE__ */ (0,
|
2544
|
+
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
2545
|
}
|
2475
2546
|
const children = defaultFields[field.type](mergedProps);
|
2476
2547
|
const Render2 = render[field.type];
|
2477
|
-
|
2478
|
-
|
2548
|
+
const nestedFieldContext = (0, import_react17.useContext)(NestedFieldContext);
|
2549
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
2550
|
+
NestedFieldContext.Provider,
|
2479
2551
|
{
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
onClick: (e) => {
|
2484
|
-
e.stopPropagation();
|
2552
|
+
value: {
|
2553
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2554
|
+
localName: nestedFieldContext.localName
|
2485
2555
|
},
|
2486
|
-
children: /* @__PURE__ */ (0,
|
2556
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
2557
|
+
"div",
|
2558
|
+
{
|
2559
|
+
className: getClassNameWrapper(),
|
2560
|
+
onFocus,
|
2561
|
+
onBlur,
|
2562
|
+
onClick: (e) => {
|
2563
|
+
e.stopPropagation();
|
2564
|
+
},
|
2565
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2566
|
+
}
|
2567
|
+
)
|
2487
2568
|
}
|
2488
2569
|
);
|
2489
2570
|
}
|
2490
2571
|
function AutoFieldPrivate(props) {
|
2491
2572
|
const { state } = useAppContext();
|
2492
2573
|
const { value, onChange } = props;
|
2493
|
-
const [localValue, setLocalValue] = (0,
|
2574
|
+
const [localValue, setLocalValue] = (0, import_react17.useState)(value);
|
2494
2575
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
2495
2576
|
(val, ui) => {
|
2496
2577
|
onChange(val, ui);
|
@@ -2498,11 +2579,11 @@ function AutoFieldPrivate(props) {
|
|
2498
2579
|
50,
|
2499
2580
|
{ leading: true }
|
2500
2581
|
);
|
2501
|
-
const onChangeLocal = (0,
|
2582
|
+
const onChangeLocal = (0, import_react17.useCallback)((val, ui) => {
|
2502
2583
|
setLocalValue(val);
|
2503
2584
|
onChangeDb(val, ui);
|
2504
2585
|
}, []);
|
2505
|
-
(0,
|
2586
|
+
(0, import_react17.useEffect)(() => {
|
2506
2587
|
if (state.ui.field.focus !== props.name) {
|
2507
2588
|
setLocalValue(value);
|
2508
2589
|
}
|
@@ -2511,11 +2592,11 @@ function AutoFieldPrivate(props) {
|
|
2511
2592
|
value: localValue,
|
2512
2593
|
onChange: onChangeLocal
|
2513
2594
|
};
|
2514
|
-
return /* @__PURE__ */ (0,
|
2595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2515
2596
|
}
|
2516
2597
|
function AutoField(props) {
|
2517
|
-
const DefaultLabel = (0,
|
2518
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
2598
|
+
const DefaultLabel = (0, import_react17.useMemo)(() => {
|
2599
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
2519
2600
|
"div",
|
2520
2601
|
__spreadProps(__spreadValues({}, labelProps), {
|
2521
2602
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2523,7 +2604,7 @@ function AutoField(props) {
|
|
2523
2604
|
);
|
2524
2605
|
return DefaultLabel2;
|
2525
2606
|
}, [props.readOnly]);
|
2526
|
-
return /* @__PURE__ */ (0,
|
2607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2527
2608
|
}
|
2528
2609
|
|
2529
2610
|
// components/Drawer/index.tsx
|
@@ -2534,11 +2615,11 @@ init_react_import();
|
|
2534
2615
|
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
2616
|
|
2536
2617
|
// components/Drawer/index.tsx
|
2537
|
-
var
|
2538
|
-
var
|
2618
|
+
var import_react18 = require("react");
|
2619
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
2539
2620
|
var getClassName16 = get_class_name_factory_default("Drawer", styles_module_default10);
|
2540
2621
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
2541
|
-
var drawerContext = (0,
|
2622
|
+
var drawerContext = (0, import_react18.createContext)({
|
2542
2623
|
droppableId: ""
|
2543
2624
|
});
|
2544
2625
|
var DrawerDraggable = ({
|
@@ -2547,7 +2628,7 @@ var DrawerDraggable = ({
|
|
2547
2628
|
index,
|
2548
2629
|
isDragDisabled
|
2549
2630
|
}) => {
|
2550
|
-
return /* @__PURE__ */ (0,
|
2631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
2551
2632
|
Draggable,
|
2552
2633
|
{
|
2553
2634
|
id,
|
@@ -2569,21 +2650,21 @@ var DrawerItem = ({
|
|
2569
2650
|
index,
|
2570
2651
|
isDragDisabled
|
2571
2652
|
}) => {
|
2572
|
-
const ctx = (0,
|
2653
|
+
const ctx = (0, import_react18.useContext)(drawerContext);
|
2573
2654
|
const resolvedId = `${ctx.droppableId}::${id || name}`;
|
2574
|
-
const CustomInner = (0,
|
2575
|
-
() => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ (0,
|
2655
|
+
const CustomInner = (0, import_react18.useMemo)(
|
2656
|
+
() => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
2576
2657
|
[children]
|
2577
2658
|
);
|
2578
|
-
return /* @__PURE__ */ (0,
|
2659
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
2579
2660
|
DrawerDraggable,
|
2580
2661
|
{
|
2581
2662
|
id: resolvedId,
|
2582
2663
|
index,
|
2583
2664
|
isDragDisabled,
|
2584
|
-
children: /* @__PURE__ */ (0,
|
2585
|
-
/* @__PURE__ */ (0,
|
2586
|
-
/* @__PURE__ */ (0,
|
2665
|
+
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: [
|
2666
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
2667
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DragIcon, { isDragDisabled }) })
|
2587
2668
|
] }) }) })
|
2588
2669
|
}
|
2589
2670
|
);
|
@@ -2594,7 +2675,7 @@ var Drawer = ({
|
|
2594
2675
|
direction = "vertical"
|
2595
2676
|
}) => {
|
2596
2677
|
const droppableId = `component-list:${_droppableId}`;
|
2597
|
-
return /* @__PURE__ */ (0,
|
2678
|
+
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
2679
|
"div",
|
2599
2680
|
__spreadProps(__spreadValues({}, provided.droppableProps), {
|
2600
2681
|
ref: provided.innerRef,
|
@@ -2603,7 +2684,7 @@ var Drawer = ({
|
|
2603
2684
|
}),
|
2604
2685
|
children: [
|
2605
2686
|
children,
|
2606
|
-
/* @__PURE__ */ (0,
|
2687
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { display: "none" }, children: provided.placeholder })
|
2607
2688
|
]
|
2608
2689
|
})
|
2609
2690
|
) }) });
|
@@ -2612,11 +2693,11 @@ Drawer.Item = DrawerItem;
|
|
2612
2693
|
|
2613
2694
|
// components/DropZone/index.tsx
|
2614
2695
|
init_react_import();
|
2615
|
-
var
|
2696
|
+
var import_react22 = require("react");
|
2616
2697
|
|
2617
2698
|
// components/DraggableComponent/index.tsx
|
2618
2699
|
init_react_import();
|
2619
|
-
var
|
2700
|
+
var import_react20 = require("react");
|
2620
2701
|
var import_dnd4 = require("@measured/dnd");
|
2621
2702
|
|
2622
2703
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -2625,10 +2706,10 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1bhad
|
|
2625
2706
|
|
2626
2707
|
// lib/use-modifier-held.ts
|
2627
2708
|
init_react_import();
|
2628
|
-
var
|
2709
|
+
var import_react19 = require("react");
|
2629
2710
|
var useModifierHeld = (modifier) => {
|
2630
|
-
const [modifierHeld, setModifierHeld] = (0,
|
2631
|
-
(0,
|
2711
|
+
const [modifierHeld, setModifierHeld] = (0, import_react19.useState)(false);
|
2712
|
+
(0, import_react19.useEffect)(() => {
|
2632
2713
|
function downHandler({ key }) {
|
2633
2714
|
if (key === modifier) {
|
2634
2715
|
setModifierHeld(true);
|
@@ -2662,7 +2743,7 @@ var isIos = () => [
|
|
2662
2743
|
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
2663
2744
|
|
2664
2745
|
// components/DraggableComponent/index.tsx
|
2665
|
-
var
|
2746
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
2666
2747
|
var getClassName17 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2667
2748
|
var space = 8;
|
2668
2749
|
var actionsOverlayTop = space * 6.5;
|
@@ -2671,7 +2752,7 @@ var actionsRight = space;
|
|
2671
2752
|
var DefaultActionBar = ({
|
2672
2753
|
label,
|
2673
2754
|
children
|
2674
|
-
}) => /* @__PURE__ */ (0,
|
2755
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar, { label, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar.Group, { children }) });
|
2675
2756
|
var DraggableComponent = ({
|
2676
2757
|
children,
|
2677
2758
|
id,
|
@@ -2697,28 +2778,28 @@ var DraggableComponent = ({
|
|
2697
2778
|
const { zoomConfig, status, overrides, selectedItem, getPermissions } = useAppContext();
|
2698
2779
|
const isModifierHeld = useModifierHeld("Alt");
|
2699
2780
|
const El = status !== "LOADING" ? import_dnd4.Draggable : DefaultDraggable;
|
2700
|
-
(0,
|
2701
|
-
const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0,
|
2702
|
-
(0,
|
2781
|
+
(0, import_react20.useEffect)(onMount, []);
|
2782
|
+
const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0, import_react20.useState)(false);
|
2783
|
+
(0, import_react20.useEffect)(() => {
|
2703
2784
|
if (isIos()) {
|
2704
2785
|
setDisableSecondaryAnimation(true);
|
2705
2786
|
}
|
2706
2787
|
}, []);
|
2707
|
-
const CustomActionBar = (0,
|
2788
|
+
const CustomActionBar = (0, import_react20.useMemo)(
|
2708
2789
|
() => overrides.actionBar || DefaultActionBar,
|
2709
2790
|
[overrides.actionBar]
|
2710
2791
|
);
|
2711
2792
|
const permissions = getPermissions({
|
2712
2793
|
item: selectedItem
|
2713
2794
|
});
|
2714
|
-
return /* @__PURE__ */ (0,
|
2795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
2715
2796
|
El,
|
2716
2797
|
{
|
2717
2798
|
draggableId: id,
|
2718
2799
|
index,
|
2719
2800
|
isDragDisabled,
|
2720
2801
|
disableSecondaryAnimation,
|
2721
|
-
children: (provided, snapshot) => /* @__PURE__ */ (0,
|
2802
|
+
children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
2722
2803
|
"div",
|
2723
2804
|
__spreadProps(__spreadValues(__spreadValues({
|
2724
2805
|
ref: provided.innerRef
|
@@ -2741,15 +2822,15 @@ var DraggableComponent = ({
|
|
2741
2822
|
onClick,
|
2742
2823
|
children: [
|
2743
2824
|
debug,
|
2744
|
-
isLoading && /* @__PURE__ */ (0,
|
2745
|
-
isSelected && /* @__PURE__ */ (0,
|
2825
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName17("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Loader, {}) }),
|
2826
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
2746
2827
|
"div",
|
2747
2828
|
{
|
2748
2829
|
className: getClassName17("actionsOverlay"),
|
2749
2830
|
style: {
|
2750
2831
|
top: actionsOverlayTop / zoomConfig.zoom
|
2751
2832
|
},
|
2752
|
-
children: /* @__PURE__ */ (0,
|
2833
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
2753
2834
|
"div",
|
2754
2835
|
{
|
2755
2836
|
className: getClassName17("actions"),
|
@@ -2758,16 +2839,16 @@ var DraggableComponent = ({
|
|
2758
2839
|
top: actionsTop / zoomConfig.zoom,
|
2759
2840
|
right: actionsRight / zoomConfig.zoom
|
2760
2841
|
},
|
2761
|
-
children: /* @__PURE__ */ (0,
|
2762
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
2763
|
-
permissions.delete && /* @__PURE__ */ (0,
|
2842
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(CustomActionBar, { label, children: [
|
2843
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Copy, { size: 16 }) }),
|
2844
|
+
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
2845
|
] })
|
2765
2846
|
}
|
2766
2847
|
)
|
2767
2848
|
}
|
2768
2849
|
),
|
2769
|
-
/* @__PURE__ */ (0,
|
2770
|
-
/* @__PURE__ */ (0,
|
2850
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName17("overlay") }),
|
2851
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName17("contents"), children })
|
2771
2852
|
]
|
2772
2853
|
})
|
2773
2854
|
)
|
@@ -2782,7 +2863,7 @@ var styles_module_default12 = { "DropZone": "_DropZone_djoti_1", "DropZone-conte
|
|
2782
2863
|
|
2783
2864
|
// components/DropZone/context.tsx
|
2784
2865
|
init_react_import();
|
2785
|
-
var
|
2866
|
+
var import_react21 = require("react");
|
2786
2867
|
var import_use_debounce2 = require("use-debounce");
|
2787
2868
|
|
2788
2869
|
// lib/get-zone-id.ts
|
@@ -2798,30 +2879,30 @@ var getZoneId = (zoneCompound) => {
|
|
2798
2879
|
};
|
2799
2880
|
|
2800
2881
|
// components/DropZone/context.tsx
|
2801
|
-
var
|
2802
|
-
var dropZoneContext = (0,
|
2882
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
2883
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2803
2884
|
var DropZoneProvider = ({
|
2804
2885
|
children,
|
2805
2886
|
value
|
2806
2887
|
}) => {
|
2807
|
-
const [hoveringArea, setHoveringArea] = (0,
|
2808
|
-
const [hoveringZone, setHoveringZone] = (0,
|
2888
|
+
const [hoveringArea, setHoveringArea] = (0, import_react21.useState)(null);
|
2889
|
+
const [hoveringZone, setHoveringZone] = (0, import_react21.useState)(
|
2809
2890
|
rootDroppableId
|
2810
2891
|
);
|
2811
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
2892
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
2812
2893
|
const [hoveringAreaDb] = (0, import_use_debounce2.useDebounce)(hoveringArea, 75, { leading: false });
|
2813
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
2894
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
2814
2895
|
{}
|
2815
2896
|
);
|
2816
|
-
const [activeZones, setActiveZones] = (0,
|
2897
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
2817
2898
|
const { dispatch = null } = value ? value : {};
|
2818
|
-
const registerZoneArea = (0,
|
2899
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
2819
2900
|
(area) => {
|
2820
2901
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2821
2902
|
},
|
2822
2903
|
[setAreasWithZones]
|
2823
2904
|
);
|
2824
|
-
const registerZone = (0,
|
2905
|
+
const registerZone = (0, import_react21.useCallback)(
|
2825
2906
|
(zoneCompound) => {
|
2826
2907
|
if (!dispatch) {
|
2827
2908
|
return;
|
@@ -2834,7 +2915,7 @@ var DropZoneProvider = ({
|
|
2834
2915
|
},
|
2835
2916
|
[setActiveZones, dispatch]
|
2836
2917
|
);
|
2837
|
-
const unregisterZone = (0,
|
2918
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
2838
2919
|
(zoneCompound) => {
|
2839
2920
|
if (!dispatch) {
|
2840
2921
|
return;
|
@@ -2849,8 +2930,8 @@ var DropZoneProvider = ({
|
|
2849
2930
|
},
|
2850
2931
|
[setActiveZones, dispatch]
|
2851
2932
|
);
|
2852
|
-
const [pathData, setPathData] = (0,
|
2853
|
-
const registerPath = (0,
|
2933
|
+
const [pathData, setPathData] = (0, import_react21.useState)();
|
2934
|
+
const registerPath = (0, import_react21.useCallback)(
|
2854
2935
|
(selector) => {
|
2855
2936
|
if (!(value == null ? void 0 : value.data)) {
|
2856
2937
|
return;
|
@@ -2875,8 +2956,8 @@ var DropZoneProvider = ({
|
|
2875
2956
|
},
|
2876
2957
|
[value, setPathData]
|
2877
2958
|
);
|
2878
|
-
const [zoneWillDrag, setZoneWillDrag] = (0,
|
2879
|
-
return /* @__PURE__ */ (0,
|
2959
|
+
const [zoneWillDrag, setZoneWillDrag] = (0, import_react21.useState)("");
|
2960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: value && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
2880
2961
|
dropZoneContext.Provider,
|
2881
2962
|
{
|
2882
2963
|
value: __spreadValues({
|
@@ -2902,12 +2983,12 @@ var DropZoneProvider = ({
|
|
2902
2983
|
};
|
2903
2984
|
|
2904
2985
|
// components/DropZone/index.tsx
|
2905
|
-
var
|
2986
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
2906
2987
|
var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
|
2907
2988
|
function DropZoneEdit({ zone, allow, disallow, style }) {
|
2908
2989
|
var _a;
|
2909
2990
|
const appContext2 = useAppContext();
|
2910
|
-
const ctx = (0,
|
2991
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
2911
2992
|
const {
|
2912
2993
|
// These all need setting via context
|
2913
2994
|
data,
|
@@ -2926,12 +3007,12 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2926
3007
|
} = ctx || {};
|
2927
3008
|
let content = data.content || [];
|
2928
3009
|
let zoneCompound = rootDroppableId;
|
2929
|
-
(0,
|
3010
|
+
(0, import_react22.useEffect)(() => {
|
2930
3011
|
if (areaId && registerZoneArea) {
|
2931
3012
|
registerZoneArea(areaId);
|
2932
3013
|
}
|
2933
3014
|
}, [areaId]);
|
2934
|
-
(0,
|
3015
|
+
(0, import_react22.useEffect)(() => {
|
2935
3016
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
2936
3017
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
2937
3018
|
}
|
@@ -2957,7 +3038,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2957
3038
|
const draggingOverArea = userIsDragging && zoneArea === draggedSourceArea;
|
2958
3039
|
const draggingNewComponent = draggedSourceId == null ? void 0 : draggedSourceId.startsWith("component-list");
|
2959
3040
|
if (!(ctx == null ? void 0 : ctx.config) || !ctx.setHoveringArea || !ctx.setHoveringZone || !ctx.setHoveringComponent || !ctx.setItemSelector || !ctx.registerPath || !ctx.dispatch) {
|
2960
|
-
return /* @__PURE__ */ (0,
|
3041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: "DropZone requires context to work." });
|
2961
3042
|
}
|
2962
3043
|
const {
|
2963
3044
|
hoveringArea = "root",
|
@@ -2998,7 +3079,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2998
3079
|
}
|
2999
3080
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3000
3081
|
const isAreaSelected = selectedItem && zoneArea === selectedItem.props.id;
|
3001
|
-
return /* @__PURE__ */ (0,
|
3082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3002
3083
|
"div",
|
3003
3084
|
{
|
3004
3085
|
className: getClassName18({
|
@@ -3015,14 +3096,14 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3015
3096
|
onMouseUp: () => {
|
3016
3097
|
setZoneWillDrag("");
|
3017
3098
|
},
|
3018
|
-
children: /* @__PURE__ */ (0,
|
3099
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3019
3100
|
Droppable,
|
3020
3101
|
{
|
3021
3102
|
droppableId: zoneCompound,
|
3022
3103
|
direction: "vertical",
|
3023
3104
|
isDropDisabled: !isEnabled,
|
3024
3105
|
children: (provided, snapshot) => {
|
3025
|
-
return /* @__PURE__ */ (0,
|
3106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
3026
3107
|
"div",
|
3027
3108
|
__spreadProps(__spreadValues({}, (provided || { droppableProps: {} }).droppableProps), {
|
3028
3109
|
className: getClassName18("content"),
|
@@ -3052,7 +3133,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3052
3133
|
"draggable-"
|
3053
3134
|
)[1] === componentId;
|
3054
3135
|
const containsZone = areasWithZones ? areasWithZones[componentId] : false;
|
3055
|
-
const Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ (0,
|
3136
|
+
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
3137
|
"No configuration for ",
|
3057
3138
|
item.type
|
3058
3139
|
] });
|
@@ -3064,19 +3145,19 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3064
3145
|
appContext2.state.data
|
3065
3146
|
)
|
3066
3147
|
}).drag;
|
3067
|
-
return /* @__PURE__ */ (0,
|
3148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
3068
3149
|
"div",
|
3069
3150
|
{
|
3070
3151
|
className: getClassName18("item"),
|
3071
3152
|
style: { zIndex: isDragging ? 1 : void 0 },
|
3072
3153
|
children: [
|
3073
|
-
/* @__PURE__ */ (0,
|
3154
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3074
3155
|
DropZoneProvider,
|
3075
3156
|
{
|
3076
3157
|
value: __spreadProps(__spreadValues({}, ctx), {
|
3077
3158
|
areaId: componentId
|
3078
3159
|
}),
|
3079
|
-
children: /* @__PURE__ */ (0,
|
3160
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3080
3161
|
DraggableComponent,
|
3081
3162
|
{
|
3082
3163
|
label,
|
@@ -3144,12 +3225,12 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3144
3225
|
style: {
|
3145
3226
|
pointerEvents: userIsDragging && draggingNewComponent ? "all" : void 0
|
3146
3227
|
},
|
3147
|
-
children: /* @__PURE__ */ (0,
|
3228
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName18("renderWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3148
3229
|
}
|
3149
3230
|
)
|
3150
3231
|
}
|
3151
3232
|
),
|
3152
|
-
userIsDragging && /* @__PURE__ */ (0,
|
3233
|
+
userIsDragging && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3153
3234
|
"div",
|
3154
3235
|
{
|
3155
3236
|
className: getClassName18("hitbox"),
|
@@ -3166,7 +3247,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3166
3247
|
);
|
3167
3248
|
}),
|
3168
3249
|
provided == null ? void 0 : provided.placeholder,
|
3169
|
-
(snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ (0,
|
3250
|
+
(snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3170
3251
|
"div",
|
3171
3252
|
{
|
3172
3253
|
"data-puck-placeholder": true,
|
@@ -3187,7 +3268,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
3187
3268
|
);
|
3188
3269
|
}
|
3189
3270
|
function DropZoneRender({ zone }) {
|
3190
|
-
const ctx = (0,
|
3271
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
3191
3272
|
const { data, areaId = "root", config } = ctx || {};
|
3192
3273
|
let zoneCompound = rootDroppableId;
|
3193
3274
|
let content = (data == null ? void 0 : data.content) || [];
|
@@ -3198,14 +3279,14 @@ function DropZoneRender({ zone }) {
|
|
3198
3279
|
zoneCompound = `${areaId}:${zone}`;
|
3199
3280
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3200
3281
|
}
|
3201
|
-
return /* @__PURE__ */ (0,
|
3282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: content.map((item) => {
|
3202
3283
|
const Component = config.components[item.type];
|
3203
3284
|
if (Component) {
|
3204
|
-
return /* @__PURE__ */ (0,
|
3285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3205
3286
|
DropZoneProvider,
|
3206
3287
|
{
|
3207
3288
|
value: { data, config, areaId: item.props.id },
|
3208
|
-
children: /* @__PURE__ */ (0,
|
3289
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3209
3290
|
Component.render,
|
3210
3291
|
__spreadProps(__spreadValues({}, item.props), {
|
3211
3292
|
puck: { renderDropZone: DropZone }
|
@@ -3219,35 +3300,35 @@ function DropZoneRender({ zone }) {
|
|
3219
3300
|
}) });
|
3220
3301
|
}
|
3221
3302
|
function DropZone(props) {
|
3222
|
-
const ctx = (0,
|
3303
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
3223
3304
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3224
|
-
return /* @__PURE__ */ (0,
|
3305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadValues({}, props));
|
3225
3306
|
}
|
3226
|
-
return /* @__PURE__ */ (0,
|
3307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender, __spreadValues({}, props));
|
3227
3308
|
}
|
3228
3309
|
|
3229
3310
|
// components/Puck/index.tsx
|
3230
3311
|
init_react_import();
|
3231
|
-
var
|
3312
|
+
var import_react37 = require("react");
|
3232
3313
|
|
3233
3314
|
// lib/use-placeholder-style.ts
|
3234
3315
|
init_react_import();
|
3235
|
-
var
|
3316
|
+
var import_react23 = require("react");
|
3236
3317
|
|
3237
3318
|
// lib/get-frame.ts
|
3238
3319
|
init_react_import();
|
3239
3320
|
var getFrame = () => {
|
3240
|
-
let
|
3241
|
-
if ((
|
3242
|
-
|
3321
|
+
let frameEl = document.querySelector("#preview-frame");
|
3322
|
+
if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
|
3323
|
+
return frameEl.contentDocument || document;
|
3243
3324
|
}
|
3244
|
-
return
|
3325
|
+
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3245
3326
|
};
|
3246
3327
|
|
3247
3328
|
// lib/use-placeholder-style.ts
|
3248
3329
|
var usePlaceholderStyle = () => {
|
3249
3330
|
const queryAttr = "data-rfd-drag-handle-draggable-id";
|
3250
|
-
const [placeholderStyle, setPlaceholderStyle] = (0,
|
3331
|
+
const [placeholderStyle, setPlaceholderStyle] = (0, import_react23.useState)();
|
3251
3332
|
const onDragStartOrUpdate = (draggedItem) => {
|
3252
3333
|
var _a;
|
3253
3334
|
const draggableId = draggedItem.draggableId;
|
@@ -3300,7 +3381,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
3300
3381
|
|
3301
3382
|
// lib/use-breadcrumbs.ts
|
3302
3383
|
init_react_import();
|
3303
|
-
var
|
3384
|
+
var import_react24 = require("react");
|
3304
3385
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
3305
3386
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
3306
3387
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -3350,8 +3431,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
3350
3431
|
state: { data },
|
3351
3432
|
selectedItem
|
3352
3433
|
} = useAppContext();
|
3353
|
-
const dzContext = (0,
|
3354
|
-
return (0,
|
3434
|
+
const dzContext = (0, import_react24.useContext)(dropZoneContext);
|
3435
|
+
return (0, import_react24.useMemo)(() => {
|
3355
3436
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
3356
3437
|
selectedItem,
|
3357
3438
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -3365,7 +3446,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
3365
3446
|
};
|
3366
3447
|
|
3367
3448
|
// components/SidebarSection/index.tsx
|
3368
|
-
var
|
3449
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
3369
3450
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
3370
3451
|
var SidebarSection = ({
|
3371
3452
|
children,
|
@@ -3378,15 +3459,15 @@ var SidebarSection = ({
|
|
3378
3459
|
}) => {
|
3379
3460
|
const { setUi } = useAppContext();
|
3380
3461
|
const breadcrumbs = useBreadcrumbs(1);
|
3381
|
-
return /* @__PURE__ */ (0,
|
3462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
3382
3463
|
"div",
|
3383
3464
|
{
|
3384
3465
|
className: getClassName19({ noBorderTop, noPadding }),
|
3385
3466
|
style: { background },
|
3386
3467
|
children: [
|
3387
|
-
/* @__PURE__ */ (0,
|
3388
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
3389
|
-
/* @__PURE__ */ (0,
|
3468
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
3469
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
3470
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
3390
3471
|
"button",
|
3391
3472
|
{
|
3392
3473
|
type: "button",
|
@@ -3395,12 +3476,12 @@ var SidebarSection = ({
|
|
3395
3476
|
children: breadcrumb.label
|
3396
3477
|
}
|
3397
3478
|
),
|
3398
|
-
/* @__PURE__ */ (0,
|
3479
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChevronRight, { size: 16 })
|
3399
3480
|
] }, i)) : null,
|
3400
|
-
/* @__PURE__ */ (0,
|
3481
|
+
/* @__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
3482
|
] }) }),
|
3402
|
-
/* @__PURE__ */ (0,
|
3403
|
-
isLoading && /* @__PURE__ */ (0,
|
3483
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("content"), children }),
|
3484
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Loader, { size: 32 }) })
|
3404
3485
|
]
|
3405
3486
|
}
|
3406
3487
|
);
|
@@ -3603,6 +3684,9 @@ function reduceData(data, action, config) {
|
|
3603
3684
|
});
|
3604
3685
|
}
|
3605
3686
|
if (action.type === "move") {
|
3687
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
3688
|
+
return data;
|
3689
|
+
}
|
3606
3690
|
const newData = setupZone(
|
3607
3691
|
setupZone(data, action.sourceZone),
|
3608
3692
|
action.destinationZone
|
@@ -3781,7 +3865,7 @@ init_react_import();
|
|
3781
3865
|
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
3866
|
|
3783
3867
|
// components/MenuBar/index.tsx
|
3784
|
-
var
|
3868
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
3785
3869
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
3786
3870
|
function MenuBar({
|
3787
3871
|
appState,
|
@@ -3795,7 +3879,7 @@ function MenuBar({
|
|
3795
3879
|
history: { back, forward, historyStore }
|
3796
3880
|
} = useAppContext();
|
3797
3881
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
3798
|
-
return /* @__PURE__ */ (0,
|
3882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
3799
3883
|
"div",
|
3800
3884
|
{
|
3801
3885
|
className: getClassName20({ menuOpen }),
|
@@ -3809,12 +3893,12 @@ function MenuBar({
|
|
3809
3893
|
setMenuOpen(false);
|
3810
3894
|
}
|
3811
3895
|
},
|
3812
|
-
children: /* @__PURE__ */ (0,
|
3813
|
-
/* @__PURE__ */ (0,
|
3814
|
-
/* @__PURE__ */ (0,
|
3815
|
-
/* @__PURE__ */ (0,
|
3896
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName20("inner"), children: [
|
3897
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName20("history"), children: [
|
3898
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Undo2, { size: 21 }) }),
|
3899
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Redo2, { size: 21 }) })
|
3816
3900
|
] }),
|
3817
|
-
/* @__PURE__ */ (0,
|
3901
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
3818
3902
|
state: appState,
|
3819
3903
|
dispatch
|
3820
3904
|
}) })
|
@@ -3835,15 +3919,15 @@ init_react_import();
|
|
3835
3919
|
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
3920
|
|
3837
3921
|
// components/Puck/components/Fields/index.tsx
|
3838
|
-
var
|
3922
|
+
var import_react26 = require("react");
|
3839
3923
|
|
3840
3924
|
// lib/use-parent.ts
|
3841
3925
|
init_react_import();
|
3842
|
-
var
|
3926
|
+
var import_react25 = require("react");
|
3843
3927
|
var useParent = (itemSelector) => {
|
3844
3928
|
var _a;
|
3845
3929
|
const { selectedItem, state } = useAppContext();
|
3846
|
-
const { pathData } = (0,
|
3930
|
+
const { pathData } = (0, import_react25.useContext)(dropZoneContext) || {};
|
3847
3931
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
3848
3932
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
3849
3933
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -3852,7 +3936,7 @@ var useParent = (itemSelector) => {
|
|
3852
3936
|
};
|
3853
3937
|
|
3854
3938
|
// components/Puck/components/Fields/index.tsx
|
3855
|
-
var
|
3939
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
3856
3940
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
3857
3941
|
var defaultPageFields = {
|
3858
3942
|
title: { type: "text" }
|
@@ -3860,7 +3944,7 @@ var defaultPageFields = {
|
|
3860
3944
|
var DefaultFields = ({
|
3861
3945
|
children
|
3862
3946
|
}) => {
|
3863
|
-
return /* @__PURE__ */ (0,
|
3947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_jsx_runtime28.Fragment, { children });
|
3864
3948
|
};
|
3865
3949
|
var useResolvedFields = () => {
|
3866
3950
|
var _a, _b;
|
@@ -3869,20 +3953,20 @@ var useResolvedFields = () => {
|
|
3869
3953
|
const { data } = state;
|
3870
3954
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
3871
3955
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
3872
|
-
const defaultFields = (0,
|
3956
|
+
const defaultFields = (0, import_react26.useMemo)(
|
3873
3957
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
3874
3958
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
3875
3959
|
);
|
3876
3960
|
const rootProps = data.root.props || data.root;
|
3877
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
3878
|
-
const [resolvedFields, setResolvedFields] = (0,
|
3879
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
3961
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react26.useState)({});
|
3962
|
+
const [resolvedFields, setResolvedFields] = (0, import_react26.useState)(defaultFields);
|
3963
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react26.useState)(false);
|
3880
3964
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
3881
3965
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
3882
3966
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
3883
3967
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
3884
3968
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
3885
|
-
const resolveFields = (0,
|
3969
|
+
const resolveFields = (0, import_react26.useCallback)(
|
3886
3970
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
3887
3971
|
var _a2;
|
3888
3972
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -3920,7 +4004,7 @@ var useResolvedFields = () => {
|
|
3920
4004
|
}),
|
3921
4005
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
3922
4006
|
);
|
3923
|
-
(0,
|
4007
|
+
(0, import_react26.useEffect)(() => {
|
3924
4008
|
if (hasResolver) {
|
3925
4009
|
setFieldsLoading(true);
|
3926
4010
|
resolveFields(defaultFields).then((fields) => {
|
@@ -3951,8 +4035,8 @@ var Fields = () => {
|
|
3951
4035
|
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
4036
|
const isLoading = fieldsResolving || componentResolving;
|
3953
4037
|
const rootProps = data.root.props || data.root;
|
3954
|
-
const Wrapper = (0,
|
3955
|
-
return /* @__PURE__ */ (0,
|
4038
|
+
const Wrapper = (0, import_react26.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
4039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
3956
4040
|
"form",
|
3957
4041
|
{
|
3958
4042
|
className: getClassName21(),
|
@@ -3960,7 +4044,7 @@ var Fields = () => {
|
|
3960
4044
|
e.preventDefault();
|
3961
4045
|
},
|
3962
4046
|
children: [
|
3963
|
-
/* @__PURE__ */ (0,
|
4047
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
3964
4048
|
const field = fields[fieldName];
|
3965
4049
|
if (!(field == null ? void 0 : field.type)) return null;
|
3966
4050
|
const onChange = (value, updatedUi) => {
|
@@ -4031,7 +4115,7 @@ var Fields = () => {
|
|
4031
4115
|
item: selectedItem
|
4032
4116
|
});
|
4033
4117
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
4034
|
-
return /* @__PURE__ */ (0,
|
4118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
4035
4119
|
AutoFieldPrivate,
|
4036
4120
|
{
|
4037
4121
|
field,
|
@@ -4049,7 +4133,7 @@ var Fields = () => {
|
|
4049
4133
|
root: true
|
4050
4134
|
});
|
4051
4135
|
const id = `root_${field.type}_${fieldName}`;
|
4052
|
-
return /* @__PURE__ */ (0,
|
4136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
4053
4137
|
AutoFieldPrivate,
|
4054
4138
|
{
|
4055
4139
|
field,
|
@@ -4063,7 +4147,7 @@ var Fields = () => {
|
|
4063
4147
|
);
|
4064
4148
|
}
|
4065
4149
|
}) }),
|
4066
|
-
isLoading && /* @__PURE__ */ (0,
|
4150
|
+
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
4151
|
]
|
4068
4152
|
}
|
4069
4153
|
);
|
@@ -4074,7 +4158,7 @@ init_react_import();
|
|
4074
4158
|
|
4075
4159
|
// lib/use-component-list.tsx
|
4076
4160
|
init_react_import();
|
4077
|
-
var
|
4161
|
+
var import_react27 = require("react");
|
4078
4162
|
|
4079
4163
|
// components/ComponentList/index.tsx
|
4080
4164
|
init_react_import();
|
@@ -4084,7 +4168,7 @@ init_react_import();
|
|
4084
4168
|
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
4169
|
|
4086
4170
|
// components/ComponentList/index.tsx
|
4087
|
-
var
|
4171
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
4088
4172
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
4089
4173
|
var ComponentListItem = ({
|
4090
4174
|
name,
|
@@ -4095,7 +4179,7 @@ var ComponentListItem = ({
|
|
4095
4179
|
const canInsert = getPermissions({
|
4096
4180
|
type: name
|
4097
4181
|
}).insert;
|
4098
|
-
return /* @__PURE__ */ (0,
|
4182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
4099
4183
|
Drawer.Item,
|
4100
4184
|
{
|
4101
4185
|
label,
|
@@ -4113,8 +4197,8 @@ var ComponentList = ({
|
|
4113
4197
|
}) => {
|
4114
4198
|
const { config, state, setUi } = useAppContext();
|
4115
4199
|
const { expanded = true } = state.ui.componentList[id] || {};
|
4116
|
-
return /* @__PURE__ */ (0,
|
4117
|
-
title && /* @__PURE__ */ (0,
|
4200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
4201
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
4118
4202
|
"button",
|
4119
4203
|
{
|
4120
4204
|
type: "button",
|
@@ -4128,14 +4212,14 @@ var ComponentList = ({
|
|
4128
4212
|
}),
|
4129
4213
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
4130
4214
|
children: [
|
4131
|
-
/* @__PURE__ */ (0,
|
4132
|
-
/* @__PURE__ */ (0,
|
4215
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: title }),
|
4216
|
+
/* @__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
4217
|
]
|
4134
4218
|
}
|
4135
4219
|
),
|
4136
|
-
/* @__PURE__ */ (0,
|
4220
|
+
/* @__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
4221
|
var _a;
|
4138
|
-
return /* @__PURE__ */ (0,
|
4222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
4139
4223
|
ComponentListItem,
|
4140
4224
|
{
|
4141
4225
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -4150,10 +4234,10 @@ var ComponentList = ({
|
|
4150
4234
|
ComponentList.Item = ComponentListItem;
|
4151
4235
|
|
4152
4236
|
// lib/use-component-list.tsx
|
4153
|
-
var
|
4237
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
4154
4238
|
var useComponentList = (config, ui) => {
|
4155
|
-
const [componentList, setComponentList] = (0,
|
4156
|
-
(0,
|
4239
|
+
const [componentList, setComponentList] = (0, import_react27.useState)();
|
4240
|
+
(0, import_react27.useEffect)(() => {
|
4157
4241
|
var _a, _b, _c;
|
4158
4242
|
if (Object.keys(ui.componentList).length > 0) {
|
4159
4243
|
const matchedComponents = [];
|
@@ -4163,7 +4247,7 @@ var useComponentList = (config, ui) => {
|
|
4163
4247
|
if (category.visible === false || !category.components) {
|
4164
4248
|
return null;
|
4165
4249
|
}
|
4166
|
-
return /* @__PURE__ */ (0,
|
4250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4167
4251
|
ComponentList,
|
4168
4252
|
{
|
4169
4253
|
id: categoryKey,
|
@@ -4172,7 +4256,7 @@ var useComponentList = (config, ui) => {
|
|
4172
4256
|
var _a2;
|
4173
4257
|
matchedComponents.push(componentName);
|
4174
4258
|
const componentConf = config.components[componentName] || {};
|
4175
|
-
return /* @__PURE__ */ (0,
|
4259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4176
4260
|
ComponentList.Item,
|
4177
4261
|
{
|
4178
4262
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -4192,7 +4276,7 @@ var useComponentList = (config, ui) => {
|
|
4192
4276
|
);
|
4193
4277
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
4194
4278
|
_componentList.push(
|
4195
|
-
/* @__PURE__ */ (0,
|
4279
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4196
4280
|
ComponentList,
|
4197
4281
|
{
|
4198
4282
|
id: "other",
|
@@ -4200,7 +4284,7 @@ var useComponentList = (config, ui) => {
|
|
4200
4284
|
children: remainingComponents.map((componentName, i) => {
|
4201
4285
|
var _a2;
|
4202
4286
|
const componentConf = config.components[componentName] || {};
|
4203
|
-
return /* @__PURE__ */ (0,
|
4287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
4204
4288
|
ComponentList.Item,
|
4205
4289
|
{
|
4206
4290
|
name: componentName,
|
@@ -4222,25 +4306,25 @@ var useComponentList = (config, ui) => {
|
|
4222
4306
|
};
|
4223
4307
|
|
4224
4308
|
// components/Puck/components/Components/index.tsx
|
4225
|
-
var
|
4226
|
-
var
|
4309
|
+
var import_react28 = require("react");
|
4310
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
4227
4311
|
var Components = () => {
|
4228
4312
|
const { config, state, overrides } = useAppContext();
|
4229
4313
|
const componentList = useComponentList(config, state.ui);
|
4230
|
-
const Wrapper = (0,
|
4231
|
-
return /* @__PURE__ */ (0,
|
4314
|
+
const Wrapper = (0, import_react28.useMemo)(() => overrides.components || "div", [overrides]);
|
4315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComponentList, { id: "all" }) });
|
4232
4316
|
};
|
4233
4317
|
|
4234
4318
|
// components/Puck/components/Preview/index.tsx
|
4235
4319
|
init_react_import();
|
4236
|
-
var
|
4320
|
+
var import_react30 = require("react");
|
4237
4321
|
|
4238
4322
|
// components/AutoFrame/index.tsx
|
4239
4323
|
init_react_import();
|
4240
|
-
var
|
4324
|
+
var import_react29 = require("react");
|
4241
4325
|
var import_object_hash = __toESM(require("object-hash"));
|
4242
4326
|
var import_react_dom2 = require("react-dom");
|
4243
|
-
var
|
4327
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
4244
4328
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
4245
4329
|
var collectStyles = (doc) => {
|
4246
4330
|
const collected = [];
|
@@ -4283,7 +4367,7 @@ var CopyHostStyles = ({
|
|
4283
4367
|
onStylesLoaded = () => null
|
4284
4368
|
}) => {
|
4285
4369
|
const { document: doc, window: win } = useFrame();
|
4286
|
-
(0,
|
4370
|
+
(0, import_react29.useEffect)(() => {
|
4287
4371
|
if (!win || !doc) {
|
4288
4372
|
return () => {
|
4289
4373
|
};
|
@@ -4440,10 +4524,10 @@ var CopyHostStyles = ({
|
|
4440
4524
|
observer.disconnect();
|
4441
4525
|
};
|
4442
4526
|
}, []);
|
4443
|
-
return /* @__PURE__ */ (0,
|
4527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
|
4444
4528
|
};
|
4445
|
-
var autoFrameContext = (0,
|
4446
|
-
var useFrame = () => (0,
|
4529
|
+
var autoFrameContext = (0, import_react29.createContext)({});
|
4530
|
+
var useFrame = () => (0, import_react29.useContext)(autoFrameContext);
|
4447
4531
|
function AutoFrame(_a) {
|
4448
4532
|
var _b = _a, {
|
4449
4533
|
children,
|
@@ -4458,11 +4542,11 @@ function AutoFrame(_a) {
|
|
4458
4542
|
"id",
|
4459
4543
|
"onStylesLoaded"
|
4460
4544
|
]);
|
4461
|
-
const [loaded, setLoaded] = (0,
|
4462
|
-
const [ctx, setCtx] = (0,
|
4463
|
-
const ref = (0,
|
4464
|
-
const [mountTarget, setMountTarget] = (0,
|
4465
|
-
(0,
|
4545
|
+
const [loaded, setLoaded] = (0, import_react29.useState)(false);
|
4546
|
+
const [ctx, setCtx] = (0, import_react29.useState)({});
|
4547
|
+
const ref = (0, import_react29.useRef)(null);
|
4548
|
+
const [mountTarget, setMountTarget] = (0, import_react29.useState)();
|
4549
|
+
(0, import_react29.useEffect)(() => {
|
4466
4550
|
var _a2;
|
4467
4551
|
if (ref.current) {
|
4468
4552
|
setCtx({
|
@@ -4472,7 +4556,7 @@ function AutoFrame(_a) {
|
|
4472
4556
|
setMountTarget((_a2 = ref.current.contentDocument) == null ? void 0 : _a2.getElementById("frame-root"));
|
4473
4557
|
}
|
4474
4558
|
}, [ref, loaded]);
|
4475
|
-
return /* @__PURE__ */ (0,
|
4559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
4476
4560
|
"iframe",
|
4477
4561
|
__spreadProps(__spreadValues({}, props), {
|
4478
4562
|
className,
|
@@ -4482,7 +4566,7 @@ function AutoFrame(_a) {
|
|
4482
4566
|
onLoad: () => {
|
4483
4567
|
setLoaded(true);
|
4484
4568
|
},
|
4485
|
-
children: /* @__PURE__ */ (0,
|
4569
|
+
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
4570
|
})
|
4487
4571
|
);
|
4488
4572
|
}
|
@@ -4494,22 +4578,22 @@ init_react_import();
|
|
4494
4578
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
|
4495
4579
|
|
4496
4580
|
// components/Puck/components/Preview/index.tsx
|
4497
|
-
var
|
4581
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
4498
4582
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
4499
4583
|
var Preview = ({ id = "puck-preview" }) => {
|
4500
4584
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
4501
|
-
const Page = (0,
|
4585
|
+
const Page = (0, import_react30.useCallback)(
|
4502
4586
|
(pageProps) => {
|
4503
4587
|
var _a, _b;
|
4504
4588
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
4505
4589
|
id: "puck-root"
|
4506
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
4590
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
4507
4591
|
},
|
4508
4592
|
[config.root]
|
4509
4593
|
);
|
4510
|
-
const Frame = (0,
|
4594
|
+
const Frame = (0, import_react30.useMemo)(() => overrides.iframe, [overrides]);
|
4511
4595
|
const rootProps = state.data.root.props || state.data.root;
|
4512
|
-
return /* @__PURE__ */ (0,
|
4596
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4513
4597
|
"div",
|
4514
4598
|
{
|
4515
4599
|
className: getClassName23(),
|
@@ -4517,7 +4601,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4517
4601
|
onClick: () => {
|
4518
4602
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
4519
4603
|
},
|
4520
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
4604
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4521
4605
|
AutoFrame_default,
|
4522
4606
|
{
|
4523
4607
|
id: "preview-frame",
|
@@ -4526,27 +4610,27 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4526
4610
|
onStylesLoaded: () => {
|
4527
4611
|
setStatus("READY");
|
4528
4612
|
},
|
4529
|
-
children: /* @__PURE__ */ (0,
|
4530
|
-
const inner = /* @__PURE__ */ (0,
|
4613
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
4614
|
+
const inner = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4531
4615
|
Page,
|
4532
4616
|
__spreadProps(__spreadValues({}, rootProps), {
|
4533
4617
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4534
4618
|
editMode: true,
|
4535
|
-
children: /* @__PURE__ */ (0,
|
4619
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
4536
4620
|
})
|
4537
4621
|
);
|
4538
4622
|
if (Frame) {
|
4539
|
-
return /* @__PURE__ */ (0,
|
4623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
4540
4624
|
}
|
4541
4625
|
return inner;
|
4542
4626
|
} })
|
4543
4627
|
}
|
4544
|
-
) : /* @__PURE__ */ (0,
|
4628
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4545
4629
|
Page,
|
4546
4630
|
__spreadProps(__spreadValues({}, rootProps), {
|
4547
4631
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4548
4632
|
editMode: true,
|
4549
|
-
children: /* @__PURE__ */ (0,
|
4633
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
4550
4634
|
})
|
4551
4635
|
) })
|
4552
4636
|
}
|
@@ -4596,7 +4680,7 @@ var scrollIntoView = (el) => {
|
|
4596
4680
|
};
|
4597
4681
|
|
4598
4682
|
// components/LayerTree/index.tsx
|
4599
|
-
var
|
4683
|
+
var import_react31 = require("react");
|
4600
4684
|
|
4601
4685
|
// lib/is-child-of-zone.ts
|
4602
4686
|
init_react_import();
|
@@ -4610,7 +4694,7 @@ var isChildOfZone = (item, maybeChild, ctx) => {
|
|
4610
4694
|
};
|
4611
4695
|
|
4612
4696
|
// components/LayerTree/index.tsx
|
4613
|
-
var
|
4697
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
4614
4698
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
4615
4699
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
4616
4700
|
var LayerTree = ({
|
@@ -4623,15 +4707,15 @@ var LayerTree = ({
|
|
4623
4707
|
label
|
4624
4708
|
}) => {
|
4625
4709
|
const zones = data.zones || {};
|
4626
|
-
const ctx = (0,
|
4627
|
-
return /* @__PURE__ */ (0,
|
4628
|
-
label && /* @__PURE__ */ (0,
|
4629
|
-
/* @__PURE__ */ (0,
|
4710
|
+
const ctx = (0, import_react31.useContext)(dropZoneContext);
|
4711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
4712
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
4713
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
4630
4714
|
" ",
|
4631
4715
|
label
|
4632
4716
|
] }),
|
4633
|
-
/* @__PURE__ */ (0,
|
4634
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
4717
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
|
4718
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
4635
4719
|
zoneContent.map((item, i) => {
|
4636
4720
|
var _a;
|
4637
4721
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -4649,7 +4733,7 @@ var LayerTree = ({
|
|
4649
4733
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
4650
4734
|
const componentConfig = config.components[item.type];
|
4651
4735
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
4652
|
-
return /* @__PURE__ */ (0,
|
4736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
4653
4737
|
"li",
|
4654
4738
|
{
|
4655
4739
|
className: getClassNameLayer({
|
@@ -4659,7 +4743,7 @@ var LayerTree = ({
|
|
4659
4743
|
childIsSelected
|
4660
4744
|
}),
|
4661
4745
|
children: [
|
4662
|
-
/* @__PURE__ */ (0,
|
4746
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
4663
4747
|
"button",
|
4664
4748
|
{
|
4665
4749
|
type: "button",
|
@@ -4692,22 +4776,22 @@ var LayerTree = ({
|
|
4692
4776
|
setHoveringComponent(null);
|
4693
4777
|
},
|
4694
4778
|
children: [
|
4695
|
-
containsZone && /* @__PURE__ */ (0,
|
4779
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
4696
4780
|
"div",
|
4697
4781
|
{
|
4698
4782
|
className: getClassNameLayer("chevron"),
|
4699
4783
|
title: isSelected ? "Collapse" : "Expand",
|
4700
|
-
children: /* @__PURE__ */ (0,
|
4784
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
4701
4785
|
}
|
4702
4786
|
),
|
4703
|
-
/* @__PURE__ */ (0,
|
4704
|
-
/* @__PURE__ */ (0,
|
4705
|
-
/* @__PURE__ */ (0,
|
4787
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
4788
|
+
/* @__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" }) }),
|
4789
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
4706
4790
|
] })
|
4707
4791
|
]
|
4708
4792
|
}
|
4709
4793
|
) }),
|
4710
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
4794
|
+
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
4795
|
LayerTree,
|
4712
4796
|
{
|
4713
4797
|
config,
|
@@ -4729,13 +4813,13 @@ var LayerTree = ({
|
|
4729
4813
|
};
|
4730
4814
|
|
4731
4815
|
// components/Puck/components/Outline/index.tsx
|
4732
|
-
var
|
4733
|
-
var
|
4816
|
+
var import_react32 = require("react");
|
4817
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
4734
4818
|
var Outline = () => {
|
4735
4819
|
const { dispatch, state, overrides, config } = useAppContext();
|
4736
4820
|
const { data, ui } = state;
|
4737
4821
|
const { itemSelector } = ui;
|
4738
|
-
const setItemSelector = (0,
|
4822
|
+
const setItemSelector = (0, import_react32.useCallback)(
|
4739
4823
|
(newItemSelector) => {
|
4740
4824
|
dispatch({
|
4741
4825
|
type: "setUi",
|
@@ -4744,9 +4828,9 @@ var Outline = () => {
|
|
4744
4828
|
},
|
4745
4829
|
[]
|
4746
4830
|
);
|
4747
|
-
const Wrapper = (0,
|
4748
|
-
return /* @__PURE__ */ (0,
|
4749
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
4831
|
+
const Wrapper = (0, import_react32.useMemo)(() => overrides.outline || "div", [overrides]);
|
4832
|
+
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: [
|
4833
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4750
4834
|
LayerTree,
|
4751
4835
|
{
|
4752
4836
|
config,
|
@@ -4759,7 +4843,7 @@ var Outline = () => {
|
|
4759
4843
|
),
|
4760
4844
|
Object.entries(findZonesForArea(data, "root")).map(
|
4761
4845
|
([zoneKey, zone]) => {
|
4762
|
-
return /* @__PURE__ */ (0,
|
4846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4763
4847
|
LayerTree,
|
4764
4848
|
{
|
4765
4849
|
config,
|
@@ -4783,7 +4867,8 @@ var import_react_hotkeys_hook = require("react-hotkeys-hook");
|
|
4783
4867
|
function usePuckHistory({
|
4784
4868
|
dispatch,
|
4785
4869
|
initialAppState,
|
4786
|
-
historyStore
|
4870
|
+
historyStore,
|
4871
|
+
iframeEnabled
|
4787
4872
|
}) {
|
4788
4873
|
const back = () => {
|
4789
4874
|
var _a;
|
@@ -4801,6 +4886,16 @@ function usePuckHistory({
|
|
4801
4886
|
historyStore.forward();
|
4802
4887
|
}
|
4803
4888
|
};
|
4889
|
+
const backIframe = () => {
|
4890
|
+
if (iframeEnabled) {
|
4891
|
+
back();
|
4892
|
+
}
|
4893
|
+
};
|
4894
|
+
const forwardIframe = () => {
|
4895
|
+
if (iframeEnabled) {
|
4896
|
+
forward();
|
4897
|
+
}
|
4898
|
+
};
|
4804
4899
|
const setHistories = (histories) => {
|
4805
4900
|
var _a;
|
4806
4901
|
dispatch({
|
@@ -4819,9 +4914,23 @@ function usePuckHistory({
|
|
4819
4914
|
historyStore.setHistoryIndex(index);
|
4820
4915
|
}
|
4821
4916
|
};
|
4917
|
+
const frame = getFrame();
|
4918
|
+
const resolvedFrame = frame !== document ? frame : void 0;
|
4822
4919
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+z", back, { preventDefault: true });
|
4823
4920
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+shift+z", forward, { preventDefault: true });
|
4824
4921
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+y", forward, { preventDefault: true });
|
4922
|
+
(0, import_react_hotkeys_hook.useHotkeys)("meta+z", backIframe, {
|
4923
|
+
preventDefault: true,
|
4924
|
+
document: resolvedFrame
|
4925
|
+
});
|
4926
|
+
(0, import_react_hotkeys_hook.useHotkeys)("meta+shift+z", forwardIframe, {
|
4927
|
+
preventDefault: true,
|
4928
|
+
document: resolvedFrame
|
4929
|
+
});
|
4930
|
+
(0, import_react_hotkeys_hook.useHotkeys)("meta+y", forwardIframe, {
|
4931
|
+
preventDefault: true,
|
4932
|
+
document: resolvedFrame
|
4933
|
+
});
|
4825
4934
|
return {
|
4826
4935
|
back,
|
4827
4936
|
forward,
|
@@ -4833,19 +4942,19 @@ function usePuckHistory({
|
|
4833
4942
|
|
4834
4943
|
// lib/use-history-store.ts
|
4835
4944
|
init_react_import();
|
4836
|
-
var
|
4945
|
+
var import_react33 = require("react");
|
4837
4946
|
var import_use_debounce3 = require("use-debounce");
|
4838
4947
|
var EMPTY_HISTORY_INDEX = 0;
|
4839
4948
|
function useHistoryStore(initialHistory) {
|
4840
4949
|
var _a, _b;
|
4841
|
-
const [histories, setHistories] = (0,
|
4950
|
+
const [histories, setHistories] = (0, import_react33.useState)(
|
4842
4951
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
4843
4952
|
);
|
4844
4953
|
const updateHistories = (histories2) => {
|
4845
4954
|
setHistories(histories2);
|
4846
4955
|
setIndex(histories2.length - 1);
|
4847
4956
|
};
|
4848
|
-
const [index, setIndex] = (0,
|
4957
|
+
const [index, setIndex] = (0, import_react33.useState)(
|
4849
4958
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
4850
4959
|
);
|
4851
4960
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -5005,22 +5114,22 @@ var getBox = function getBox2(el) {
|
|
5005
5114
|
};
|
5006
5115
|
|
5007
5116
|
// components/Puck/components/Canvas/index.tsx
|
5008
|
-
var
|
5117
|
+
var import_react35 = require("react");
|
5009
5118
|
|
5010
5119
|
// components/ViewportControls/index.tsx
|
5011
5120
|
init_react_import();
|
5012
|
-
var
|
5121
|
+
var import_react34 = require("react");
|
5013
5122
|
|
5014
5123
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
5015
5124
|
init_react_import();
|
5016
5125
|
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
5126
|
|
5018
5127
|
// components/ViewportControls/index.tsx
|
5019
|
-
var
|
5128
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
5020
5129
|
var icons = {
|
5021
|
-
Smartphone: /* @__PURE__ */ (0,
|
5022
|
-
Tablet: /* @__PURE__ */ (0,
|
5023
|
-
Monitor: /* @__PURE__ */ (0,
|
5130
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
|
5131
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
|
5132
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
|
5024
5133
|
};
|
5025
5134
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
5026
5135
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -5032,11 +5141,11 @@ var ViewportButton = ({
|
|
5032
5141
|
onClick
|
5033
5142
|
}) => {
|
5034
5143
|
const { state } = useAppContext();
|
5035
|
-
const [isActive, setIsActive] = (0,
|
5036
|
-
(0,
|
5144
|
+
const [isActive, setIsActive] = (0, import_react34.useState)(false);
|
5145
|
+
(0, import_react34.useEffect)(() => {
|
5037
5146
|
setIsActive(width === state.ui.viewports.current.width);
|
5038
5147
|
}, [width, state.ui.viewports.current.width]);
|
5039
|
-
return /* @__PURE__ */ (0,
|
5148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5040
5149
|
IconButton,
|
5041
5150
|
{
|
5042
5151
|
title,
|
@@ -5045,7 +5154,7 @@ var ViewportButton = ({
|
|
5045
5154
|
e.stopPropagation();
|
5046
5155
|
onClick({ width, height });
|
5047
5156
|
},
|
5048
|
-
children: /* @__PURE__ */ (0,
|
5157
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
|
5049
5158
|
}
|
5050
5159
|
) });
|
5051
5160
|
};
|
@@ -5069,7 +5178,7 @@ var ViewportControls = ({
|
|
5069
5178
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
5070
5179
|
(option) => option.value === autoZoom
|
5071
5180
|
);
|
5072
|
-
const zoomOptions = (0,
|
5181
|
+
const zoomOptions = (0, import_react34.useMemo)(
|
5073
5182
|
() => [
|
5074
5183
|
...defaultZoomOptions,
|
5075
5184
|
...defaultsContainAutoZoom ? [] : [
|
@@ -5081,8 +5190,8 @@ var ViewportControls = ({
|
|
5081
5190
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
5082
5191
|
[autoZoom]
|
5083
5192
|
);
|
5084
|
-
return /* @__PURE__ */ (0,
|
5085
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
5193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
|
5194
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5086
5195
|
ViewportButton,
|
5087
5196
|
{
|
5088
5197
|
height: viewport.height,
|
@@ -5093,8 +5202,8 @@ var ViewportControls = ({
|
|
5093
5202
|
},
|
5094
5203
|
i
|
5095
5204
|
)),
|
5096
|
-
/* @__PURE__ */ (0,
|
5097
|
-
/* @__PURE__ */ (0,
|
5205
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
5206
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5098
5207
|
IconButton,
|
5099
5208
|
{
|
5100
5209
|
title: "Zoom viewport out",
|
@@ -5108,10 +5217,10 @@ var ViewportControls = ({
|
|
5108
5217
|
)].value
|
5109
5218
|
);
|
5110
5219
|
},
|
5111
|
-
children: /* @__PURE__ */ (0,
|
5220
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
|
5112
5221
|
}
|
5113
5222
|
),
|
5114
|
-
/* @__PURE__ */ (0,
|
5223
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5115
5224
|
IconButton,
|
5116
5225
|
{
|
5117
5226
|
title: "Zoom viewport in",
|
@@ -5125,11 +5234,11 @@ var ViewportControls = ({
|
|
5125
5234
|
)].value
|
5126
5235
|
);
|
5127
5236
|
},
|
5128
|
-
children: /* @__PURE__ */ (0,
|
5237
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
|
5129
5238
|
}
|
5130
5239
|
),
|
5131
|
-
/* @__PURE__ */ (0,
|
5132
|
-
/* @__PURE__ */ (0,
|
5240
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
5241
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5133
5242
|
"select",
|
5134
5243
|
{
|
5135
5244
|
className: getClassName25("zoomSelect"),
|
@@ -5137,7 +5246,7 @@ var ViewportControls = ({
|
|
5137
5246
|
onChange: (e) => {
|
5138
5247
|
onZoom(parseFloat(e.currentTarget.value));
|
5139
5248
|
},
|
5140
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
5249
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5141
5250
|
"option",
|
5142
5251
|
{
|
5143
5252
|
value: option.value,
|
@@ -5152,7 +5261,7 @@ var ViewportControls = ({
|
|
5152
5261
|
|
5153
5262
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
5154
5263
|
init_react_import();
|
5155
|
-
var styles_module_default21 = { "PuckCanvas": "
|
5264
|
+
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
5265
|
|
5157
5266
|
// lib/get-zoom-config.ts
|
5158
5267
|
init_react_import();
|
@@ -5185,24 +5294,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
5185
5294
|
};
|
5186
5295
|
|
5187
5296
|
// components/Puck/components/Canvas/index.tsx
|
5188
|
-
var
|
5297
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
5189
5298
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
5190
5299
|
var ZOOM_ON_CHANGE = true;
|
5191
5300
|
var Canvas = () => {
|
5192
5301
|
const { status, iframe } = useAppContext();
|
5193
5302
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
5194
5303
|
const { ui } = state;
|
5195
|
-
const frameRef = (0,
|
5196
|
-
const [showTransition, setShowTransition] = (0,
|
5197
|
-
const defaultRender = (0,
|
5198
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
5304
|
+
const frameRef = (0, import_react35.useRef)(null);
|
5305
|
+
const [showTransition, setShowTransition] = (0, import_react35.useState)(false);
|
5306
|
+
const defaultRender = (0, import_react35.useMemo)(() => {
|
5307
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
5199
5308
|
return PuckDefault;
|
5200
5309
|
}, []);
|
5201
|
-
const CustomPreview = (0,
|
5310
|
+
const CustomPreview = (0, import_react35.useMemo)(
|
5202
5311
|
() => overrides.preview || defaultRender,
|
5203
5312
|
[overrides]
|
5204
5313
|
);
|
5205
|
-
const getFrameDimensions = (0,
|
5314
|
+
const getFrameDimensions = (0, import_react35.useCallback)(() => {
|
5206
5315
|
if (frameRef.current) {
|
5207
5316
|
const frame = frameRef.current;
|
5208
5317
|
const box = getBox(frame);
|
@@ -5210,7 +5319,7 @@ var Canvas = () => {
|
|
5210
5319
|
}
|
5211
5320
|
return { width: 0, height: 0 };
|
5212
5321
|
}, [frameRef]);
|
5213
|
-
const resetAutoZoom = (0,
|
5322
|
+
const resetAutoZoom = (0, import_react35.useCallback)(
|
5214
5323
|
(ui2 = state.ui) => {
|
5215
5324
|
if (frameRef.current) {
|
5216
5325
|
setZoomConfig(
|
@@ -5220,11 +5329,11 @@ var Canvas = () => {
|
|
5220
5329
|
},
|
5221
5330
|
[frameRef, zoomConfig, state.ui]
|
5222
5331
|
);
|
5223
|
-
(0,
|
5332
|
+
(0, import_react35.useEffect)(() => {
|
5224
5333
|
setShowTransition(false);
|
5225
5334
|
resetAutoZoom();
|
5226
5335
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
5227
|
-
(0,
|
5336
|
+
(0, import_react35.useEffect)(() => {
|
5228
5337
|
const { height: frameHeight } = getFrameDimensions();
|
5229
5338
|
if (ui.viewports.current.height === "auto") {
|
5230
5339
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -5232,13 +5341,13 @@ var Canvas = () => {
|
|
5232
5341
|
}));
|
5233
5342
|
}
|
5234
5343
|
}, [zoomConfig.zoom]);
|
5235
|
-
(0,
|
5344
|
+
(0, import_react35.useEffect)(() => {
|
5236
5345
|
if (ZOOM_ON_CHANGE) {
|
5237
5346
|
setShowTransition(true);
|
5238
5347
|
resetAutoZoom(ui);
|
5239
5348
|
}
|
5240
5349
|
}, [ui.viewports.current.width]);
|
5241
|
-
(0,
|
5350
|
+
(0, import_react35.useEffect)(() => {
|
5242
5351
|
const observer = new ResizeObserver(() => {
|
5243
5352
|
setShowTransition(false);
|
5244
5353
|
resetAutoZoom();
|
@@ -5250,13 +5359,13 @@ var Canvas = () => {
|
|
5250
5359
|
observer.disconnect();
|
5251
5360
|
};
|
5252
5361
|
}, []);
|
5253
|
-
const [showLoader, setShowLoader] = (0,
|
5254
|
-
(0,
|
5362
|
+
const [showLoader, setShowLoader] = (0, import_react35.useState)(false);
|
5363
|
+
(0, import_react35.useEffect)(() => {
|
5255
5364
|
setTimeout(() => {
|
5256
5365
|
setShowLoader(true);
|
5257
5366
|
}, 500);
|
5258
5367
|
}, []);
|
5259
|
-
return /* @__PURE__ */ (0,
|
5368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
5260
5369
|
"div",
|
5261
5370
|
{
|
5262
5371
|
className: getClassName26({
|
@@ -5269,7 +5378,7 @@ var Canvas = () => {
|
|
5269
5378
|
recordHistory: true
|
5270
5379
|
}),
|
5271
5380
|
children: [
|
5272
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
5381
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
5273
5382
|
ViewportControls,
|
5274
5383
|
{
|
5275
5384
|
autoZoom: zoomConfig.autoZoom,
|
@@ -5294,8 +5403,8 @@ var Canvas = () => {
|
|
5294
5403
|
}
|
5295
5404
|
}
|
5296
5405
|
) }),
|
5297
|
-
/* @__PURE__ */ (0,
|
5298
|
-
/* @__PURE__ */ (0,
|
5406
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
5407
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
5299
5408
|
"div",
|
5300
5409
|
{
|
5301
5410
|
className: getClassName26("root"),
|
@@ -5307,10 +5416,10 @@ var Canvas = () => {
|
|
5307
5416
|
overflow: iframe.enabled ? void 0 : "auto"
|
5308
5417
|
},
|
5309
5418
|
suppressHydrationWarning: true,
|
5310
|
-
children: /* @__PURE__ */ (0,
|
5419
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview, {}) })
|
5311
5420
|
}
|
5312
5421
|
),
|
5313
|
-
/* @__PURE__ */ (0,
|
5422
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
5314
5423
|
] })
|
5315
5424
|
]
|
5316
5425
|
}
|
@@ -5354,7 +5463,7 @@ var insertComponent = (componentType, zone, index, {
|
|
5354
5463
|
|
5355
5464
|
// lib/use-loaded-overrides.ts
|
5356
5465
|
init_react_import();
|
5357
|
-
var
|
5466
|
+
var import_react36 = require("react");
|
5358
5467
|
|
5359
5468
|
// lib/load-overrides.ts
|
5360
5469
|
init_react_import();
|
@@ -5393,18 +5502,18 @@ var useLoadedOverrides = ({
|
|
5393
5502
|
overrides,
|
5394
5503
|
plugins
|
5395
5504
|
}) => {
|
5396
|
-
return (0,
|
5505
|
+
return (0, import_react36.useMemo)(() => {
|
5397
5506
|
return loadOverrides({ overrides, plugins });
|
5398
5507
|
}, [plugins, overrides]);
|
5399
5508
|
};
|
5400
5509
|
|
5401
5510
|
// components/DefaultOverride/index.tsx
|
5402
5511
|
init_react_import();
|
5403
|
-
var
|
5404
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
5512
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
5513
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
5405
5514
|
|
5406
5515
|
// components/Puck/index.tsx
|
5407
|
-
var
|
5516
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
5408
5517
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
5409
5518
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
5410
5519
|
function Puck({
|
@@ -5427,13 +5536,13 @@ function Puck({
|
|
5427
5536
|
dnd,
|
5428
5537
|
initialHistory: _initialHistory
|
5429
5538
|
}) {
|
5430
|
-
var _a;
|
5539
|
+
var _a, _b;
|
5431
5540
|
const iframe = __spreadValues({
|
5432
5541
|
enabled: true,
|
5433
5542
|
waitForStyles: true
|
5434
5543
|
}, _iframe);
|
5435
|
-
const [generatedAppState] = (0,
|
5436
|
-
var _a2,
|
5544
|
+
const [generatedAppState] = (0, import_react37.useState)(() => {
|
5545
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
5437
5546
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
5438
5547
|
let clientUiState = {};
|
5439
5548
|
if (typeof window !== "undefined") {
|
@@ -5453,7 +5562,7 @@ function Puck({
|
|
5453
5562
|
clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
|
5454
5563
|
viewports: __spreadProps(__spreadValues({}, initial.viewports), {
|
5455
5564
|
current: __spreadProps(__spreadValues({}, initial.viewports.current), {
|
5456
|
-
height: ((
|
5565
|
+
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
5566
|
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
5567
|
})
|
5459
5568
|
})
|
@@ -5504,22 +5613,27 @@ function Puck({
|
|
5504
5613
|
histories,
|
5505
5614
|
index: initialHistoryIndex
|
5506
5615
|
});
|
5507
|
-
const [reducer] = (0,
|
5616
|
+
const [reducer] = (0, import_react37.useState)(
|
5508
5617
|
() => createReducer({
|
5509
5618
|
config,
|
5510
5619
|
record: historyStore.record,
|
5511
5620
|
onAction
|
5512
5621
|
})
|
5513
5622
|
);
|
5514
|
-
const [appState, dispatch] = (0,
|
5623
|
+
const [appState, dispatch] = (0, import_react37.useReducer)(
|
5515
5624
|
reducer,
|
5516
5625
|
flushZones(initialAppState)
|
5517
5626
|
);
|
5518
5627
|
const { data, ui } = appState;
|
5519
|
-
const history = usePuckHistory({
|
5520
|
-
|
5628
|
+
const history = usePuckHistory({
|
5629
|
+
dispatch,
|
5630
|
+
initialAppState,
|
5631
|
+
historyStore,
|
5632
|
+
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
5633
|
+
});
|
5634
|
+
const [menuOpen, setMenuOpen] = (0, import_react37.useState)(false);
|
5521
5635
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
5522
|
-
const setItemSelector = (0,
|
5636
|
+
const setItemSelector = (0, import_react37.useCallback)(
|
5523
5637
|
(newItemSelector) => {
|
5524
5638
|
if (newItemSelector === itemSelector) return;
|
5525
5639
|
dispatch({
|
@@ -5531,13 +5645,13 @@ function Puck({
|
|
5531
5645
|
[itemSelector]
|
5532
5646
|
);
|
5533
5647
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
5534
|
-
(0,
|
5648
|
+
(0, import_react37.useEffect)(() => {
|
5535
5649
|
if (onChange) onChange(data);
|
5536
5650
|
}, [data]);
|
5537
5651
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
5538
|
-
const [draggedItem, setDraggedItem] = (0,
|
5652
|
+
const [draggedItem, setDraggedItem] = (0, import_react37.useState)();
|
5539
5653
|
const rootProps = data.root.props || data.root;
|
5540
|
-
const toggleSidebars = (0,
|
5654
|
+
const toggleSidebars = (0, import_react37.useCallback)(
|
5541
5655
|
(sidebar) => {
|
5542
5656
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
5543
5657
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -5551,7 +5665,7 @@ function Puck({
|
|
5551
5665
|
},
|
5552
5666
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
5553
5667
|
);
|
5554
|
-
(0,
|
5668
|
+
(0, import_react37.useEffect)(() => {
|
5555
5669
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
5556
5670
|
dispatch({
|
5557
5671
|
type: "setUi",
|
@@ -5574,28 +5688,28 @@ function Puck({
|
|
5574
5688
|
window.removeEventListener("resize", handleResize);
|
5575
5689
|
};
|
5576
5690
|
}, []);
|
5577
|
-
const defaultHeaderRender = (0,
|
5691
|
+
const defaultHeaderRender = (0, import_react37.useMemo)(() => {
|
5578
5692
|
if (renderHeader) {
|
5579
5693
|
console.warn(
|
5580
5694
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
5581
5695
|
);
|
5582
5696
|
const RenderHeader = (_a2) => {
|
5583
|
-
var
|
5697
|
+
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
5584
5698
|
const Comp = renderHeader;
|
5585
|
-
return /* @__PURE__ */ (0,
|
5699
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
5586
5700
|
};
|
5587
5701
|
return RenderHeader;
|
5588
5702
|
}
|
5589
5703
|
return DefaultOverride;
|
5590
5704
|
}, [renderHeader]);
|
5591
|
-
const defaultHeaderActionsRender = (0,
|
5705
|
+
const defaultHeaderActionsRender = (0, import_react37.useMemo)(() => {
|
5592
5706
|
if (renderHeaderActions) {
|
5593
5707
|
console.warn(
|
5594
5708
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
5595
5709
|
);
|
5596
5710
|
const RenderHeader = (props) => {
|
5597
5711
|
const Comp = renderHeaderActions;
|
5598
|
-
return /* @__PURE__ */ (0,
|
5712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
5599
5713
|
};
|
5600
5714
|
return RenderHeader;
|
5601
5715
|
}
|
@@ -5605,26 +5719,26 @@ function Puck({
|
|
5605
5719
|
overrides,
|
5606
5720
|
plugins
|
5607
5721
|
});
|
5608
|
-
const CustomPuck = (0,
|
5722
|
+
const CustomPuck = (0, import_react37.useMemo)(
|
5609
5723
|
() => loadedOverrides.puck || DefaultOverride,
|
5610
5724
|
[loadedOverrides]
|
5611
5725
|
);
|
5612
|
-
const CustomHeader = (0,
|
5726
|
+
const CustomHeader = (0, import_react37.useMemo)(
|
5613
5727
|
() => loadedOverrides.header || defaultHeaderRender,
|
5614
5728
|
[loadedOverrides]
|
5615
5729
|
);
|
5616
|
-
const CustomHeaderActions = (0,
|
5730
|
+
const CustomHeaderActions = (0, import_react37.useMemo)(
|
5617
5731
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
5618
5732
|
[loadedOverrides]
|
5619
5733
|
);
|
5620
|
-
const [mounted, setMounted] = (0,
|
5621
|
-
(0,
|
5734
|
+
const [mounted, setMounted] = (0, import_react37.useState)(false);
|
5735
|
+
(0, import_react37.useEffect)(() => {
|
5622
5736
|
setMounted(true);
|
5623
5737
|
}, []);
|
5624
5738
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
5625
|
-
const selectedComponentLabel = selectedItem ? (
|
5626
|
-
return /* @__PURE__ */ (0,
|
5627
|
-
/* @__PURE__ */ (0,
|
5739
|
+
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
5740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
5741
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5628
5742
|
AppProvider,
|
5629
5743
|
{
|
5630
5744
|
value: {
|
@@ -5646,7 +5760,7 @@ function Puck({
|
|
5646
5760
|
getPermissions: () => ({}),
|
5647
5761
|
refreshPermissions: () => null
|
5648
5762
|
},
|
5649
|
-
children: /* @__PURE__ */ (0,
|
5763
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(appContext.Consumer, { children: ({ resolveData }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5650
5764
|
DragDropContext,
|
5651
5765
|
{
|
5652
5766
|
autoScrollerOptions: { disabled: dnd == null ? void 0 : dnd.disableAutoScroll },
|
@@ -5698,7 +5812,7 @@ function Puck({
|
|
5698
5812
|
});
|
5699
5813
|
}
|
5700
5814
|
},
|
5701
|
-
children: /* @__PURE__ */ (0,
|
5815
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5702
5816
|
DropZoneProvider,
|
5703
5817
|
{
|
5704
5818
|
value: {
|
@@ -5712,7 +5826,7 @@ function Puck({
|
|
5712
5826
|
mode: "edit",
|
5713
5827
|
areaId: "root"
|
5714
5828
|
},
|
5715
|
-
children: /* @__PURE__ */ (0,
|
5829
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5716
5830
|
"div",
|
5717
5831
|
{
|
5718
5832
|
className: getLayoutClassName({
|
@@ -5721,58 +5835,58 @@ function Puck({
|
|
5721
5835
|
mounted,
|
5722
5836
|
rightSideBarVisible
|
5723
5837
|
}),
|
5724
|
-
children: /* @__PURE__ */ (0,
|
5725
|
-
/* @__PURE__ */ (0,
|
5838
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
5839
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5726
5840
|
CustomHeader,
|
5727
5841
|
{
|
5728
|
-
actions: /* @__PURE__ */ (0,
|
5842
|
+
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
5843
|
Button,
|
5730
5844
|
{
|
5731
5845
|
onClick: () => {
|
5732
5846
|
onPublish && onPublish(data);
|
5733
5847
|
},
|
5734
|
-
icon: /* @__PURE__ */ (0,
|
5848
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
5735
5849
|
children: "Publish"
|
5736
5850
|
}
|
5737
5851
|
) }) }),
|
5738
|
-
children: /* @__PURE__ */ (0,
|
5739
|
-
/* @__PURE__ */ (0,
|
5852
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
5853
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
5740
5854
|
"div",
|
5741
5855
|
{
|
5742
5856
|
className: getLayoutClassName("headerToggle"),
|
5743
5857
|
children: [
|
5744
|
-
/* @__PURE__ */ (0,
|
5858
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5745
5859
|
"div",
|
5746
5860
|
{
|
5747
5861
|
className: getLayoutClassName(
|
5748
5862
|
"leftSideBarToggle"
|
5749
5863
|
),
|
5750
|
-
children: /* @__PURE__ */ (0,
|
5864
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5751
5865
|
IconButton,
|
5752
5866
|
{
|
5753
5867
|
onClick: () => {
|
5754
5868
|
toggleSidebars("left");
|
5755
5869
|
},
|
5756
5870
|
title: "Toggle left sidebar",
|
5757
|
-
children: /* @__PURE__ */ (0,
|
5871
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
5758
5872
|
}
|
5759
5873
|
)
|
5760
5874
|
}
|
5761
5875
|
),
|
5762
|
-
/* @__PURE__ */ (0,
|
5876
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5763
5877
|
"div",
|
5764
5878
|
{
|
5765
5879
|
className: getLayoutClassName(
|
5766
5880
|
"rightSideBarToggle"
|
5767
5881
|
),
|
5768
|
-
children: /* @__PURE__ */ (0,
|
5882
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5769
5883
|
IconButton,
|
5770
5884
|
{
|
5771
5885
|
onClick: () => {
|
5772
5886
|
toggleSidebars("right");
|
5773
5887
|
},
|
5774
5888
|
title: "Toggle right sidebar",
|
5775
|
-
children: /* @__PURE__ */ (0,
|
5889
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
5776
5890
|
}
|
5777
5891
|
)
|
5778
5892
|
}
|
@@ -5780,15 +5894,15 @@ function Puck({
|
|
5780
5894
|
]
|
5781
5895
|
}
|
5782
5896
|
),
|
5783
|
-
/* @__PURE__ */ (0,
|
5897
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5784
5898
|
"div",
|
5785
5899
|
{
|
5786
5900
|
className: getLayoutClassName("headerTitle"),
|
5787
|
-
children: /* @__PURE__ */ (0,
|
5901
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
5788
5902
|
headerTitle || rootProps.title || "Page",
|
5789
|
-
headerPath && /* @__PURE__ */ (0,
|
5903
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
5790
5904
|
" ",
|
5791
|
-
/* @__PURE__ */ (0,
|
5905
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5792
5906
|
"code",
|
5793
5907
|
{
|
5794
5908
|
className: getLayoutClassName(
|
@@ -5801,41 +5915,41 @@ function Puck({
|
|
5801
5915
|
] })
|
5802
5916
|
}
|
5803
5917
|
),
|
5804
|
-
/* @__PURE__ */ (0,
|
5918
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
5805
5919
|
"div",
|
5806
5920
|
{
|
5807
5921
|
className: getLayoutClassName("headerTools"),
|
5808
5922
|
children: [
|
5809
|
-
/* @__PURE__ */ (0,
|
5923
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5810
5924
|
"div",
|
5811
5925
|
{
|
5812
5926
|
className: getLayoutClassName("menuButton"),
|
5813
|
-
children: /* @__PURE__ */ (0,
|
5927
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5814
5928
|
IconButton,
|
5815
5929
|
{
|
5816
5930
|
onClick: () => {
|
5817
5931
|
return setMenuOpen(!menuOpen);
|
5818
5932
|
},
|
5819
5933
|
title: "Toggle menu bar",
|
5820
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
5934
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
5821
5935
|
}
|
5822
5936
|
)
|
5823
5937
|
}
|
5824
5938
|
),
|
5825
|
-
/* @__PURE__ */ (0,
|
5939
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5826
5940
|
MenuBar,
|
5827
5941
|
{
|
5828
5942
|
appState,
|
5829
5943
|
dispatch,
|
5830
5944
|
onPublish,
|
5831
5945
|
menuOpen,
|
5832
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
5946
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5833
5947
|
Button,
|
5834
5948
|
{
|
5835
5949
|
onClick: () => {
|
5836
5950
|
onPublish && onPublish(data);
|
5837
5951
|
},
|
5838
|
-
icon: /* @__PURE__ */ (0,
|
5952
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
5839
5953
|
children: "Publish"
|
5840
5954
|
}
|
5841
5955
|
) }),
|
@@ -5848,19 +5962,19 @@ function Puck({
|
|
5848
5962
|
] }) })
|
5849
5963
|
}
|
5850
5964
|
),
|
5851
|
-
/* @__PURE__ */ (0,
|
5852
|
-
/* @__PURE__ */ (0,
|
5853
|
-
/* @__PURE__ */ (0,
|
5965
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
5966
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
|
5967
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
|
5854
5968
|
] }),
|
5855
|
-
/* @__PURE__ */ (0,
|
5856
|
-
/* @__PURE__ */ (0,
|
5969
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
|
5970
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
5857
5971
|
SidebarSection,
|
5858
5972
|
{
|
5859
5973
|
noPadding: true,
|
5860
5974
|
noBorderTop: true,
|
5861
5975
|
showBreadcrumbs: true,
|
5862
5976
|
title: selectedItem ? selectedComponentLabel : "Page",
|
5863
|
-
children: /* @__PURE__ */ (0,
|
5977
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
|
5864
5978
|
}
|
5865
5979
|
) })
|
5866
5980
|
] })
|
@@ -5872,7 +5986,7 @@ function Puck({
|
|
5872
5986
|
) })
|
5873
5987
|
}
|
5874
5988
|
),
|
5875
|
-
/* @__PURE__ */ (0,
|
5989
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
5876
5990
|
] });
|
5877
5991
|
}
|
5878
5992
|
Puck.Components = Components;
|
@@ -5882,7 +5996,7 @@ Puck.Preview = Preview;
|
|
5882
5996
|
|
5883
5997
|
// components/Render/index.tsx
|
5884
5998
|
init_react_import();
|
5885
|
-
var
|
5999
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
5886
6000
|
function Render({
|
5887
6001
|
config,
|
5888
6002
|
data
|
@@ -5895,7 +6009,7 @@ function Render({
|
|
5895
6009
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
5896
6010
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
5897
6011
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5898
|
-
return /* @__PURE__ */ (0,
|
6012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
5899
6013
|
config.root.render,
|
5900
6014
|
__spreadProps(__spreadValues({}, rootProps), {
|
5901
6015
|
puck: {
|
@@ -5905,11 +6019,11 @@ function Render({
|
|
5905
6019
|
title,
|
5906
6020
|
editMode: false,
|
5907
6021
|
id: "puck-root",
|
5908
|
-
children: /* @__PURE__ */ (0,
|
6022
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DropZone, { zone: rootDroppableId })
|
5909
6023
|
})
|
5910
6024
|
) });
|
5911
6025
|
}
|
5912
|
-
return /* @__PURE__ */ (0,
|
6026
|
+
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
6027
|
}
|
5914
6028
|
|
5915
6029
|
// lib/migrate.ts
|