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