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