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