@measured/puck 0.18.0-canary.d253d54 → 0.18.0-canary.d5324f1
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/README.md +3 -3
- package/dist/{chunk-EXKSBUY5.mjs → chunk-CHWFBYEM.mjs} +2 -4
- package/dist/index.css +72 -82
- package/dist/index.d.mts +7 -11
- package/dist/index.d.ts +7 -11
- package/dist/index.js +1451 -1019
- package/dist/index.mjs +1350 -915
- package/dist/{resolve-all-data-GYzT3ont.d.mts → resolve-all-data-DzJEE28m.d.mts} +2 -1
- package/dist/{resolve-all-data-GYzT3ont.d.ts → resolve-all-data-DzJEE28m.d.ts} +2 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +2 -4
- package/dist/rsc.mjs +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
@@ -308,10 +308,10 @@ init_react_import();
|
|
308
308
|
|
309
309
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
310
310
|
init_react_import();
|
311
|
-
var styles_module_default2 = { "InputWrapper": "
|
311
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
|
312
312
|
|
313
313
|
// components/AutoField/index.tsx
|
314
|
-
var
|
314
|
+
var import_react20 = require("react");
|
315
315
|
|
316
316
|
// components/AutoField/fields/index.tsx
|
317
317
|
init_react_import();
|
@@ -771,7 +771,7 @@ var IconButton = ({
|
|
771
771
|
};
|
772
772
|
|
773
773
|
// components/AutoField/fields/ArrayField/index.tsx
|
774
|
-
var
|
774
|
+
var import_react12 = require("react");
|
775
775
|
|
776
776
|
// components/DragIcon/index.tsx
|
777
777
|
init_react_import();
|
@@ -988,13 +988,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
988
988
|
onResolveStart(item);
|
989
989
|
}
|
990
990
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
991
|
-
const { readOnly: existingReadOnly = {} } = item || {};
|
992
|
-
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
993
991
|
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
994
992
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
995
993
|
});
|
996
|
-
if (Object.keys(
|
997
|
-
resolvedItem.readOnly =
|
994
|
+
if (Object.keys(readOnly).length) {
|
995
|
+
resolvedItem.readOnly = readOnly;
|
998
996
|
}
|
999
997
|
cache.lastChange[item.props.id] = {
|
1000
998
|
item,
|
@@ -1161,6 +1159,7 @@ var defaultAppState = {
|
|
1161
1159
|
itemSelector: null,
|
1162
1160
|
componentList: {},
|
1163
1161
|
isDragging: false,
|
1162
|
+
previewMode: "edit",
|
1164
1163
|
viewports: {
|
1165
1164
|
current: {
|
1166
1165
|
width: defaultViewports[0].width,
|
@@ -1283,7 +1282,7 @@ init_react_import();
|
|
1283
1282
|
var import_react9 = require("@dnd-kit/react");
|
1284
1283
|
var import_react10 = require("react");
|
1285
1284
|
|
1286
|
-
// lib/dnd-kit/safe.ts
|
1285
|
+
// lib/dnd/dnd-kit/safe.ts
|
1287
1286
|
init_react_import();
|
1288
1287
|
var import_react8 = require("@dnd-kit/react");
|
1289
1288
|
var import_sortable = require("@dnd-kit/react/sortable");
|
@@ -1360,8 +1359,53 @@ var Sortable = ({
|
|
1360
1359
|
return children({ status, ref: sortableRef });
|
1361
1360
|
};
|
1362
1361
|
|
1363
|
-
// components/AutoField/
|
1362
|
+
// components/AutoField/context.tsx
|
1363
|
+
init_react_import();
|
1364
|
+
var import_react11 = require("react");
|
1364
1365
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
1366
|
+
var NestedFieldContext = (0, import_react11.createContext)({});
|
1367
|
+
var useNestedFieldContext = () => {
|
1368
|
+
const context = (0, import_react11.useContext)(NestedFieldContext);
|
1369
|
+
return __spreadProps(__spreadValues({}, context), {
|
1370
|
+
readOnlyFields: context.readOnlyFields || {}
|
1371
|
+
});
|
1372
|
+
};
|
1373
|
+
var NestedFieldProvider = ({
|
1374
|
+
children,
|
1375
|
+
name,
|
1376
|
+
subName,
|
1377
|
+
wildcardName = name,
|
1378
|
+
readOnlyFields
|
1379
|
+
}) => {
|
1380
|
+
const subPath = `${name}.${subName}`;
|
1381
|
+
const wildcardSubPath = `${wildcardName}.${subName}`;
|
1382
|
+
const subReadOnlyFields = (0, import_react11.useMemo)(
|
1383
|
+
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
1384
|
+
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
1385
|
+
if (isLocal) {
|
1386
|
+
const subPathPattern = new RegExp(
|
1387
|
+
`^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
|
1388
|
+
);
|
1389
|
+
const localName = readOnlyKey.replace(subPathPattern, "");
|
1390
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1391
|
+
[localName]: readOnlyFields[readOnlyKey]
|
1392
|
+
});
|
1393
|
+
}
|
1394
|
+
return acc;
|
1395
|
+
}, {}),
|
1396
|
+
[name, subName, wildcardName, readOnlyFields]
|
1397
|
+
);
|
1398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
1399
|
+
NestedFieldContext.Provider,
|
1400
|
+
{
|
1401
|
+
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
1402
|
+
children
|
1403
|
+
}
|
1404
|
+
);
|
1405
|
+
};
|
1406
|
+
|
1407
|
+
// components/AutoField/fields/ArrayField/index.tsx
|
1408
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
1365
1409
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
1366
1410
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
1367
1411
|
var ArrayField = ({
|
@@ -1372,10 +1416,10 @@ var ArrayField = ({
|
|
1372
1416
|
label,
|
1373
1417
|
readOnly,
|
1374
1418
|
id,
|
1375
|
-
Label: Label2 = (props) => /* @__PURE__ */ (0,
|
1419
|
+
Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadValues({}, props))
|
1376
1420
|
}) => {
|
1377
1421
|
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
1378
|
-
const readOnlyFields =
|
1422
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
1379
1423
|
const value = _value;
|
1380
1424
|
const arrayState = state.ui.arrayState[id] || {
|
1381
1425
|
items: Array.from(value || []).map((item, idx) => {
|
@@ -1386,11 +1430,11 @@ var ArrayField = ({
|
|
1386
1430
|
}),
|
1387
1431
|
openId: ""
|
1388
1432
|
};
|
1389
|
-
const [localState, setLocalState] = (0,
|
1390
|
-
(0,
|
1433
|
+
const [localState, setLocalState] = (0, import_react12.useState)({ arrayState, value });
|
1434
|
+
(0, import_react12.useEffect)(() => {
|
1391
1435
|
setLocalState({ arrayState, value });
|
1392
1436
|
}, [value, state.ui.arrayState[id]]);
|
1393
|
-
const mapArrayStateToUi = (0,
|
1437
|
+
const mapArrayStateToUi = (0, import_react12.useCallback)(
|
1394
1438
|
(partialArrayState) => {
|
1395
1439
|
return {
|
1396
1440
|
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
@@ -1400,13 +1444,13 @@ var ArrayField = ({
|
|
1400
1444
|
},
|
1401
1445
|
[arrayState]
|
1402
1446
|
);
|
1403
|
-
const getHighestIndex = (0,
|
1447
|
+
const getHighestIndex = (0, import_react12.useCallback)(() => {
|
1404
1448
|
return arrayState.items.reduce(
|
1405
1449
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
1406
1450
|
-1
|
1407
1451
|
);
|
1408
1452
|
}, [arrayState]);
|
1409
|
-
const regenerateArrayState = (0,
|
1453
|
+
const regenerateArrayState = (0, import_react12.useCallback)(
|
1410
1454
|
(value2) => {
|
1411
1455
|
let highestIndex = getHighestIndex();
|
1412
1456
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -1425,7 +1469,7 @@ var ArrayField = ({
|
|
1425
1469
|
},
|
1426
1470
|
[arrayState]
|
1427
1471
|
);
|
1428
|
-
(0,
|
1472
|
+
(0, import_react12.useEffect)(() => {
|
1429
1473
|
if (arrayState.items.length > 0) {
|
1430
1474
|
setUi(mapArrayStateToUi(arrayState));
|
1431
1475
|
}
|
@@ -1435,14 +1479,14 @@ var ArrayField = ({
|
|
1435
1479
|
return null;
|
1436
1480
|
}
|
1437
1481
|
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
1438
|
-
return /* @__PURE__ */ (0,
|
1482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1439
1483
|
Label2,
|
1440
1484
|
{
|
1441
1485
|
label: label || name,
|
1442
|
-
icon: /* @__PURE__ */ (0,
|
1486
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(List, { size: 16 }),
|
1443
1487
|
el: "div",
|
1444
1488
|
readOnly,
|
1445
|
-
children: /* @__PURE__ */ (0,
|
1489
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1446
1490
|
SortableProvider,
|
1447
1491
|
{
|
1448
1492
|
onMove: (move) => {
|
@@ -1464,7 +1508,7 @@ var ArrayField = ({
|
|
1464
1508
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
1465
1509
|
});
|
1466
1510
|
},
|
1467
|
-
children: /* @__PURE__ */ (0,
|
1511
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
1468
1512
|
"div",
|
1469
1513
|
{
|
1470
1514
|
className: getClassName5({
|
@@ -1478,13 +1522,13 @@ var ArrayField = ({
|
|
1478
1522
|
localState.arrayState.items.map((item, i) => {
|
1479
1523
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
1480
1524
|
const data = Array.from(localState.value || [])[i] || {};
|
1481
|
-
return /* @__PURE__ */ (0,
|
1525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1482
1526
|
Sortable,
|
1483
1527
|
{
|
1484
1528
|
id: _arrayId,
|
1485
1529
|
index: i,
|
1486
1530
|
disabled: readOnly,
|
1487
|
-
children: ({ status, ref }) => /* @__PURE__ */ (0,
|
1531
|
+
children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
1488
1532
|
"div",
|
1489
1533
|
{
|
1490
1534
|
ref,
|
@@ -1494,7 +1538,7 @@ var ArrayField = ({
|
|
1494
1538
|
readOnly
|
1495
1539
|
}),
|
1496
1540
|
children: [
|
1497
|
-
/* @__PURE__ */ (0,
|
1541
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
1498
1542
|
"div",
|
1499
1543
|
{
|
1500
1544
|
onClick: (e) => {
|
@@ -1517,9 +1561,9 @@ var ArrayField = ({
|
|
1517
1561
|
className: getClassNameItem("summary"),
|
1518
1562
|
children: [
|
1519
1563
|
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
1520
|
-
/* @__PURE__ */ (0,
|
1521
|
-
!readOnly && /* @__PURE__ */ (0,
|
1522
|
-
/* @__PURE__ */ (0,
|
1564
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
1565
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1523
1567
|
IconButton,
|
1524
1568
|
{
|
1525
1569
|
type: "button",
|
@@ -1536,10 +1580,10 @@ var ArrayField = ({
|
|
1536
1580
|
);
|
1537
1581
|
},
|
1538
1582
|
title: "Duplicate",
|
1539
|
-
children: /* @__PURE__ */ (0,
|
1583
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
|
1540
1584
|
}
|
1541
1585
|
) }),
|
1542
|
-
/* @__PURE__ */ (0,
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1543
1587
|
IconButton,
|
1544
1588
|
{
|
1545
1589
|
type: "button",
|
@@ -1560,39 +1604,56 @@ var ArrayField = ({
|
|
1560
1604
|
);
|
1561
1605
|
},
|
1562
1606
|
title: "Delete",
|
1563
|
-
children: /* @__PURE__ */ (0,
|
1607
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
|
1564
1608
|
}
|
1565
1609
|
) })
|
1566
1610
|
] }),
|
1567
|
-
/* @__PURE__ */ (0,
|
1611
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
|
1568
1612
|
] })
|
1569
1613
|
]
|
1570
1614
|
}
|
1571
1615
|
),
|
1572
|
-
/* @__PURE__ */ (0,
|
1573
|
-
const subField = field.arrayFields[
|
1574
|
-
const
|
1575
|
-
const
|
1576
|
-
const
|
1577
|
-
|
1578
|
-
|
1616
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
1617
|
+
const subField = field.arrayFields[subName];
|
1618
|
+
const indexName = `${name}[${i}]`;
|
1619
|
+
const subPath = `${indexName}.${subName}`;
|
1620
|
+
const localIndexName = `${localName}[${i}]`;
|
1621
|
+
const localWildcardName = `${localName}[*]`;
|
1622
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
1623
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
1624
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
1625
|
+
const label2 = subField.label || subName;
|
1626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1627
|
+
NestedFieldProvider,
|
1579
1628
|
{
|
1580
|
-
name:
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1629
|
+
name: localIndexName,
|
1630
|
+
wildcardName: localWildcardName,
|
1631
|
+
subName,
|
1632
|
+
readOnlyFields,
|
1633
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1634
|
+
AutoFieldPrivate,
|
1635
|
+
{
|
1636
|
+
name: subPath,
|
1637
|
+
label: label2,
|
1638
|
+
id: `${_arrayId}_${subName}`,
|
1639
|
+
readOnly: subReadOnly,
|
1640
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
1641
|
+
label: label2
|
1642
|
+
// May be used by custom fields
|
1643
|
+
}),
|
1644
|
+
value: data[subName],
|
1645
|
+
onChange: (val, ui) => {
|
1646
|
+
onChange(
|
1647
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
1648
|
+
[subName]: val
|
1649
|
+
})),
|
1650
|
+
ui
|
1651
|
+
);
|
1652
|
+
}
|
1653
|
+
}
|
1654
|
+
)
|
1594
1655
|
},
|
1595
|
-
|
1656
|
+
subPath
|
1596
1657
|
);
|
1597
1658
|
}) }) })
|
1598
1659
|
]
|
@@ -1602,7 +1663,7 @@ var ArrayField = ({
|
|
1602
1663
|
_arrayId
|
1603
1664
|
);
|
1604
1665
|
}),
|
1605
|
-
!addDisabled && /* @__PURE__ */ (0,
|
1666
|
+
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1606
1667
|
"button",
|
1607
1668
|
{
|
1608
1669
|
type: "button",
|
@@ -1616,7 +1677,7 @@ var ArrayField = ({
|
|
1616
1677
|
const newArrayState = regenerateArrayState(newValue);
|
1617
1678
|
onChange(newValue, mapArrayStateToUi(newArrayState));
|
1618
1679
|
},
|
1619
|
-
children: /* @__PURE__ */ (0,
|
1680
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Plus, { size: 21 })
|
1620
1681
|
}
|
1621
1682
|
)
|
1622
1683
|
]
|
@@ -1630,28 +1691,29 @@ var ArrayField = ({
|
|
1630
1691
|
|
1631
1692
|
// components/AutoField/fields/DefaultField/index.tsx
|
1632
1693
|
init_react_import();
|
1633
|
-
var
|
1694
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
1634
1695
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
1635
1696
|
var DefaultField = ({
|
1636
1697
|
field,
|
1637
1698
|
onChange,
|
1638
1699
|
readOnly,
|
1639
|
-
value,
|
1700
|
+
value: _value,
|
1640
1701
|
name,
|
1641
1702
|
label,
|
1642
1703
|
Label: Label2,
|
1643
1704
|
id
|
1644
1705
|
}) => {
|
1645
|
-
|
1706
|
+
const value = _value;
|
1707
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1646
1708
|
Label2,
|
1647
1709
|
{
|
1648
1710
|
label: label || name,
|
1649
|
-
icon: /* @__PURE__ */ (0,
|
1650
|
-
field.type === "text" && /* @__PURE__ */ (0,
|
1651
|
-
field.type === "number" && /* @__PURE__ */ (0,
|
1711
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
1712
|
+
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Type, { size: 16 }),
|
1713
|
+
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Hash, { size: 16 })
|
1652
1714
|
] }),
|
1653
1715
|
readOnly,
|
1654
|
-
children: /* @__PURE__ */ (0,
|
1716
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1655
1717
|
"input",
|
1656
1718
|
{
|
1657
1719
|
className: getClassName6("input"),
|
@@ -1659,10 +1721,17 @@ var DefaultField = ({
|
|
1659
1721
|
type: field.type,
|
1660
1722
|
title: label || name,
|
1661
1723
|
name,
|
1662
|
-
value:
|
1724
|
+
value: (value == null ? void 0 : value.toString) ? value.toString() : "",
|
1663
1725
|
onChange: (e) => {
|
1664
1726
|
if (field.type === "number") {
|
1665
|
-
|
1727
|
+
const numberValue = Number(e.currentTarget.value);
|
1728
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
1729
|
+
return;
|
1730
|
+
}
|
1731
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
1732
|
+
return;
|
1733
|
+
}
|
1734
|
+
onChange(numberValue);
|
1666
1735
|
} else {
|
1667
1736
|
onChange(e.currentTarget.value);
|
1668
1737
|
}
|
@@ -1680,11 +1749,11 @@ var DefaultField = ({
|
|
1680
1749
|
|
1681
1750
|
// components/AutoField/fields/ExternalField/index.tsx
|
1682
1751
|
init_react_import();
|
1683
|
-
var
|
1752
|
+
var import_react16 = require("react");
|
1684
1753
|
|
1685
1754
|
// components/ExternalInput/index.tsx
|
1686
1755
|
init_react_import();
|
1687
|
-
var
|
1756
|
+
var import_react15 = require("react");
|
1688
1757
|
|
1689
1758
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
1690
1759
|
init_react_import();
|
@@ -1692,7 +1761,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
1692
1761
|
|
1693
1762
|
// components/Modal/index.tsx
|
1694
1763
|
init_react_import();
|
1695
|
-
var
|
1764
|
+
var import_react13 = require("react");
|
1696
1765
|
|
1697
1766
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
1698
1767
|
init_react_import();
|
@@ -1700,22 +1769,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1700
1769
|
|
1701
1770
|
// components/Modal/index.tsx
|
1702
1771
|
var import_react_dom = require("react-dom");
|
1703
|
-
var
|
1772
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
1704
1773
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1705
1774
|
var Modal = ({
|
1706
1775
|
children,
|
1707
1776
|
onClose,
|
1708
1777
|
isOpen
|
1709
1778
|
}) => {
|
1710
|
-
const [rootEl, setRootEl] = (0,
|
1711
|
-
(0,
|
1779
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
1780
|
+
(0, import_react13.useEffect)(() => {
|
1712
1781
|
setRootEl(document.getElementById("puck-portal-root"));
|
1713
1782
|
}, []);
|
1714
1783
|
if (!rootEl) {
|
1715
|
-
return /* @__PURE__ */ (0,
|
1784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
|
1716
1785
|
}
|
1717
1786
|
return (0, import_react_dom.createPortal)(
|
1718
|
-
/* @__PURE__ */ (0,
|
1787
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
1719
1788
|
"div",
|
1720
1789
|
{
|
1721
1790
|
className: getClassName7("inner"),
|
@@ -1735,11 +1804,11 @@ init_react_import();
|
|
1735
1804
|
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" };
|
1736
1805
|
|
1737
1806
|
// components/Heading/index.tsx
|
1738
|
-
var
|
1807
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
1739
1808
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1740
1809
|
var Heading = ({ children, rank, size = "m" }) => {
|
1741
1810
|
const Tag = rank ? `h${rank}` : "span";
|
1742
|
-
return /* @__PURE__ */ (0,
|
1811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
1743
1812
|
Tag,
|
1744
1813
|
{
|
1745
1814
|
className: getClassName8({
|
@@ -1755,7 +1824,7 @@ init_react_import();
|
|
1755
1824
|
|
1756
1825
|
// components/Button/Button.tsx
|
1757
1826
|
init_react_import();
|
1758
|
-
var
|
1827
|
+
var import_react14 = require("react");
|
1759
1828
|
|
1760
1829
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
1761
1830
|
init_react_import();
|
@@ -1775,7 +1844,7 @@ var filterDataAttrs = (props) => {
|
|
1775
1844
|
};
|
1776
1845
|
|
1777
1846
|
// components/Button/Button.tsx
|
1778
|
-
var
|
1847
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
1779
1848
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1780
1849
|
var Button = (_a) => {
|
1781
1850
|
var _b = _a, {
|
@@ -1805,11 +1874,11 @@ var Button = (_a) => {
|
|
1805
1874
|
"size",
|
1806
1875
|
"loading"
|
1807
1876
|
]);
|
1808
|
-
const [loading, setLoading] = (0,
|
1809
|
-
(0,
|
1877
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
1878
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
1810
1879
|
const ElementType = href ? "a" : type ? "button" : "span";
|
1811
1880
|
const dataAttrs = filterDataAttrs(props);
|
1812
|
-
const el = /* @__PURE__ */ (0,
|
1881
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
1813
1882
|
ElementType,
|
1814
1883
|
__spreadProps(__spreadValues({
|
1815
1884
|
className: getClassName9({
|
@@ -1834,9 +1903,9 @@ var Button = (_a) => {
|
|
1834
1903
|
href
|
1835
1904
|
}, dataAttrs), {
|
1836
1905
|
children: [
|
1837
|
-
icon && /* @__PURE__ */ (0,
|
1906
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
1838
1907
|
children,
|
1839
|
-
loading && /* @__PURE__ */ (0,
|
1908
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 14 }) })
|
1840
1909
|
]
|
1841
1910
|
})
|
1842
1911
|
);
|
@@ -1844,7 +1913,7 @@ var Button = (_a) => {
|
|
1844
1913
|
};
|
1845
1914
|
|
1846
1915
|
// components/ExternalInput/index.tsx
|
1847
|
-
var
|
1916
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
1848
1917
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1849
1918
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1850
1919
|
var dataCache = {};
|
@@ -1861,28 +1930,28 @@ var ExternalInput = ({
|
|
1861
1930
|
mapRow = (val) => val,
|
1862
1931
|
filterFields
|
1863
1932
|
} = field || {};
|
1864
|
-
const [data, setData] = (0,
|
1865
|
-
const [isOpen, setOpen] = (0,
|
1866
|
-
const [isLoading, setIsLoading] = (0,
|
1933
|
+
const [data, setData] = (0, import_react15.useState)([]);
|
1934
|
+
const [isOpen, setOpen] = (0, import_react15.useState)(false);
|
1935
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
|
1867
1936
|
const hasFilterFields = !!filterFields;
|
1868
|
-
const [filters, setFilters] = (0,
|
1869
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
1870
|
-
const mappedData = (0,
|
1937
|
+
const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
|
1938
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
|
1939
|
+
const mappedData = (0, import_react15.useMemo)(() => {
|
1871
1940
|
return data.map(mapRow);
|
1872
1941
|
}, [data]);
|
1873
|
-
const keys = (0,
|
1942
|
+
const keys = (0, import_react15.useMemo)(() => {
|
1874
1943
|
const validKeys = /* @__PURE__ */ new Set();
|
1875
1944
|
for (const item of mappedData) {
|
1876
1945
|
for (const key of Object.keys(item)) {
|
1877
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
1946
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
|
1878
1947
|
validKeys.add(key);
|
1879
1948
|
}
|
1880
1949
|
}
|
1881
1950
|
}
|
1882
1951
|
return Array.from(validKeys);
|
1883
1952
|
}, [mappedData]);
|
1884
|
-
const [searchQuery, setSearchQuery] = (0,
|
1885
|
-
const search = (0,
|
1953
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
1954
|
+
const search = (0, import_react15.useCallback)(
|
1886
1955
|
(query, filters2) => __async(void 0, null, function* () {
|
1887
1956
|
setIsLoading(true);
|
1888
1957
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -1895,18 +1964,18 @@ var ExternalInput = ({
|
|
1895
1964
|
}),
|
1896
1965
|
[id, field]
|
1897
1966
|
);
|
1898
|
-
const Footer = (0,
|
1899
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
1967
|
+
const Footer = (0, import_react15.useCallback)(
|
1968
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
1900
1969
|
props.items.length,
|
1901
1970
|
" result",
|
1902
1971
|
props.items.length === 1 ? "" : "s"
|
1903
1972
|
] }),
|
1904
1973
|
[field.renderFooter]
|
1905
1974
|
);
|
1906
|
-
(0,
|
1975
|
+
(0, import_react15.useEffect)(() => {
|
1907
1976
|
search(searchQuery, filters);
|
1908
1977
|
}, []);
|
1909
|
-
return /* @__PURE__ */ (0,
|
1978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1910
1979
|
"div",
|
1911
1980
|
{
|
1912
1981
|
className: getClassName10({
|
@@ -1916,21 +1985,21 @@ var ExternalInput = ({
|
|
1916
1985
|
}),
|
1917
1986
|
id,
|
1918
1987
|
children: [
|
1919
|
-
/* @__PURE__ */ (0,
|
1920
|
-
/* @__PURE__ */ (0,
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("actions"), children: [
|
1989
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1921
1990
|
"button",
|
1922
1991
|
{
|
1923
1992
|
type: "button",
|
1924
1993
|
onClick: () => setOpen(true),
|
1925
1994
|
className: getClassName10("button"),
|
1926
1995
|
disabled: readOnly,
|
1927
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
1928
|
-
/* @__PURE__ */ (0,
|
1929
|
-
/* @__PURE__ */ (0,
|
1996
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: "16" }),
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: field.placeholder })
|
1930
1999
|
] })
|
1931
2000
|
}
|
1932
2001
|
),
|
1933
|
-
value && /* @__PURE__ */ (0,
|
2002
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1934
2003
|
"button",
|
1935
2004
|
{
|
1936
2005
|
type: "button",
|
@@ -1939,11 +2008,11 @@ var ExternalInput = ({
|
|
1939
2008
|
onChange(null);
|
1940
2009
|
},
|
1941
2010
|
disabled: readOnly,
|
1942
|
-
children: /* @__PURE__ */ (0,
|
2011
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LockOpen, { size: 16 })
|
1943
2012
|
}
|
1944
2013
|
)
|
1945
2014
|
] }),
|
1946
|
-
/* @__PURE__ */ (0,
|
2015
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1947
2016
|
"form",
|
1948
2017
|
{
|
1949
2018
|
className: getClassNameModal({
|
@@ -1957,11 +2026,11 @@ var ExternalInput = ({
|
|
1957
2026
|
search(searchQuery, filters);
|
1958
2027
|
},
|
1959
2028
|
children: [
|
1960
|
-
/* @__PURE__ */ (0,
|
1961
|
-
/* @__PURE__ */ (0,
|
1962
|
-
/* @__PURE__ */ (0,
|
1963
|
-
/* @__PURE__ */ (0,
|
1964
|
-
/* @__PURE__ */ (0,
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
2030
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: getClassNameModal("search"), children: [
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Search, { size: "18" }) }),
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1965
2034
|
"input",
|
1966
2035
|
{
|
1967
2036
|
className: getClassNameModal("searchInput"),
|
@@ -1976,9 +2045,9 @@ var ExternalInput = ({
|
|
1976
2045
|
}
|
1977
2046
|
)
|
1978
2047
|
] }),
|
1979
|
-
/* @__PURE__ */ (0,
|
1980
|
-
/* @__PURE__ */ (0,
|
1981
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2048
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
2049
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
2050
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1982
2051
|
IconButton,
|
1983
2052
|
{
|
1984
2053
|
title: "Toggle filters",
|
@@ -1987,15 +2056,15 @@ var ExternalInput = ({
|
|
1987
2056
|
e.stopPropagation();
|
1988
2057
|
setFiltersToggled(!filtersToggled);
|
1989
2058
|
},
|
1990
|
-
children: /* @__PURE__ */ (0,
|
2059
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SlidersHorizontal, { size: 20 })
|
1991
2060
|
}
|
1992
2061
|
) })
|
1993
2062
|
] })
|
1994
|
-
] }) : /* @__PURE__ */ (0,
|
1995
|
-
/* @__PURE__ */ (0,
|
1996
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
2063
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
2064
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
2065
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
1997
2066
|
const filterField = filterFields[fieldName];
|
1998
|
-
return /* @__PURE__ */ (0,
|
2067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
1999
2068
|
AutoFieldPrivate,
|
2000
2069
|
{
|
2001
2070
|
field: filterField,
|
@@ -2012,9 +2081,9 @@ var ExternalInput = ({
|
|
2012
2081
|
fieldName
|
2013
2082
|
);
|
2014
2083
|
}) }),
|
2015
|
-
/* @__PURE__ */ (0,
|
2016
|
-
/* @__PURE__ */ (0,
|
2017
|
-
/* @__PURE__ */ (0,
|
2084
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
2085
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: getClassNameModal("table"), children: [
|
2086
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2018
2087
|
"th",
|
2019
2088
|
{
|
2020
2089
|
className: getClassNameModal("th"),
|
@@ -2023,8 +2092,8 @@ var ExternalInput = ({
|
|
2023
2092
|
},
|
2024
2093
|
key
|
2025
2094
|
)) }) }),
|
2026
|
-
/* @__PURE__ */ (0,
|
2027
|
-
return /* @__PURE__ */ (0,
|
2095
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
2096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2028
2097
|
"tr",
|
2029
2098
|
{
|
2030
2099
|
style: { whiteSpace: "nowrap" },
|
@@ -2033,16 +2102,16 @@ var ExternalInput = ({
|
|
2033
2102
|
onChange(mapProp(data[i]));
|
2034
2103
|
setOpen(false);
|
2035
2104
|
},
|
2036
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
2105
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
2037
2106
|
},
|
2038
2107
|
i
|
2039
2108
|
);
|
2040
2109
|
}) })
|
2041
2110
|
] }),
|
2042
|
-
/* @__PURE__ */ (0,
|
2111
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 24 }) })
|
2043
2112
|
] })
|
2044
2113
|
] }),
|
2045
|
-
/* @__PURE__ */ (0,
|
2114
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footer, { items: mappedData }) })
|
2046
2115
|
]
|
2047
2116
|
}
|
2048
2117
|
) })
|
@@ -2052,7 +2121,7 @@ var ExternalInput = ({
|
|
2052
2121
|
};
|
2053
2122
|
|
2054
2123
|
// components/AutoField/fields/ExternalField/index.tsx
|
2055
|
-
var
|
2124
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
2056
2125
|
var ExternalField = ({
|
2057
2126
|
field,
|
2058
2127
|
onChange,
|
@@ -2066,7 +2135,7 @@ var ExternalField = ({
|
|
2066
2135
|
var _a, _b, _c;
|
2067
2136
|
const validField = field;
|
2068
2137
|
const deprecatedField = field;
|
2069
|
-
(0,
|
2138
|
+
(0, import_react16.useEffect)(() => {
|
2070
2139
|
if (deprecatedField.adaptor) {
|
2071
2140
|
console.error(
|
2072
2141
|
"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."
|
@@ -2076,7 +2145,7 @@ var ExternalField = ({
|
|
2076
2145
|
if (field.type !== "external") {
|
2077
2146
|
return null;
|
2078
2147
|
}
|
2079
|
-
return /* @__PURE__ */ (0,
|
2148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
2080
2149
|
ExternalInput,
|
2081
2150
|
{
|
2082
2151
|
name,
|
@@ -2101,7 +2170,7 @@ var ExternalField = ({
|
|
2101
2170
|
|
2102
2171
|
// components/AutoField/fields/RadioField/index.tsx
|
2103
2172
|
init_react_import();
|
2104
|
-
var
|
2173
|
+
var import_react17 = require("react");
|
2105
2174
|
|
2106
2175
|
// lib/safe-json-parse.ts
|
2107
2176
|
init_react_import();
|
@@ -2115,7 +2184,7 @@ var safeJsonParse = (str) => {
|
|
2115
2184
|
};
|
2116
2185
|
|
2117
2186
|
// components/AutoField/fields/RadioField/index.tsx
|
2118
|
-
var
|
2187
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
2119
2188
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
2120
2189
|
var RadioField = ({
|
2121
2190
|
field,
|
@@ -2127,26 +2196,26 @@ var RadioField = ({
|
|
2127
2196
|
label,
|
2128
2197
|
Label: Label2
|
2129
2198
|
}) => {
|
2130
|
-
const flatOptions = (0,
|
2199
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2131
2200
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2132
2201
|
[field]
|
2133
2202
|
);
|
2134
2203
|
if (field.type !== "radio" || !field.options) {
|
2135
2204
|
return null;
|
2136
2205
|
}
|
2137
|
-
return /* @__PURE__ */ (0,
|
2206
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2138
2207
|
Label2,
|
2139
2208
|
{
|
2140
|
-
icon: /* @__PURE__ */ (0,
|
2209
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CircleCheckBig, { size: 16 }),
|
2141
2210
|
label: label || name,
|
2142
2211
|
readOnly,
|
2143
2212
|
el: "div",
|
2144
|
-
children: /* @__PURE__ */ (0,
|
2213
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
2145
2214
|
"label",
|
2146
2215
|
{
|
2147
2216
|
className: getClassName11("radio"),
|
2148
2217
|
children: [
|
2149
|
-
/* @__PURE__ */ (0,
|
2218
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
2150
2219
|
"input",
|
2151
2220
|
{
|
2152
2221
|
type: "radio",
|
@@ -2166,7 +2235,7 @@ var RadioField = ({
|
|
2166
2235
|
checked: value === option.value
|
2167
2236
|
}
|
2168
2237
|
),
|
2169
|
-
/* @__PURE__ */ (0,
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
2170
2239
|
]
|
2171
2240
|
},
|
2172
2241
|
option.label + option.value
|
@@ -2177,8 +2246,8 @@ var RadioField = ({
|
|
2177
2246
|
|
2178
2247
|
// components/AutoField/fields/SelectField/index.tsx
|
2179
2248
|
init_react_import();
|
2180
|
-
var
|
2181
|
-
var
|
2249
|
+
var import_react18 = require("react");
|
2250
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2182
2251
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2183
2252
|
var SelectField = ({
|
2184
2253
|
field,
|
@@ -2190,20 +2259,20 @@ var SelectField = ({
|
|
2190
2259
|
readOnly,
|
2191
2260
|
id
|
2192
2261
|
}) => {
|
2193
|
-
const flatOptions = (0,
|
2262
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2194
2263
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2195
2264
|
[field]
|
2196
2265
|
);
|
2197
2266
|
if (field.type !== "select" || !field.options) {
|
2198
2267
|
return null;
|
2199
2268
|
}
|
2200
|
-
return /* @__PURE__ */ (0,
|
2269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2201
2270
|
Label2,
|
2202
2271
|
{
|
2203
2272
|
label: label || name,
|
2204
|
-
icon: /* @__PURE__ */ (0,
|
2273
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronDown, { size: 16 }),
|
2205
2274
|
readOnly,
|
2206
|
-
children: /* @__PURE__ */ (0,
|
2275
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2207
2276
|
"select",
|
2208
2277
|
{
|
2209
2278
|
id,
|
@@ -2220,7 +2289,7 @@ var SelectField = ({
|
|
2220
2289
|
}
|
2221
2290
|
},
|
2222
2291
|
value,
|
2223
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
2292
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
2224
2293
|
"option",
|
2225
2294
|
{
|
2226
2295
|
label: option.label,
|
@@ -2236,7 +2305,7 @@ var SelectField = ({
|
|
2236
2305
|
|
2237
2306
|
// components/AutoField/fields/TextareaField/index.tsx
|
2238
2307
|
init_react_import();
|
2239
|
-
var
|
2308
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
2240
2309
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2241
2310
|
var TextareaField = ({
|
2242
2311
|
onChange,
|
@@ -2247,7 +2316,7 @@ var TextareaField = ({
|
|
2247
2316
|
Label: Label2,
|
2248
2317
|
id
|
2249
2318
|
}) => {
|
2250
|
-
return /* @__PURE__ */ (0,
|
2319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
2251
2320
|
"textarea",
|
2252
2321
|
{
|
2253
2322
|
id,
|
@@ -2274,7 +2343,7 @@ init_react_import();
|
|
2274
2343
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2275
2344
|
|
2276
2345
|
// components/AutoField/fields/ObjectField/index.tsx
|
2277
|
-
var
|
2346
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
2278
2347
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2279
2348
|
var ObjectField = ({
|
2280
2349
|
field,
|
@@ -2286,43 +2355,54 @@ var ObjectField = ({
|
|
2286
2355
|
readOnly,
|
2287
2356
|
id
|
2288
2357
|
}) => {
|
2289
|
-
const {
|
2358
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2290
2359
|
if (field.type !== "object" || !field.objectFields) {
|
2291
2360
|
return null;
|
2292
2361
|
}
|
2293
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2294
2362
|
const data = value || {};
|
2295
|
-
return /* @__PURE__ */ (0,
|
2363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2296
2364
|
Label2,
|
2297
2365
|
{
|
2298
2366
|
label: label || name,
|
2299
|
-
icon: /* @__PURE__ */ (0,
|
2367
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EllipsisVertical, { size: 16 }),
|
2300
2368
|
el: "div",
|
2301
2369
|
readOnly,
|
2302
|
-
children: /* @__PURE__ */ (0,
|
2303
|
-
const subField = field.objectFields[
|
2304
|
-
const
|
2305
|
-
const
|
2306
|
-
const subReadOnly = readOnly ? readOnly :
|
2307
|
-
|
2308
|
-
|
2370
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
2371
|
+
const subField = field.objectFields[subName];
|
2372
|
+
const subPath = `${name}.${subName}`;
|
2373
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2374
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2375
|
+
const label2 = subField.label || subName;
|
2376
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2377
|
+
NestedFieldProvider,
|
2309
2378
|
{
|
2310
|
-
name:
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2379
|
+
name: localName || id,
|
2380
|
+
subName,
|
2381
|
+
readOnlyFields,
|
2382
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
2383
|
+
AutoFieldPrivate,
|
2384
|
+
{
|
2385
|
+
name: subPath,
|
2386
|
+
label: subPath,
|
2387
|
+
id: `${id}_${subName}`,
|
2388
|
+
readOnly: subReadOnly,
|
2389
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2390
|
+
label: label2
|
2391
|
+
// May be used by custom fields
|
2320
2392
|
}),
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2393
|
+
value: data[subName],
|
2394
|
+
onChange: (val, ui) => {
|
2395
|
+
onChange(
|
2396
|
+
__spreadProps(__spreadValues({}, data), {
|
2397
|
+
[subName]: val
|
2398
|
+
}),
|
2399
|
+
ui
|
2400
|
+
);
|
2401
|
+
}
|
2402
|
+
}
|
2403
|
+
)
|
2324
2404
|
},
|
2325
|
-
|
2405
|
+
subPath
|
2326
2406
|
);
|
2327
2407
|
}) }) })
|
2328
2408
|
}
|
@@ -2331,7 +2411,7 @@ var ObjectField = ({
|
|
2331
2411
|
|
2332
2412
|
// lib/use-safe-id.ts
|
2333
2413
|
init_react_import();
|
2334
|
-
var
|
2414
|
+
var import_react19 = __toESM(require("react"));
|
2335
2415
|
|
2336
2416
|
// lib/generate-id.ts
|
2337
2417
|
init_react_import();
|
@@ -2340,15 +2420,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
2340
2420
|
|
2341
2421
|
// lib/use-safe-id.ts
|
2342
2422
|
var useSafeId = () => {
|
2343
|
-
if (typeof
|
2344
|
-
return
|
2423
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
2424
|
+
return import_react19.default.useId();
|
2345
2425
|
}
|
2346
|
-
const [id] = (0,
|
2426
|
+
const [id] = (0, import_react19.useState)(generateId());
|
2347
2427
|
return id;
|
2348
2428
|
};
|
2349
2429
|
|
2350
2430
|
// components/AutoField/index.tsx
|
2351
|
-
var
|
2431
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
2352
2432
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2353
2433
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2354
2434
|
var FieldLabel = ({
|
@@ -2360,16 +2440,16 @@ var FieldLabel = ({
|
|
2360
2440
|
className
|
2361
2441
|
}) => {
|
2362
2442
|
const El = el;
|
2363
|
-
return /* @__PURE__ */ (0,
|
2364
|
-
/* @__PURE__ */ (0,
|
2365
|
-
icon ? /* @__PURE__ */ (0,
|
2443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(El, { className, children: [
|
2444
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName15("label"), children: [
|
2445
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {}),
|
2366
2446
|
label,
|
2367
|
-
readOnly && /* @__PURE__ */ (0,
|
2447
|
+
readOnly && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Lock, { size: "12" }) })
|
2368
2448
|
] }),
|
2369
2449
|
children
|
2370
2450
|
] });
|
2371
2451
|
};
|
2372
|
-
var
|
2452
|
+
var FieldLabelInternal = ({
|
2373
2453
|
children,
|
2374
2454
|
icon,
|
2375
2455
|
label,
|
@@ -2377,14 +2457,14 @@ var FieldLabelInternal2 = ({
|
|
2377
2457
|
readOnly
|
2378
2458
|
}) => {
|
2379
2459
|
const { overrides } = useAppContext();
|
2380
|
-
const Wrapper = (0,
|
2460
|
+
const Wrapper = (0, import_react20.useMemo)(
|
2381
2461
|
() => overrides.fieldLabel || FieldLabel,
|
2382
2462
|
[overrides]
|
2383
2463
|
);
|
2384
2464
|
if (!label) {
|
2385
|
-
return /* @__PURE__ */ (0,
|
2465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
2386
2466
|
}
|
2387
|
-
return /* @__PURE__ */ (0,
|
2467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2388
2468
|
Wrapper,
|
2389
2469
|
{
|
2390
2470
|
label,
|
@@ -2398,8 +2478,9 @@ var FieldLabelInternal2 = ({
|
|
2398
2478
|
};
|
2399
2479
|
function AutoFieldInternal(props) {
|
2400
2480
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2401
|
-
const { dispatch, overrides } = useAppContext();
|
2402
|
-
const
|
2481
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2482
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
2483
|
+
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2403
2484
|
const field = props.field;
|
2404
2485
|
const label = field.label;
|
2405
2486
|
const defaultId = useSafeId();
|
@@ -2430,7 +2511,7 @@ function AutoFieldInternal(props) {
|
|
2430
2511
|
Label: Label2,
|
2431
2512
|
id: resolvedId
|
2432
2513
|
});
|
2433
|
-
const onFocus = (0,
|
2514
|
+
const onFocus = (0, import_react20.useCallback)(
|
2434
2515
|
(e) => {
|
2435
2516
|
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
2436
2517
|
e.stopPropagation();
|
@@ -2444,7 +2525,7 @@ function AutoFieldInternal(props) {
|
|
2444
2525
|
},
|
2445
2526
|
[mergedProps.name]
|
2446
2527
|
);
|
2447
|
-
const onBlur = (0,
|
2528
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
2448
2529
|
if ("name" in e.target) {
|
2449
2530
|
dispatch({
|
2450
2531
|
type: "setUi",
|
@@ -2459,27 +2540,36 @@ function AutoFieldInternal(props) {
|
|
2459
2540
|
return null;
|
2460
2541
|
}
|
2461
2542
|
const CustomField = field.render;
|
2462
|
-
return /* @__PURE__ */ (0,
|
2543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
|
2463
2544
|
}
|
2464
2545
|
const children = defaultFields[field.type](mergedProps);
|
2465
2546
|
const Render2 = render[field.type];
|
2466
|
-
return /* @__PURE__ */ (0,
|
2467
|
-
|
2547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2548
|
+
NestedFieldContext.Provider,
|
2468
2549
|
{
|
2469
|
-
|
2470
|
-
|
2471
|
-
|
2472
|
-
onClick: (e) => {
|
2473
|
-
e.stopPropagation();
|
2550
|
+
value: {
|
2551
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2552
|
+
localName: nestedFieldContext.localName
|
2474
2553
|
},
|
2475
|
-
children: /* @__PURE__ */ (0,
|
2554
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2555
|
+
"div",
|
2556
|
+
{
|
2557
|
+
className: getClassNameWrapper(),
|
2558
|
+
onFocus,
|
2559
|
+
onBlur,
|
2560
|
+
onClick: (e) => {
|
2561
|
+
e.stopPropagation();
|
2562
|
+
},
|
2563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2564
|
+
}
|
2565
|
+
)
|
2476
2566
|
}
|
2477
2567
|
);
|
2478
2568
|
}
|
2479
2569
|
function AutoFieldPrivate(props) {
|
2480
2570
|
const { state } = useAppContext();
|
2481
2571
|
const { value, onChange } = props;
|
2482
|
-
const [localValue, setLocalValue] = (0,
|
2572
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
2483
2573
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
2484
2574
|
(val, ui) => {
|
2485
2575
|
onChange(val, ui);
|
@@ -2487,11 +2577,11 @@ function AutoFieldPrivate(props) {
|
|
2487
2577
|
50,
|
2488
2578
|
{ leading: true }
|
2489
2579
|
);
|
2490
|
-
const onChangeLocal = (0,
|
2580
|
+
const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
|
2491
2581
|
setLocalValue(val);
|
2492
2582
|
onChangeDb(val, ui);
|
2493
2583
|
}, []);
|
2494
|
-
(0,
|
2584
|
+
(0, import_react20.useEffect)(() => {
|
2495
2585
|
if (state.ui.field.focus !== props.name) {
|
2496
2586
|
setLocalValue(value);
|
2497
2587
|
}
|
@@ -2500,11 +2590,11 @@ function AutoFieldPrivate(props) {
|
|
2500
2590
|
value: localValue,
|
2501
2591
|
onChange: onChangeLocal
|
2502
2592
|
};
|
2503
|
-
return /* @__PURE__ */ (0,
|
2593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2504
2594
|
}
|
2505
2595
|
function AutoField(props) {
|
2506
|
-
const DefaultLabel = (0,
|
2507
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
2596
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
2597
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2508
2598
|
"div",
|
2509
2599
|
__spreadProps(__spreadValues({}, labelProps), {
|
2510
2600
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2512,7 +2602,7 @@ function AutoField(props) {
|
|
2512
2602
|
);
|
2513
2603
|
return DefaultLabel2;
|
2514
2604
|
}, [props.readOnly]);
|
2515
|
-
return /* @__PURE__ */ (0,
|
2605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2516
2606
|
}
|
2517
2607
|
|
2518
2608
|
// components/Drawer/index.tsx
|
@@ -2523,64 +2613,38 @@ init_react_import();
|
|
2523
2613
|
var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
|
2524
2614
|
|
2525
2615
|
// components/Drawer/index.tsx
|
2526
|
-
var
|
2616
|
+
var import_react32 = require("react");
|
2527
2617
|
|
2528
2618
|
// components/DragDropContext/index.tsx
|
2529
2619
|
init_react_import();
|
2530
|
-
var
|
2531
|
-
var
|
2620
|
+
var import_react30 = require("@dnd-kit/react");
|
2621
|
+
var import_react31 = require("react");
|
2532
2622
|
var import_dom = require("@dnd-kit/dom");
|
2533
2623
|
|
2534
2624
|
// components/DropZone/index.tsx
|
2535
2625
|
init_react_import();
|
2536
|
-
var
|
2626
|
+
var import_react29 = require("react");
|
2537
2627
|
|
2538
2628
|
// components/DraggableComponent/index.tsx
|
2539
2629
|
init_react_import();
|
2540
|
-
var
|
2630
|
+
var import_react23 = require("react");
|
2541
2631
|
|
2542
2632
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2543
2633
|
init_react_import();
|
2544
2634
|
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
|
2545
2635
|
|
2546
|
-
// lib/use-modifier-held.ts
|
2547
|
-
init_react_import();
|
2548
|
-
var import_react20 = require("react");
|
2549
|
-
var useModifierHeld = (modifier) => {
|
2550
|
-
const [modifierHeld, setModifierHeld] = (0, import_react20.useState)(false);
|
2551
|
-
(0, import_react20.useEffect)(() => {
|
2552
|
-
function downHandler({ key }) {
|
2553
|
-
if (key === modifier) {
|
2554
|
-
setModifierHeld(true);
|
2555
|
-
}
|
2556
|
-
}
|
2557
|
-
function upHandler({ key }) {
|
2558
|
-
if (key === modifier) {
|
2559
|
-
setModifierHeld(false);
|
2560
|
-
}
|
2561
|
-
}
|
2562
|
-
window.addEventListener("keydown", downHandler);
|
2563
|
-
window.addEventListener("keyup", upHandler);
|
2564
|
-
return () => {
|
2565
|
-
window.removeEventListener("keydown", downHandler);
|
2566
|
-
window.removeEventListener("keyup", upHandler);
|
2567
|
-
};
|
2568
|
-
}, [modifier]);
|
2569
|
-
return modifierHeld;
|
2570
|
-
};
|
2571
|
-
|
2572
2636
|
// components/DraggableComponent/index.tsx
|
2573
2637
|
var import_react_dom2 = require("react-dom");
|
2574
2638
|
|
2575
|
-
//
|
2639
|
+
// lib/dnd/collision/dynamic/index.ts
|
2576
2640
|
init_react_import();
|
2577
2641
|
var import_abstract8 = require("@dnd-kit/abstract");
|
2578
2642
|
|
2579
|
-
//
|
2643
|
+
// lib/dnd/collision/directional/index.ts
|
2580
2644
|
init_react_import();
|
2581
2645
|
var import_abstract = require("@dnd-kit/abstract");
|
2582
2646
|
|
2583
|
-
//
|
2647
|
+
// lib/dnd/collision/collision-debug.ts
|
2584
2648
|
init_react_import();
|
2585
2649
|
var DEBUG = false;
|
2586
2650
|
var debugElements = {};
|
@@ -2629,7 +2693,7 @@ var collisionDebug = (a, b, id, color, label) => {
|
|
2629
2693
|
});
|
2630
2694
|
};
|
2631
2695
|
|
2632
|
-
//
|
2696
|
+
// lib/dnd/collision/directional/index.ts
|
2633
2697
|
var distanceChange = "increasing";
|
2634
2698
|
var directionalCollision = (input, previous) => {
|
2635
2699
|
var _a;
|
@@ -2662,7 +2726,7 @@ var directionalCollision = (input, previous) => {
|
|
2662
2726
|
return null;
|
2663
2727
|
};
|
2664
2728
|
|
2665
|
-
//
|
2729
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
2666
2730
|
init_react_import();
|
2667
2731
|
var getDirection = (dragAxis, delta) => {
|
2668
2732
|
if (dragAxis === "dynamic") {
|
@@ -2677,7 +2741,7 @@ var getDirection = (dragAxis, delta) => {
|
|
2677
2741
|
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2678
2742
|
};
|
2679
2743
|
|
2680
|
-
//
|
2744
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
2681
2745
|
init_react_import();
|
2682
2746
|
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2683
2747
|
const dragRect = dragShape.boundingRectangle;
|
@@ -2696,7 +2760,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2696
2760
|
return dragRect.right - offset >= dropCenter.x;
|
2697
2761
|
};
|
2698
2762
|
|
2699
|
-
//
|
2763
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2700
2764
|
init_react_import();
|
2701
2765
|
var import_geometry = require("@dnd-kit/geometry");
|
2702
2766
|
var INTERVAL_SENSITIVITY = 10;
|
@@ -2800,7 +2864,14 @@ var closestCorners = (input) => {
|
|
2800
2864
|
};
|
2801
2865
|
};
|
2802
2866
|
|
2803
|
-
//
|
2867
|
+
// lib/dnd/collision/dynamic/store.ts
|
2868
|
+
init_react_import();
|
2869
|
+
var import_vanilla = require("zustand/vanilla");
|
2870
|
+
var collisionStore = (0, import_vanilla.createStore)(() => ({
|
2871
|
+
fallbackEnabled: false
|
2872
|
+
}));
|
2873
|
+
|
2874
|
+
// lib/dnd/collision/dynamic/index.ts
|
2804
2875
|
var flushNext = "";
|
2805
2876
|
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2806
2877
|
var _a, _b, _c, _d, _e;
|
@@ -2812,6 +2883,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2812
2883
|
return null;
|
2813
2884
|
}
|
2814
2885
|
const { center: dragCenter } = dragShape;
|
2886
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2815
2887
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2816
2888
|
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2817
2889
|
direction: interval.direction
|
@@ -2857,7 +2929,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2857
2929
|
flushNext = "";
|
2858
2930
|
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2859
2931
|
}
|
2860
|
-
if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2932
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2861
2933
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2862
2934
|
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2863
2935
|
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
@@ -2918,8 +2990,102 @@ function getDeepScrollPosition(element) {
|
|
2918
2990
|
return totalScroll;
|
2919
2991
|
}
|
2920
2992
|
|
2993
|
+
// components/DropZone/context.tsx
|
2994
|
+
init_react_import();
|
2995
|
+
var import_react21 = require("react");
|
2996
|
+
var import_zustand = require("zustand");
|
2997
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2998
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2999
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
3000
|
+
(0, import_zustand.createStore)(() => ({
|
3001
|
+
zoneDepthIndex: {},
|
3002
|
+
nextZoneDepthIndex: {},
|
3003
|
+
areaDepthIndex: {},
|
3004
|
+
nextAreaDepthIndex: {},
|
3005
|
+
draggedItem: null,
|
3006
|
+
previewIndex: {}
|
3007
|
+
}))
|
3008
|
+
);
|
3009
|
+
var ZoneStoreProvider = ({
|
3010
|
+
children,
|
3011
|
+
store
|
3012
|
+
}) => {
|
3013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
3014
|
+
};
|
3015
|
+
var DropZoneProvider = ({
|
3016
|
+
children,
|
3017
|
+
value
|
3018
|
+
}) => {
|
3019
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3020
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3021
|
+
{}
|
3022
|
+
);
|
3023
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3024
|
+
const { dispatch } = useAppContext();
|
3025
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
3026
|
+
(area) => {
|
3027
|
+
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3028
|
+
},
|
3029
|
+
[setAreasWithZones]
|
3030
|
+
);
|
3031
|
+
const registerZone = (0, import_react21.useCallback)(
|
3032
|
+
(zoneCompound) => {
|
3033
|
+
if (!dispatch) {
|
3034
|
+
return;
|
3035
|
+
}
|
3036
|
+
dispatch({
|
3037
|
+
type: "registerZone",
|
3038
|
+
zone: zoneCompound
|
3039
|
+
});
|
3040
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
3041
|
+
},
|
3042
|
+
[setActiveZones, dispatch]
|
3043
|
+
);
|
3044
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
3045
|
+
(zoneCompound) => {
|
3046
|
+
if (!dispatch) {
|
3047
|
+
return;
|
3048
|
+
}
|
3049
|
+
dispatch({
|
3050
|
+
type: "unregisterZone",
|
3051
|
+
zone: zoneCompound
|
3052
|
+
});
|
3053
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
3054
|
+
[zoneCompound]: false
|
3055
|
+
}));
|
3056
|
+
},
|
3057
|
+
[setActiveZones, dispatch]
|
3058
|
+
);
|
3059
|
+
const memoValue = (0, import_react21.useMemo)(
|
3060
|
+
() => __spreadValues({
|
3061
|
+
hoveringComponent,
|
3062
|
+
setHoveringComponent,
|
3063
|
+
registerZoneArea,
|
3064
|
+
areasWithZones,
|
3065
|
+
registerZone,
|
3066
|
+
unregisterZone,
|
3067
|
+
activeZones
|
3068
|
+
}, value),
|
3069
|
+
[value, hoveringComponent, areasWithZones, activeZones]
|
3070
|
+
);
|
3071
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
3072
|
+
};
|
3073
|
+
|
3074
|
+
// lib/use-context-store.ts
|
3075
|
+
init_react_import();
|
3076
|
+
var import_react22 = require("react");
|
3077
|
+
var import_zustand2 = require("zustand");
|
3078
|
+
var import_shallow = require("zustand/react/shallow");
|
3079
|
+
function useContextStore(context, selector) {
|
3080
|
+
const store = (0, import_react22.useContext)(context);
|
3081
|
+
if (!store) {
|
3082
|
+
throw new Error("useContextStore must be used inside context");
|
3083
|
+
}
|
3084
|
+
return (0, import_zustand2.useStore)(store, (0, import_shallow.useShallow)(selector));
|
3085
|
+
}
|
3086
|
+
|
2921
3087
|
// components/DraggableComponent/index.tsx
|
2922
|
-
var
|
3088
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
2923
3089
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2924
3090
|
var DEBUG2 = false;
|
2925
3091
|
var space = 8;
|
@@ -2930,12 +3096,12 @@ var DefaultActionBar = ({
|
|
2930
3096
|
label,
|
2931
3097
|
children,
|
2932
3098
|
parentAction
|
2933
|
-
}) => /* @__PURE__ */ (0,
|
2934
|
-
/* @__PURE__ */ (0,
|
3099
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar, { children: [
|
3100
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar.Group, { children: [
|
2935
3101
|
parentAction,
|
2936
|
-
label && /* @__PURE__ */ (0,
|
3102
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Label, { label })
|
2937
3103
|
] }),
|
2938
|
-
/* @__PURE__ */ (0,
|
3104
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Group, { children })
|
2939
3105
|
] });
|
2940
3106
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
2941
3107
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -2970,10 +3136,9 @@ var DraggableComponent = ({
|
|
2970
3136
|
iframe,
|
2971
3137
|
state
|
2972
3138
|
} = useAppContext();
|
2973
|
-
const
|
2974
|
-
const
|
2975
|
-
const
|
2976
|
-
const registerLocalZone = (0, import_react21.useCallback)(
|
3139
|
+
const ctx = (0, import_react23.useContext)(dropZoneContext);
|
3140
|
+
const [localZones, setLocalZones] = (0, import_react23.useState)({});
|
3141
|
+
const registerLocalZone = (0, import_react23.useCallback)(
|
2977
3142
|
(zoneCompound2, active) => {
|
2978
3143
|
var _a;
|
2979
3144
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -2983,7 +3148,7 @@ var DraggableComponent = ({
|
|
2983
3148
|
},
|
2984
3149
|
[setLocalZones]
|
2985
3150
|
);
|
2986
|
-
const unregisterLocalZone = (0,
|
3151
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
2987
3152
|
(zoneCompound2) => {
|
2988
3153
|
var _a;
|
2989
3154
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -2997,8 +3162,8 @@ var DraggableComponent = ({
|
|
2997
3162
|
);
|
2998
3163
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
2999
3164
|
const { path = [] } = ctx || {};
|
3000
|
-
const [canDrag, setCanDrag] = (0,
|
3001
|
-
(0,
|
3165
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3166
|
+
(0, import_react23.useEffect)(() => {
|
3002
3167
|
var _a;
|
3003
3168
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
3004
3169
|
if (item) {
|
@@ -3008,10 +3173,13 @@ var DraggableComponent = ({
|
|
3008
3173
|
setCanDrag((_a = perms.drag) != null ? _a : true);
|
3009
3174
|
}
|
3010
3175
|
}, [state, index, zoneCompound, getPermissions]);
|
3011
|
-
const userIsDragging =
|
3176
|
+
const userIsDragging = useContextStore(
|
3177
|
+
ZoneStoreContext,
|
3178
|
+
(s) => !!s.draggedItem
|
3179
|
+
);
|
3012
3180
|
const canCollide = canDrag || userIsDragging;
|
3013
3181
|
const disabled = !isEnabled || !canCollide;
|
3014
|
-
const [dragAxis, setDragAxis] = (0,
|
3182
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
3015
3183
|
const { ref: sortableRef, status } = useSortableSafe({
|
3016
3184
|
id,
|
3017
3185
|
index,
|
@@ -3037,8 +3205,8 @@ var DraggableComponent = ({
|
|
3037
3205
|
}
|
3038
3206
|
});
|
3039
3207
|
const thisIsDragging = status === "dragging";
|
3040
|
-
const ref = (0,
|
3041
|
-
const refSetter = (0,
|
3208
|
+
const ref = (0, import_react23.useRef)(null);
|
3209
|
+
const refSetter = (0, import_react23.useCallback)(
|
3042
3210
|
(el) => {
|
3043
3211
|
sortableRef(el);
|
3044
3212
|
if (el) {
|
@@ -3047,14 +3215,14 @@ var DraggableComponent = ({
|
|
3047
3215
|
},
|
3048
3216
|
[sortableRef]
|
3049
3217
|
);
|
3050
|
-
const [portalEl, setPortalEl] = (0,
|
3051
|
-
(0,
|
3218
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3219
|
+
(0, import_react23.useEffect)(() => {
|
3052
3220
|
var _a, _b, _c;
|
3053
3221
|
setPortalEl(
|
3054
3222
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
3055
3223
|
);
|
3056
3224
|
}, [iframe.enabled, ref.current]);
|
3057
|
-
const getStyle = (0,
|
3225
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3058
3226
|
var _a, _b, _c;
|
3059
3227
|
if (!ref.current) return;
|
3060
3228
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3074,11 +3242,11 @@ var DraggableComponent = ({
|
|
3074
3242
|
};
|
3075
3243
|
return style2;
|
3076
3244
|
}, [ref.current]);
|
3077
|
-
const [style, setStyle] = (0,
|
3078
|
-
const sync = (0,
|
3245
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3246
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3079
3247
|
setStyle(getStyle());
|
3080
3248
|
}, [ref.current, iframe]);
|
3081
|
-
(0,
|
3249
|
+
(0, import_react23.useEffect)(() => {
|
3082
3250
|
if (ref.current) {
|
3083
3251
|
const observer = new ResizeObserver(sync);
|
3084
3252
|
observer.observe(ref.current);
|
@@ -3087,20 +3255,28 @@ var DraggableComponent = ({
|
|
3087
3255
|
};
|
3088
3256
|
}
|
3089
3257
|
}, [ref.current]);
|
3090
|
-
(0,
|
3091
|
-
ctx == null ? void 0 : ctx.registerPath(
|
3092
|
-
|
3093
|
-
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3258
|
+
(0, import_react23.useEffect)(() => {
|
3259
|
+
ctx == null ? void 0 : ctx.registerPath(
|
3260
|
+
id,
|
3261
|
+
{
|
3262
|
+
index,
|
3263
|
+
zone: zoneCompound
|
3264
|
+
},
|
3265
|
+
componentType
|
3266
|
+
);
|
3267
|
+
return () => {
|
3268
|
+
var _a;
|
3269
|
+
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3270
|
+
};
|
3271
|
+
}, [id, zoneCompound, index, componentType]);
|
3272
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3097
3273
|
() => overrides.actionBar || DefaultActionBar,
|
3098
3274
|
[overrides.actionBar]
|
3099
3275
|
);
|
3100
3276
|
const permissions = getPermissions({
|
3101
3277
|
item: selectedItem
|
3102
3278
|
});
|
3103
|
-
const onClick = (0,
|
3279
|
+
const onClick = (0, import_react23.useCallback)(
|
3104
3280
|
(e) => {
|
3105
3281
|
e.stopPropagation();
|
3106
3282
|
dispatch({
|
@@ -3112,7 +3288,7 @@ var DraggableComponent = ({
|
|
3112
3288
|
},
|
3113
3289
|
[index, zoneCompound, id]
|
3114
3290
|
);
|
3115
|
-
const onSelectParent = (0,
|
3291
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3116
3292
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3117
3293
|
return;
|
3118
3294
|
}
|
@@ -3130,23 +3306,23 @@ var DraggableComponent = ({
|
|
3130
3306
|
}
|
3131
3307
|
});
|
3132
3308
|
}, [ctx, path]);
|
3133
|
-
const onDuplicate = (0,
|
3309
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3134
3310
|
dispatch({
|
3135
3311
|
type: "duplicate",
|
3136
3312
|
sourceIndex: index,
|
3137
3313
|
sourceZone: zoneCompound
|
3138
3314
|
});
|
3139
3315
|
}, [index, zoneCompound]);
|
3140
|
-
const onDelete = (0,
|
3316
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3141
3317
|
dispatch({
|
3142
3318
|
type: "remove",
|
3143
3319
|
index,
|
3144
3320
|
zone: zoneCompound
|
3145
3321
|
});
|
3146
3322
|
}, [index, zoneCompound]);
|
3147
|
-
const [hover, setHover] = (0,
|
3323
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3148
3324
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3149
|
-
(0,
|
3325
|
+
(0, import_react23.useEffect)(() => {
|
3150
3326
|
if (!ref.current) {
|
3151
3327
|
return;
|
3152
3328
|
}
|
@@ -3196,7 +3372,7 @@ var DraggableComponent = ({
|
|
3196
3372
|
thisIsDragging,
|
3197
3373
|
inDroppableZone
|
3198
3374
|
]);
|
3199
|
-
(0,
|
3375
|
+
(0, import_react23.useEffect)(() => {
|
3200
3376
|
if (ref.current && disabled) {
|
3201
3377
|
ref.current.setAttribute("data-puck-disabled", "");
|
3202
3378
|
return () => {
|
@@ -3205,8 +3381,8 @@ var DraggableComponent = ({
|
|
3205
3381
|
};
|
3206
3382
|
}
|
3207
3383
|
}, [disabled, ref]);
|
3208
|
-
const [isVisible, setIsVisible] = (0,
|
3209
|
-
(0,
|
3384
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3385
|
+
(0, import_react23.useEffect)(() => {
|
3210
3386
|
sync();
|
3211
3387
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3212
3388
|
setIsVisible(true);
|
@@ -3214,7 +3390,7 @@ var DraggableComponent = ({
|
|
3214
3390
|
setIsVisible(false);
|
3215
3391
|
}
|
3216
3392
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3217
|
-
const syncActionsPosition = (0,
|
3393
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3218
3394
|
(el) => {
|
3219
3395
|
if (el) {
|
3220
3396
|
const view = el.ownerDocument.defaultView;
|
@@ -3231,7 +3407,7 @@ var DraggableComponent = ({
|
|
3231
3407
|
},
|
3232
3408
|
[zoomConfig]
|
3233
3409
|
);
|
3234
|
-
(0,
|
3410
|
+
(0, import_react23.useEffect)(() => {
|
3235
3411
|
if (userDragAxis) {
|
3236
3412
|
setDragAxis(userDragAxis);
|
3237
3413
|
return;
|
@@ -3245,8 +3421,8 @@ var DraggableComponent = ({
|
|
3245
3421
|
}
|
3246
3422
|
setDragAxis(autoDragAxis);
|
3247
3423
|
}, [ref, userDragAxis, autoDragAxis]);
|
3248
|
-
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0,
|
3249
|
-
return /* @__PURE__ */ (0,
|
3424
|
+
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CornerLeftUp, { size: 16 }) });
|
3425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3250
3426
|
DropZoneProvider,
|
3251
3427
|
{
|
3252
3428
|
value: __spreadProps(__spreadValues({}, ctx), {
|
@@ -3260,28 +3436,27 @@ var DraggableComponent = ({
|
|
3260
3436
|
}),
|
3261
3437
|
children: [
|
3262
3438
|
isVisible && (0, import_react_dom2.createPortal)(
|
3263
|
-
/* @__PURE__ */ (0,
|
3439
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3264
3440
|
"div",
|
3265
3441
|
{
|
3266
3442
|
className: getClassName16({
|
3267
3443
|
isSelected,
|
3268
3444
|
isDragging: thisIsDragging,
|
3269
|
-
isModifierHeld,
|
3270
3445
|
hover: hover || indicativeHover
|
3271
3446
|
}),
|
3272
3447
|
style: __spreadValues({}, style),
|
3273
3448
|
"data-puck-overlay": true,
|
3274
3449
|
children: [
|
3275
3450
|
debug,
|
3276
|
-
isLoading && /* @__PURE__ */ (0,
|
3277
|
-
/* @__PURE__ */ (0,
|
3451
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {}) }),
|
3452
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3278
3453
|
"div",
|
3279
3454
|
{
|
3280
3455
|
className: getClassName16("actionsOverlay"),
|
3281
3456
|
style: {
|
3282
3457
|
top: actionsOverlayTop / zoomConfig.zoom
|
3283
3458
|
},
|
3284
|
-
children: /* @__PURE__ */ (0,
|
3459
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3285
3460
|
"div",
|
3286
3461
|
{
|
3287
3462
|
className: getClassName16("actions"),
|
@@ -3293,14 +3468,14 @@ var DraggableComponent = ({
|
|
3293
3468
|
paddingRight: actionsSide
|
3294
3469
|
},
|
3295
3470
|
ref: syncActionsPosition,
|
3296
|
-
children: /* @__PURE__ */ (0,
|
3471
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
3297
3472
|
CustomActionBar,
|
3298
3473
|
{
|
3299
3474
|
parentAction,
|
3300
3475
|
label: DEBUG2 ? id : label,
|
3301
3476
|
children: [
|
3302
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
3303
|
-
permissions.delete && /* @__PURE__ */ (0,
|
3477
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Copy, { size: 16 }) }),
|
3478
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Trash, { size: 16 }) })
|
3304
3479
|
]
|
3305
3480
|
}
|
3306
3481
|
)
|
@@ -3308,7 +3483,7 @@ var DraggableComponent = ({
|
|
3308
3483
|
)
|
3309
3484
|
}
|
3310
3485
|
),
|
3311
|
-
/* @__PURE__ */ (0,
|
3486
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("overlay") })
|
3312
3487
|
]
|
3313
3488
|
}
|
3314
3489
|
),
|
@@ -3324,96 +3499,29 @@ var DraggableComponent = ({
|
|
3324
3499
|
init_react_import();
|
3325
3500
|
var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isActive": "_DropZone--isActive_kmkdc_10", "DropZone--hasChildren": "_DropZone--hasChildren_kmkdc_14", "DropZone--userIsDragging": "_DropZone--userIsDragging_kmkdc_22", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_kmkdc_26", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_kmkdc_27", "DropZone--isRootZone": "_DropZone--isRootZone_kmkdc_27", "DropZone--isDestination": "_DropZone--isDestination_kmkdc_37", "DropZone-item": "_DropZone-item_kmkdc_49", "DropZone-hitbox": "_DropZone-hitbox_kmkdc_53", "DropZone--isEnabled": "_DropZone--isEnabled_kmkdc_61", "DropZone--isAnimating": "_DropZone--isAnimating_kmkdc_70" };
|
3326
3501
|
|
3327
|
-
// components/DropZone/
|
3502
|
+
// components/DropZone/lib/use-min-empty-height.ts
|
3328
3503
|
init_react_import();
|
3329
|
-
var
|
3330
|
-
var
|
3331
|
-
|
3332
|
-
|
3333
|
-
|
3334
|
-
value
|
3504
|
+
var import_react24 = require("react");
|
3505
|
+
var useMinEmptyHeight = ({
|
3506
|
+
zoneCompound,
|
3507
|
+
userMinEmptyHeight,
|
3508
|
+
ref
|
3335
3509
|
}) => {
|
3336
|
-
const [
|
3337
|
-
const [
|
3338
|
-
|
3339
|
-
|
3340
|
-
|
3341
|
-
|
3342
|
-
|
3343
|
-
|
3344
|
-
|
3345
|
-
|
3346
|
-
|
3347
|
-
|
3348
|
-
|
3349
|
-
|
3350
|
-
|
3351
|
-
return;
|
3352
|
-
}
|
3353
|
-
dispatch({
|
3354
|
-
type: "registerZone",
|
3355
|
-
zone: zoneCompound
|
3356
|
-
});
|
3357
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
3358
|
-
},
|
3359
|
-
[setActiveZones, dispatch]
|
3360
|
-
);
|
3361
|
-
const unregisterZone = (0, import_react22.useCallback)(
|
3362
|
-
(zoneCompound) => {
|
3363
|
-
if (!dispatch) {
|
3364
|
-
return;
|
3365
|
-
}
|
3366
|
-
dispatch({
|
3367
|
-
type: "unregisterZone",
|
3368
|
-
zone: zoneCompound
|
3369
|
-
});
|
3370
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
3371
|
-
[zoneCompound]: false
|
3372
|
-
}));
|
3373
|
-
},
|
3374
|
-
[setActiveZones, dispatch]
|
3375
|
-
);
|
3376
|
-
const memoValue = (0, import_react22.useMemo)(
|
3377
|
-
() => __spreadValues({
|
3378
|
-
hoveringComponent,
|
3379
|
-
setHoveringComponent,
|
3380
|
-
registerZoneArea,
|
3381
|
-
areasWithZones,
|
3382
|
-
registerZone,
|
3383
|
-
unregisterZone,
|
3384
|
-
activeZones
|
3385
|
-
}, value),
|
3386
|
-
[value, hoveringComponent, areasWithZones, activeZones]
|
3387
|
-
);
|
3388
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
3389
|
-
};
|
3390
|
-
|
3391
|
-
// lib/insert.ts
|
3392
|
-
init_react_import();
|
3393
|
-
var insert = (list, index, item) => {
|
3394
|
-
const result = Array.from(list);
|
3395
|
-
result.splice(index, 0, item);
|
3396
|
-
return result;
|
3397
|
-
};
|
3398
|
-
|
3399
|
-
// components/DropZone/use-min-empty-height.ts
|
3400
|
-
init_react_import();
|
3401
|
-
var import_react23 = require("react");
|
3402
|
-
var useMinEmptyHeight = ({
|
3403
|
-
draggedItem,
|
3404
|
-
zoneCompound,
|
3405
|
-
userMinEmptyHeight,
|
3406
|
-
ref
|
3407
|
-
}) => {
|
3408
|
-
const [prevHeight, setPrevHeight] = (0, import_react23.useState)(0);
|
3409
|
-
const [isAnimating, setIsAnimating] = (0, import_react23.useState)(false);
|
3410
|
-
(0, import_react23.useEffect)(() => {
|
3411
|
-
if (draggedItem && ref.current) {
|
3412
|
-
const componentData = draggedItem.data;
|
3413
|
-
if (componentData.zone === zoneCompound) {
|
3414
|
-
const rect = ref.current.getBoundingClientRect();
|
3415
|
-
setPrevHeight(rect.height);
|
3416
|
-
setIsAnimating(true);
|
3510
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3511
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3512
|
+
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3513
|
+
var _a, _b;
|
3514
|
+
return {
|
3515
|
+
draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
|
3516
|
+
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3517
|
+
};
|
3518
|
+
});
|
3519
|
+
(0, import_react24.useEffect)(() => {
|
3520
|
+
if (draggedItem && ref.current) {
|
3521
|
+
if (isZone) {
|
3522
|
+
const rect = ref.current.getBoundingClientRect();
|
3523
|
+
setPrevHeight(rect.height);
|
3524
|
+
setIsAnimating(true);
|
3417
3525
|
return;
|
3418
3526
|
}
|
3419
3527
|
}
|
@@ -3440,15 +3548,143 @@ function assignRefs(refs, node) {
|
|
3440
3548
|
});
|
3441
3549
|
}
|
3442
3550
|
|
3443
|
-
// components/DropZone/
|
3444
|
-
|
3445
|
-
var
|
3446
|
-
|
3551
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3552
|
+
init_react_import();
|
3553
|
+
var import_react27 = require("react");
|
3554
|
+
|
3555
|
+
// lib/dnd/use-rendered-callback.ts
|
3556
|
+
init_react_import();
|
3557
|
+
var import_react25 = require("@dnd-kit/react");
|
3558
|
+
var import_react26 = require("react");
|
3559
|
+
function useRenderedCallback(callback, deps) {
|
3560
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3561
|
+
return (0, import_react26.useCallback)(
|
3562
|
+
(...args) => __async(this, null, function* () {
|
3563
|
+
yield manager == null ? void 0 : manager.renderer.rendering;
|
3564
|
+
return callback(...args);
|
3565
|
+
}),
|
3566
|
+
[...deps, manager]
|
3567
|
+
);
|
3568
|
+
}
|
3569
|
+
|
3570
|
+
// lib/insert.ts
|
3571
|
+
init_react_import();
|
3572
|
+
var insert = (list, index, item) => {
|
3573
|
+
const result = Array.from(list);
|
3574
|
+
result.splice(index, 0, item);
|
3575
|
+
return result;
|
3576
|
+
};
|
3577
|
+
|
3578
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3579
|
+
var useContentWithPreview = (content, zoneCompound) => {
|
3580
|
+
const { draggedItemId, preview, previewExists } = useContextStore(
|
3581
|
+
ZoneStoreContext,
|
3582
|
+
(s) => {
|
3583
|
+
var _a;
|
3584
|
+
return {
|
3585
|
+
draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
|
3586
|
+
preview: s.previewIndex[zoneCompound],
|
3587
|
+
previewExists: Object.keys(s.previewIndex || {}).length > 0
|
3588
|
+
};
|
3589
|
+
}
|
3590
|
+
);
|
3591
|
+
const {
|
3592
|
+
state: {
|
3593
|
+
ui: { isDragging }
|
3594
|
+
}
|
3595
|
+
} = useAppContext();
|
3596
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3597
|
+
const [localPreview, setLocalPreview] = (0, import_react27.useState)(
|
3598
|
+
preview
|
3599
|
+
);
|
3600
|
+
const updateContent = useRenderedCallback(
|
3601
|
+
(content2, preview2, isDragging2) => {
|
3602
|
+
if (isDragging2 && !previewExists) {
|
3603
|
+
return;
|
3604
|
+
}
|
3605
|
+
if (preview2) {
|
3606
|
+
if (preview2.type === "insert") {
|
3607
|
+
setContentWithPreview(
|
3608
|
+
insert(
|
3609
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3610
|
+
preview2.index,
|
3611
|
+
{
|
3612
|
+
type: "preview",
|
3613
|
+
props: { id: preview2.props.id }
|
3614
|
+
}
|
3615
|
+
)
|
3616
|
+
);
|
3617
|
+
} else {
|
3618
|
+
setContentWithPreview(
|
3619
|
+
insert(
|
3620
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3621
|
+
preview2.index,
|
3622
|
+
{
|
3623
|
+
type: preview2.componentType,
|
3624
|
+
props: preview2.props
|
3625
|
+
}
|
3626
|
+
)
|
3627
|
+
);
|
3628
|
+
}
|
3629
|
+
} else {
|
3630
|
+
setContentWithPreview(
|
3631
|
+
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3632
|
+
);
|
3633
|
+
}
|
3634
|
+
setLocalPreview(preview2);
|
3635
|
+
},
|
3636
|
+
[draggedItemId, previewExists]
|
3637
|
+
);
|
3638
|
+
(0, import_react27.useEffect)(() => {
|
3639
|
+
updateContent(content, preview, isDragging);
|
3640
|
+
}, [content, preview, isDragging]);
|
3641
|
+
return [contentWithPreview, localPreview];
|
3642
|
+
};
|
3643
|
+
|
3644
|
+
// components/DropZone/lib/use-drag-axis.ts
|
3645
|
+
init_react_import();
|
3646
|
+
var import_react28 = require("react");
|
3447
3647
|
var GRID_DRAG_AXIS = "dynamic";
|
3448
3648
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3449
3649
|
var DEFAULT_DRAG_AXIS = "y";
|
3450
|
-
var
|
3451
|
-
|
3650
|
+
var useDragAxis = (ref, collisionAxis) => {
|
3651
|
+
const { status } = useAppContext();
|
3652
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3653
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
3654
|
+
);
|
3655
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3656
|
+
if (ref.current) {
|
3657
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
3658
|
+
if (computedStyle.display === "grid") {
|
3659
|
+
setDragAxis(GRID_DRAG_AXIS);
|
3660
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3661
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3662
|
+
} else {
|
3663
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
3664
|
+
}
|
3665
|
+
}
|
3666
|
+
}, [ref.current]);
|
3667
|
+
(0, import_react28.useEffect)(() => {
|
3668
|
+
const onViewportChange = () => {
|
3669
|
+
calculateDragAxis();
|
3670
|
+
};
|
3671
|
+
window.addEventListener("viewportchange", onViewportChange);
|
3672
|
+
return () => {
|
3673
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
3674
|
+
};
|
3675
|
+
}, []);
|
3676
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
3677
|
+
return [dragAxis, calculateDragAxis];
|
3678
|
+
};
|
3679
|
+
|
3680
|
+
// components/DropZone/index.tsx
|
3681
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
3682
|
+
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3683
|
+
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3684
|
+
var RENDER_DEBUG = false;
|
3685
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
3686
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
3687
|
+
function DropZoneEditInternal({
|
3452
3688
|
zone,
|
3453
3689
|
allow,
|
3454
3690
|
disallow,
|
@@ -3458,31 +3694,48 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3458
3694
|
collisionAxis
|
3459
3695
|
}, userRef) {
|
3460
3696
|
const appContext2 = useAppContext();
|
3461
|
-
const ctx = (0,
|
3697
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3462
3698
|
const {
|
3463
3699
|
// These all need setting via context
|
3464
3700
|
data,
|
3465
3701
|
config,
|
3466
3702
|
areaId,
|
3467
|
-
draggedItem,
|
3468
3703
|
registerZoneArea,
|
3469
3704
|
depth,
|
3470
3705
|
registerLocalZone,
|
3471
3706
|
unregisterLocalZone,
|
3472
|
-
deepestZone = rootDroppableId,
|
3473
|
-
deepestArea,
|
3474
|
-
nextDeepestArea,
|
3475
3707
|
path = [],
|
3476
3708
|
activeZones
|
3477
3709
|
} = ctx;
|
3478
|
-
const { itemSelector } = appContext2.state.ui;
|
3479
3710
|
let zoneCompound = rootDroppableId;
|
3480
|
-
|
3711
|
+
if (areaId) {
|
3712
|
+
if (zone !== rootDroppableId) {
|
3713
|
+
zoneCompound = `${areaId}:${zone}`;
|
3714
|
+
}
|
3715
|
+
}
|
3716
|
+
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
3717
|
+
const {
|
3718
|
+
isDeepestZone,
|
3719
|
+
inNextDeepestArea,
|
3720
|
+
draggedComponentType,
|
3721
|
+
userIsDragging
|
3722
|
+
} = useContextStore(ZoneStoreContext, (s) => {
|
3723
|
+
var _a, _b, _c;
|
3724
|
+
return {
|
3725
|
+
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
3726
|
+
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3727
|
+
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3728
|
+
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3729
|
+
userIsDragging: !!s.draggedItem
|
3730
|
+
};
|
3731
|
+
});
|
3732
|
+
const { itemSelector } = appContext2.state.ui;
|
3733
|
+
(0, import_react29.useEffect)(() => {
|
3481
3734
|
if (areaId && registerZoneArea) {
|
3482
3735
|
registerZoneArea(areaId);
|
3483
3736
|
}
|
3484
3737
|
}, [areaId]);
|
3485
|
-
(0,
|
3738
|
+
(0, import_react29.useEffect)(() => {
|
3486
3739
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3487
3740
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3488
3741
|
}
|
@@ -3492,25 +3745,18 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3492
3745
|
}
|
3493
3746
|
};
|
3494
3747
|
}, []);
|
3495
|
-
|
3496
|
-
if (zone !== rootDroppableId) {
|
3497
|
-
zoneCompound = `${areaId}:${zone}`;
|
3498
|
-
}
|
3499
|
-
}
|
3500
|
-
const content = (0, import_react24.useMemo)(() => {
|
3748
|
+
const content = (0, import_react29.useMemo)(() => {
|
3501
3749
|
if (areaId && zone !== rootDroppableId) {
|
3502
3750
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3503
3751
|
}
|
3504
3752
|
return data.content || [];
|
3505
3753
|
}, [data, zoneCompound]);
|
3506
|
-
const ref = (0,
|
3507
|
-
const acceptsTarget = (0,
|
3508
|
-
(
|
3509
|
-
if (!
|
3754
|
+
const ref = (0, import_react29.useRef)(null);
|
3755
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
3756
|
+
(componentType) => {
|
3757
|
+
if (!componentType) {
|
3510
3758
|
return true;
|
3511
3759
|
}
|
3512
|
-
const data2 = target.data;
|
3513
|
-
const { componentType } = data2;
|
3514
3760
|
if (disallow) {
|
3515
3761
|
const defaultedAllow = allow || [];
|
3516
3762
|
const filteredDisallow = (disallow || []).filter(
|
@@ -3528,49 +3774,29 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3528
3774
|
},
|
3529
3775
|
[allow, disallow]
|
3530
3776
|
);
|
3531
|
-
(0,
|
3777
|
+
(0, import_react29.useEffect)(() => {
|
3532
3778
|
if (registerLocalZone) {
|
3533
|
-
registerLocalZone(zoneCompound, acceptsTarget(
|
3779
|
+
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3534
3780
|
}
|
3535
3781
|
return () => {
|
3536
3782
|
if (unregisterLocalZone) {
|
3537
3783
|
unregisterLocalZone(zoneCompound);
|
3538
3784
|
}
|
3539
3785
|
};
|
3540
|
-
}, [
|
3541
|
-
const
|
3542
|
-
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3543
|
-
const userIsDragging = !!draggedItem;
|
3786
|
+
}, [draggedComponentType, zoneCompound]);
|
3787
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
3544
3788
|
let isEnabled = true;
|
3545
|
-
if (
|
3546
|
-
isEnabled =
|
3789
|
+
if (userIsDragging) {
|
3790
|
+
isEnabled = isDeepestZone;
|
3547
3791
|
}
|
3548
3792
|
if (isEnabled) {
|
3549
|
-
isEnabled = acceptsTarget(
|
3550
|
-
}
|
3551
|
-
const preview = (
|
3552
|
-
|
3553
|
-
|
3554
|
-
|
3555
|
-
|
3556
|
-
contentWithPreview2 = content.filter(
|
3557
|
-
(item) => item.props.id !== preview.props.id
|
3558
|
-
);
|
3559
|
-
if (preview.type === "insert") {
|
3560
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3561
|
-
type: "preview",
|
3562
|
-
props: { id: preview.props.id }
|
3563
|
-
});
|
3564
|
-
} else {
|
3565
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3566
|
-
type: preview.componentType,
|
3567
|
-
props: preview.props
|
3568
|
-
});
|
3569
|
-
}
|
3570
|
-
}
|
3571
|
-
return contentWithPreview2;
|
3572
|
-
}, [preview, content]);
|
3573
|
-
const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3793
|
+
isEnabled = acceptsTarget(draggedComponentType);
|
3794
|
+
}
|
3795
|
+
const [contentWithPreview, preview] = useContentWithPreview(
|
3796
|
+
content,
|
3797
|
+
zoneCompound
|
3798
|
+
);
|
3799
|
+
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3574
3800
|
const droppableConfig = {
|
3575
3801
|
id: zoneCompound,
|
3576
3802
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -3580,45 +3806,20 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3580
3806
|
data: {
|
3581
3807
|
areaId,
|
3582
3808
|
depth,
|
3583
|
-
isDroppableTarget: acceptsTarget(
|
3809
|
+
isDroppableTarget: acceptsTarget(draggedComponentType),
|
3584
3810
|
path
|
3585
3811
|
}
|
3586
3812
|
};
|
3587
3813
|
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
3588
3814
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3589
3815
|
const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
|
3590
|
-
const [dragAxis
|
3591
|
-
collisionAxis || DEFAULT_DRAG_AXIS
|
3592
|
-
);
|
3593
|
-
const calculateDragAxis = (0, import_react24.useCallback)(() => {
|
3594
|
-
if (ref.current) {
|
3595
|
-
const computedStyle = window.getComputedStyle(ref.current);
|
3596
|
-
if (computedStyle.display === "grid") {
|
3597
|
-
setDragAxis(GRID_DRAG_AXIS);
|
3598
|
-
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3599
|
-
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3600
|
-
} else {
|
3601
|
-
setDragAxis(DEFAULT_DRAG_AXIS);
|
3602
|
-
}
|
3603
|
-
}
|
3604
|
-
}, [ref.current]);
|
3605
|
-
(0, import_react24.useEffect)(calculateDragAxis, [appContext2.status, collisionAxis]);
|
3606
|
-
(0, import_react24.useEffect)(() => {
|
3607
|
-
const onViewportChange = () => {
|
3608
|
-
calculateDragAxis();
|
3609
|
-
};
|
3610
|
-
window.addEventListener("viewportchange", onViewportChange);
|
3611
|
-
return () => {
|
3612
|
-
window.removeEventListener("viewportchange", onViewportChange);
|
3613
|
-
};
|
3614
|
-
}, []);
|
3816
|
+
const [dragAxis] = useDragAxis(ref, collisionAxis);
|
3615
3817
|
const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
|
3616
|
-
draggedItem,
|
3617
3818
|
zoneCompound,
|
3618
3819
|
userMinEmptyHeight,
|
3619
3820
|
ref
|
3620
3821
|
});
|
3621
|
-
return /* @__PURE__ */ (0,
|
3822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3622
3823
|
"div",
|
3623
3824
|
{
|
3624
3825
|
className: `${getClassName17({
|
@@ -3636,89 +3837,94 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3636
3837
|
},
|
3637
3838
|
"data-testid": `dropzone:${zoneCompound}`,
|
3638
3839
|
"data-puck-dropzone": zoneCompound,
|
3639
|
-
"data-puck-dnd": zoneCompound,
|
3640
3840
|
style: __spreadProps(__spreadValues({}, style), {
|
3641
|
-
"--min-empty-height": `${minEmptyHeight}px
|
3841
|
+
"--min-empty-height": `${minEmptyHeight}px`,
|
3842
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
3642
3843
|
}),
|
3643
|
-
children:
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3844
|
+
children: contentWithPreview.map((item, i) => {
|
3845
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3846
|
+
const componentId = item.props.id;
|
3847
|
+
const puckProps = {
|
3848
|
+
renderDropZone: DropZoneEditPure,
|
3849
|
+
isEditing: true,
|
3850
|
+
dragRef: null
|
3851
|
+
};
|
3852
|
+
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
|
3853
|
+
puck: puckProps,
|
3854
|
+
editMode: true
|
3855
|
+
// DEPRECATED
|
3856
|
+
});
|
3857
|
+
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3858
|
+
let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
3859
|
+
"No configuration for ",
|
3860
|
+
item.type
|
3861
|
+
] });
|
3862
|
+
const componentConfig = config.components[item.type];
|
3863
|
+
let componentType = item.type;
|
3864
|
+
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3865
|
+
if (item.type === "preview") {
|
3866
|
+
let Preview4 = function() {
|
3867
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3655
3868
|
};
|
3656
|
-
|
3657
|
-
|
3658
|
-
|
3659
|
-
|
3660
|
-
|
3661
|
-
|
3662
|
-
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3670
|
-
|
3671
|
-
|
3672
|
-
|
3673
|
-
|
3674
|
-
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
|
3684
|
-
|
3685
|
-
id: componentId,
|
3686
|
-
componentType,
|
3687
|
-
zoneCompound,
|
3688
|
-
depth: depth + 1,
|
3689
|
-
index: i,
|
3690
|
-
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3691
|
-
isSelected,
|
3692
|
-
label,
|
3693
|
-
isEnabled,
|
3694
|
-
autoDragAxis: dragAxis,
|
3695
|
-
userDragAxis: collisionAxis,
|
3696
|
-
inDroppableZone: acceptsTarget(draggedItem),
|
3697
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3698
|
-
Render2,
|
3699
|
-
__spreadProps(__spreadValues({}, defaultedProps), {
|
3700
|
-
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3701
|
-
dragRef
|
3702
|
-
})
|
3869
|
+
var Preview3 = Preview4;
|
3870
|
+
componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
|
3871
|
+
label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
|
3872
|
+
Render2 = Preview4;
|
3873
|
+
}
|
3874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3875
|
+
DropZoneProvider,
|
3876
|
+
{
|
3877
|
+
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3878
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3879
|
+
DraggableComponent,
|
3880
|
+
{
|
3881
|
+
id: componentId,
|
3882
|
+
componentType,
|
3883
|
+
zoneCompound,
|
3884
|
+
depth: depth + 1,
|
3885
|
+
index: i,
|
3886
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3887
|
+
isSelected,
|
3888
|
+
label,
|
3889
|
+
isEnabled,
|
3890
|
+
autoDragAxis: dragAxis,
|
3891
|
+
userDragAxis: collisionAxis,
|
3892
|
+
inDroppableZone: acceptsTarget(draggedComponentType),
|
3893
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3894
|
+
Render2,
|
3895
|
+
__spreadProps(__spreadValues({}, defaultedProps), {
|
3896
|
+
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3897
|
+
dragRef
|
3703
3898
|
})
|
3704
|
-
|
3705
|
-
}
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3899
|
+
})
|
3900
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3901
|
+
}
|
3902
|
+
)
|
3903
|
+
},
|
3904
|
+
componentId
|
3905
|
+
);
|
3906
|
+
})
|
3712
3907
|
}
|
3713
3908
|
);
|
3714
3909
|
}
|
3715
3910
|
);
|
3716
|
-
var
|
3717
|
-
|
3718
|
-
|
3911
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
3912
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
3913
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3914
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3719
3915
|
const { data, areaId = "root", config } = ctx || {};
|
3720
3916
|
let zoneCompound = rootDroppableId;
|
3721
3917
|
let content = (data == null ? void 0 : data.content) || [];
|
3918
|
+
(0, import_react29.useEffect)(() => {
|
3919
|
+
if (ctx == null ? void 0 : ctx.registerZone) {
|
3920
|
+
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3921
|
+
}
|
3922
|
+
return () => {
|
3923
|
+
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
3924
|
+
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
3925
|
+
}
|
3926
|
+
};
|
3927
|
+
}, []);
|
3722
3928
|
if (!data || !config) {
|
3723
3929
|
return null;
|
3724
3930
|
}
|
@@ -3726,10 +3932,10 @@ var DropZoneRender = (0, import_react24.forwardRef)(
|
|
3726
3932
|
zoneCompound = `${areaId}:${zone}`;
|
3727
3933
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3728
3934
|
}
|
3729
|
-
return /* @__PURE__ */ (0,
|
3935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
3730
3936
|
const Component = config.components[item.type];
|
3731
3937
|
if (Component) {
|
3732
|
-
return /* @__PURE__ */ (0,
|
3938
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3733
3939
|
DropZoneProvider,
|
3734
3940
|
{
|
3735
3941
|
value: {
|
@@ -3739,10 +3945,12 @@ var DropZoneRender = (0, import_react24.forwardRef)(
|
|
3739
3945
|
depth: 1,
|
3740
3946
|
path: []
|
3741
3947
|
},
|
3742
|
-
children: /* @__PURE__ */ (0,
|
3948
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3743
3949
|
Component.render,
|
3744
3950
|
__spreadProps(__spreadValues({}, item.props), {
|
3745
|
-
puck: {
|
3951
|
+
puck: {
|
3952
|
+
renderDropZone: DropZoneRenderPure
|
3953
|
+
}
|
3746
3954
|
})
|
3747
3955
|
)
|
3748
3956
|
},
|
@@ -3753,13 +3961,13 @@ var DropZoneRender = (0, import_react24.forwardRef)(
|
|
3753
3961
|
}) });
|
3754
3962
|
}
|
3755
3963
|
);
|
3756
|
-
var DropZone = (0,
|
3964
|
+
var DropZone = (0, import_react29.forwardRef)(
|
3757
3965
|
function DropZone2(props, ref) {
|
3758
|
-
const ctx = (0,
|
3966
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3759
3967
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3760
|
-
return /* @__PURE__ */ (0,
|
3968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3761
3969
|
}
|
3762
|
-
return /* @__PURE__ */ (0,
|
3970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3763
3971
|
}
|
3764
3972
|
);
|
3765
3973
|
|
@@ -3775,7 +3983,7 @@ var getZoneId = (zoneCompound) => {
|
|
3775
3983
|
return [rootDroppableId, zoneCompound];
|
3776
3984
|
};
|
3777
3985
|
|
3778
|
-
//
|
3986
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3779
3987
|
init_react_import();
|
3780
3988
|
var import_abstract9 = require("@dnd-kit/abstract");
|
3781
3989
|
var import_state = require("@dnd-kit/state");
|
@@ -3817,7 +4025,49 @@ var getFrame = () => {
|
|
3817
4025
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3818
4026
|
};
|
3819
4027
|
|
3820
|
-
//
|
4028
|
+
// lib/global-position.ts
|
4029
|
+
init_react_import();
|
4030
|
+
var GlobalPosition = class {
|
4031
|
+
constructor(target, original) {
|
4032
|
+
this.scaleFactor = 1;
|
4033
|
+
this.frameEl = null;
|
4034
|
+
this.frameRect = null;
|
4035
|
+
var _a;
|
4036
|
+
this.target = target;
|
4037
|
+
this.original = original;
|
4038
|
+
this.frameEl = document.querySelector("iframe");
|
4039
|
+
if (this.frameEl) {
|
4040
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
4041
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4042
|
+
}
|
4043
|
+
}
|
4044
|
+
get x() {
|
4045
|
+
return this.original.x;
|
4046
|
+
}
|
4047
|
+
get y() {
|
4048
|
+
return this.original.y;
|
4049
|
+
}
|
4050
|
+
get global() {
|
4051
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
4052
|
+
return {
|
4053
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
4054
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
4055
|
+
};
|
4056
|
+
}
|
4057
|
+
return this.original;
|
4058
|
+
}
|
4059
|
+
get frame() {
|
4060
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
4061
|
+
return {
|
4062
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
4063
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
4064
|
+
};
|
4065
|
+
}
|
4066
|
+
return this.original;
|
4067
|
+
}
|
4068
|
+
};
|
4069
|
+
|
4070
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3821
4071
|
var depthSort = (candidates) => {
|
3822
4072
|
return candidates.sort((a, b) => {
|
3823
4073
|
const aData = a.data;
|
@@ -3846,10 +4096,12 @@ var getZoneId2 = (candidate) => {
|
|
3846
4096
|
}
|
3847
4097
|
return id;
|
3848
4098
|
};
|
3849
|
-
var getPointerCollisions = (position, manager
|
3850
|
-
var _a;
|
4099
|
+
var getPointerCollisions = (position, manager) => {
|
3851
4100
|
const candidates = [];
|
3852
|
-
let elements = ownerDocument.elementsFromPoint(
|
4101
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
4102
|
+
position.x,
|
4103
|
+
position.y
|
4104
|
+
);
|
3853
4105
|
const previewFrame = elements.find(
|
3854
4106
|
(el) => el.getAttribute("data-puck-preview")
|
3855
4107
|
);
|
@@ -3858,22 +4110,21 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3858
4110
|
elements = [drawer];
|
3859
4111
|
}
|
3860
4112
|
if (previewFrame) {
|
3861
|
-
const
|
3862
|
-
if (
|
3863
|
-
|
3864
|
-
const frame = getFrame();
|
3865
|
-
if (frame) {
|
3866
|
-
const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
3867
|
-
elements = frame.elementsFromPoint(
|
3868
|
-
(position.x - rect.left) / scaleFactor,
|
3869
|
-
(position.y - rect.top) / scaleFactor
|
3870
|
-
);
|
3871
|
-
}
|
4113
|
+
const frame = getFrame();
|
4114
|
+
if (frame) {
|
4115
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
3872
4116
|
}
|
3873
4117
|
}
|
3874
4118
|
if (elements) {
|
3875
4119
|
for (let i = 0; i < elements.length; i++) {
|
3876
4120
|
const element = elements[i];
|
4121
|
+
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
4122
|
+
if (dropzoneId) {
|
4123
|
+
const droppable = manager.registry.droppables.get(dropzoneId);
|
4124
|
+
if (droppable) {
|
4125
|
+
candidates.push(droppable);
|
4126
|
+
}
|
4127
|
+
}
|
3877
4128
|
const id = element.getAttribute("data-puck-dnd");
|
3878
4129
|
if (id) {
|
3879
4130
|
const droppable = manager.registry.droppables.get(id);
|
@@ -3885,9 +4136,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3885
4136
|
}
|
3886
4137
|
return candidates;
|
3887
4138
|
};
|
3888
|
-
var findDeepestCandidate = (position, manager
|
4139
|
+
var findDeepestCandidate = (position, manager) => {
|
3889
4140
|
var _a;
|
3890
|
-
const candidates = getPointerCollisions(position, manager
|
4141
|
+
const candidates = getPointerCollisions(position, manager);
|
3891
4142
|
if (candidates.length > 0) {
|
3892
4143
|
const sortedCandidates = depthSort(candidates);
|
3893
4144
|
const draggable = manager.dragOperation.source;
|
@@ -3932,9 +4183,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
|
|
3932
4183
|
area: null
|
3933
4184
|
};
|
3934
4185
|
};
|
3935
|
-
var createNestedDroppablePlugin = ({
|
3936
|
-
onChange
|
3937
|
-
}) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4186
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
3938
4187
|
constructor(manager, options) {
|
3939
4188
|
super(manager);
|
3940
4189
|
if (typeof window === "undefined") {
|
@@ -3942,16 +4191,19 @@ var createNestedDroppablePlugin = ({
|
|
3942
4191
|
}
|
3943
4192
|
const cleanupEffect = (0, import_state.effects)(() => {
|
3944
4193
|
const handleMove = (event) => {
|
3945
|
-
const
|
4194
|
+
const target = event.originalTarget || event.target;
|
4195
|
+
const position = new GlobalPosition(target, {
|
3946
4196
|
x: event.clientX,
|
3947
4197
|
y: event.clientY
|
3948
|
-
};
|
3949
|
-
const
|
3950
|
-
|
3951
|
-
|
3952
|
-
findDeepestCandidate(position, manager, ownerDocument),
|
3953
|
-
manager
|
4198
|
+
});
|
4199
|
+
const elements = document.elementsFromPoint(
|
4200
|
+
position.global.x,
|
4201
|
+
position.global.y
|
3954
4202
|
);
|
4203
|
+
const overEl = elements.some((el) => el.id === id);
|
4204
|
+
if (overEl) {
|
4205
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
4206
|
+
}
|
3955
4207
|
};
|
3956
4208
|
const handleMoveThrottled = throttle(handleMove, 50);
|
3957
4209
|
const handlePointerMove = (event) => {
|
@@ -4281,6 +4533,11 @@ var reduceUi = (ui, action) => {
|
|
4281
4533
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4282
4534
|
});
|
4283
4535
|
}
|
4536
|
+
if (action.type === "remove") {
|
4537
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4538
|
+
itemSelector: null
|
4539
|
+
});
|
4540
|
+
}
|
4284
4541
|
return ui;
|
4285
4542
|
};
|
4286
4543
|
|
@@ -4368,7 +4625,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4368
4625
|
var import_use_debounce2 = require("use-debounce");
|
4369
4626
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
4370
4627
|
|
4371
|
-
//
|
4628
|
+
// lib/dnd/PointerSensor.ts
|
4372
4629
|
init_react_import();
|
4373
4630
|
var import_state3 = require("@dnd-kit/state");
|
4374
4631
|
var import_abstract10 = require("@dnd-kit/abstract");
|
@@ -4531,6 +4788,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
|
|
4531
4788
|
}
|
4532
4789
|
}
|
4533
4790
|
handlePointerUp(event) {
|
4791
|
+
if (!this.source) {
|
4792
|
+
return;
|
4793
|
+
}
|
4534
4794
|
event.preventDefault();
|
4535
4795
|
event.stopPropagation();
|
4536
4796
|
const { status } = this.manager.dragOperation;
|
@@ -4630,13 +4890,15 @@ function patchWindow(window2) {
|
|
4630
4890
|
}
|
4631
4891
|
|
4632
4892
|
// components/DragDropContext/index.tsx
|
4633
|
-
var
|
4634
|
-
var
|
4893
|
+
var import_zustand3 = require("zustand");
|
4894
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
4895
|
+
var DEBUG3 = false;
|
4896
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
4635
4897
|
dragListeners: {}
|
4636
4898
|
});
|
4637
4899
|
function useDragListener(type, fn, deps = []) {
|
4638
|
-
const { setDragListeners } = (0,
|
4639
|
-
(0,
|
4900
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
4901
|
+
(0, import_react31.useEffect)(() => {
|
4640
4902
|
if (setDragListeners) {
|
4641
4903
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4642
4904
|
[type]: [...old[type] || [], fn]
|
@@ -4644,80 +4906,147 @@ function useDragListener(type, fn, deps = []) {
|
|
4644
4906
|
}
|
4645
4907
|
}, deps);
|
4646
4908
|
}
|
4647
|
-
var previewContext = (0, import_react26.createContext)(null);
|
4648
4909
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4910
|
+
var useTempDisableFallback = (timeout3) => {
|
4911
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
4912
|
+
return (0, import_react31.useCallback)((manager) => {
|
4913
|
+
collisionStore.setState({ fallbackEnabled: false });
|
4914
|
+
const fallbackId = generateId();
|
4915
|
+
lastFallbackDisable.current = fallbackId;
|
4916
|
+
setTimeout(() => {
|
4917
|
+
if (lastFallbackDisable.current === fallbackId) {
|
4918
|
+
collisionStore.setState({ fallbackEnabled: true });
|
4919
|
+
manager.collisionObserver.forceUpdate(true);
|
4920
|
+
}
|
4921
|
+
}, timeout3);
|
4922
|
+
}, []);
|
4923
|
+
};
|
4649
4924
|
var DragDropContextClient = ({
|
4650
4925
|
children,
|
4651
4926
|
disableAutoScroll
|
4652
4927
|
}) => {
|
4653
4928
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4654
|
-
const
|
4655
|
-
const previewRef = (0, import_react26.useRef)(null);
|
4929
|
+
const id = (0, import_react31.useId)();
|
4656
4930
|
const { data } = state;
|
4657
|
-
const
|
4658
|
-
const
|
4659
|
-
const
|
4660
|
-
|
4661
|
-
|
4931
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
4932
|
+
const tempDisableFallback = useTempDisableFallback(100);
|
4933
|
+
const [zoneStore] = (0, import_react31.useState)(
|
4934
|
+
() => (0, import_zustand3.createStore)(() => ({
|
4935
|
+
zoneDepthIndex: {},
|
4936
|
+
nextZoneDepthIndex: {},
|
4937
|
+
areaDepthIndex: {},
|
4938
|
+
nextAreaDepthIndex: {},
|
4939
|
+
draggedItem: null,
|
4940
|
+
previewIndex: {}
|
4941
|
+
}))
|
4942
|
+
);
|
4943
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
4944
|
+
(params, id2) => {
|
4945
|
+
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4946
|
+
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
4947
|
+
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
4948
|
+
let zoneChanged = false;
|
4949
|
+
let areaChanged = false;
|
4950
|
+
if (params.zone && !zoneDepthIndex[params.zone]) {
|
4951
|
+
zoneChanged = true;
|
4952
|
+
} else if (!params.zone && stateHasZone) {
|
4953
|
+
zoneChanged = true;
|
4954
|
+
}
|
4955
|
+
if (params.area && !areaDepthIndex[params.area]) {
|
4956
|
+
areaChanged = true;
|
4957
|
+
} else if (!params.area && stateHasArea) {
|
4958
|
+
areaChanged = true;
|
4959
|
+
}
|
4960
|
+
return { zoneChanged, areaChanged };
|
4961
|
+
},
|
4962
|
+
[zoneStore]
|
4963
|
+
);
|
4964
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
4662
4965
|
(params, manager) => {
|
4663
|
-
|
4966
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4967
|
+
if (!zoneChanged && !areaChanged) return;
|
4968
|
+
zoneStore.setState({
|
4969
|
+
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
4970
|
+
areaDepthIndex: params.area ? { [params.area]: true } : {}
|
4971
|
+
});
|
4972
|
+
tempDisableFallback(manager);
|
4664
4973
|
setTimeout(() => {
|
4665
4974
|
manager.collisionObserver.forceUpdate(true);
|
4666
4975
|
}, 50);
|
4667
4976
|
debouncedParamsRef.current = null;
|
4668
4977
|
},
|
4669
|
-
[]
|
4978
|
+
[zoneStore]
|
4670
4979
|
);
|
4671
4980
|
const setDeepestDb = (0, import_use_debounce2.useDebouncedCallback)(
|
4672
4981
|
setDeepestAndCollide,
|
4673
4982
|
AREA_CHANGE_DEBOUNCE_MS
|
4674
4983
|
);
|
4675
|
-
(0, import_react26.useEffect)(() => {
|
4676
|
-
deepestRef.current = deepest;
|
4677
|
-
}, [deepest]);
|
4678
4984
|
const cancelDb = () => {
|
4679
4985
|
setDeepestDb.cancel();
|
4680
4986
|
debouncedParamsRef.current = null;
|
4681
4987
|
};
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
|
4688
|
-
|
4689
|
-
|
4690
|
-
|
4691
|
-
|
4692
|
-
}
|
4693
|
-
if (params.zone !== "void" && (lastParams == null ? void 0 : lastParams.zone) === "void") {
|
4694
|
-
setDeepest(params);
|
4695
|
-
manager.collisionObserver.forceUpdate(true);
|
4696
|
-
return;
|
4988
|
+
(0, import_react31.useEffect)(() => {
|
4989
|
+
if (DEBUG3) {
|
4990
|
+
zoneStore.subscribe(
|
4991
|
+
(s) => {
|
4992
|
+
var _a, _b;
|
4993
|
+
return console.log(
|
4994
|
+
s.previewIndex,
|
4995
|
+
(_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
|
4996
|
+
(_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
|
4997
|
+
);
|
4697
4998
|
}
|
4698
|
-
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4702
|
-
|
4999
|
+
);
|
5000
|
+
}
|
5001
|
+
}, []);
|
5002
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
5003
|
+
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5004
|
+
createNestedDroppablePlugin(
|
5005
|
+
{
|
5006
|
+
onChange: (params, manager) => {
|
5007
|
+
const state2 = zoneStore.getState();
|
5008
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5009
|
+
const isDragging = manager.dragOperation.status.dragging;
|
5010
|
+
if (areaChanged || zoneChanged) {
|
5011
|
+
let nextZoneDepthIndex = {};
|
5012
|
+
let nextAreaDepthIndex = {};
|
5013
|
+
if (params.zone) {
|
5014
|
+
nextZoneDepthIndex = { [params.zone]: true };
|
5015
|
+
}
|
5016
|
+
if (params.area) {
|
5017
|
+
nextAreaDepthIndex = { [params.area]: true };
|
5018
|
+
}
|
5019
|
+
zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
|
5020
|
+
}
|
5021
|
+
if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
|
5022
|
+
setDeepestAndCollide(params, manager);
|
5023
|
+
return;
|
5024
|
+
}
|
5025
|
+
if (areaChanged) {
|
5026
|
+
if (isDragging) {
|
5027
|
+
const debouncedParams = debouncedParamsRef.current;
|
5028
|
+
const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
|
5029
|
+
if (!isSameParams) {
|
5030
|
+
cancelDb();
|
5031
|
+
setDeepestDb(params, manager);
|
5032
|
+
debouncedParamsRef.current = params;
|
5033
|
+
}
|
5034
|
+
} else {
|
4703
5035
|
cancelDb();
|
4704
|
-
|
4705
|
-
debouncedParamsRef.current = params;
|
5036
|
+
setDeepestAndCollide(params, manager);
|
4706
5037
|
}
|
4707
|
-
|
4708
|
-
|
5038
|
+
return;
|
5039
|
+
}
|
5040
|
+
if (zoneChanged) {
|
4709
5041
|
setDeepestAndCollide(params, manager);
|
4710
5042
|
}
|
4711
|
-
|
5043
|
+
cancelDb();
|
4712
5044
|
}
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
cancelDb();
|
4717
|
-
}
|
4718
|
-
})
|
5045
|
+
},
|
5046
|
+
id
|
5047
|
+
)
|
4719
5048
|
]);
|
4720
|
-
const [sensors] = (0,
|
5049
|
+
const [sensors] = (0, import_react31.useState)(() => [
|
4721
5050
|
PointerSensor.configure({
|
4722
5051
|
activationConstraints(event, source) {
|
4723
5052
|
var _a;
|
@@ -4736,67 +5065,72 @@ var DragDropContextClient = ({
|
|
4736
5065
|
}
|
4737
5066
|
})
|
4738
5067
|
]);
|
4739
|
-
const [
|
4740
|
-
const [
|
4741
|
-
const
|
4742
|
-
const
|
4743
|
-
|
4744
|
-
(selector) => {
|
4745
|
-
const item = getItem(selector, data);
|
4746
|
-
if (!item) {
|
4747
|
-
return;
|
4748
|
-
}
|
5068
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
5069
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
5070
|
+
const dragMode = (0, import_react31.useRef)(null);
|
5071
|
+
const registerPath = (0, import_react31.useCallback)(
|
5072
|
+
(id2, selector, label) => {
|
4749
5073
|
const [area] = getZoneId(selector.zone);
|
4750
5074
|
setPathData((latestPathData = {}) => {
|
4751
5075
|
const parentPathData = latestPathData[area] || { path: [] };
|
4752
5076
|
return __spreadProps(__spreadValues({}, latestPathData), {
|
4753
|
-
[
|
5077
|
+
[id2]: {
|
4754
5078
|
path: [
|
4755
5079
|
...parentPathData.path,
|
4756
5080
|
...selector.zone ? [selector.zone] : []
|
4757
5081
|
],
|
4758
|
-
label
|
5082
|
+
label
|
4759
5083
|
}
|
4760
5084
|
});
|
4761
5085
|
});
|
4762
5086
|
},
|
4763
5087
|
[data, setPathData]
|
4764
5088
|
);
|
4765
|
-
const
|
4766
|
-
|
5089
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5090
|
+
(id2) => {
|
5091
|
+
setPathData((latestPathData = {}) => {
|
5092
|
+
const newPathData = __spreadValues({}, latestPathData);
|
5093
|
+
delete newPathData[id2];
|
5094
|
+
return newPathData;
|
5095
|
+
});
|
5096
|
+
},
|
5097
|
+
[data, setPathData]
|
5098
|
+
);
|
5099
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4767
5101
|
dragListenerContext.Provider,
|
4768
5102
|
{
|
4769
5103
|
value: {
|
4770
5104
|
dragListeners,
|
4771
5105
|
setDragListeners
|
4772
5106
|
},
|
4773
|
-
children: /* @__PURE__ */ (0,
|
4774
|
-
|
5107
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5108
|
+
import_react30.DragDropProvider,
|
4775
5109
|
{
|
4776
5110
|
plugins,
|
4777
5111
|
sensors,
|
4778
5112
|
onDragEnd: (event, manager) => {
|
5113
|
+
var _a;
|
4779
5114
|
const { source, target } = event.operation;
|
4780
|
-
deepestRef.current = null;
|
4781
5115
|
if (!source) {
|
4782
|
-
|
5116
|
+
zoneStore.setState({ draggedItem: null });
|
4783
5117
|
return;
|
4784
5118
|
}
|
4785
5119
|
const { zone, index } = source.data;
|
4786
|
-
const
|
4787
|
-
|
5120
|
+
const { previewIndex = {} } = zoneStore.getState() || {};
|
5121
|
+
const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
|
4788
5122
|
setTimeout(() => {
|
4789
|
-
var
|
4790
|
-
|
5123
|
+
var _a2, _b;
|
5124
|
+
zoneStore.setState({ draggedItem: null });
|
4791
5125
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4792
|
-
|
4793
|
-
(
|
5126
|
+
zoneStore.setState({ previewIndex: {} });
|
5127
|
+
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
4794
5128
|
fn(event, manager);
|
4795
5129
|
});
|
4796
5130
|
return;
|
4797
5131
|
}
|
4798
5132
|
if (thisPreview) {
|
4799
|
-
|
5133
|
+
zoneStore.setState({ previewIndex: {} });
|
4800
5134
|
if (thisPreview.type === "insert") {
|
4801
5135
|
insertComponent(
|
4802
5136
|
thisPreview.componentType,
|
@@ -4831,8 +5165,9 @@ var DragDropContextClient = ({
|
|
4831
5165
|
}, 250);
|
4832
5166
|
},
|
4833
5167
|
onDragOver: (event, manager) => {
|
4834
|
-
var _a, _b, _c, _d;
|
5168
|
+
var _a, _b, _c, _d, _e;
|
4835
5169
|
event.preventDefault();
|
5170
|
+
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
4836
5171
|
if (!draggedItem) return;
|
4837
5172
|
cancelDb();
|
4838
5173
|
const { source, target } = event.operation;
|
@@ -4848,7 +5183,7 @@ var DragDropContextClient = ({
|
|
4848
5183
|
const targetData = target.data;
|
4849
5184
|
targetZone = targetData.zone;
|
4850
5185
|
targetIndex = targetData.index;
|
4851
|
-
const collisionData = (
|
5186
|
+
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
4852
5187
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4853
5188
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4854
5189
|
targetIndex = targetIndex - 1;
|
@@ -4860,23 +5195,26 @@ var DragDropContextClient = ({
|
|
4860
5195
|
targetZone = target.id.toString();
|
4861
5196
|
targetIndex = 0;
|
4862
5197
|
}
|
4863
|
-
if (targetId === sourceId || ((
|
5198
|
+
if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
|
4864
5199
|
const [pathId] = path.split(":");
|
4865
5200
|
return pathId === sourceId;
|
4866
5201
|
}))) {
|
4867
5202
|
return;
|
4868
5203
|
}
|
4869
5204
|
if (dragMode.current === "new") {
|
4870
|
-
|
4871
|
-
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
5205
|
+
zoneStore.setState({
|
5206
|
+
previewIndex: {
|
5207
|
+
[targetZone]: {
|
5208
|
+
componentType: sourceData.componentType,
|
5209
|
+
type: "insert",
|
5210
|
+
index: targetIndex,
|
5211
|
+
zone: targetZone,
|
5212
|
+
props: {
|
5213
|
+
id: source.id.toString()
|
5214
|
+
}
|
5215
|
+
}
|
4877
5216
|
}
|
4878
|
-
};
|
4879
|
-
setPreview(previewRef.current);
|
5217
|
+
});
|
4880
5218
|
} else {
|
4881
5219
|
if (!initialSelector.current) {
|
4882
5220
|
initialSelector.current = {
|
@@ -4886,17 +5224,20 @@ var DragDropContextClient = ({
|
|
4886
5224
|
}
|
4887
5225
|
const item = getItem(initialSelector.current, data);
|
4888
5226
|
if (item) {
|
4889
|
-
|
4890
|
-
|
4891
|
-
|
4892
|
-
|
4893
|
-
|
4894
|
-
|
4895
|
-
|
4896
|
-
|
5227
|
+
zoneStore.setState({
|
5228
|
+
previewIndex: {
|
5229
|
+
[targetZone]: {
|
5230
|
+
componentType: sourceData.componentType,
|
5231
|
+
type: "move",
|
5232
|
+
index: targetIndex,
|
5233
|
+
zone: targetZone,
|
5234
|
+
props: item.props
|
5235
|
+
}
|
5236
|
+
}
|
5237
|
+
});
|
4897
5238
|
}
|
4898
5239
|
}
|
4899
|
-
(
|
5240
|
+
(_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
|
4900
5241
|
fn(event, manager);
|
4901
5242
|
});
|
4902
5243
|
},
|
@@ -4906,46 +5247,62 @@ var DragDropContextClient = ({
|
|
4906
5247
|
type: "setUi",
|
4907
5248
|
ui: { itemSelector: null, isDragging: true }
|
4908
5249
|
});
|
5250
|
+
const { source } = event.operation;
|
5251
|
+
if (source && source.type !== "void") {
|
5252
|
+
const sourceData = source.data;
|
5253
|
+
const item = getItem(
|
5254
|
+
{
|
5255
|
+
zone: sourceData.zone,
|
5256
|
+
index: sourceData.index
|
5257
|
+
},
|
5258
|
+
data
|
5259
|
+
);
|
5260
|
+
if (item) {
|
5261
|
+
zoneStore.setState({
|
5262
|
+
previewIndex: {
|
5263
|
+
[sourceData.zone]: {
|
5264
|
+
componentType: sourceData.componentType,
|
5265
|
+
type: "move",
|
5266
|
+
index: sourceData.index,
|
5267
|
+
zone: sourceData.zone,
|
5268
|
+
props: item.props
|
5269
|
+
}
|
5270
|
+
}
|
5271
|
+
});
|
5272
|
+
}
|
5273
|
+
}
|
4909
5274
|
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4910
5275
|
fn(event, manager);
|
4911
5276
|
});
|
4912
5277
|
},
|
4913
5278
|
onBeforeDragStart: (event) => {
|
4914
5279
|
var _a;
|
4915
|
-
if (draggedItem) {
|
4916
|
-
console.warn("New drag started before previous drag cleaned up");
|
4917
|
-
}
|
4918
5280
|
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4919
5281
|
dragMode.current = isNewComponent ? "new" : "existing";
|
4920
5282
|
initialSelector.current = void 0;
|
4921
|
-
|
5283
|
+
zoneStore.setState({ draggedItem: event.operation.source });
|
4922
5284
|
},
|
4923
|
-
children: /* @__PURE__ */ (0,
|
5285
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4924
5286
|
DropZoneProvider,
|
4925
5287
|
{
|
4926
5288
|
value: {
|
4927
5289
|
data,
|
4928
5290
|
config,
|
4929
|
-
dispatch,
|
4930
|
-
draggedItem,
|
4931
5291
|
mode: "edit",
|
4932
5292
|
areaId: "root",
|
4933
5293
|
depth: 0,
|
4934
5294
|
registerPath,
|
5295
|
+
unregisterPath,
|
4935
5296
|
pathData,
|
4936
|
-
deepestZone: deepest == null ? void 0 : deepest.zone,
|
4937
|
-
deepestArea: deepest == null ? void 0 : deepest.area,
|
4938
|
-
nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
|
4939
|
-
nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
|
4940
5297
|
path: []
|
4941
5298
|
},
|
4942
5299
|
children
|
4943
5300
|
}
|
4944
|
-
)
|
5301
|
+
) })
|
4945
5302
|
}
|
4946
|
-
)
|
5303
|
+
)
|
4947
5304
|
}
|
4948
|
-
);
|
5305
|
+
) });
|
4949
5306
|
};
|
4950
5307
|
var DragDropContext = ({
|
4951
5308
|
children,
|
@@ -4955,11 +5312,11 @@ var DragDropContext = ({
|
|
4955
5312
|
if (status === "LOADING") {
|
4956
5313
|
return children;
|
4957
5314
|
}
|
4958
|
-
return /* @__PURE__ */ (0,
|
5315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
4959
5316
|
};
|
4960
5317
|
|
4961
5318
|
// components/Drawer/index.tsx
|
4962
|
-
var
|
5319
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
4963
5320
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
4964
5321
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
4965
5322
|
var DrawerItemInner = ({
|
@@ -4969,11 +5326,11 @@ var DrawerItemInner = ({
|
|
4969
5326
|
dragRef,
|
4970
5327
|
isDragDisabled
|
4971
5328
|
}) => {
|
4972
|
-
const CustomInner = (0,
|
4973
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
5329
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5330
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
4974
5331
|
[children]
|
4975
5332
|
);
|
4976
|
-
return /* @__PURE__ */ (0,
|
5333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
4977
5334
|
"div",
|
4978
5335
|
{
|
4979
5336
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -4981,9 +5338,9 @@ var DrawerItemInner = ({
|
|
4981
5338
|
onMouseDown: (e) => e.preventDefault(),
|
4982
5339
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
4983
5340
|
"data-puck-drawer-item": true,
|
4984
|
-
children: /* @__PURE__ */ (0,
|
4985
|
-
/* @__PURE__ */ (0,
|
4986
|
-
/* @__PURE__ */ (0,
|
5341
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
|
5342
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
5343
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragIcon, {}) })
|
4987
5344
|
] }) }) })
|
4988
5345
|
}
|
4989
5346
|
);
|
@@ -5000,9 +5357,9 @@ var DrawerItemDraggable = ({
|
|
5000
5357
|
data: { type: "drawer", componentType: name },
|
5001
5358
|
disabled: isDragDisabled
|
5002
5359
|
});
|
5003
|
-
return /* @__PURE__ */ (0,
|
5004
|
-
/* @__PURE__ */ (0,
|
5005
|
-
/* @__PURE__ */ (0,
|
5360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName18("draggable"), children: [
|
5361
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DrawerItemInner, { name, label, children }) }),
|
5362
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5006
5363
|
DrawerItemInner,
|
5007
5364
|
{
|
5008
5365
|
name,
|
@@ -5023,7 +5380,7 @@ var DrawerItem = ({
|
|
5023
5380
|
isDragDisabled
|
5024
5381
|
}) => {
|
5025
5382
|
const resolvedId = id || name;
|
5026
|
-
const [dynamicId, setDynamicId] = (0,
|
5383
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5027
5384
|
if (typeof index !== "undefined") {
|
5028
5385
|
console.error(
|
5029
5386
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5036,7 +5393,7 @@ var DrawerItem = ({
|
|
5036
5393
|
},
|
5037
5394
|
[resolvedId]
|
5038
5395
|
);
|
5039
|
-
return /* @__PURE__ */ (0,
|
5396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5040
5397
|
DrawerItemDraggable,
|
5041
5398
|
{
|
5042
5399
|
name,
|
@@ -5062,14 +5419,14 @@ var Drawer = ({
|
|
5062
5419
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5063
5420
|
);
|
5064
5421
|
}
|
5065
|
-
const
|
5422
|
+
const id = (0, import_react32.useId)();
|
5066
5423
|
const { ref } = useDroppableSafe({
|
5067
5424
|
id,
|
5068
5425
|
type: "void",
|
5069
5426
|
collisionPriority: 0
|
5070
5427
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
5071
5428
|
});
|
5072
|
-
return /* @__PURE__ */ (0,
|
5429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5073
5430
|
"div",
|
5074
5431
|
{
|
5075
5432
|
className: getClassName18(),
|
@@ -5084,7 +5441,7 @@ Drawer.Item = DrawerItem;
|
|
5084
5441
|
|
5085
5442
|
// components/Puck/index.tsx
|
5086
5443
|
init_react_import();
|
5087
|
-
var
|
5444
|
+
var import_react50 = require("react");
|
5088
5445
|
|
5089
5446
|
// components/SidebarSection/index.tsx
|
5090
5447
|
init_react_import();
|
@@ -5095,7 +5452,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
5095
5452
|
|
5096
5453
|
// lib/use-breadcrumbs.ts
|
5097
5454
|
init_react_import();
|
5098
|
-
var
|
5455
|
+
var import_react33 = require("react");
|
5099
5456
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5100
5457
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5101
5458
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5145,8 +5502,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5145
5502
|
state: { data },
|
5146
5503
|
selectedItem
|
5147
5504
|
} = useAppContext();
|
5148
|
-
const dzContext = (0,
|
5149
|
-
return (0,
|
5505
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5506
|
+
return (0, import_react33.useMemo)(() => {
|
5150
5507
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5151
5508
|
selectedItem,
|
5152
5509
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5160,7 +5517,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
5160
5517
|
};
|
5161
5518
|
|
5162
5519
|
// components/SidebarSection/index.tsx
|
5163
|
-
var
|
5520
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
5164
5521
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5165
5522
|
var SidebarSection = ({
|
5166
5523
|
children,
|
@@ -5173,15 +5530,15 @@ var SidebarSection = ({
|
|
5173
5530
|
}) => {
|
5174
5531
|
const { setUi } = useAppContext();
|
5175
5532
|
const breadcrumbs = useBreadcrumbs(1);
|
5176
|
-
return /* @__PURE__ */ (0,
|
5533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
5177
5534
|
"div",
|
5178
5535
|
{
|
5179
5536
|
className: getClassName19({ noBorderTop, noPadding }),
|
5180
5537
|
style: { background },
|
5181
5538
|
children: [
|
5182
|
-
/* @__PURE__ */ (0,
|
5183
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
5184
|
-
/* @__PURE__ */ (0,
|
5539
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
5540
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
5541
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5185
5542
|
"button",
|
5186
5543
|
{
|
5187
5544
|
type: "button",
|
@@ -5190,12 +5547,12 @@ var SidebarSection = ({
|
|
5190
5547
|
children: breadcrumb.label
|
5191
5548
|
}
|
5192
5549
|
),
|
5193
|
-
/* @__PURE__ */ (0,
|
5550
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
|
5194
5551
|
] }, i)) : null,
|
5195
|
-
/* @__PURE__ */ (0,
|
5552
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
5196
5553
|
] }) }),
|
5197
|
-
/* @__PURE__ */ (0,
|
5198
|
-
isLoading && /* @__PURE__ */ (0,
|
5554
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
|
5555
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
|
5199
5556
|
]
|
5200
5557
|
}
|
5201
5558
|
);
|
@@ -5226,7 +5583,7 @@ init_react_import();
|
|
5226
5583
|
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" };
|
5227
5584
|
|
5228
5585
|
// components/MenuBar/index.tsx
|
5229
|
-
var
|
5586
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
5230
5587
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5231
5588
|
function MenuBar({
|
5232
5589
|
appState,
|
@@ -5240,7 +5597,7 @@ function MenuBar({
|
|
5240
5597
|
history: { back, forward, historyStore }
|
5241
5598
|
} = useAppContext();
|
5242
5599
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5243
|
-
return /* @__PURE__ */ (0,
|
5600
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
5244
5601
|
"div",
|
5245
5602
|
{
|
5246
5603
|
className: getClassName20({ menuOpen }),
|
@@ -5254,12 +5611,12 @@ function MenuBar({
|
|
5254
5611
|
setMenuOpen(false);
|
5255
5612
|
}
|
5256
5613
|
},
|
5257
|
-
children: /* @__PURE__ */ (0,
|
5258
|
-
/* @__PURE__ */ (0,
|
5259
|
-
/* @__PURE__ */ (0,
|
5260
|
-
/* @__PURE__ */ (0,
|
5614
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
|
5615
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
|
5616
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
|
5617
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
|
5261
5618
|
] }),
|
5262
|
-
/* @__PURE__ */ (0,
|
5619
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
5263
5620
|
state: appState,
|
5264
5621
|
dispatch
|
5265
5622
|
}) })
|
@@ -5270,43 +5627,68 @@ function MenuBar({
|
|
5270
5627
|
|
5271
5628
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5272
5629
|
init_react_import();
|
5273
|
-
var styles_module_default15 = { "Puck": "
|
5630
|
+
var styles_module_default15 = { "Puck": "_Puck_12s9r_19", "Puck-portal": "_Puck-portal_12s9r_24", "PuckLayout-inner": "_PuckLayout-inner_12s9r_31", "PuckLayout--mounted": "_PuckLayout--mounted_12s9r_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_12s9r_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_12s9r_53", "PuckLayout-mounted": "_PuckLayout-mounted_12s9r_67", "PuckLayout": "_PuckLayout_12s9r_31", "PuckLayout-header": "_PuckLayout-header_12s9r_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_12s9r_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_12s9r_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_12s9r_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_12s9r_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_12s9r_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_12s9r_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_12s9r_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_12s9r_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_12s9r_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_12s9r_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_12s9r_134" };
|
5274
5631
|
|
5275
5632
|
// components/Puck/components/Fields/index.tsx
|
5276
5633
|
init_react_import();
|
5277
5634
|
|
5278
5635
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5279
5636
|
init_react_import();
|
5280
|
-
var styles_module_default16 = { "PuckFields": "
|
5637
|
+
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
5281
5638
|
|
5282
5639
|
// components/Puck/components/Fields/index.tsx
|
5283
|
-
var
|
5640
|
+
var import_react37 = require("react");
|
5641
|
+
|
5642
|
+
// lib/use-resolved-fields.ts
|
5643
|
+
init_react_import();
|
5644
|
+
var import_react36 = require("react");
|
5284
5645
|
|
5285
5646
|
// lib/use-parent.ts
|
5286
5647
|
init_react_import();
|
5287
|
-
var
|
5288
|
-
var
|
5648
|
+
var import_react34 = require("react");
|
5649
|
+
var getParent = (itemSelector, pathData, data) => {
|
5289
5650
|
var _a;
|
5290
|
-
|
5291
|
-
const
|
5292
|
-
const
|
5293
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5651
|
+
if (!itemSelector) return null;
|
5652
|
+
const item = getItem(itemSelector, data);
|
5653
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5294
5654
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5295
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5655
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5296
5656
|
return parent || null;
|
5297
5657
|
};
|
5658
|
+
var useGetParent = () => {
|
5659
|
+
const { state } = useAppContext();
|
5660
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5661
|
+
return (0, import_react34.useCallback)(
|
5662
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5663
|
+
[state.ui.itemSelector, pathData, state.data]
|
5664
|
+
);
|
5665
|
+
};
|
5666
|
+
var useParent = () => {
|
5667
|
+
return useGetParent()();
|
5668
|
+
};
|
5298
5669
|
|
5299
|
-
//
|
5300
|
-
|
5301
|
-
var
|
5670
|
+
// lib/use-on-value-change.ts
|
5671
|
+
init_react_import();
|
5672
|
+
var import_react35 = require("react");
|
5673
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5674
|
+
const tracked = (0, import_react35.useRef)(value);
|
5675
|
+
(0, import_react35.useEffect)(() => {
|
5676
|
+
const oldValue = tracked.current;
|
5677
|
+
if (!compare(value, oldValue)) {
|
5678
|
+
tracked.current = value;
|
5679
|
+
onChange(value, oldValue);
|
5680
|
+
}
|
5681
|
+
}, [onChange, compare, value, ...deps]);
|
5682
|
+
}
|
5683
|
+
|
5684
|
+
// lib/selector-is.ts
|
5685
|
+
init_react_import();
|
5686
|
+
var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
|
5687
|
+
|
5688
|
+
// lib/use-resolved-fields.ts
|
5302
5689
|
var defaultPageFields = {
|
5303
5690
|
title: { type: "text" }
|
5304
5691
|
};
|
5305
|
-
var DefaultFields = ({
|
5306
|
-
children
|
5307
|
-
}) => {
|
5308
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
|
5309
|
-
};
|
5310
5692
|
var useResolvedFields = () => {
|
5311
5693
|
var _a, _b;
|
5312
5694
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5314,20 +5696,21 @@ var useResolvedFields = () => {
|
|
5314
5696
|
const { data } = state;
|
5315
5697
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5316
5698
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5317
|
-
const defaultFields = (0,
|
5699
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5318
5700
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5319
5701
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5320
5702
|
);
|
5321
5703
|
const rootProps = data.root.props || data.root;
|
5322
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5323
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5324
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5704
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5705
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
|
5706
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5707
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5325
5708
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5326
5709
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5327
5710
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5328
5711
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5329
5712
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5330
|
-
const resolveFields = (0,
|
5713
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5331
5714
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5332
5715
|
var _a2;
|
5333
5716
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5339,7 +5722,7 @@ var useResolvedFields = () => {
|
|
5339
5722
|
{
|
5340
5723
|
changed,
|
5341
5724
|
fields,
|
5342
|
-
lastFields:
|
5725
|
+
lastFields: lastFields.current,
|
5343
5726
|
lastData,
|
5344
5727
|
appState: state,
|
5345
5728
|
parent
|
@@ -5350,7 +5733,7 @@ var useResolvedFields = () => {
|
|
5350
5733
|
return yield config.root.resolveFields(componentData, {
|
5351
5734
|
changed,
|
5352
5735
|
fields,
|
5353
|
-
lastFields:
|
5736
|
+
lastFields: lastFields.current,
|
5354
5737
|
lastData,
|
5355
5738
|
appState: state,
|
5356
5739
|
parent
|
@@ -5359,26 +5742,56 @@ var useResolvedFields = () => {
|
|
5359
5742
|
return defaultResolveFields(componentData, {
|
5360
5743
|
changed,
|
5361
5744
|
fields,
|
5362
|
-
lastFields:
|
5745
|
+
lastFields: lastFields.current,
|
5363
5746
|
lastData
|
5364
5747
|
});
|
5365
5748
|
}),
|
5366
|
-
[data, config, componentData, selectedItem,
|
5749
|
+
[data, config, componentData, selectedItem, state, parent]
|
5367
5750
|
);
|
5368
|
-
(0,
|
5369
|
-
|
5370
|
-
|
5371
|
-
|
5372
|
-
|
5373
|
-
|
5374
|
-
|
5375
|
-
|
5376
|
-
|
5751
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5752
|
+
var _a2, _b2;
|
5753
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5754
|
+
if (hasResolver) {
|
5755
|
+
setFieldsLoading(true);
|
5756
|
+
resolveFields(defaultFields).then((fields) => {
|
5757
|
+
setResolvedFields(fields || {});
|
5758
|
+
lastFields.current = fields;
|
5759
|
+
setFieldsLoading(false);
|
5760
|
+
});
|
5761
|
+
return;
|
5762
|
+
}
|
5377
5763
|
}
|
5378
|
-
|
5764
|
+
setResolvedFields(defaultFields);
|
5765
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5766
|
+
useOnValueChange(
|
5767
|
+
state.ui.itemSelector,
|
5768
|
+
() => {
|
5769
|
+
lastFields.current = defaultFields;
|
5770
|
+
},
|
5771
|
+
selectorIs
|
5772
|
+
);
|
5773
|
+
useOnValueChange(
|
5774
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5775
|
+
() => {
|
5776
|
+
triggerResolver();
|
5777
|
+
},
|
5778
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5779
|
+
);
|
5780
|
+
(0, import_react36.useEffect)(() => {
|
5781
|
+
triggerResolver();
|
5782
|
+
}, []);
|
5379
5783
|
return [resolvedFields, fieldsLoading];
|
5380
5784
|
};
|
5381
|
-
|
5785
|
+
|
5786
|
+
// components/Puck/components/Fields/index.tsx
|
5787
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
5788
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5789
|
+
var DefaultFields = ({
|
5790
|
+
children
|
5791
|
+
}) => {
|
5792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5793
|
+
};
|
5794
|
+
var Fields = ({ wrapFields = true }) => {
|
5382
5795
|
var _a, _b;
|
5383
5796
|
const {
|
5384
5797
|
selectedItem,
|
@@ -5396,16 +5809,16 @@ var Fields = () => {
|
|
5396
5809
|
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;
|
5397
5810
|
const isLoading = fieldsResolving || componentResolving;
|
5398
5811
|
const rootProps = data.root.props || data.root;
|
5399
|
-
const Wrapper = (0,
|
5400
|
-
return /* @__PURE__ */ (0,
|
5812
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5401
5814
|
"form",
|
5402
5815
|
{
|
5403
|
-
className: getClassName21(),
|
5816
|
+
className: getClassName21({ wrapFields }),
|
5404
5817
|
onSubmit: (e) => {
|
5405
5818
|
e.preventDefault();
|
5406
5819
|
},
|
5407
5820
|
children: [
|
5408
|
-
/* @__PURE__ */ (0,
|
5821
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5409
5822
|
const field = fields[fieldName];
|
5410
5823
|
if (!(field == null ? void 0 : field.type)) return null;
|
5411
5824
|
const onChange = (value, updatedUi) => {
|
@@ -5476,7 +5889,7 @@ var Fields = () => {
|
|
5476
5889
|
item: selectedItem
|
5477
5890
|
});
|
5478
5891
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5479
|
-
return /* @__PURE__ */ (0,
|
5892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5480
5893
|
AutoFieldPrivate,
|
5481
5894
|
{
|
5482
5895
|
field,
|
@@ -5485,16 +5898,15 @@ var Fields = () => {
|
|
5485
5898
|
readOnly: !edit || readOnly[fieldName],
|
5486
5899
|
value: selectedItem.props[fieldName],
|
5487
5900
|
onChange
|
5488
|
-
}
|
5489
|
-
|
5490
|
-
);
|
5901
|
+
}
|
5902
|
+
) }, id);
|
5491
5903
|
} else {
|
5492
5904
|
const readOnly = data.root.readOnly || {};
|
5493
5905
|
const { edit } = getPermissions({
|
5494
5906
|
root: true
|
5495
5907
|
});
|
5496
5908
|
const id = `root_${field.type}_${fieldName}`;
|
5497
|
-
return /* @__PURE__ */ (0,
|
5909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5498
5910
|
AutoFieldPrivate,
|
5499
5911
|
{
|
5500
5912
|
field,
|
@@ -5503,12 +5915,11 @@ var Fields = () => {
|
|
5503
5915
|
readOnly: !edit || readOnly[fieldName],
|
5504
5916
|
value: rootProps[fieldName],
|
5505
5917
|
onChange
|
5506
|
-
}
|
5507
|
-
|
5508
|
-
);
|
5918
|
+
}
|
5919
|
+
) }, id);
|
5509
5920
|
}
|
5510
5921
|
}) }),
|
5511
|
-
isLoading && /* @__PURE__ */ (0,
|
5922
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Loader, { size: 16 }) }) })
|
5512
5923
|
]
|
5513
5924
|
}
|
5514
5925
|
);
|
@@ -5519,7 +5930,7 @@ init_react_import();
|
|
5519
5930
|
|
5520
5931
|
// lib/use-component-list.tsx
|
5521
5932
|
init_react_import();
|
5522
|
-
var
|
5933
|
+
var import_react38 = require("react");
|
5523
5934
|
|
5524
5935
|
// components/ComponentList/index.tsx
|
5525
5936
|
init_react_import();
|
@@ -5529,7 +5940,7 @@ init_react_import();
|
|
5529
5940
|
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" };
|
5530
5941
|
|
5531
5942
|
// components/ComponentList/index.tsx
|
5532
|
-
var
|
5943
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
5533
5944
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5534
5945
|
var ComponentListItem = ({
|
5535
5946
|
name,
|
@@ -5539,7 +5950,7 @@ var ComponentListItem = ({
|
|
5539
5950
|
const canInsert = getPermissions({
|
5540
5951
|
type: name
|
5541
5952
|
}).insert;
|
5542
|
-
return /* @__PURE__ */ (0,
|
5953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5543
5954
|
};
|
5544
5955
|
var ComponentList = ({
|
5545
5956
|
children,
|
@@ -5548,8 +5959,8 @@ var ComponentList = ({
|
|
5548
5959
|
}) => {
|
5549
5960
|
const { config, state, setUi } = useAppContext();
|
5550
5961
|
const { expanded = true } = state.ui.componentList[id] || {};
|
5551
|
-
return /* @__PURE__ */ (0,
|
5552
|
-
title && /* @__PURE__ */ (0,
|
5962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
5963
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
5553
5964
|
"button",
|
5554
5965
|
{
|
5555
5966
|
type: "button",
|
@@ -5563,14 +5974,14 @@ var ComponentList = ({
|
|
5563
5974
|
}),
|
5564
5975
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5565
5976
|
children: [
|
5566
|
-
/* @__PURE__ */ (0,
|
5567
|
-
/* @__PURE__ */ (0,
|
5977
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
|
5978
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronDown, { size: 12 }) })
|
5568
5979
|
]
|
5569
5980
|
}
|
5570
5981
|
),
|
5571
|
-
/* @__PURE__ */ (0,
|
5982
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
5572
5983
|
var _a;
|
5573
|
-
return /* @__PURE__ */ (0,
|
5984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
5574
5985
|
ComponentListItem,
|
5575
5986
|
{
|
5576
5987
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5584,10 +5995,10 @@ var ComponentList = ({
|
|
5584
5995
|
ComponentList.Item = ComponentListItem;
|
5585
5996
|
|
5586
5997
|
// lib/use-component-list.tsx
|
5587
|
-
var
|
5998
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5588
5999
|
var useComponentList = (config, ui) => {
|
5589
|
-
const [componentList, setComponentList] = (0,
|
5590
|
-
(0,
|
6000
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
6001
|
+
(0, import_react38.useEffect)(() => {
|
5591
6002
|
var _a, _b, _c;
|
5592
6003
|
if (Object.keys(ui.componentList).length > 0) {
|
5593
6004
|
const matchedComponents = [];
|
@@ -5597,7 +6008,7 @@ var useComponentList = (config, ui) => {
|
|
5597
6008
|
if (category.visible === false || !category.components) {
|
5598
6009
|
return null;
|
5599
6010
|
}
|
5600
|
-
return /* @__PURE__ */ (0,
|
6011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5601
6012
|
ComponentList,
|
5602
6013
|
{
|
5603
6014
|
id: categoryKey,
|
@@ -5606,7 +6017,7 @@ var useComponentList = (config, ui) => {
|
|
5606
6017
|
var _a2;
|
5607
6018
|
matchedComponents.push(componentName);
|
5608
6019
|
const componentConf = config.components[componentName] || {};
|
5609
|
-
return /* @__PURE__ */ (0,
|
6020
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5610
6021
|
ComponentList.Item,
|
5611
6022
|
{
|
5612
6023
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5626,7 +6037,7 @@ var useComponentList = (config, ui) => {
|
|
5626
6037
|
);
|
5627
6038
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5628
6039
|
_componentList.push(
|
5629
|
-
/* @__PURE__ */ (0,
|
6040
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5630
6041
|
ComponentList,
|
5631
6042
|
{
|
5632
6043
|
id: "other",
|
@@ -5634,7 +6045,7 @@ var useComponentList = (config, ui) => {
|
|
5634
6045
|
children: remainingComponents.map((componentName, i) => {
|
5635
6046
|
var _a2;
|
5636
6047
|
const componentConf = config.components[componentName] || {};
|
5637
|
-
return /* @__PURE__ */ (0,
|
6048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5638
6049
|
ComponentList.Item,
|
5639
6050
|
{
|
5640
6051
|
name: componentName,
|
@@ -5656,25 +6067,25 @@ var useComponentList = (config, ui) => {
|
|
5656
6067
|
};
|
5657
6068
|
|
5658
6069
|
// components/Puck/components/Components/index.tsx
|
5659
|
-
var
|
5660
|
-
var
|
6070
|
+
var import_react39 = require("react");
|
6071
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5661
6072
|
var Components = () => {
|
5662
6073
|
const { config, state, overrides } = useAppContext();
|
5663
6074
|
const componentList = useComponentList(config, state.ui);
|
5664
|
-
const Wrapper = (0,
|
5665
|
-
return /* @__PURE__ */ (0,
|
6075
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
5666
6077
|
};
|
5667
6078
|
|
5668
6079
|
// components/Puck/components/Preview/index.tsx
|
5669
6080
|
init_react_import();
|
5670
|
-
var
|
6081
|
+
var import_react41 = require("react");
|
5671
6082
|
|
5672
6083
|
// components/AutoFrame/index.tsx
|
5673
6084
|
init_react_import();
|
5674
|
-
var
|
6085
|
+
var import_react40 = require("react");
|
5675
6086
|
var import_object_hash = __toESM(require("object-hash"));
|
5676
6087
|
var import_react_dom3 = require("react-dom");
|
5677
|
-
var
|
6088
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
5678
6089
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5679
6090
|
var collectStyles = (doc) => {
|
5680
6091
|
const collected = [];
|
@@ -5717,7 +6128,7 @@ var CopyHostStyles = ({
|
|
5717
6128
|
onStylesLoaded = () => null
|
5718
6129
|
}) => {
|
5719
6130
|
const { document: doc, window: win } = useFrame();
|
5720
|
-
(0,
|
6131
|
+
(0, import_react40.useEffect)(() => {
|
5721
6132
|
if (!win || !doc) {
|
5722
6133
|
return () => {
|
5723
6134
|
};
|
@@ -5874,10 +6285,10 @@ var CopyHostStyles = ({
|
|
5874
6285
|
observer.disconnect();
|
5875
6286
|
};
|
5876
6287
|
}, []);
|
5877
|
-
return /* @__PURE__ */ (0,
|
6288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
5878
6289
|
};
|
5879
|
-
var autoFrameContext = (0,
|
5880
|
-
var useFrame = () => (0,
|
6290
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6291
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
5881
6292
|
function AutoFrame(_a) {
|
5882
6293
|
var _b = _a, {
|
5883
6294
|
children,
|
@@ -5894,10 +6305,10 @@ function AutoFrame(_a) {
|
|
5894
6305
|
"onStylesLoaded",
|
5895
6306
|
"frameRef"
|
5896
6307
|
]);
|
5897
|
-
const [loaded, setLoaded] = (0,
|
5898
|
-
const [ctx, setCtx] = (0,
|
5899
|
-
const [mountTarget, setMountTarget] = (0,
|
5900
|
-
(0,
|
6308
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6309
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6310
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6311
|
+
(0, import_react40.useEffect)(() => {
|
5901
6312
|
var _a2;
|
5902
6313
|
if (frameRef.current) {
|
5903
6314
|
setCtx({
|
@@ -5909,7 +6320,7 @@ function AutoFrame(_a) {
|
|
5909
6320
|
);
|
5910
6321
|
}
|
5911
6322
|
}, [frameRef, loaded]);
|
5912
|
-
return /* @__PURE__ */ (0,
|
6323
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
5913
6324
|
"iframe",
|
5914
6325
|
__spreadProps(__spreadValues({}, props), {
|
5915
6326
|
className,
|
@@ -5919,7 +6330,7 @@ function AutoFrame(_a) {
|
|
5919
6330
|
onLoad: () => {
|
5920
6331
|
setLoaded(true);
|
5921
6332
|
},
|
5922
|
-
children: /* @__PURE__ */ (0,
|
6333
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CopyHostStyles, { debug, onStylesLoaded, children: (0, import_react_dom3.createPortal)(children, mountTarget) }) })
|
5923
6334
|
})
|
5924
6335
|
);
|
5925
6336
|
}
|
@@ -5930,12 +6341,68 @@ var AutoFrame_default = AutoFrame;
|
|
5930
6341
|
init_react_import();
|
5931
6342
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
5932
6343
|
|
6344
|
+
// components/Render/index.tsx
|
6345
|
+
init_react_import();
|
6346
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
6347
|
+
function Render({
|
6348
|
+
config,
|
6349
|
+
data
|
6350
|
+
}) {
|
6351
|
+
var _a;
|
6352
|
+
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
6353
|
+
root: data.root || {},
|
6354
|
+
content: data.content || []
|
6355
|
+
});
|
6356
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
6357
|
+
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
6358
|
+
if ((_a = config.root) == null ? void 0 : _a.render) {
|
6359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6360
|
+
DropZoneProvider,
|
6361
|
+
{
|
6362
|
+
value: {
|
6363
|
+
data: defaultedData,
|
6364
|
+
config,
|
6365
|
+
mode: "render",
|
6366
|
+
depth: 0,
|
6367
|
+
path: []
|
6368
|
+
},
|
6369
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6370
|
+
config.root.render,
|
6371
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
6372
|
+
puck: {
|
6373
|
+
renderDropZone: DropZone,
|
6374
|
+
isEditing: false
|
6375
|
+
},
|
6376
|
+
title,
|
6377
|
+
editMode: false,
|
6378
|
+
id: "puck-root",
|
6379
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6380
|
+
})
|
6381
|
+
)
|
6382
|
+
}
|
6383
|
+
);
|
6384
|
+
}
|
6385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6386
|
+
DropZoneProvider,
|
6387
|
+
{
|
6388
|
+
value: {
|
6389
|
+
data: defaultedData,
|
6390
|
+
config,
|
6391
|
+
mode: "render",
|
6392
|
+
depth: 0,
|
6393
|
+
path: []
|
6394
|
+
},
|
6395
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6396
|
+
}
|
6397
|
+
);
|
6398
|
+
}
|
6399
|
+
|
5933
6400
|
// components/Puck/components/Preview/index.tsx
|
5934
|
-
var
|
6401
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
5935
6402
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5936
6403
|
var useBubbleIframeEvents = (ref) => {
|
5937
6404
|
const { status } = useAppContext();
|
5938
|
-
(0,
|
6405
|
+
(0, import_react41.useEffect)(() => {
|
5939
6406
|
var _a;
|
5940
6407
|
if (ref.current && status === "READY") {
|
5941
6408
|
const iframe = ref.current;
|
@@ -5972,22 +6439,34 @@ var useBubbleIframeEvents = (ref) => {
|
|
5972
6439
|
}
|
5973
6440
|
}, [status]);
|
5974
6441
|
};
|
5975
|
-
var
|
6442
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
5976
6443
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
5977
|
-
const Page = (0,
|
6444
|
+
const Page = (0, import_react41.useCallback)(
|
5978
6445
|
(pageProps) => {
|
5979
6446
|
var _a, _b;
|
5980
6447
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
5981
6448
|
id: "puck-root"
|
5982
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
6449
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
5983
6450
|
},
|
5984
6451
|
[config.root]
|
5985
6452
|
);
|
5986
|
-
const Frame = (0,
|
6453
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
5987
6454
|
const rootProps = state.data.root.props || state.data.root;
|
5988
|
-
const ref = (0,
|
6455
|
+
const ref = (0, import_react41.useRef)(null);
|
5989
6456
|
useBubbleIframeEvents(ref);
|
5990
|
-
|
6457
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6458
|
+
Page,
|
6459
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
6460
|
+
puck: {
|
6461
|
+
renderDropZone: DropZone,
|
6462
|
+
isEditing: true,
|
6463
|
+
dragRef: null
|
6464
|
+
},
|
6465
|
+
editMode: true,
|
6466
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
6467
|
+
})
|
6468
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
|
6469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
5991
6470
|
"div",
|
5992
6471
|
{
|
5993
6472
|
className: getClassName23(),
|
@@ -5996,7 +6475,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5996
6475
|
onClick: () => {
|
5997
6476
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
5998
6477
|
},
|
5999
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
6478
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6000
6479
|
AutoFrame_default,
|
6001
6480
|
{
|
6002
6481
|
id: "preview-frame",
|
@@ -6006,40 +6485,21 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6006
6485
|
setStatus("READY");
|
6007
6486
|
},
|
6008
6487
|
frameRef: ref,
|
6009
|
-
children: /* @__PURE__ */ (0,
|
6010
|
-
const inner = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
6011
|
-
Page,
|
6012
|
-
__spreadProps(__spreadValues({}, rootProps), {
|
6013
|
-
puck: {
|
6014
|
-
renderDropZone: DropZone,
|
6015
|
-
isEditing: true,
|
6016
|
-
dragRef: null
|
6017
|
-
},
|
6018
|
-
editMode: true,
|
6019
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DropZone, { zone: rootDroppableId })
|
6020
|
-
})
|
6021
|
-
);
|
6488
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
6022
6489
|
if (Frame) {
|
6023
|
-
return /* @__PURE__ */ (0,
|
6490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
6024
6491
|
}
|
6025
6492
|
return inner;
|
6026
6493
|
} })
|
6027
6494
|
}
|
6028
|
-
) : /* @__PURE__ */ (0,
|
6495
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6029
6496
|
"div",
|
6030
6497
|
{
|
6031
6498
|
id: "preview-frame",
|
6032
6499
|
className: getClassName23("frame"),
|
6033
6500
|
ref,
|
6034
6501
|
"data-puck-entry": true,
|
6035
|
-
children:
|
6036
|
-
Page,
|
6037
|
-
__spreadProps(__spreadValues({}, rootProps), {
|
6038
|
-
puck: { renderDropZone: DropZone, isEditing: true, dragRef: null },
|
6039
|
-
editMode: true,
|
6040
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DropZone, { zone: rootDroppableId })
|
6041
|
-
})
|
6042
|
-
)
|
6502
|
+
children: inner
|
6043
6503
|
}
|
6044
6504
|
)
|
6045
6505
|
}
|
@@ -6089,7 +6549,7 @@ var scrollIntoView = (el) => {
|
|
6089
6549
|
};
|
6090
6550
|
|
6091
6551
|
// components/LayerTree/index.tsx
|
6092
|
-
var
|
6552
|
+
var import_react42 = require("react");
|
6093
6553
|
|
6094
6554
|
// lib/is-child-of-zone.ts
|
6095
6555
|
init_react_import();
|
@@ -6122,7 +6582,7 @@ var onScrollEnd = (frame, cb) => {
|
|
6122
6582
|
};
|
6123
6583
|
|
6124
6584
|
// components/LayerTree/index.tsx
|
6125
|
-
var
|
6585
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6126
6586
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6127
6587
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6128
6588
|
var LayerTree = ({
|
@@ -6135,15 +6595,15 @@ var LayerTree = ({
|
|
6135
6595
|
label
|
6136
6596
|
}) => {
|
6137
6597
|
const zones = data.zones || {};
|
6138
|
-
const ctx = (0,
|
6139
|
-
return /* @__PURE__ */ (0,
|
6140
|
-
label && /* @__PURE__ */ (0,
|
6141
|
-
/* @__PURE__ */ (0,
|
6598
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6600
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6601
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
6142
6602
|
" ",
|
6143
6603
|
label
|
6144
6604
|
] }),
|
6145
|
-
/* @__PURE__ */ (0,
|
6146
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
6605
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
|
6606
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
6147
6607
|
zoneContent.map((item, i) => {
|
6148
6608
|
var _a;
|
6149
6609
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6156,7 +6616,7 @@ var LayerTree = ({
|
|
6156
6616
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
6157
6617
|
const componentConfig = config.components[item.type];
|
6158
6618
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
6159
|
-
return /* @__PURE__ */ (0,
|
6619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6160
6620
|
"li",
|
6161
6621
|
{
|
6162
6622
|
className: getClassNameLayer({
|
@@ -6166,7 +6626,7 @@ var LayerTree = ({
|
|
6166
6626
|
childIsSelected
|
6167
6627
|
}),
|
6168
6628
|
children: [
|
6169
|
-
/* @__PURE__ */ (0,
|
6629
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6170
6630
|
"button",
|
6171
6631
|
{
|
6172
6632
|
type: "button",
|
@@ -6205,22 +6665,22 @@ var LayerTree = ({
|
|
6205
6665
|
setHoveringComponent(null);
|
6206
6666
|
},
|
6207
6667
|
children: [
|
6208
|
-
containsZone && /* @__PURE__ */ (0,
|
6668
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6209
6669
|
"div",
|
6210
6670
|
{
|
6211
6671
|
className: getClassNameLayer("chevron"),
|
6212
6672
|
title: isSelected ? "Collapse" : "Expand",
|
6213
|
-
children: /* @__PURE__ */ (0,
|
6673
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
6214
6674
|
}
|
6215
6675
|
),
|
6216
|
-
/* @__PURE__ */ (0,
|
6217
|
-
/* @__PURE__ */ (0,
|
6218
|
-
/* @__PURE__ */ (0,
|
6676
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
6677
|
+
/* @__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" }) }),
|
6678
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
6219
6679
|
] })
|
6220
6680
|
]
|
6221
6681
|
}
|
6222
6682
|
) }),
|
6223
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
6683
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6224
6684
|
LayerTree,
|
6225
6685
|
{
|
6226
6686
|
config,
|
@@ -6242,13 +6702,13 @@ var LayerTree = ({
|
|
6242
6702
|
};
|
6243
6703
|
|
6244
6704
|
// components/Puck/components/Outline/index.tsx
|
6245
|
-
var
|
6246
|
-
var
|
6705
|
+
var import_react43 = require("react");
|
6706
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6247
6707
|
var Outline = () => {
|
6248
6708
|
const { dispatch, state, overrides, config } = useAppContext();
|
6249
6709
|
const { data, ui } = state;
|
6250
6710
|
const { itemSelector } = ui;
|
6251
|
-
const setItemSelector = (0,
|
6711
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6252
6712
|
(newItemSelector) => {
|
6253
6713
|
dispatch({
|
6254
6714
|
type: "setUi",
|
@@ -6257,9 +6717,9 @@ var Outline = () => {
|
|
6257
6717
|
},
|
6258
6718
|
[]
|
6259
6719
|
);
|
6260
|
-
const Wrapper = (0,
|
6261
|
-
return /* @__PURE__ */ (0,
|
6262
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
6720
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6721
|
+
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: [
|
6722
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6263
6723
|
LayerTree,
|
6264
6724
|
{
|
6265
6725
|
config,
|
@@ -6272,7 +6732,7 @@ var Outline = () => {
|
|
6272
6732
|
),
|
6273
6733
|
Object.entries(findZonesForArea(data, "root")).map(
|
6274
6734
|
([zoneKey, zone]) => {
|
6275
|
-
return /* @__PURE__ */ (0,
|
6735
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6276
6736
|
LayerTree,
|
6277
6737
|
{
|
6278
6738
|
config,
|
@@ -6371,19 +6831,19 @@ function usePuckHistory({
|
|
6371
6831
|
|
6372
6832
|
// lib/use-history-store.ts
|
6373
6833
|
init_react_import();
|
6374
|
-
var
|
6834
|
+
var import_react44 = require("react");
|
6375
6835
|
var import_use_debounce3 = require("use-debounce");
|
6376
6836
|
var EMPTY_HISTORY_INDEX = 0;
|
6377
6837
|
function useHistoryStore(initialHistory) {
|
6378
6838
|
var _a, _b;
|
6379
|
-
const [histories, setHistories] = (0,
|
6839
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6380
6840
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6381
6841
|
);
|
6382
6842
|
const updateHistories = (histories2) => {
|
6383
6843
|
setHistories(histories2);
|
6384
6844
|
setIndex(histories2.length - 1);
|
6385
6845
|
};
|
6386
|
-
const [index, setIndex] = (0,
|
6846
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6387
6847
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6388
6848
|
);
|
6389
6849
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6543,22 +7003,22 @@ var getBox = function getBox2(el) {
|
|
6543
7003
|
};
|
6544
7004
|
|
6545
7005
|
// components/Puck/components/Canvas/index.tsx
|
6546
|
-
var
|
7006
|
+
var import_react46 = require("react");
|
6547
7007
|
|
6548
7008
|
// components/ViewportControls/index.tsx
|
6549
7009
|
init_react_import();
|
6550
|
-
var
|
7010
|
+
var import_react45 = require("react");
|
6551
7011
|
|
6552
7012
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6553
7013
|
init_react_import();
|
6554
7014
|
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" };
|
6555
7015
|
|
6556
7016
|
// components/ViewportControls/index.tsx
|
6557
|
-
var
|
7017
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
6558
7018
|
var icons = {
|
6559
|
-
Smartphone: /* @__PURE__ */ (0,
|
6560
|
-
Tablet: /* @__PURE__ */ (0,
|
6561
|
-
Monitor: /* @__PURE__ */ (0,
|
7019
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
|
7020
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
|
7021
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
|
6562
7022
|
};
|
6563
7023
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6564
7024
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6570,11 +7030,11 @@ var ViewportButton = ({
|
|
6570
7030
|
onClick
|
6571
7031
|
}) => {
|
6572
7032
|
const { state } = useAppContext();
|
6573
|
-
const [isActive, setIsActive] = (0,
|
6574
|
-
(0,
|
7033
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7034
|
+
(0, import_react45.useEffect)(() => {
|
6575
7035
|
setIsActive(width === state.ui.viewports.current.width);
|
6576
7036
|
}, [width, state.ui.viewports.current.width]);
|
6577
|
-
return /* @__PURE__ */ (0,
|
7037
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6578
7038
|
IconButton,
|
6579
7039
|
{
|
6580
7040
|
title,
|
@@ -6583,7 +7043,7 @@ var ViewportButton = ({
|
|
6583
7043
|
e.stopPropagation();
|
6584
7044
|
onClick({ width, height });
|
6585
7045
|
},
|
6586
|
-
children: /* @__PURE__ */ (0,
|
7046
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
|
6587
7047
|
}
|
6588
7048
|
) });
|
6589
7049
|
};
|
@@ -6607,7 +7067,7 @@ var ViewportControls = ({
|
|
6607
7067
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6608
7068
|
(option) => option.value === autoZoom
|
6609
7069
|
);
|
6610
|
-
const zoomOptions = (0,
|
7070
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
6611
7071
|
() => [
|
6612
7072
|
...defaultZoomOptions,
|
6613
7073
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6619,8 +7079,8 @@ var ViewportControls = ({
|
|
6619
7079
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
6620
7080
|
[autoZoom]
|
6621
7081
|
);
|
6622
|
-
return /* @__PURE__ */ (0,
|
6623
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
7082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
|
7083
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6624
7084
|
ViewportButton,
|
6625
7085
|
{
|
6626
7086
|
height: viewport.height,
|
@@ -6631,8 +7091,8 @@ var ViewportControls = ({
|
|
6631
7091
|
},
|
6632
7092
|
i
|
6633
7093
|
)),
|
6634
|
-
/* @__PURE__ */ (0,
|
6635
|
-
/* @__PURE__ */ (0,
|
7094
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7095
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6636
7096
|
IconButton,
|
6637
7097
|
{
|
6638
7098
|
title: "Zoom viewport out",
|
@@ -6646,10 +7106,10 @@ var ViewportControls = ({
|
|
6646
7106
|
)].value
|
6647
7107
|
);
|
6648
7108
|
},
|
6649
|
-
children: /* @__PURE__ */ (0,
|
7109
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
|
6650
7110
|
}
|
6651
7111
|
),
|
6652
|
-
/* @__PURE__ */ (0,
|
7112
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6653
7113
|
IconButton,
|
6654
7114
|
{
|
6655
7115
|
title: "Zoom viewport in",
|
@@ -6663,11 +7123,11 @@ var ViewportControls = ({
|
|
6663
7123
|
)].value
|
6664
7124
|
);
|
6665
7125
|
},
|
6666
|
-
children: /* @__PURE__ */ (0,
|
7126
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
|
6667
7127
|
}
|
6668
7128
|
),
|
6669
|
-
/* @__PURE__ */ (0,
|
6670
|
-
/* @__PURE__ */ (0,
|
7129
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7130
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6671
7131
|
"select",
|
6672
7132
|
{
|
6673
7133
|
className: getClassName25("zoomSelect"),
|
@@ -6675,7 +7135,7 @@ var ViewportControls = ({
|
|
6675
7135
|
onChange: (e) => {
|
6676
7136
|
onZoom(parseFloat(e.currentTarget.value));
|
6677
7137
|
},
|
6678
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
7138
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6679
7139
|
"option",
|
6680
7140
|
{
|
6681
7141
|
value: option.value,
|
@@ -6723,24 +7183,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6723
7183
|
};
|
6724
7184
|
|
6725
7185
|
// components/Puck/components/Canvas/index.tsx
|
6726
|
-
var
|
7186
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
6727
7187
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6728
7188
|
var ZOOM_ON_CHANGE = true;
|
6729
7189
|
var Canvas = () => {
|
6730
7190
|
const { status, iframe } = useAppContext();
|
6731
7191
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6732
7192
|
const { ui } = state;
|
6733
|
-
const frameRef = (0,
|
6734
|
-
const [showTransition, setShowTransition] = (0,
|
6735
|
-
const defaultRender = (0,
|
6736
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
7193
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7194
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7195
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7196
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
6737
7197
|
return PuckDefault;
|
6738
7198
|
}, []);
|
6739
|
-
const CustomPreview = (0,
|
7199
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
6740
7200
|
() => overrides.preview || defaultRender,
|
6741
7201
|
[overrides]
|
6742
7202
|
);
|
6743
|
-
const getFrameDimensions = (0,
|
7203
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
6744
7204
|
if (frameRef.current) {
|
6745
7205
|
const frame = frameRef.current;
|
6746
7206
|
const box = getBox(frame);
|
@@ -6748,7 +7208,7 @@ var Canvas = () => {
|
|
6748
7208
|
}
|
6749
7209
|
return { width: 0, height: 0 };
|
6750
7210
|
}, [frameRef]);
|
6751
|
-
const resetAutoZoom = (0,
|
7211
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
6752
7212
|
(ui2 = state.ui) => {
|
6753
7213
|
if (frameRef.current) {
|
6754
7214
|
setZoomConfig(
|
@@ -6758,11 +7218,11 @@ var Canvas = () => {
|
|
6758
7218
|
},
|
6759
7219
|
[frameRef, zoomConfig, state.ui]
|
6760
7220
|
);
|
6761
|
-
(0,
|
7221
|
+
(0, import_react46.useEffect)(() => {
|
6762
7222
|
setShowTransition(false);
|
6763
7223
|
resetAutoZoom();
|
6764
7224
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6765
|
-
(0,
|
7225
|
+
(0, import_react46.useEffect)(() => {
|
6766
7226
|
const { height: frameHeight } = getFrameDimensions();
|
6767
7227
|
if (ui.viewports.current.height === "auto") {
|
6768
7228
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6770,13 +7230,13 @@ var Canvas = () => {
|
|
6770
7230
|
}));
|
6771
7231
|
}
|
6772
7232
|
}, [zoomConfig.zoom]);
|
6773
|
-
(0,
|
7233
|
+
(0, import_react46.useEffect)(() => {
|
6774
7234
|
if (ZOOM_ON_CHANGE) {
|
6775
7235
|
setShowTransition(true);
|
6776
7236
|
resetAutoZoom(ui);
|
6777
7237
|
}
|
6778
7238
|
}, [ui.viewports.current.width]);
|
6779
|
-
(0,
|
7239
|
+
(0, import_react46.useEffect)(() => {
|
6780
7240
|
const cb = () => {
|
6781
7241
|
setShowTransition(false);
|
6782
7242
|
resetAutoZoom();
|
@@ -6786,13 +7246,13 @@ var Canvas = () => {
|
|
6786
7246
|
window.removeEventListener("resize", cb);
|
6787
7247
|
};
|
6788
7248
|
}, []);
|
6789
|
-
const [showLoader, setShowLoader] = (0,
|
6790
|
-
(0,
|
7249
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7250
|
+
(0, import_react46.useEffect)(() => {
|
6791
7251
|
setTimeout(() => {
|
6792
7252
|
setShowLoader(true);
|
6793
7253
|
}, 500);
|
6794
7254
|
}, []);
|
6795
|
-
return /* @__PURE__ */ (0,
|
7255
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
6796
7256
|
"div",
|
6797
7257
|
{
|
6798
7258
|
className: getClassName26({
|
@@ -6805,7 +7265,7 @@ var Canvas = () => {
|
|
6805
7265
|
recordHistory: true
|
6806
7266
|
}),
|
6807
7267
|
children: [
|
6808
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
7268
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
6809
7269
|
ViewportControls,
|
6810
7270
|
{
|
6811
7271
|
autoZoom: zoomConfig.autoZoom,
|
@@ -6831,8 +7291,8 @@ var Canvas = () => {
|
|
6831
7291
|
}
|
6832
7292
|
}
|
6833
7293
|
) }),
|
6834
|
-
/* @__PURE__ */ (0,
|
6835
|
-
/* @__PURE__ */ (0,
|
7294
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7295
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
6836
7296
|
"div",
|
6837
7297
|
{
|
6838
7298
|
className: getClassName26("root"),
|
@@ -6853,10 +7313,10 @@ var Canvas = () => {
|
|
6853
7313
|
})
|
6854
7314
|
);
|
6855
7315
|
},
|
6856
|
-
children: /* @__PURE__ */ (0,
|
7316
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview2, {}) })
|
6857
7317
|
}
|
6858
7318
|
),
|
6859
|
-
/* @__PURE__ */ (0,
|
7319
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
6860
7320
|
] })
|
6861
7321
|
]
|
6862
7322
|
}
|
@@ -6865,7 +7325,7 @@ var Canvas = () => {
|
|
6865
7325
|
|
6866
7326
|
// lib/use-loaded-overrides.ts
|
6867
7327
|
init_react_import();
|
6868
|
-
var
|
7328
|
+
var import_react47 = require("react");
|
6869
7329
|
|
6870
7330
|
// lib/load-overrides.ts
|
6871
7331
|
init_react_import();
|
@@ -6904,26 +7364,26 @@ var useLoadedOverrides = ({
|
|
6904
7364
|
overrides,
|
6905
7365
|
plugins
|
6906
7366
|
}) => {
|
6907
|
-
return (0,
|
7367
|
+
return (0, import_react47.useMemo)(() => {
|
6908
7368
|
return loadOverrides({ overrides, plugins });
|
6909
7369
|
}, [plugins, overrides]);
|
6910
7370
|
};
|
6911
7371
|
|
6912
7372
|
// components/DefaultOverride/index.tsx
|
6913
7373
|
init_react_import();
|
6914
|
-
var
|
6915
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
7374
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7375
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
6916
7376
|
|
6917
7377
|
// lib/use-inject-css.ts
|
6918
7378
|
init_react_import();
|
6919
|
-
var
|
7379
|
+
var import_react48 = require("react");
|
6920
7380
|
var styles = ``;
|
6921
7381
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6922
|
-
const [el, setEl] = (0,
|
6923
|
-
(0,
|
7382
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7383
|
+
(0, import_react48.useEffect)(() => {
|
6924
7384
|
setEl(document.createElement("style"));
|
6925
7385
|
}, []);
|
6926
|
-
(0,
|
7386
|
+
(0, import_react48.useEffect)(() => {
|
6927
7387
|
var _a;
|
6928
7388
|
if (!el || typeof window === "undefined") {
|
6929
7389
|
return;
|
@@ -6941,8 +7401,35 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
6941
7401
|
return useInjectStyleSheet(styles, iframeEnabled);
|
6942
7402
|
};
|
6943
7403
|
|
7404
|
+
// lib/use-preview-mode-hotkeys.ts
|
7405
|
+
init_react_import();
|
7406
|
+
var import_react49 = require("react");
|
7407
|
+
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7408
|
+
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7409
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7410
|
+
dispatch({
|
7411
|
+
type: "setUi",
|
7412
|
+
ui: (ui) => ({
|
7413
|
+
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
7414
|
+
})
|
7415
|
+
});
|
7416
|
+
}, [dispatch]);
|
7417
|
+
const toggleInteractiveIframe = () => {
|
7418
|
+
if (iframeEnabled) {
|
7419
|
+
toggleInteractive();
|
7420
|
+
}
|
7421
|
+
};
|
7422
|
+
const frame = getFrame();
|
7423
|
+
const resolvedFrame = typeof window !== "undefined" && frame !== document ? frame : void 0;
|
7424
|
+
(0, import_react_hotkeys_hook2.useHotkeys)("meta+i", toggleInteractive, { preventDefault: true });
|
7425
|
+
(0, import_react_hotkeys_hook2.useHotkeys)("meta+i", toggleInteractiveIframe, {
|
7426
|
+
preventDefault: true,
|
7427
|
+
document: resolvedFrame
|
7428
|
+
});
|
7429
|
+
};
|
7430
|
+
|
6944
7431
|
// components/Puck/index.tsx
|
6945
|
-
var
|
7432
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
6946
7433
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
6947
7434
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
6948
7435
|
function Puck({
|
@@ -6971,7 +7458,7 @@ function Puck({
|
|
6971
7458
|
waitForStyles: true
|
6972
7459
|
}, _iframe);
|
6973
7460
|
useInjectGlobalCss(iframe.enabled);
|
6974
|
-
const [generatedAppState] = (0,
|
7461
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
6975
7462
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
6976
7463
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
6977
7464
|
let clientUiState = {};
|
@@ -7043,14 +7530,14 @@ function Puck({
|
|
7043
7530
|
histories,
|
7044
7531
|
index: initialHistoryIndex
|
7045
7532
|
});
|
7046
|
-
const [reducer] = (0,
|
7533
|
+
const [reducer] = (0, import_react50.useState)(
|
7047
7534
|
() => createReducer({
|
7048
7535
|
config,
|
7049
7536
|
record: historyStore.record,
|
7050
7537
|
onAction
|
7051
7538
|
})
|
7052
7539
|
);
|
7053
|
-
const [appState, dispatch] = (0,
|
7540
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7054
7541
|
reducer,
|
7055
7542
|
flushZones(initialAppState)
|
7056
7543
|
);
|
@@ -7061,14 +7548,14 @@ function Puck({
|
|
7061
7548
|
historyStore,
|
7062
7549
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7063
7550
|
});
|
7064
|
-
const [menuOpen, setMenuOpen] = (0,
|
7551
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7065
7552
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7066
7553
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7067
|
-
(0,
|
7554
|
+
(0, import_react50.useEffect)(() => {
|
7068
7555
|
if (onChange) onChange(data);
|
7069
7556
|
}, [data]);
|
7070
7557
|
const rootProps = data.root.props || data.root;
|
7071
|
-
const toggleSidebars = (0,
|
7558
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7072
7559
|
(sidebar) => {
|
7073
7560
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7074
7561
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7082,7 +7569,7 @@ function Puck({
|
|
7082
7569
|
},
|
7083
7570
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7084
7571
|
);
|
7085
|
-
(0,
|
7572
|
+
(0, import_react50.useEffect)(() => {
|
7086
7573
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7087
7574
|
dispatch({
|
7088
7575
|
type: "setUi",
|
@@ -7105,7 +7592,7 @@ function Puck({
|
|
7105
7592
|
window.removeEventListener("resize", handleResize);
|
7106
7593
|
};
|
7107
7594
|
}, []);
|
7108
|
-
const defaultHeaderRender = (0,
|
7595
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7109
7596
|
if (renderHeader) {
|
7110
7597
|
console.warn(
|
7111
7598
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7113,20 +7600,20 @@ function Puck({
|
|
7113
7600
|
const RenderHeader = (_a2) => {
|
7114
7601
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
7115
7602
|
const Comp = renderHeader;
|
7116
|
-
return /* @__PURE__ */ (0,
|
7603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7117
7604
|
};
|
7118
7605
|
return RenderHeader;
|
7119
7606
|
}
|
7120
7607
|
return DefaultOverride;
|
7121
7608
|
}, [renderHeader]);
|
7122
|
-
const defaultHeaderActionsRender = (0,
|
7609
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7123
7610
|
if (renderHeaderActions) {
|
7124
7611
|
console.warn(
|
7125
7612
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7126
7613
|
);
|
7127
7614
|
const RenderHeader = (props) => {
|
7128
7615
|
const Comp = renderHeaderActions;
|
7129
|
-
return /* @__PURE__ */ (0,
|
7616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7130
7617
|
};
|
7131
7618
|
return RenderHeader;
|
7132
7619
|
}
|
@@ -7136,26 +7623,27 @@ function Puck({
|
|
7136
7623
|
overrides,
|
7137
7624
|
plugins
|
7138
7625
|
});
|
7139
|
-
const CustomPuck = (0,
|
7626
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7140
7627
|
() => loadedOverrides.puck || DefaultOverride,
|
7141
7628
|
[loadedOverrides]
|
7142
7629
|
);
|
7143
|
-
const CustomHeader = (0,
|
7630
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7144
7631
|
() => loadedOverrides.header || defaultHeaderRender,
|
7145
7632
|
[loadedOverrides]
|
7146
7633
|
);
|
7147
|
-
const CustomHeaderActions = (0,
|
7634
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7148
7635
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7149
7636
|
[loadedOverrides]
|
7150
7637
|
);
|
7151
|
-
const [mounted, setMounted] = (0,
|
7152
|
-
(0,
|
7638
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7639
|
+
(0, import_react50.useEffect)(() => {
|
7153
7640
|
setMounted(true);
|
7154
7641
|
}, []);
|
7155
7642
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7156
7643
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7157
|
-
|
7158
|
-
|
7644
|
+
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
7646
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7159
7647
|
AppProvider,
|
7160
7648
|
{
|
7161
7649
|
value: {
|
@@ -7177,7 +7665,7 @@ function Puck({
|
|
7177
7665
|
getPermissions: () => ({}),
|
7178
7666
|
refreshPermissions: () => null
|
7179
7667
|
},
|
7180
|
-
children: /* @__PURE__ */ (0,
|
7668
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7181
7669
|
"div",
|
7182
7670
|
{
|
7183
7671
|
className: getLayoutClassName({
|
@@ -7186,60 +7674,60 @@ function Puck({
|
|
7186
7674
|
mounted,
|
7187
7675
|
rightSideBarVisible
|
7188
7676
|
}),
|
7189
|
-
children: /* @__PURE__ */ (0,
|
7190
|
-
/* @__PURE__ */ (0,
|
7677
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
7678
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7191
7679
|
CustomHeader,
|
7192
7680
|
{
|
7193
|
-
actions: /* @__PURE__ */ (0,
|
7681
|
+
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)(
|
7194
7682
|
Button,
|
7195
7683
|
{
|
7196
7684
|
onClick: () => {
|
7197
7685
|
onPublish && onPublish(data);
|
7198
7686
|
},
|
7199
|
-
icon: /* @__PURE__ */ (0,
|
7687
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7200
7688
|
children: "Publish"
|
7201
7689
|
}
|
7202
7690
|
) }) }),
|
7203
|
-
children: /* @__PURE__ */ (0,
|
7204
|
-
/* @__PURE__ */ (0,
|
7205
|
-
/* @__PURE__ */ (0,
|
7691
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
7692
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
|
7693
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7206
7694
|
"div",
|
7207
7695
|
{
|
7208
7696
|
className: getLayoutClassName("leftSideBarToggle"),
|
7209
|
-
children: /* @__PURE__ */ (0,
|
7697
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7210
7698
|
IconButton,
|
7211
7699
|
{
|
7212
7700
|
onClick: () => {
|
7213
7701
|
toggleSidebars("left");
|
7214
7702
|
},
|
7215
7703
|
title: "Toggle left sidebar",
|
7216
|
-
children: /* @__PURE__ */ (0,
|
7704
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
7217
7705
|
}
|
7218
7706
|
)
|
7219
7707
|
}
|
7220
7708
|
),
|
7221
|
-
/* @__PURE__ */ (0,
|
7709
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7222
7710
|
"div",
|
7223
7711
|
{
|
7224
7712
|
className: getLayoutClassName("rightSideBarToggle"),
|
7225
|
-
children: /* @__PURE__ */ (0,
|
7713
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7226
7714
|
IconButton,
|
7227
7715
|
{
|
7228
7716
|
onClick: () => {
|
7229
7717
|
toggleSidebars("right");
|
7230
7718
|
},
|
7231
7719
|
title: "Toggle right sidebar",
|
7232
|
-
children: /* @__PURE__ */ (0,
|
7720
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
7233
7721
|
}
|
7234
7722
|
)
|
7235
7723
|
}
|
7236
7724
|
)
|
7237
7725
|
] }),
|
7238
|
-
/* @__PURE__ */ (0,
|
7726
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
7239
7727
|
headerTitle || rootProps.title || "Page",
|
7240
|
-
headerPath && /* @__PURE__ */ (0,
|
7728
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
7241
7729
|
" ",
|
7242
|
-
/* @__PURE__ */ (0,
|
7730
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7243
7731
|
"code",
|
7244
7732
|
{
|
7245
7733
|
className: getLayoutClassName("headerPath"),
|
@@ -7248,31 +7736,31 @@ function Puck({
|
|
7248
7736
|
)
|
7249
7737
|
] })
|
7250
7738
|
] }) }),
|
7251
|
-
/* @__PURE__ */ (0,
|
7252
|
-
/* @__PURE__ */ (0,
|
7739
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
|
7740
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7253
7741
|
IconButton,
|
7254
7742
|
{
|
7255
7743
|
onClick: () => {
|
7256
7744
|
return setMenuOpen(!menuOpen);
|
7257
7745
|
},
|
7258
7746
|
title: "Toggle menu bar",
|
7259
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
7747
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
7260
7748
|
}
|
7261
7749
|
) }),
|
7262
|
-
/* @__PURE__ */ (0,
|
7750
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7263
7751
|
MenuBar,
|
7264
7752
|
{
|
7265
7753
|
appState,
|
7266
7754
|
dispatch,
|
7267
7755
|
onPublish,
|
7268
7756
|
menuOpen,
|
7269
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
7757
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7270
7758
|
Button,
|
7271
7759
|
{
|
7272
7760
|
onClick: () => {
|
7273
7761
|
onPublish && onPublish(data);
|
7274
7762
|
},
|
7275
|
-
icon: /* @__PURE__ */ (0,
|
7763
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7276
7764
|
children: "Publish"
|
7277
7765
|
}
|
7278
7766
|
) }),
|
@@ -7283,19 +7771,19 @@ function Puck({
|
|
7283
7771
|
] }) })
|
7284
7772
|
}
|
7285
7773
|
),
|
7286
|
-
/* @__PURE__ */ (0,
|
7287
|
-
/* @__PURE__ */ (0,
|
7288
|
-
/* @__PURE__ */ (0,
|
7774
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7775
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
|
7776
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
|
7289
7777
|
] }),
|
7290
|
-
/* @__PURE__ */ (0,
|
7291
|
-
/* @__PURE__ */ (0,
|
7778
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
|
7779
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7292
7780
|
SidebarSection,
|
7293
7781
|
{
|
7294
7782
|
noPadding: true,
|
7295
7783
|
noBorderTop: true,
|
7296
7784
|
showBreadcrumbs: true,
|
7297
7785
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7298
|
-
children: /* @__PURE__ */ (0,
|
7786
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
|
7299
7787
|
}
|
7300
7788
|
) })
|
7301
7789
|
] })
|
@@ -7303,69 +7791,13 @@ function Puck({
|
|
7303
7791
|
) }) })
|
7304
7792
|
}
|
7305
7793
|
),
|
7306
|
-
/* @__PURE__ */ (0,
|
7794
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7307
7795
|
] });
|
7308
7796
|
}
|
7309
7797
|
Puck.Components = Components;
|
7310
7798
|
Puck.Fields = Fields;
|
7311
7799
|
Puck.Outline = Outline;
|
7312
|
-
Puck.Preview =
|
7313
|
-
|
7314
|
-
// components/Render/index.tsx
|
7315
|
-
init_react_import();
|
7316
|
-
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7317
|
-
function Render({
|
7318
|
-
config,
|
7319
|
-
data
|
7320
|
-
}) {
|
7321
|
-
var _a;
|
7322
|
-
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
7323
|
-
root: data.root || {},
|
7324
|
-
content: data.content || []
|
7325
|
-
});
|
7326
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
7327
|
-
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
7328
|
-
if ((_a = config.root) == null ? void 0 : _a.render) {
|
7329
|
-
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7330
|
-
DropZoneProvider,
|
7331
|
-
{
|
7332
|
-
value: {
|
7333
|
-
data: defaultedData,
|
7334
|
-
config,
|
7335
|
-
mode: "render",
|
7336
|
-
depth: 0,
|
7337
|
-
path: []
|
7338
|
-
},
|
7339
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7340
|
-
config.root.render,
|
7341
|
-
__spreadProps(__spreadValues({}, rootProps), {
|
7342
|
-
puck: {
|
7343
|
-
renderDropZone: DropZone,
|
7344
|
-
isEditing: false
|
7345
|
-
},
|
7346
|
-
title,
|
7347
|
-
editMode: false,
|
7348
|
-
id: "puck-root",
|
7349
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DropZone, { zone: rootDroppableId })
|
7350
|
-
})
|
7351
|
-
)
|
7352
|
-
}
|
7353
|
-
);
|
7354
|
-
}
|
7355
|
-
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7356
|
-
DropZoneProvider,
|
7357
|
-
{
|
7358
|
-
value: {
|
7359
|
-
data: defaultedData,
|
7360
|
-
config,
|
7361
|
-
mode: "render",
|
7362
|
-
depth: 0,
|
7363
|
-
path: []
|
7364
|
-
},
|
7365
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DropZone, { zone: rootDroppableId })
|
7366
|
-
}
|
7367
|
-
);
|
7368
|
-
}
|
7800
|
+
Puck.Preview = Preview2;
|
7369
7801
|
|
7370
7802
|
// lib/migrate.ts
|
7371
7803
|
init_react_import();
|