@measured/puck 0.18.0-canary.d253d54 → 0.18.0-canary.e2139f5
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 +71 -81
- package/dist/index.d.mts +7 -11
- package/dist/index.d.ts +7 -11
- package/dist/index.js +1431 -1018
- package/dist/index.mjs +1330 -914
- 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,131 @@ 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 [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3592
|
+
const updateContent = useRenderedCallback(
|
3593
|
+
(content2, preview2) => {
|
3594
|
+
if (preview2) {
|
3595
|
+
if (preview2.type === "insert") {
|
3596
|
+
setContentWithPreview(
|
3597
|
+
insert(
|
3598
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3599
|
+
preview2.index,
|
3600
|
+
{
|
3601
|
+
type: "preview",
|
3602
|
+
props: { id: preview2.props.id }
|
3603
|
+
}
|
3604
|
+
)
|
3605
|
+
);
|
3606
|
+
} else {
|
3607
|
+
setContentWithPreview(
|
3608
|
+
insert(
|
3609
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3610
|
+
preview2.index,
|
3611
|
+
{
|
3612
|
+
type: preview2.componentType,
|
3613
|
+
props: preview2.props
|
3614
|
+
}
|
3615
|
+
)
|
3616
|
+
);
|
3617
|
+
}
|
3618
|
+
} else {
|
3619
|
+
setContentWithPreview(
|
3620
|
+
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3621
|
+
);
|
3622
|
+
}
|
3623
|
+
},
|
3624
|
+
[draggedItemId, previewExists]
|
3625
|
+
);
|
3626
|
+
(0, import_react27.useEffect)(() => {
|
3627
|
+
updateContent(content, preview);
|
3628
|
+
}, [content, preview]);
|
3629
|
+
return contentWithPreview;
|
3630
|
+
};
|
3631
|
+
|
3632
|
+
// components/DropZone/lib/use-drag-axis.ts
|
3633
|
+
init_react_import();
|
3634
|
+
var import_react28 = require("react");
|
3447
3635
|
var GRID_DRAG_AXIS = "dynamic";
|
3448
3636
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3449
3637
|
var DEFAULT_DRAG_AXIS = "y";
|
3450
|
-
var
|
3451
|
-
|
3638
|
+
var useDragAxis = (ref, collisionAxis) => {
|
3639
|
+
const { status } = useAppContext();
|
3640
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3641
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
3642
|
+
);
|
3643
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3644
|
+
if (ref.current) {
|
3645
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
3646
|
+
if (computedStyle.display === "grid") {
|
3647
|
+
setDragAxis(GRID_DRAG_AXIS);
|
3648
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3649
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3650
|
+
} else {
|
3651
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
3652
|
+
}
|
3653
|
+
}
|
3654
|
+
}, [ref.current]);
|
3655
|
+
(0, import_react28.useEffect)(() => {
|
3656
|
+
const onViewportChange = () => {
|
3657
|
+
calculateDragAxis();
|
3658
|
+
};
|
3659
|
+
window.addEventListener("viewportchange", onViewportChange);
|
3660
|
+
return () => {
|
3661
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
3662
|
+
};
|
3663
|
+
}, []);
|
3664
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
3665
|
+
return [dragAxis, calculateDragAxis];
|
3666
|
+
};
|
3667
|
+
|
3668
|
+
// components/DropZone/index.tsx
|
3669
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
3670
|
+
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3671
|
+
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3672
|
+
var RENDER_DEBUG = false;
|
3673
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
3674
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
3675
|
+
function DropZoneEditInternal({
|
3452
3676
|
zone,
|
3453
3677
|
allow,
|
3454
3678
|
disallow,
|
@@ -3458,31 +3682,50 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3458
3682
|
collisionAxis
|
3459
3683
|
}, userRef) {
|
3460
3684
|
const appContext2 = useAppContext();
|
3461
|
-
const ctx = (0,
|
3685
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3462
3686
|
const {
|
3463
3687
|
// These all need setting via context
|
3464
3688
|
data,
|
3465
3689
|
config,
|
3466
3690
|
areaId,
|
3467
|
-
draggedItem,
|
3468
3691
|
registerZoneArea,
|
3469
3692
|
depth,
|
3470
3693
|
registerLocalZone,
|
3471
3694
|
unregisterLocalZone,
|
3472
|
-
deepestZone = rootDroppableId,
|
3473
|
-
deepestArea,
|
3474
|
-
nextDeepestArea,
|
3475
3695
|
path = [],
|
3476
3696
|
activeZones
|
3477
3697
|
} = ctx;
|
3478
|
-
const { itemSelector } = appContext2.state.ui;
|
3479
3698
|
let zoneCompound = rootDroppableId;
|
3480
|
-
|
3699
|
+
if (areaId) {
|
3700
|
+
if (zone !== rootDroppableId) {
|
3701
|
+
zoneCompound = `${areaId}:${zone}`;
|
3702
|
+
}
|
3703
|
+
}
|
3704
|
+
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
3705
|
+
const {
|
3706
|
+
isDeepestZone,
|
3707
|
+
inNextDeepestArea,
|
3708
|
+
draggedComponentType,
|
3709
|
+
userIsDragging,
|
3710
|
+
preview
|
3711
|
+
} = useContextStore(ZoneStoreContext, (s) => {
|
3712
|
+
var _a, _b, _c;
|
3713
|
+
return {
|
3714
|
+
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
3715
|
+
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3716
|
+
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3717
|
+
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3718
|
+
userIsDragging: !!s.draggedItem,
|
3719
|
+
preview: s.previewIndex[zoneCompound]
|
3720
|
+
};
|
3721
|
+
});
|
3722
|
+
const { itemSelector } = appContext2.state.ui;
|
3723
|
+
(0, import_react29.useEffect)(() => {
|
3481
3724
|
if (areaId && registerZoneArea) {
|
3482
3725
|
registerZoneArea(areaId);
|
3483
3726
|
}
|
3484
3727
|
}, [areaId]);
|
3485
|
-
(0,
|
3728
|
+
(0, import_react29.useEffect)(() => {
|
3486
3729
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3487
3730
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3488
3731
|
}
|
@@ -3492,25 +3735,18 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3492
3735
|
}
|
3493
3736
|
};
|
3494
3737
|
}, []);
|
3495
|
-
|
3496
|
-
if (zone !== rootDroppableId) {
|
3497
|
-
zoneCompound = `${areaId}:${zone}`;
|
3498
|
-
}
|
3499
|
-
}
|
3500
|
-
const content = (0, import_react24.useMemo)(() => {
|
3738
|
+
const content = (0, import_react29.useMemo)(() => {
|
3501
3739
|
if (areaId && zone !== rootDroppableId) {
|
3502
3740
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3503
3741
|
}
|
3504
3742
|
return data.content || [];
|
3505
3743
|
}, [data, zoneCompound]);
|
3506
|
-
const ref = (0,
|
3507
|
-
const acceptsTarget = (0,
|
3508
|
-
(
|
3509
|
-
if (!
|
3744
|
+
const ref = (0, import_react29.useRef)(null);
|
3745
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
3746
|
+
(componentType) => {
|
3747
|
+
if (!componentType) {
|
3510
3748
|
return true;
|
3511
3749
|
}
|
3512
|
-
const data2 = target.data;
|
3513
|
-
const { componentType } = data2;
|
3514
3750
|
if (disallow) {
|
3515
3751
|
const defaultedAllow = allow || [];
|
3516
3752
|
const filteredDisallow = (disallow || []).filter(
|
@@ -3528,49 +3764,26 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3528
3764
|
},
|
3529
3765
|
[allow, disallow]
|
3530
3766
|
);
|
3531
|
-
(0,
|
3767
|
+
(0, import_react29.useEffect)(() => {
|
3532
3768
|
if (registerLocalZone) {
|
3533
|
-
registerLocalZone(zoneCompound, acceptsTarget(
|
3769
|
+
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3534
3770
|
}
|
3535
3771
|
return () => {
|
3536
3772
|
if (unregisterLocalZone) {
|
3537
3773
|
unregisterLocalZone(zoneCompound);
|
3538
3774
|
}
|
3539
3775
|
};
|
3540
|
-
}, [
|
3541
|
-
const
|
3542
|
-
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3543
|
-
const userIsDragging = !!draggedItem;
|
3776
|
+
}, [draggedComponentType, zoneCompound]);
|
3777
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
3544
3778
|
let isEnabled = true;
|
3545
|
-
if (
|
3546
|
-
isEnabled =
|
3779
|
+
if (userIsDragging) {
|
3780
|
+
isEnabled = isDeepestZone;
|
3547
3781
|
}
|
3548
3782
|
if (isEnabled) {
|
3549
|
-
isEnabled = acceptsTarget(
|
3550
|
-
}
|
3551
|
-
const
|
3552
|
-
const
|
3553
|
-
const contentWithPreview = (0, import_react24.useMemo)(() => {
|
3554
|
-
let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
|
3555
|
-
if (previewInZone) {
|
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);
|
3783
|
+
isEnabled = acceptsTarget(draggedComponentType);
|
3784
|
+
}
|
3785
|
+
const contentWithPreview = useContentWithPreview(content, zoneCompound);
|
3786
|
+
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3574
3787
|
const droppableConfig = {
|
3575
3788
|
id: zoneCompound,
|
3576
3789
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -3580,45 +3793,20 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3580
3793
|
data: {
|
3581
3794
|
areaId,
|
3582
3795
|
depth,
|
3583
|
-
isDroppableTarget: acceptsTarget(
|
3796
|
+
isDroppableTarget: acceptsTarget(draggedComponentType),
|
3584
3797
|
path
|
3585
3798
|
}
|
3586
3799
|
};
|
3587
3800
|
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
3588
3801
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3589
3802
|
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
|
-
}, []);
|
3803
|
+
const [dragAxis] = useDragAxis(ref, collisionAxis);
|
3615
3804
|
const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
|
3616
|
-
draggedItem,
|
3617
3805
|
zoneCompound,
|
3618
3806
|
userMinEmptyHeight,
|
3619
3807
|
ref
|
3620
3808
|
});
|
3621
|
-
return /* @__PURE__ */ (0,
|
3809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3622
3810
|
"div",
|
3623
3811
|
{
|
3624
3812
|
className: `${getClassName17({
|
@@ -3638,87 +3826,93 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
|
|
3638
3826
|
"data-puck-dropzone": zoneCompound,
|
3639
3827
|
"data-puck-dnd": zoneCompound,
|
3640
3828
|
style: __spreadProps(__spreadValues({}, style), {
|
3641
|
-
"--min-empty-height": `${minEmptyHeight}px
|
3829
|
+
"--min-empty-height": `${minEmptyHeight}px`,
|
3830
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3642
3831
|
}),
|
3643
|
-
children:
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3832
|
+
children: contentWithPreview.map((item, i) => {
|
3833
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3834
|
+
const componentId = item.props.id;
|
3835
|
+
const puckProps = {
|
3836
|
+
renderDropZone: DropZoneEditPure,
|
3837
|
+
isEditing: true,
|
3838
|
+
dragRef: null
|
3839
|
+
};
|
3840
|
+
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
|
3841
|
+
puck: puckProps,
|
3842
|
+
editMode: true
|
3843
|
+
// DEPRECATED
|
3844
|
+
});
|
3845
|
+
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3846
|
+
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: [
|
3847
|
+
"No configuration for ",
|
3848
|
+
item.type
|
3849
|
+
] });
|
3850
|
+
const componentConfig = config.components[item.type];
|
3851
|
+
let componentType = item.type;
|
3852
|
+
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3853
|
+
if (item.type === "preview") {
|
3854
|
+
let Preview4 = function() {
|
3855
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3655
3856
|
};
|
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
|
-
})
|
3857
|
+
var Preview3 = Preview4;
|
3858
|
+
componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
|
3859
|
+
label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
|
3860
|
+
Render2 = Preview4;
|
3861
|
+
}
|
3862
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3863
|
+
DropZoneProvider,
|
3864
|
+
{
|
3865
|
+
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3866
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3867
|
+
DraggableComponent,
|
3868
|
+
{
|
3869
|
+
id: componentId,
|
3870
|
+
componentType,
|
3871
|
+
zoneCompound,
|
3872
|
+
depth: depth + 1,
|
3873
|
+
index: i,
|
3874
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3875
|
+
isSelected,
|
3876
|
+
label,
|
3877
|
+
isEnabled,
|
3878
|
+
autoDragAxis: dragAxis,
|
3879
|
+
userDragAxis: collisionAxis,
|
3880
|
+
inDroppableZone: acceptsTarget(draggedComponentType),
|
3881
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3882
|
+
Render2,
|
3883
|
+
__spreadProps(__spreadValues({}, defaultedProps), {
|
3884
|
+
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3885
|
+
dragRef
|
3703
3886
|
})
|
3704
|
-
|
3705
|
-
}
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3887
|
+
})
|
3888
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3889
|
+
}
|
3890
|
+
)
|
3891
|
+
},
|
3892
|
+
componentId
|
3893
|
+
);
|
3894
|
+
})
|
3712
3895
|
}
|
3713
3896
|
);
|
3714
3897
|
}
|
3715
3898
|
);
|
3716
|
-
var
|
3717
|
-
|
3718
|
-
|
3899
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
3900
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
3901
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3902
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3719
3903
|
const { data, areaId = "root", config } = ctx || {};
|
3720
3904
|
let zoneCompound = rootDroppableId;
|
3721
3905
|
let content = (data == null ? void 0 : data.content) || [];
|
3906
|
+
(0, import_react29.useEffect)(() => {
|
3907
|
+
if (ctx == null ? void 0 : ctx.registerZone) {
|
3908
|
+
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3909
|
+
}
|
3910
|
+
return () => {
|
3911
|
+
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
3912
|
+
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
3913
|
+
}
|
3914
|
+
};
|
3915
|
+
}, []);
|
3722
3916
|
if (!data || !config) {
|
3723
3917
|
return null;
|
3724
3918
|
}
|
@@ -3726,10 +3920,10 @@ var DropZoneRender = (0, import_react24.forwardRef)(
|
|
3726
3920
|
zoneCompound = `${areaId}:${zone}`;
|
3727
3921
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3728
3922
|
}
|
3729
|
-
return /* @__PURE__ */ (0,
|
3923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
3730
3924
|
const Component = config.components[item.type];
|
3731
3925
|
if (Component) {
|
3732
|
-
return /* @__PURE__ */ (0,
|
3926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3733
3927
|
DropZoneProvider,
|
3734
3928
|
{
|
3735
3929
|
value: {
|
@@ -3739,10 +3933,12 @@ var DropZoneRender = (0, import_react24.forwardRef)(
|
|
3739
3933
|
depth: 1,
|
3740
3934
|
path: []
|
3741
3935
|
},
|
3742
|
-
children: /* @__PURE__ */ (0,
|
3936
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3743
3937
|
Component.render,
|
3744
3938
|
__spreadProps(__spreadValues({}, item.props), {
|
3745
|
-
puck: {
|
3939
|
+
puck: {
|
3940
|
+
renderDropZone: DropZoneRenderPure
|
3941
|
+
}
|
3746
3942
|
})
|
3747
3943
|
)
|
3748
3944
|
},
|
@@ -3753,13 +3949,13 @@ var DropZoneRender = (0, import_react24.forwardRef)(
|
|
3753
3949
|
}) });
|
3754
3950
|
}
|
3755
3951
|
);
|
3756
|
-
var DropZone = (0,
|
3952
|
+
var DropZone = (0, import_react29.forwardRef)(
|
3757
3953
|
function DropZone2(props, ref) {
|
3758
|
-
const ctx = (0,
|
3954
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3759
3955
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3760
|
-
return /* @__PURE__ */ (0,
|
3956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3761
3957
|
}
|
3762
|
-
return /* @__PURE__ */ (0,
|
3958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3763
3959
|
}
|
3764
3960
|
);
|
3765
3961
|
|
@@ -3775,7 +3971,7 @@ var getZoneId = (zoneCompound) => {
|
|
3775
3971
|
return [rootDroppableId, zoneCompound];
|
3776
3972
|
};
|
3777
3973
|
|
3778
|
-
//
|
3974
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3779
3975
|
init_react_import();
|
3780
3976
|
var import_abstract9 = require("@dnd-kit/abstract");
|
3781
3977
|
var import_state = require("@dnd-kit/state");
|
@@ -3817,7 +4013,49 @@ var getFrame = () => {
|
|
3817
4013
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3818
4014
|
};
|
3819
4015
|
|
3820
|
-
//
|
4016
|
+
// lib/global-position.ts
|
4017
|
+
init_react_import();
|
4018
|
+
var GlobalPosition = class {
|
4019
|
+
constructor(target, original) {
|
4020
|
+
this.scaleFactor = 1;
|
4021
|
+
this.frameEl = null;
|
4022
|
+
this.frameRect = null;
|
4023
|
+
var _a;
|
4024
|
+
this.target = target;
|
4025
|
+
this.original = original;
|
4026
|
+
this.frameEl = document.querySelector("iframe");
|
4027
|
+
if (this.frameEl) {
|
4028
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
4029
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4030
|
+
}
|
4031
|
+
}
|
4032
|
+
get x() {
|
4033
|
+
return this.original.x;
|
4034
|
+
}
|
4035
|
+
get y() {
|
4036
|
+
return this.original.y;
|
4037
|
+
}
|
4038
|
+
get global() {
|
4039
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
4040
|
+
return {
|
4041
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
4042
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
4043
|
+
};
|
4044
|
+
}
|
4045
|
+
return this.original;
|
4046
|
+
}
|
4047
|
+
get frame() {
|
4048
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
4049
|
+
return {
|
4050
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
4051
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
4052
|
+
};
|
4053
|
+
}
|
4054
|
+
return this.original;
|
4055
|
+
}
|
4056
|
+
};
|
4057
|
+
|
4058
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3821
4059
|
var depthSort = (candidates) => {
|
3822
4060
|
return candidates.sort((a, b) => {
|
3823
4061
|
const aData = a.data;
|
@@ -3846,10 +4084,12 @@ var getZoneId2 = (candidate) => {
|
|
3846
4084
|
}
|
3847
4085
|
return id;
|
3848
4086
|
};
|
3849
|
-
var getPointerCollisions = (position, manager
|
3850
|
-
var _a;
|
4087
|
+
var getPointerCollisions = (position, manager) => {
|
3851
4088
|
const candidates = [];
|
3852
|
-
let elements = ownerDocument.elementsFromPoint(
|
4089
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
4090
|
+
position.x,
|
4091
|
+
position.y
|
4092
|
+
);
|
3853
4093
|
const previewFrame = elements.find(
|
3854
4094
|
(el) => el.getAttribute("data-puck-preview")
|
3855
4095
|
);
|
@@ -3858,17 +4098,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3858
4098
|
elements = [drawer];
|
3859
4099
|
}
|
3860
4100
|
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
|
-
}
|
4101
|
+
const frame = getFrame();
|
4102
|
+
if (frame) {
|
4103
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
3872
4104
|
}
|
3873
4105
|
}
|
3874
4106
|
if (elements) {
|
@@ -3885,9 +4117,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3885
4117
|
}
|
3886
4118
|
return candidates;
|
3887
4119
|
};
|
3888
|
-
var findDeepestCandidate = (position, manager
|
4120
|
+
var findDeepestCandidate = (position, manager) => {
|
3889
4121
|
var _a;
|
3890
|
-
const candidates = getPointerCollisions(position, manager
|
4122
|
+
const candidates = getPointerCollisions(position, manager);
|
3891
4123
|
if (candidates.length > 0) {
|
3892
4124
|
const sortedCandidates = depthSort(candidates);
|
3893
4125
|
const draggable = manager.dragOperation.source;
|
@@ -3932,9 +4164,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
|
|
3932
4164
|
area: null
|
3933
4165
|
};
|
3934
4166
|
};
|
3935
|
-
var createNestedDroppablePlugin = ({
|
3936
|
-
onChange
|
3937
|
-
}) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4167
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
3938
4168
|
constructor(manager, options) {
|
3939
4169
|
super(manager);
|
3940
4170
|
if (typeof window === "undefined") {
|
@@ -3942,16 +4172,19 @@ var createNestedDroppablePlugin = ({
|
|
3942
4172
|
}
|
3943
4173
|
const cleanupEffect = (0, import_state.effects)(() => {
|
3944
4174
|
const handleMove = (event) => {
|
3945
|
-
const
|
4175
|
+
const target = event.originalTarget || event.target;
|
4176
|
+
const position = new GlobalPosition(target, {
|
3946
4177
|
x: event.clientX,
|
3947
4178
|
y: event.clientY
|
3948
|
-
};
|
3949
|
-
const
|
3950
|
-
|
3951
|
-
|
3952
|
-
findDeepestCandidate(position, manager, ownerDocument),
|
3953
|
-
manager
|
4179
|
+
});
|
4180
|
+
const elements = document.elementsFromPoint(
|
4181
|
+
position.global.x,
|
4182
|
+
position.global.y
|
3954
4183
|
);
|
4184
|
+
const overEl = elements.some((el) => el.id === id);
|
4185
|
+
if (overEl) {
|
4186
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
4187
|
+
}
|
3955
4188
|
};
|
3956
4189
|
const handleMoveThrottled = throttle(handleMove, 50);
|
3957
4190
|
const handlePointerMove = (event) => {
|
@@ -4281,6 +4514,11 @@ var reduceUi = (ui, action) => {
|
|
4281
4514
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4282
4515
|
});
|
4283
4516
|
}
|
4517
|
+
if (action.type === "remove") {
|
4518
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4519
|
+
itemSelector: null
|
4520
|
+
});
|
4521
|
+
}
|
4284
4522
|
return ui;
|
4285
4523
|
};
|
4286
4524
|
|
@@ -4368,7 +4606,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4368
4606
|
var import_use_debounce2 = require("use-debounce");
|
4369
4607
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
4370
4608
|
|
4371
|
-
//
|
4609
|
+
// lib/dnd/PointerSensor.ts
|
4372
4610
|
init_react_import();
|
4373
4611
|
var import_state3 = require("@dnd-kit/state");
|
4374
4612
|
var import_abstract10 = require("@dnd-kit/abstract");
|
@@ -4531,6 +4769,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
|
|
4531
4769
|
}
|
4532
4770
|
}
|
4533
4771
|
handlePointerUp(event) {
|
4772
|
+
if (!this.source) {
|
4773
|
+
return;
|
4774
|
+
}
|
4534
4775
|
event.preventDefault();
|
4535
4776
|
event.stopPropagation();
|
4536
4777
|
const { status } = this.manager.dragOperation;
|
@@ -4630,13 +4871,15 @@ function patchWindow(window2) {
|
|
4630
4871
|
}
|
4631
4872
|
|
4632
4873
|
// components/DragDropContext/index.tsx
|
4633
|
-
var
|
4634
|
-
var
|
4874
|
+
var import_zustand3 = require("zustand");
|
4875
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
4876
|
+
var DEBUG3 = false;
|
4877
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
4635
4878
|
dragListeners: {}
|
4636
4879
|
});
|
4637
4880
|
function useDragListener(type, fn, deps = []) {
|
4638
|
-
const { setDragListeners } = (0,
|
4639
|
-
(0,
|
4881
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
4882
|
+
(0, import_react31.useEffect)(() => {
|
4640
4883
|
if (setDragListeners) {
|
4641
4884
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4642
4885
|
[type]: [...old[type] || [], fn]
|
@@ -4644,80 +4887,147 @@ function useDragListener(type, fn, deps = []) {
|
|
4644
4887
|
}
|
4645
4888
|
}, deps);
|
4646
4889
|
}
|
4647
|
-
var previewContext = (0, import_react26.createContext)(null);
|
4648
4890
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4891
|
+
var useTempDisableFallback = (timeout3) => {
|
4892
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
4893
|
+
return (0, import_react31.useCallback)((manager) => {
|
4894
|
+
collisionStore.setState({ fallbackEnabled: false });
|
4895
|
+
const fallbackId = generateId();
|
4896
|
+
lastFallbackDisable.current = fallbackId;
|
4897
|
+
setTimeout(() => {
|
4898
|
+
if (lastFallbackDisable.current === fallbackId) {
|
4899
|
+
collisionStore.setState({ fallbackEnabled: true });
|
4900
|
+
manager.collisionObserver.forceUpdate(true);
|
4901
|
+
}
|
4902
|
+
}, timeout3);
|
4903
|
+
}, []);
|
4904
|
+
};
|
4649
4905
|
var DragDropContextClient = ({
|
4650
4906
|
children,
|
4651
4907
|
disableAutoScroll
|
4652
4908
|
}) => {
|
4653
4909
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4654
|
-
const
|
4655
|
-
const previewRef = (0, import_react26.useRef)(null);
|
4910
|
+
const id = (0, import_react31.useId)();
|
4656
4911
|
const { data } = state;
|
4657
|
-
const
|
4658
|
-
const
|
4659
|
-
const
|
4660
|
-
|
4661
|
-
|
4912
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
4913
|
+
const tempDisableFallback = useTempDisableFallback(100);
|
4914
|
+
const [zoneStore] = (0, import_react31.useState)(
|
4915
|
+
() => (0, import_zustand3.createStore)(() => ({
|
4916
|
+
zoneDepthIndex: {},
|
4917
|
+
nextZoneDepthIndex: {},
|
4918
|
+
areaDepthIndex: {},
|
4919
|
+
nextAreaDepthIndex: {},
|
4920
|
+
draggedItem: null,
|
4921
|
+
previewIndex: {}
|
4922
|
+
}))
|
4923
|
+
);
|
4924
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
4925
|
+
(params, id2) => {
|
4926
|
+
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4927
|
+
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
4928
|
+
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
4929
|
+
let zoneChanged = false;
|
4930
|
+
let areaChanged = false;
|
4931
|
+
if (params.zone && !zoneDepthIndex[params.zone]) {
|
4932
|
+
zoneChanged = true;
|
4933
|
+
} else if (!params.zone && stateHasZone) {
|
4934
|
+
zoneChanged = true;
|
4935
|
+
}
|
4936
|
+
if (params.area && !areaDepthIndex[params.area]) {
|
4937
|
+
areaChanged = true;
|
4938
|
+
} else if (!params.area && stateHasArea) {
|
4939
|
+
areaChanged = true;
|
4940
|
+
}
|
4941
|
+
return { zoneChanged, areaChanged };
|
4942
|
+
},
|
4943
|
+
[zoneStore]
|
4944
|
+
);
|
4945
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
4662
4946
|
(params, manager) => {
|
4663
|
-
|
4947
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4948
|
+
if (!zoneChanged && !areaChanged) return;
|
4949
|
+
zoneStore.setState({
|
4950
|
+
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
4951
|
+
areaDepthIndex: params.area ? { [params.area]: true } : {}
|
4952
|
+
});
|
4953
|
+
tempDisableFallback(manager);
|
4664
4954
|
setTimeout(() => {
|
4665
4955
|
manager.collisionObserver.forceUpdate(true);
|
4666
4956
|
}, 50);
|
4667
4957
|
debouncedParamsRef.current = null;
|
4668
4958
|
},
|
4669
|
-
[]
|
4959
|
+
[zoneStore]
|
4670
4960
|
);
|
4671
4961
|
const setDeepestDb = (0, import_use_debounce2.useDebouncedCallback)(
|
4672
4962
|
setDeepestAndCollide,
|
4673
4963
|
AREA_CHANGE_DEBOUNCE_MS
|
4674
4964
|
);
|
4675
|
-
(0, import_react26.useEffect)(() => {
|
4676
|
-
deepestRef.current = deepest;
|
4677
|
-
}, [deepest]);
|
4678
4965
|
const cancelDb = () => {
|
4679
4966
|
setDeepestDb.cancel();
|
4680
4967
|
debouncedParamsRef.current = null;
|
4681
4968
|
};
|
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;
|
4969
|
+
(0, import_react31.useEffect)(() => {
|
4970
|
+
if (DEBUG3) {
|
4971
|
+
zoneStore.subscribe(
|
4972
|
+
(s) => {
|
4973
|
+
var _a, _b;
|
4974
|
+
return console.log(
|
4975
|
+
s.previewIndex,
|
4976
|
+
(_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
|
4977
|
+
(_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
|
4978
|
+
);
|
4697
4979
|
}
|
4698
|
-
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4702
|
-
|
4980
|
+
);
|
4981
|
+
}
|
4982
|
+
}, []);
|
4983
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
4984
|
+
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
4985
|
+
createNestedDroppablePlugin(
|
4986
|
+
{
|
4987
|
+
onChange: (params, manager) => {
|
4988
|
+
const state2 = zoneStore.getState();
|
4989
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4990
|
+
const isDragging = manager.dragOperation.status.dragging;
|
4991
|
+
if (areaChanged || zoneChanged) {
|
4992
|
+
let nextZoneDepthIndex = {};
|
4993
|
+
let nextAreaDepthIndex = {};
|
4994
|
+
if (params.zone) {
|
4995
|
+
nextZoneDepthIndex = { [params.zone]: true };
|
4996
|
+
}
|
4997
|
+
if (params.area) {
|
4998
|
+
nextAreaDepthIndex = { [params.area]: true };
|
4999
|
+
}
|
5000
|
+
zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
|
5001
|
+
}
|
5002
|
+
if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
|
5003
|
+
setDeepestAndCollide(params, manager);
|
5004
|
+
return;
|
5005
|
+
}
|
5006
|
+
if (areaChanged) {
|
5007
|
+
if (isDragging) {
|
5008
|
+
const debouncedParams = debouncedParamsRef.current;
|
5009
|
+
const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
|
5010
|
+
if (!isSameParams) {
|
5011
|
+
cancelDb();
|
5012
|
+
setDeepestDb(params, manager);
|
5013
|
+
debouncedParamsRef.current = params;
|
5014
|
+
}
|
5015
|
+
} else {
|
4703
5016
|
cancelDb();
|
4704
|
-
|
4705
|
-
debouncedParamsRef.current = params;
|
5017
|
+
setDeepestAndCollide(params, manager);
|
4706
5018
|
}
|
4707
|
-
|
4708
|
-
|
5019
|
+
return;
|
5020
|
+
}
|
5021
|
+
if (zoneChanged) {
|
4709
5022
|
setDeepestAndCollide(params, manager);
|
4710
5023
|
}
|
4711
|
-
|
5024
|
+
cancelDb();
|
4712
5025
|
}
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
cancelDb();
|
4717
|
-
}
|
4718
|
-
})
|
5026
|
+
},
|
5027
|
+
id
|
5028
|
+
)
|
4719
5029
|
]);
|
4720
|
-
const [sensors] = (0,
|
5030
|
+
const [sensors] = (0, import_react31.useState)(() => [
|
4721
5031
|
PointerSensor.configure({
|
4722
5032
|
activationConstraints(event, source) {
|
4723
5033
|
var _a;
|
@@ -4736,67 +5046,72 @@ var DragDropContextClient = ({
|
|
4736
5046
|
}
|
4737
5047
|
})
|
4738
5048
|
]);
|
4739
|
-
const [
|
4740
|
-
const [
|
4741
|
-
const
|
4742
|
-
const
|
4743
|
-
|
4744
|
-
(selector) => {
|
4745
|
-
const item = getItem(selector, data);
|
4746
|
-
if (!item) {
|
4747
|
-
return;
|
4748
|
-
}
|
5049
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
5050
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
5051
|
+
const dragMode = (0, import_react31.useRef)(null);
|
5052
|
+
const registerPath = (0, import_react31.useCallback)(
|
5053
|
+
(id2, selector, label) => {
|
4749
5054
|
const [area] = getZoneId(selector.zone);
|
4750
5055
|
setPathData((latestPathData = {}) => {
|
4751
5056
|
const parentPathData = latestPathData[area] || { path: [] };
|
4752
5057
|
return __spreadProps(__spreadValues({}, latestPathData), {
|
4753
|
-
[
|
5058
|
+
[id2]: {
|
4754
5059
|
path: [
|
4755
5060
|
...parentPathData.path,
|
4756
5061
|
...selector.zone ? [selector.zone] : []
|
4757
5062
|
],
|
4758
|
-
label
|
5063
|
+
label
|
4759
5064
|
}
|
4760
5065
|
});
|
4761
5066
|
});
|
4762
5067
|
},
|
4763
5068
|
[data, setPathData]
|
4764
5069
|
);
|
4765
|
-
const
|
4766
|
-
|
5070
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5071
|
+
(id2) => {
|
5072
|
+
setPathData((latestPathData = {}) => {
|
5073
|
+
const newPathData = __spreadValues({}, latestPathData);
|
5074
|
+
delete newPathData[id2];
|
5075
|
+
return newPathData;
|
5076
|
+
});
|
5077
|
+
},
|
5078
|
+
[data, setPathData]
|
5079
|
+
);
|
5080
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4767
5082
|
dragListenerContext.Provider,
|
4768
5083
|
{
|
4769
5084
|
value: {
|
4770
5085
|
dragListeners,
|
4771
5086
|
setDragListeners
|
4772
5087
|
},
|
4773
|
-
children: /* @__PURE__ */ (0,
|
4774
|
-
|
5088
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5089
|
+
import_react30.DragDropProvider,
|
4775
5090
|
{
|
4776
5091
|
plugins,
|
4777
5092
|
sensors,
|
4778
5093
|
onDragEnd: (event, manager) => {
|
5094
|
+
var _a;
|
4779
5095
|
const { source, target } = event.operation;
|
4780
|
-
deepestRef.current = null;
|
4781
5096
|
if (!source) {
|
4782
|
-
|
5097
|
+
zoneStore.setState({ draggedItem: null });
|
4783
5098
|
return;
|
4784
5099
|
}
|
4785
5100
|
const { zone, index } = source.data;
|
4786
|
-
const
|
4787
|
-
|
5101
|
+
const { previewIndex = {} } = zoneStore.getState() || {};
|
5102
|
+
const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
|
4788
5103
|
setTimeout(() => {
|
4789
|
-
var
|
4790
|
-
|
5104
|
+
var _a2, _b;
|
5105
|
+
zoneStore.setState({ draggedItem: null });
|
4791
5106
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4792
|
-
|
4793
|
-
(
|
5107
|
+
zoneStore.setState({ previewIndex: {} });
|
5108
|
+
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
4794
5109
|
fn(event, manager);
|
4795
5110
|
});
|
4796
5111
|
return;
|
4797
5112
|
}
|
4798
5113
|
if (thisPreview) {
|
4799
|
-
|
5114
|
+
zoneStore.setState({ previewIndex: {} });
|
4800
5115
|
if (thisPreview.type === "insert") {
|
4801
5116
|
insertComponent(
|
4802
5117
|
thisPreview.componentType,
|
@@ -4831,8 +5146,9 @@ var DragDropContextClient = ({
|
|
4831
5146
|
}, 250);
|
4832
5147
|
},
|
4833
5148
|
onDragOver: (event, manager) => {
|
4834
|
-
var _a, _b, _c, _d;
|
5149
|
+
var _a, _b, _c, _d, _e;
|
4835
5150
|
event.preventDefault();
|
5151
|
+
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
4836
5152
|
if (!draggedItem) return;
|
4837
5153
|
cancelDb();
|
4838
5154
|
const { source, target } = event.operation;
|
@@ -4848,7 +5164,7 @@ var DragDropContextClient = ({
|
|
4848
5164
|
const targetData = target.data;
|
4849
5165
|
targetZone = targetData.zone;
|
4850
5166
|
targetIndex = targetData.index;
|
4851
|
-
const collisionData = (
|
5167
|
+
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
4852
5168
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4853
5169
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4854
5170
|
targetIndex = targetIndex - 1;
|
@@ -4860,23 +5176,26 @@ var DragDropContextClient = ({
|
|
4860
5176
|
targetZone = target.id.toString();
|
4861
5177
|
targetIndex = 0;
|
4862
5178
|
}
|
4863
|
-
if (targetId === sourceId || ((
|
5179
|
+
if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
|
4864
5180
|
const [pathId] = path.split(":");
|
4865
5181
|
return pathId === sourceId;
|
4866
5182
|
}))) {
|
4867
5183
|
return;
|
4868
5184
|
}
|
4869
5185
|
if (dragMode.current === "new") {
|
4870
|
-
|
4871
|
-
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
5186
|
+
zoneStore.setState({
|
5187
|
+
previewIndex: {
|
5188
|
+
[targetZone]: {
|
5189
|
+
componentType: sourceData.componentType,
|
5190
|
+
type: "insert",
|
5191
|
+
index: targetIndex,
|
5192
|
+
zone: targetZone,
|
5193
|
+
props: {
|
5194
|
+
id: source.id.toString()
|
5195
|
+
}
|
5196
|
+
}
|
4877
5197
|
}
|
4878
|
-
};
|
4879
|
-
setPreview(previewRef.current);
|
5198
|
+
});
|
4880
5199
|
} else {
|
4881
5200
|
if (!initialSelector.current) {
|
4882
5201
|
initialSelector.current = {
|
@@ -4886,17 +5205,20 @@ var DragDropContextClient = ({
|
|
4886
5205
|
}
|
4887
5206
|
const item = getItem(initialSelector.current, data);
|
4888
5207
|
if (item) {
|
4889
|
-
|
4890
|
-
|
4891
|
-
|
4892
|
-
|
4893
|
-
|
4894
|
-
|
4895
|
-
|
4896
|
-
|
5208
|
+
zoneStore.setState({
|
5209
|
+
previewIndex: {
|
5210
|
+
[targetZone]: {
|
5211
|
+
componentType: sourceData.componentType,
|
5212
|
+
type: "move",
|
5213
|
+
index: targetIndex,
|
5214
|
+
zone: targetZone,
|
5215
|
+
props: item.props
|
5216
|
+
}
|
5217
|
+
}
|
5218
|
+
});
|
4897
5219
|
}
|
4898
5220
|
}
|
4899
|
-
(
|
5221
|
+
(_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
|
4900
5222
|
fn(event, manager);
|
4901
5223
|
});
|
4902
5224
|
},
|
@@ -4906,46 +5228,62 @@ var DragDropContextClient = ({
|
|
4906
5228
|
type: "setUi",
|
4907
5229
|
ui: { itemSelector: null, isDragging: true }
|
4908
5230
|
});
|
5231
|
+
const { source } = event.operation;
|
5232
|
+
if (source && source.type !== "void") {
|
5233
|
+
const sourceData = source.data;
|
5234
|
+
const item = getItem(
|
5235
|
+
{
|
5236
|
+
zone: sourceData.zone,
|
5237
|
+
index: sourceData.index
|
5238
|
+
},
|
5239
|
+
data
|
5240
|
+
);
|
5241
|
+
if (item) {
|
5242
|
+
zoneStore.setState({
|
5243
|
+
previewIndex: {
|
5244
|
+
[sourceData.zone]: {
|
5245
|
+
componentType: sourceData.componentType,
|
5246
|
+
type: "move",
|
5247
|
+
index: sourceData.index,
|
5248
|
+
zone: sourceData.zone,
|
5249
|
+
props: item.props
|
5250
|
+
}
|
5251
|
+
}
|
5252
|
+
});
|
5253
|
+
}
|
5254
|
+
}
|
4909
5255
|
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4910
5256
|
fn(event, manager);
|
4911
5257
|
});
|
4912
5258
|
},
|
4913
5259
|
onBeforeDragStart: (event) => {
|
4914
5260
|
var _a;
|
4915
|
-
if (draggedItem) {
|
4916
|
-
console.warn("New drag started before previous drag cleaned up");
|
4917
|
-
}
|
4918
5261
|
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4919
5262
|
dragMode.current = isNewComponent ? "new" : "existing";
|
4920
5263
|
initialSelector.current = void 0;
|
4921
|
-
|
5264
|
+
zoneStore.setState({ draggedItem: event.operation.source });
|
4922
5265
|
},
|
4923
|
-
children: /* @__PURE__ */ (0,
|
5266
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4924
5267
|
DropZoneProvider,
|
4925
5268
|
{
|
4926
5269
|
value: {
|
4927
5270
|
data,
|
4928
5271
|
config,
|
4929
|
-
dispatch,
|
4930
|
-
draggedItem,
|
4931
5272
|
mode: "edit",
|
4932
5273
|
areaId: "root",
|
4933
5274
|
depth: 0,
|
4934
5275
|
registerPath,
|
5276
|
+
unregisterPath,
|
4935
5277
|
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
5278
|
path: []
|
4941
5279
|
},
|
4942
5280
|
children
|
4943
5281
|
}
|
4944
|
-
)
|
5282
|
+
) })
|
4945
5283
|
}
|
4946
|
-
)
|
5284
|
+
)
|
4947
5285
|
}
|
4948
|
-
);
|
5286
|
+
) });
|
4949
5287
|
};
|
4950
5288
|
var DragDropContext = ({
|
4951
5289
|
children,
|
@@ -4955,11 +5293,11 @@ var DragDropContext = ({
|
|
4955
5293
|
if (status === "LOADING") {
|
4956
5294
|
return children;
|
4957
5295
|
}
|
4958
|
-
return /* @__PURE__ */ (0,
|
5296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
4959
5297
|
};
|
4960
5298
|
|
4961
5299
|
// components/Drawer/index.tsx
|
4962
|
-
var
|
5300
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
4963
5301
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
4964
5302
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
4965
5303
|
var DrawerItemInner = ({
|
@@ -4969,11 +5307,11 @@ var DrawerItemInner = ({
|
|
4969
5307
|
dragRef,
|
4970
5308
|
isDragDisabled
|
4971
5309
|
}) => {
|
4972
|
-
const CustomInner = (0,
|
4973
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
5310
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5311
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
4974
5312
|
[children]
|
4975
5313
|
);
|
4976
|
-
return /* @__PURE__ */ (0,
|
5314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
4977
5315
|
"div",
|
4978
5316
|
{
|
4979
5317
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -4981,9 +5319,9 @@ var DrawerItemInner = ({
|
|
4981
5319
|
onMouseDown: (e) => e.preventDefault(),
|
4982
5320
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
4983
5321
|
"data-puck-drawer-item": true,
|
4984
|
-
children: /* @__PURE__ */ (0,
|
4985
|
-
/* @__PURE__ */ (0,
|
4986
|
-
/* @__PURE__ */ (0,
|
5322
|
+
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: [
|
5323
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
5324
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragIcon, {}) })
|
4987
5325
|
] }) }) })
|
4988
5326
|
}
|
4989
5327
|
);
|
@@ -5000,9 +5338,9 @@ var DrawerItemDraggable = ({
|
|
5000
5338
|
data: { type: "drawer", componentType: name },
|
5001
5339
|
disabled: isDragDisabled
|
5002
5340
|
});
|
5003
|
-
return /* @__PURE__ */ (0,
|
5004
|
-
/* @__PURE__ */ (0,
|
5005
|
-
/* @__PURE__ */ (0,
|
5341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName18("draggable"), children: [
|
5342
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DrawerItemInner, { name, label, children }) }),
|
5343
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5006
5344
|
DrawerItemInner,
|
5007
5345
|
{
|
5008
5346
|
name,
|
@@ -5023,7 +5361,7 @@ var DrawerItem = ({
|
|
5023
5361
|
isDragDisabled
|
5024
5362
|
}) => {
|
5025
5363
|
const resolvedId = id || name;
|
5026
|
-
const [dynamicId, setDynamicId] = (0,
|
5364
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5027
5365
|
if (typeof index !== "undefined") {
|
5028
5366
|
console.error(
|
5029
5367
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5036,7 +5374,7 @@ var DrawerItem = ({
|
|
5036
5374
|
},
|
5037
5375
|
[resolvedId]
|
5038
5376
|
);
|
5039
|
-
return /* @__PURE__ */ (0,
|
5377
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5040
5378
|
DrawerItemDraggable,
|
5041
5379
|
{
|
5042
5380
|
name,
|
@@ -5062,14 +5400,14 @@ var Drawer = ({
|
|
5062
5400
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5063
5401
|
);
|
5064
5402
|
}
|
5065
|
-
const
|
5403
|
+
const id = (0, import_react32.useId)();
|
5066
5404
|
const { ref } = useDroppableSafe({
|
5067
5405
|
id,
|
5068
5406
|
type: "void",
|
5069
5407
|
collisionPriority: 0
|
5070
5408
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
5071
5409
|
});
|
5072
|
-
return /* @__PURE__ */ (0,
|
5410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5073
5411
|
"div",
|
5074
5412
|
{
|
5075
5413
|
className: getClassName18(),
|
@@ -5084,7 +5422,7 @@ Drawer.Item = DrawerItem;
|
|
5084
5422
|
|
5085
5423
|
// components/Puck/index.tsx
|
5086
5424
|
init_react_import();
|
5087
|
-
var
|
5425
|
+
var import_react50 = require("react");
|
5088
5426
|
|
5089
5427
|
// components/SidebarSection/index.tsx
|
5090
5428
|
init_react_import();
|
@@ -5095,7 +5433,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
5095
5433
|
|
5096
5434
|
// lib/use-breadcrumbs.ts
|
5097
5435
|
init_react_import();
|
5098
|
-
var
|
5436
|
+
var import_react33 = require("react");
|
5099
5437
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5100
5438
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5101
5439
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5145,8 +5483,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5145
5483
|
state: { data },
|
5146
5484
|
selectedItem
|
5147
5485
|
} = useAppContext();
|
5148
|
-
const dzContext = (0,
|
5149
|
-
return (0,
|
5486
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5487
|
+
return (0, import_react33.useMemo)(() => {
|
5150
5488
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5151
5489
|
selectedItem,
|
5152
5490
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5160,7 +5498,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
5160
5498
|
};
|
5161
5499
|
|
5162
5500
|
// components/SidebarSection/index.tsx
|
5163
|
-
var
|
5501
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
5164
5502
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5165
5503
|
var SidebarSection = ({
|
5166
5504
|
children,
|
@@ -5173,15 +5511,15 @@ var SidebarSection = ({
|
|
5173
5511
|
}) => {
|
5174
5512
|
const { setUi } = useAppContext();
|
5175
5513
|
const breadcrumbs = useBreadcrumbs(1);
|
5176
|
-
return /* @__PURE__ */ (0,
|
5514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
5177
5515
|
"div",
|
5178
5516
|
{
|
5179
5517
|
className: getClassName19({ noBorderTop, noPadding }),
|
5180
5518
|
style: { background },
|
5181
5519
|
children: [
|
5182
|
-
/* @__PURE__ */ (0,
|
5183
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
5184
|
-
/* @__PURE__ */ (0,
|
5520
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
5521
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
5522
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5185
5523
|
"button",
|
5186
5524
|
{
|
5187
5525
|
type: "button",
|
@@ -5190,12 +5528,12 @@ var SidebarSection = ({
|
|
5190
5528
|
children: breadcrumb.label
|
5191
5529
|
}
|
5192
5530
|
),
|
5193
|
-
/* @__PURE__ */ (0,
|
5531
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
|
5194
5532
|
] }, i)) : null,
|
5195
|
-
/* @__PURE__ */ (0,
|
5533
|
+
/* @__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
5534
|
] }) }),
|
5197
|
-
/* @__PURE__ */ (0,
|
5198
|
-
isLoading && /* @__PURE__ */ (0,
|
5535
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
|
5536
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
|
5199
5537
|
]
|
5200
5538
|
}
|
5201
5539
|
);
|
@@ -5226,7 +5564,7 @@ init_react_import();
|
|
5226
5564
|
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
5565
|
|
5228
5566
|
// components/MenuBar/index.tsx
|
5229
|
-
var
|
5567
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
5230
5568
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5231
5569
|
function MenuBar({
|
5232
5570
|
appState,
|
@@ -5240,7 +5578,7 @@ function MenuBar({
|
|
5240
5578
|
history: { back, forward, historyStore }
|
5241
5579
|
} = useAppContext();
|
5242
5580
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5243
|
-
return /* @__PURE__ */ (0,
|
5581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
5244
5582
|
"div",
|
5245
5583
|
{
|
5246
5584
|
className: getClassName20({ menuOpen }),
|
@@ -5254,12 +5592,12 @@ function MenuBar({
|
|
5254
5592
|
setMenuOpen(false);
|
5255
5593
|
}
|
5256
5594
|
},
|
5257
|
-
children: /* @__PURE__ */ (0,
|
5258
|
-
/* @__PURE__ */ (0,
|
5259
|
-
/* @__PURE__ */ (0,
|
5260
|
-
/* @__PURE__ */ (0,
|
5595
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
|
5596
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
|
5597
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
|
5598
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
|
5261
5599
|
] }),
|
5262
|
-
/* @__PURE__ */ (0,
|
5600
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
5263
5601
|
state: appState,
|
5264
5602
|
dispatch
|
5265
5603
|
}) })
|
@@ -5270,43 +5608,68 @@ function MenuBar({
|
|
5270
5608
|
|
5271
5609
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5272
5610
|
init_react_import();
|
5273
|
-
var styles_module_default15 = { "Puck": "
|
5611
|
+
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
5612
|
|
5275
5613
|
// components/Puck/components/Fields/index.tsx
|
5276
5614
|
init_react_import();
|
5277
5615
|
|
5278
5616
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5279
5617
|
init_react_import();
|
5280
|
-
var styles_module_default16 = { "PuckFields": "
|
5618
|
+
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
5619
|
|
5282
5620
|
// components/Puck/components/Fields/index.tsx
|
5283
|
-
var
|
5621
|
+
var import_react37 = require("react");
|
5622
|
+
|
5623
|
+
// lib/use-resolved-fields.ts
|
5624
|
+
init_react_import();
|
5625
|
+
var import_react36 = require("react");
|
5284
5626
|
|
5285
5627
|
// lib/use-parent.ts
|
5286
5628
|
init_react_import();
|
5287
|
-
var
|
5288
|
-
var
|
5629
|
+
var import_react34 = require("react");
|
5630
|
+
var getParent = (itemSelector, pathData, data) => {
|
5289
5631
|
var _a;
|
5290
|
-
|
5291
|
-
const
|
5292
|
-
const
|
5293
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5632
|
+
if (!itemSelector) return null;
|
5633
|
+
const item = getItem(itemSelector, data);
|
5634
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5294
5635
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5295
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5636
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5296
5637
|
return parent || null;
|
5297
5638
|
};
|
5639
|
+
var useGetParent = () => {
|
5640
|
+
const { state } = useAppContext();
|
5641
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5642
|
+
return (0, import_react34.useCallback)(
|
5643
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5644
|
+
[state.ui.itemSelector, pathData, state.data]
|
5645
|
+
);
|
5646
|
+
};
|
5647
|
+
var useParent = () => {
|
5648
|
+
return useGetParent()();
|
5649
|
+
};
|
5298
5650
|
|
5299
|
-
//
|
5300
|
-
|
5301
|
-
var
|
5651
|
+
// lib/use-on-value-change.ts
|
5652
|
+
init_react_import();
|
5653
|
+
var import_react35 = require("react");
|
5654
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5655
|
+
const tracked = (0, import_react35.useRef)(value);
|
5656
|
+
(0, import_react35.useEffect)(() => {
|
5657
|
+
const oldValue = tracked.current;
|
5658
|
+
if (!compare(value, oldValue)) {
|
5659
|
+
tracked.current = value;
|
5660
|
+
onChange(value, oldValue);
|
5661
|
+
}
|
5662
|
+
}, [onChange, compare, value, ...deps]);
|
5663
|
+
}
|
5664
|
+
|
5665
|
+
// lib/selector-is.ts
|
5666
|
+
init_react_import();
|
5667
|
+
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);
|
5668
|
+
|
5669
|
+
// lib/use-resolved-fields.ts
|
5302
5670
|
var defaultPageFields = {
|
5303
5671
|
title: { type: "text" }
|
5304
5672
|
};
|
5305
|
-
var DefaultFields = ({
|
5306
|
-
children
|
5307
|
-
}) => {
|
5308
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
|
5309
|
-
};
|
5310
5673
|
var useResolvedFields = () => {
|
5311
5674
|
var _a, _b;
|
5312
5675
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5314,20 +5677,21 @@ var useResolvedFields = () => {
|
|
5314
5677
|
const { data } = state;
|
5315
5678
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5316
5679
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5317
|
-
const defaultFields = (0,
|
5680
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5318
5681
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5319
5682
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5320
5683
|
);
|
5321
5684
|
const rootProps = data.root.props || data.root;
|
5322
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5323
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5324
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5685
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5686
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
|
5687
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5688
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5325
5689
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5326
5690
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5327
5691
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5328
5692
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5329
5693
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5330
|
-
const resolveFields = (0,
|
5694
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5331
5695
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5332
5696
|
var _a2;
|
5333
5697
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5339,7 +5703,7 @@ var useResolvedFields = () => {
|
|
5339
5703
|
{
|
5340
5704
|
changed,
|
5341
5705
|
fields,
|
5342
|
-
lastFields:
|
5706
|
+
lastFields: lastFields.current,
|
5343
5707
|
lastData,
|
5344
5708
|
appState: state,
|
5345
5709
|
parent
|
@@ -5350,7 +5714,7 @@ var useResolvedFields = () => {
|
|
5350
5714
|
return yield config.root.resolveFields(componentData, {
|
5351
5715
|
changed,
|
5352
5716
|
fields,
|
5353
|
-
lastFields:
|
5717
|
+
lastFields: lastFields.current,
|
5354
5718
|
lastData,
|
5355
5719
|
appState: state,
|
5356
5720
|
parent
|
@@ -5359,26 +5723,56 @@ var useResolvedFields = () => {
|
|
5359
5723
|
return defaultResolveFields(componentData, {
|
5360
5724
|
changed,
|
5361
5725
|
fields,
|
5362
|
-
lastFields:
|
5726
|
+
lastFields: lastFields.current,
|
5363
5727
|
lastData
|
5364
5728
|
});
|
5365
5729
|
}),
|
5366
|
-
[data, config, componentData, selectedItem,
|
5730
|
+
[data, config, componentData, selectedItem, state, parent]
|
5367
5731
|
);
|
5368
|
-
(0,
|
5369
|
-
|
5370
|
-
|
5371
|
-
|
5372
|
-
|
5373
|
-
|
5374
|
-
|
5375
|
-
|
5376
|
-
|
5732
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5733
|
+
var _a2, _b2;
|
5734
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5735
|
+
if (hasResolver) {
|
5736
|
+
setFieldsLoading(true);
|
5737
|
+
resolveFields(defaultFields).then((fields) => {
|
5738
|
+
setResolvedFields(fields || {});
|
5739
|
+
lastFields.current = fields;
|
5740
|
+
setFieldsLoading(false);
|
5741
|
+
});
|
5742
|
+
return;
|
5743
|
+
}
|
5377
5744
|
}
|
5378
|
-
|
5745
|
+
setResolvedFields(defaultFields);
|
5746
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5747
|
+
useOnValueChange(
|
5748
|
+
state.ui.itemSelector,
|
5749
|
+
() => {
|
5750
|
+
lastFields.current = defaultFields;
|
5751
|
+
},
|
5752
|
+
selectorIs
|
5753
|
+
);
|
5754
|
+
useOnValueChange(
|
5755
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5756
|
+
() => {
|
5757
|
+
triggerResolver();
|
5758
|
+
},
|
5759
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5760
|
+
);
|
5761
|
+
(0, import_react36.useEffect)(() => {
|
5762
|
+
triggerResolver();
|
5763
|
+
}, []);
|
5379
5764
|
return [resolvedFields, fieldsLoading];
|
5380
5765
|
};
|
5381
|
-
|
5766
|
+
|
5767
|
+
// components/Puck/components/Fields/index.tsx
|
5768
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
5769
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5770
|
+
var DefaultFields = ({
|
5771
|
+
children
|
5772
|
+
}) => {
|
5773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5774
|
+
};
|
5775
|
+
var Fields = ({ wrapFields = true }) => {
|
5382
5776
|
var _a, _b;
|
5383
5777
|
const {
|
5384
5778
|
selectedItem,
|
@@ -5396,16 +5790,16 @@ var Fields = () => {
|
|
5396
5790
|
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
5791
|
const isLoading = fieldsResolving || componentResolving;
|
5398
5792
|
const rootProps = data.root.props || data.root;
|
5399
|
-
const Wrapper = (0,
|
5400
|
-
return /* @__PURE__ */ (0,
|
5793
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5401
5795
|
"form",
|
5402
5796
|
{
|
5403
|
-
className: getClassName21(),
|
5797
|
+
className: getClassName21({ wrapFields }),
|
5404
5798
|
onSubmit: (e) => {
|
5405
5799
|
e.preventDefault();
|
5406
5800
|
},
|
5407
5801
|
children: [
|
5408
|
-
/* @__PURE__ */ (0,
|
5802
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5409
5803
|
const field = fields[fieldName];
|
5410
5804
|
if (!(field == null ? void 0 : field.type)) return null;
|
5411
5805
|
const onChange = (value, updatedUi) => {
|
@@ -5476,7 +5870,7 @@ var Fields = () => {
|
|
5476
5870
|
item: selectedItem
|
5477
5871
|
});
|
5478
5872
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5479
|
-
return /* @__PURE__ */ (0,
|
5873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5480
5874
|
AutoFieldPrivate,
|
5481
5875
|
{
|
5482
5876
|
field,
|
@@ -5485,16 +5879,15 @@ var Fields = () => {
|
|
5485
5879
|
readOnly: !edit || readOnly[fieldName],
|
5486
5880
|
value: selectedItem.props[fieldName],
|
5487
5881
|
onChange
|
5488
|
-
}
|
5489
|
-
|
5490
|
-
);
|
5882
|
+
}
|
5883
|
+
) }, id);
|
5491
5884
|
} else {
|
5492
5885
|
const readOnly = data.root.readOnly || {};
|
5493
5886
|
const { edit } = getPermissions({
|
5494
5887
|
root: true
|
5495
5888
|
});
|
5496
5889
|
const id = `root_${field.type}_${fieldName}`;
|
5497
|
-
return /* @__PURE__ */ (0,
|
5890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5498
5891
|
AutoFieldPrivate,
|
5499
5892
|
{
|
5500
5893
|
field,
|
@@ -5503,12 +5896,11 @@ var Fields = () => {
|
|
5503
5896
|
readOnly: !edit || readOnly[fieldName],
|
5504
5897
|
value: rootProps[fieldName],
|
5505
5898
|
onChange
|
5506
|
-
}
|
5507
|
-
|
5508
|
-
);
|
5899
|
+
}
|
5900
|
+
) }, id);
|
5509
5901
|
}
|
5510
5902
|
}) }),
|
5511
|
-
isLoading && /* @__PURE__ */ (0,
|
5903
|
+
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
5904
|
]
|
5513
5905
|
}
|
5514
5906
|
);
|
@@ -5519,7 +5911,7 @@ init_react_import();
|
|
5519
5911
|
|
5520
5912
|
// lib/use-component-list.tsx
|
5521
5913
|
init_react_import();
|
5522
|
-
var
|
5914
|
+
var import_react38 = require("react");
|
5523
5915
|
|
5524
5916
|
// components/ComponentList/index.tsx
|
5525
5917
|
init_react_import();
|
@@ -5529,7 +5921,7 @@ init_react_import();
|
|
5529
5921
|
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
5922
|
|
5531
5923
|
// components/ComponentList/index.tsx
|
5532
|
-
var
|
5924
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
5533
5925
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5534
5926
|
var ComponentListItem = ({
|
5535
5927
|
name,
|
@@ -5539,7 +5931,7 @@ var ComponentListItem = ({
|
|
5539
5931
|
const canInsert = getPermissions({
|
5540
5932
|
type: name
|
5541
5933
|
}).insert;
|
5542
|
-
return /* @__PURE__ */ (0,
|
5934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5543
5935
|
};
|
5544
5936
|
var ComponentList = ({
|
5545
5937
|
children,
|
@@ -5548,8 +5940,8 @@ var ComponentList = ({
|
|
5548
5940
|
}) => {
|
5549
5941
|
const { config, state, setUi } = useAppContext();
|
5550
5942
|
const { expanded = true } = state.ui.componentList[id] || {};
|
5551
|
-
return /* @__PURE__ */ (0,
|
5552
|
-
title && /* @__PURE__ */ (0,
|
5943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
5944
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
5553
5945
|
"button",
|
5554
5946
|
{
|
5555
5947
|
type: "button",
|
@@ -5563,14 +5955,14 @@ var ComponentList = ({
|
|
5563
5955
|
}),
|
5564
5956
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5565
5957
|
children: [
|
5566
|
-
/* @__PURE__ */ (0,
|
5567
|
-
/* @__PURE__ */ (0,
|
5958
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
|
5959
|
+
/* @__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
5960
|
]
|
5569
5961
|
}
|
5570
5962
|
),
|
5571
|
-
/* @__PURE__ */ (0,
|
5963
|
+
/* @__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
5964
|
var _a;
|
5573
|
-
return /* @__PURE__ */ (0,
|
5965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
5574
5966
|
ComponentListItem,
|
5575
5967
|
{
|
5576
5968
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5584,10 +5976,10 @@ var ComponentList = ({
|
|
5584
5976
|
ComponentList.Item = ComponentListItem;
|
5585
5977
|
|
5586
5978
|
// lib/use-component-list.tsx
|
5587
|
-
var
|
5979
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5588
5980
|
var useComponentList = (config, ui) => {
|
5589
|
-
const [componentList, setComponentList] = (0,
|
5590
|
-
(0,
|
5981
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
5982
|
+
(0, import_react38.useEffect)(() => {
|
5591
5983
|
var _a, _b, _c;
|
5592
5984
|
if (Object.keys(ui.componentList).length > 0) {
|
5593
5985
|
const matchedComponents = [];
|
@@ -5597,7 +5989,7 @@ var useComponentList = (config, ui) => {
|
|
5597
5989
|
if (category.visible === false || !category.components) {
|
5598
5990
|
return null;
|
5599
5991
|
}
|
5600
|
-
return /* @__PURE__ */ (0,
|
5992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5601
5993
|
ComponentList,
|
5602
5994
|
{
|
5603
5995
|
id: categoryKey,
|
@@ -5606,7 +5998,7 @@ var useComponentList = (config, ui) => {
|
|
5606
5998
|
var _a2;
|
5607
5999
|
matchedComponents.push(componentName);
|
5608
6000
|
const componentConf = config.components[componentName] || {};
|
5609
|
-
return /* @__PURE__ */ (0,
|
6001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5610
6002
|
ComponentList.Item,
|
5611
6003
|
{
|
5612
6004
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5626,7 +6018,7 @@ var useComponentList = (config, ui) => {
|
|
5626
6018
|
);
|
5627
6019
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5628
6020
|
_componentList.push(
|
5629
|
-
/* @__PURE__ */ (0,
|
6021
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5630
6022
|
ComponentList,
|
5631
6023
|
{
|
5632
6024
|
id: "other",
|
@@ -5634,7 +6026,7 @@ var useComponentList = (config, ui) => {
|
|
5634
6026
|
children: remainingComponents.map((componentName, i) => {
|
5635
6027
|
var _a2;
|
5636
6028
|
const componentConf = config.components[componentName] || {};
|
5637
|
-
return /* @__PURE__ */ (0,
|
6029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
5638
6030
|
ComponentList.Item,
|
5639
6031
|
{
|
5640
6032
|
name: componentName,
|
@@ -5656,25 +6048,25 @@ var useComponentList = (config, ui) => {
|
|
5656
6048
|
};
|
5657
6049
|
|
5658
6050
|
// components/Puck/components/Components/index.tsx
|
5659
|
-
var
|
5660
|
-
var
|
6051
|
+
var import_react39 = require("react");
|
6052
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5661
6053
|
var Components = () => {
|
5662
6054
|
const { config, state, overrides } = useAppContext();
|
5663
6055
|
const componentList = useComponentList(config, state.ui);
|
5664
|
-
const Wrapper = (0,
|
5665
|
-
return /* @__PURE__ */ (0,
|
6056
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6057
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
5666
6058
|
};
|
5667
6059
|
|
5668
6060
|
// components/Puck/components/Preview/index.tsx
|
5669
6061
|
init_react_import();
|
5670
|
-
var
|
6062
|
+
var import_react41 = require("react");
|
5671
6063
|
|
5672
6064
|
// components/AutoFrame/index.tsx
|
5673
6065
|
init_react_import();
|
5674
|
-
var
|
6066
|
+
var import_react40 = require("react");
|
5675
6067
|
var import_object_hash = __toESM(require("object-hash"));
|
5676
6068
|
var import_react_dom3 = require("react-dom");
|
5677
|
-
var
|
6069
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
5678
6070
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5679
6071
|
var collectStyles = (doc) => {
|
5680
6072
|
const collected = [];
|
@@ -5717,7 +6109,7 @@ var CopyHostStyles = ({
|
|
5717
6109
|
onStylesLoaded = () => null
|
5718
6110
|
}) => {
|
5719
6111
|
const { document: doc, window: win } = useFrame();
|
5720
|
-
(0,
|
6112
|
+
(0, import_react40.useEffect)(() => {
|
5721
6113
|
if (!win || !doc) {
|
5722
6114
|
return () => {
|
5723
6115
|
};
|
@@ -5874,10 +6266,10 @@ var CopyHostStyles = ({
|
|
5874
6266
|
observer.disconnect();
|
5875
6267
|
};
|
5876
6268
|
}, []);
|
5877
|
-
return /* @__PURE__ */ (0,
|
6269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
5878
6270
|
};
|
5879
|
-
var autoFrameContext = (0,
|
5880
|
-
var useFrame = () => (0,
|
6271
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6272
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
5881
6273
|
function AutoFrame(_a) {
|
5882
6274
|
var _b = _a, {
|
5883
6275
|
children,
|
@@ -5894,10 +6286,10 @@ function AutoFrame(_a) {
|
|
5894
6286
|
"onStylesLoaded",
|
5895
6287
|
"frameRef"
|
5896
6288
|
]);
|
5897
|
-
const [loaded, setLoaded] = (0,
|
5898
|
-
const [ctx, setCtx] = (0,
|
5899
|
-
const [mountTarget, setMountTarget] = (0,
|
5900
|
-
(0,
|
6289
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6290
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6291
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6292
|
+
(0, import_react40.useEffect)(() => {
|
5901
6293
|
var _a2;
|
5902
6294
|
if (frameRef.current) {
|
5903
6295
|
setCtx({
|
@@ -5909,7 +6301,7 @@ function AutoFrame(_a) {
|
|
5909
6301
|
);
|
5910
6302
|
}
|
5911
6303
|
}, [frameRef, loaded]);
|
5912
|
-
return /* @__PURE__ */ (0,
|
6304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
5913
6305
|
"iframe",
|
5914
6306
|
__spreadProps(__spreadValues({}, props), {
|
5915
6307
|
className,
|
@@ -5919,7 +6311,7 @@ function AutoFrame(_a) {
|
|
5919
6311
|
onLoad: () => {
|
5920
6312
|
setLoaded(true);
|
5921
6313
|
},
|
5922
|
-
children: /* @__PURE__ */ (0,
|
6314
|
+
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
6315
|
})
|
5924
6316
|
);
|
5925
6317
|
}
|
@@ -5930,12 +6322,68 @@ var AutoFrame_default = AutoFrame;
|
|
5930
6322
|
init_react_import();
|
5931
6323
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
5932
6324
|
|
6325
|
+
// components/Render/index.tsx
|
6326
|
+
init_react_import();
|
6327
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
6328
|
+
function Render({
|
6329
|
+
config,
|
6330
|
+
data
|
6331
|
+
}) {
|
6332
|
+
var _a;
|
6333
|
+
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
6334
|
+
root: data.root || {},
|
6335
|
+
content: data.content || []
|
6336
|
+
});
|
6337
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
6338
|
+
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
6339
|
+
if ((_a = config.root) == null ? void 0 : _a.render) {
|
6340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6341
|
+
DropZoneProvider,
|
6342
|
+
{
|
6343
|
+
value: {
|
6344
|
+
data: defaultedData,
|
6345
|
+
config,
|
6346
|
+
mode: "render",
|
6347
|
+
depth: 0,
|
6348
|
+
path: []
|
6349
|
+
},
|
6350
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6351
|
+
config.root.render,
|
6352
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
6353
|
+
puck: {
|
6354
|
+
renderDropZone: DropZone,
|
6355
|
+
isEditing: false
|
6356
|
+
},
|
6357
|
+
title,
|
6358
|
+
editMode: false,
|
6359
|
+
id: "puck-root",
|
6360
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6361
|
+
})
|
6362
|
+
)
|
6363
|
+
}
|
6364
|
+
);
|
6365
|
+
}
|
6366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6367
|
+
DropZoneProvider,
|
6368
|
+
{
|
6369
|
+
value: {
|
6370
|
+
data: defaultedData,
|
6371
|
+
config,
|
6372
|
+
mode: "render",
|
6373
|
+
depth: 0,
|
6374
|
+
path: []
|
6375
|
+
},
|
6376
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
6377
|
+
}
|
6378
|
+
);
|
6379
|
+
}
|
6380
|
+
|
5933
6381
|
// components/Puck/components/Preview/index.tsx
|
5934
|
-
var
|
6382
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
5935
6383
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5936
6384
|
var useBubbleIframeEvents = (ref) => {
|
5937
6385
|
const { status } = useAppContext();
|
5938
|
-
(0,
|
6386
|
+
(0, import_react41.useEffect)(() => {
|
5939
6387
|
var _a;
|
5940
6388
|
if (ref.current && status === "READY") {
|
5941
6389
|
const iframe = ref.current;
|
@@ -5972,22 +6420,34 @@ var useBubbleIframeEvents = (ref) => {
|
|
5972
6420
|
}
|
5973
6421
|
}, [status]);
|
5974
6422
|
};
|
5975
|
-
var
|
6423
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
5976
6424
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
5977
|
-
const Page = (0,
|
6425
|
+
const Page = (0, import_react41.useCallback)(
|
5978
6426
|
(pageProps) => {
|
5979
6427
|
var _a, _b;
|
5980
6428
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
5981
6429
|
id: "puck-root"
|
5982
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
6430
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
5983
6431
|
},
|
5984
6432
|
[config.root]
|
5985
6433
|
);
|
5986
|
-
const Frame = (0,
|
6434
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
5987
6435
|
const rootProps = state.data.root.props || state.data.root;
|
5988
|
-
const ref = (0,
|
6436
|
+
const ref = (0, import_react41.useRef)(null);
|
5989
6437
|
useBubbleIframeEvents(ref);
|
5990
|
-
|
6438
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6439
|
+
Page,
|
6440
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
6441
|
+
puck: {
|
6442
|
+
renderDropZone: DropZone,
|
6443
|
+
isEditing: true,
|
6444
|
+
dragRef: null
|
6445
|
+
},
|
6446
|
+
editMode: true,
|
6447
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
6448
|
+
})
|
6449
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
|
6450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
5991
6451
|
"div",
|
5992
6452
|
{
|
5993
6453
|
className: getClassName23(),
|
@@ -5996,7 +6456,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5996
6456
|
onClick: () => {
|
5997
6457
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
5998
6458
|
},
|
5999
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
6459
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6000
6460
|
AutoFrame_default,
|
6001
6461
|
{
|
6002
6462
|
id: "preview-frame",
|
@@ -6006,40 +6466,21 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6006
6466
|
setStatus("READY");
|
6007
6467
|
},
|
6008
6468
|
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
|
-
);
|
6469
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
6022
6470
|
if (Frame) {
|
6023
|
-
return /* @__PURE__ */ (0,
|
6471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
6024
6472
|
}
|
6025
6473
|
return inner;
|
6026
6474
|
} })
|
6027
6475
|
}
|
6028
|
-
) : /* @__PURE__ */ (0,
|
6476
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6029
6477
|
"div",
|
6030
6478
|
{
|
6031
6479
|
id: "preview-frame",
|
6032
6480
|
className: getClassName23("frame"),
|
6033
6481
|
ref,
|
6034
6482
|
"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
|
-
)
|
6483
|
+
children: inner
|
6043
6484
|
}
|
6044
6485
|
)
|
6045
6486
|
}
|
@@ -6089,7 +6530,7 @@ var scrollIntoView = (el) => {
|
|
6089
6530
|
};
|
6090
6531
|
|
6091
6532
|
// components/LayerTree/index.tsx
|
6092
|
-
var
|
6533
|
+
var import_react42 = require("react");
|
6093
6534
|
|
6094
6535
|
// lib/is-child-of-zone.ts
|
6095
6536
|
init_react_import();
|
@@ -6122,7 +6563,7 @@ var onScrollEnd = (frame, cb) => {
|
|
6122
6563
|
};
|
6123
6564
|
|
6124
6565
|
// components/LayerTree/index.tsx
|
6125
|
-
var
|
6566
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6126
6567
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6127
6568
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6128
6569
|
var LayerTree = ({
|
@@ -6135,15 +6576,15 @@ var LayerTree = ({
|
|
6135
6576
|
label
|
6136
6577
|
}) => {
|
6137
6578
|
const zones = data.zones || {};
|
6138
|
-
const ctx = (0,
|
6139
|
-
return /* @__PURE__ */ (0,
|
6140
|
-
label && /* @__PURE__ */ (0,
|
6141
|
-
/* @__PURE__ */ (0,
|
6579
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6580
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6581
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6582
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
6142
6583
|
" ",
|
6143
6584
|
label
|
6144
6585
|
] }),
|
6145
|
-
/* @__PURE__ */ (0,
|
6146
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
6586
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
|
6587
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
6147
6588
|
zoneContent.map((item, i) => {
|
6148
6589
|
var _a;
|
6149
6590
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6156,7 +6597,7 @@ var LayerTree = ({
|
|
6156
6597
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
6157
6598
|
const componentConfig = config.components[item.type];
|
6158
6599
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
6159
|
-
return /* @__PURE__ */ (0,
|
6600
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6160
6601
|
"li",
|
6161
6602
|
{
|
6162
6603
|
className: getClassNameLayer({
|
@@ -6166,7 +6607,7 @@ var LayerTree = ({
|
|
6166
6607
|
childIsSelected
|
6167
6608
|
}),
|
6168
6609
|
children: [
|
6169
|
-
/* @__PURE__ */ (0,
|
6610
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
6170
6611
|
"button",
|
6171
6612
|
{
|
6172
6613
|
type: "button",
|
@@ -6205,22 +6646,22 @@ var LayerTree = ({
|
|
6205
6646
|
setHoveringComponent(null);
|
6206
6647
|
},
|
6207
6648
|
children: [
|
6208
|
-
containsZone && /* @__PURE__ */ (0,
|
6649
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6209
6650
|
"div",
|
6210
6651
|
{
|
6211
6652
|
className: getClassNameLayer("chevron"),
|
6212
6653
|
title: isSelected ? "Collapse" : "Expand",
|
6213
|
-
children: /* @__PURE__ */ (0,
|
6654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
6214
6655
|
}
|
6215
6656
|
),
|
6216
|
-
/* @__PURE__ */ (0,
|
6217
|
-
/* @__PURE__ */ (0,
|
6218
|
-
/* @__PURE__ */ (0,
|
6657
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
6658
|
+
/* @__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" }) }),
|
6659
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
6219
6660
|
] })
|
6220
6661
|
]
|
6221
6662
|
}
|
6222
6663
|
) }),
|
6223
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
6664
|
+
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
6665
|
LayerTree,
|
6225
6666
|
{
|
6226
6667
|
config,
|
@@ -6242,13 +6683,13 @@ var LayerTree = ({
|
|
6242
6683
|
};
|
6243
6684
|
|
6244
6685
|
// components/Puck/components/Outline/index.tsx
|
6245
|
-
var
|
6246
|
-
var
|
6686
|
+
var import_react43 = require("react");
|
6687
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6247
6688
|
var Outline = () => {
|
6248
6689
|
const { dispatch, state, overrides, config } = useAppContext();
|
6249
6690
|
const { data, ui } = state;
|
6250
6691
|
const { itemSelector } = ui;
|
6251
|
-
const setItemSelector = (0,
|
6692
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6252
6693
|
(newItemSelector) => {
|
6253
6694
|
dispatch({
|
6254
6695
|
type: "setUi",
|
@@ -6257,9 +6698,9 @@ var Outline = () => {
|
|
6257
6698
|
},
|
6258
6699
|
[]
|
6259
6700
|
);
|
6260
|
-
const Wrapper = (0,
|
6261
|
-
return /* @__PURE__ */ (0,
|
6262
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
6701
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6702
|
+
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: [
|
6703
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6263
6704
|
LayerTree,
|
6264
6705
|
{
|
6265
6706
|
config,
|
@@ -6272,7 +6713,7 @@ var Outline = () => {
|
|
6272
6713
|
),
|
6273
6714
|
Object.entries(findZonesForArea(data, "root")).map(
|
6274
6715
|
([zoneKey, zone]) => {
|
6275
|
-
return /* @__PURE__ */ (0,
|
6716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6276
6717
|
LayerTree,
|
6277
6718
|
{
|
6278
6719
|
config,
|
@@ -6371,19 +6812,19 @@ function usePuckHistory({
|
|
6371
6812
|
|
6372
6813
|
// lib/use-history-store.ts
|
6373
6814
|
init_react_import();
|
6374
|
-
var
|
6815
|
+
var import_react44 = require("react");
|
6375
6816
|
var import_use_debounce3 = require("use-debounce");
|
6376
6817
|
var EMPTY_HISTORY_INDEX = 0;
|
6377
6818
|
function useHistoryStore(initialHistory) {
|
6378
6819
|
var _a, _b;
|
6379
|
-
const [histories, setHistories] = (0,
|
6820
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6380
6821
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6381
6822
|
);
|
6382
6823
|
const updateHistories = (histories2) => {
|
6383
6824
|
setHistories(histories2);
|
6384
6825
|
setIndex(histories2.length - 1);
|
6385
6826
|
};
|
6386
|
-
const [index, setIndex] = (0,
|
6827
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6387
6828
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6388
6829
|
);
|
6389
6830
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6543,22 +6984,22 @@ var getBox = function getBox2(el) {
|
|
6543
6984
|
};
|
6544
6985
|
|
6545
6986
|
// components/Puck/components/Canvas/index.tsx
|
6546
|
-
var
|
6987
|
+
var import_react46 = require("react");
|
6547
6988
|
|
6548
6989
|
// components/ViewportControls/index.tsx
|
6549
6990
|
init_react_import();
|
6550
|
-
var
|
6991
|
+
var import_react45 = require("react");
|
6551
6992
|
|
6552
6993
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6553
6994
|
init_react_import();
|
6554
6995
|
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
6996
|
|
6556
6997
|
// components/ViewportControls/index.tsx
|
6557
|
-
var
|
6998
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
6558
6999
|
var icons = {
|
6559
|
-
Smartphone: /* @__PURE__ */ (0,
|
6560
|
-
Tablet: /* @__PURE__ */ (0,
|
6561
|
-
Monitor: /* @__PURE__ */ (0,
|
7000
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
|
7001
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
|
7002
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
|
6562
7003
|
};
|
6563
7004
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6564
7005
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6570,11 +7011,11 @@ var ViewportButton = ({
|
|
6570
7011
|
onClick
|
6571
7012
|
}) => {
|
6572
7013
|
const { state } = useAppContext();
|
6573
|
-
const [isActive, setIsActive] = (0,
|
6574
|
-
(0,
|
7014
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7015
|
+
(0, import_react45.useEffect)(() => {
|
6575
7016
|
setIsActive(width === state.ui.viewports.current.width);
|
6576
7017
|
}, [width, state.ui.viewports.current.width]);
|
6577
|
-
return /* @__PURE__ */ (0,
|
7018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6578
7019
|
IconButton,
|
6579
7020
|
{
|
6580
7021
|
title,
|
@@ -6583,7 +7024,7 @@ var ViewportButton = ({
|
|
6583
7024
|
e.stopPropagation();
|
6584
7025
|
onClick({ width, height });
|
6585
7026
|
},
|
6586
|
-
children: /* @__PURE__ */ (0,
|
7027
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
|
6587
7028
|
}
|
6588
7029
|
) });
|
6589
7030
|
};
|
@@ -6607,7 +7048,7 @@ var ViewportControls = ({
|
|
6607
7048
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6608
7049
|
(option) => option.value === autoZoom
|
6609
7050
|
);
|
6610
|
-
const zoomOptions = (0,
|
7051
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
6611
7052
|
() => [
|
6612
7053
|
...defaultZoomOptions,
|
6613
7054
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6619,8 +7060,8 @@ var ViewportControls = ({
|
|
6619
7060
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
6620
7061
|
[autoZoom]
|
6621
7062
|
);
|
6622
|
-
return /* @__PURE__ */ (0,
|
6623
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
7063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
|
7064
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6624
7065
|
ViewportButton,
|
6625
7066
|
{
|
6626
7067
|
height: viewport.height,
|
@@ -6631,8 +7072,8 @@ var ViewportControls = ({
|
|
6631
7072
|
},
|
6632
7073
|
i
|
6633
7074
|
)),
|
6634
|
-
/* @__PURE__ */ (0,
|
6635
|
-
/* @__PURE__ */ (0,
|
7075
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7076
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6636
7077
|
IconButton,
|
6637
7078
|
{
|
6638
7079
|
title: "Zoom viewport out",
|
@@ -6646,10 +7087,10 @@ var ViewportControls = ({
|
|
6646
7087
|
)].value
|
6647
7088
|
);
|
6648
7089
|
},
|
6649
|
-
children: /* @__PURE__ */ (0,
|
7090
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
|
6650
7091
|
}
|
6651
7092
|
),
|
6652
|
-
/* @__PURE__ */ (0,
|
7093
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6653
7094
|
IconButton,
|
6654
7095
|
{
|
6655
7096
|
title: "Zoom viewport in",
|
@@ -6663,11 +7104,11 @@ var ViewportControls = ({
|
|
6663
7104
|
)].value
|
6664
7105
|
);
|
6665
7106
|
},
|
6666
|
-
children: /* @__PURE__ */ (0,
|
7107
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
|
6667
7108
|
}
|
6668
7109
|
),
|
6669
|
-
/* @__PURE__ */ (0,
|
6670
|
-
/* @__PURE__ */ (0,
|
7110
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
|
7111
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6671
7112
|
"select",
|
6672
7113
|
{
|
6673
7114
|
className: getClassName25("zoomSelect"),
|
@@ -6675,7 +7116,7 @@ var ViewportControls = ({
|
|
6675
7116
|
onChange: (e) => {
|
6676
7117
|
onZoom(parseFloat(e.currentTarget.value));
|
6677
7118
|
},
|
6678
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
7119
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
6679
7120
|
"option",
|
6680
7121
|
{
|
6681
7122
|
value: option.value,
|
@@ -6723,24 +7164,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6723
7164
|
};
|
6724
7165
|
|
6725
7166
|
// components/Puck/components/Canvas/index.tsx
|
6726
|
-
var
|
7167
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
6727
7168
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6728
7169
|
var ZOOM_ON_CHANGE = true;
|
6729
7170
|
var Canvas = () => {
|
6730
7171
|
const { status, iframe } = useAppContext();
|
6731
7172
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6732
7173
|
const { ui } = state;
|
6733
|
-
const frameRef = (0,
|
6734
|
-
const [showTransition, setShowTransition] = (0,
|
6735
|
-
const defaultRender = (0,
|
6736
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
7174
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7175
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7176
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7177
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
6737
7178
|
return PuckDefault;
|
6738
7179
|
}, []);
|
6739
|
-
const CustomPreview = (0,
|
7180
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
6740
7181
|
() => overrides.preview || defaultRender,
|
6741
7182
|
[overrides]
|
6742
7183
|
);
|
6743
|
-
const getFrameDimensions = (0,
|
7184
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
6744
7185
|
if (frameRef.current) {
|
6745
7186
|
const frame = frameRef.current;
|
6746
7187
|
const box = getBox(frame);
|
@@ -6748,7 +7189,7 @@ var Canvas = () => {
|
|
6748
7189
|
}
|
6749
7190
|
return { width: 0, height: 0 };
|
6750
7191
|
}, [frameRef]);
|
6751
|
-
const resetAutoZoom = (0,
|
7192
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
6752
7193
|
(ui2 = state.ui) => {
|
6753
7194
|
if (frameRef.current) {
|
6754
7195
|
setZoomConfig(
|
@@ -6758,11 +7199,11 @@ var Canvas = () => {
|
|
6758
7199
|
},
|
6759
7200
|
[frameRef, zoomConfig, state.ui]
|
6760
7201
|
);
|
6761
|
-
(0,
|
7202
|
+
(0, import_react46.useEffect)(() => {
|
6762
7203
|
setShowTransition(false);
|
6763
7204
|
resetAutoZoom();
|
6764
7205
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6765
|
-
(0,
|
7206
|
+
(0, import_react46.useEffect)(() => {
|
6766
7207
|
const { height: frameHeight } = getFrameDimensions();
|
6767
7208
|
if (ui.viewports.current.height === "auto") {
|
6768
7209
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6770,13 +7211,13 @@ var Canvas = () => {
|
|
6770
7211
|
}));
|
6771
7212
|
}
|
6772
7213
|
}, [zoomConfig.zoom]);
|
6773
|
-
(0,
|
7214
|
+
(0, import_react46.useEffect)(() => {
|
6774
7215
|
if (ZOOM_ON_CHANGE) {
|
6775
7216
|
setShowTransition(true);
|
6776
7217
|
resetAutoZoom(ui);
|
6777
7218
|
}
|
6778
7219
|
}, [ui.viewports.current.width]);
|
6779
|
-
(0,
|
7220
|
+
(0, import_react46.useEffect)(() => {
|
6780
7221
|
const cb = () => {
|
6781
7222
|
setShowTransition(false);
|
6782
7223
|
resetAutoZoom();
|
@@ -6786,13 +7227,13 @@ var Canvas = () => {
|
|
6786
7227
|
window.removeEventListener("resize", cb);
|
6787
7228
|
};
|
6788
7229
|
}, []);
|
6789
|
-
const [showLoader, setShowLoader] = (0,
|
6790
|
-
(0,
|
7230
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7231
|
+
(0, import_react46.useEffect)(() => {
|
6791
7232
|
setTimeout(() => {
|
6792
7233
|
setShowLoader(true);
|
6793
7234
|
}, 500);
|
6794
7235
|
}, []);
|
6795
|
-
return /* @__PURE__ */ (0,
|
7236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
6796
7237
|
"div",
|
6797
7238
|
{
|
6798
7239
|
className: getClassName26({
|
@@ -6805,7 +7246,7 @@ var Canvas = () => {
|
|
6805
7246
|
recordHistory: true
|
6806
7247
|
}),
|
6807
7248
|
children: [
|
6808
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
7249
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
6809
7250
|
ViewportControls,
|
6810
7251
|
{
|
6811
7252
|
autoZoom: zoomConfig.autoZoom,
|
@@ -6831,8 +7272,8 @@ var Canvas = () => {
|
|
6831
7272
|
}
|
6832
7273
|
}
|
6833
7274
|
) }),
|
6834
|
-
/* @__PURE__ */ (0,
|
6835
|
-
/* @__PURE__ */ (0,
|
7275
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7276
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
6836
7277
|
"div",
|
6837
7278
|
{
|
6838
7279
|
className: getClassName26("root"),
|
@@ -6853,10 +7294,10 @@ var Canvas = () => {
|
|
6853
7294
|
})
|
6854
7295
|
);
|
6855
7296
|
},
|
6856
|
-
children: /* @__PURE__ */ (0,
|
7297
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview2, {}) })
|
6857
7298
|
}
|
6858
7299
|
),
|
6859
|
-
/* @__PURE__ */ (0,
|
7300
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
6860
7301
|
] })
|
6861
7302
|
]
|
6862
7303
|
}
|
@@ -6865,7 +7306,7 @@ var Canvas = () => {
|
|
6865
7306
|
|
6866
7307
|
// lib/use-loaded-overrides.ts
|
6867
7308
|
init_react_import();
|
6868
|
-
var
|
7309
|
+
var import_react47 = require("react");
|
6869
7310
|
|
6870
7311
|
// lib/load-overrides.ts
|
6871
7312
|
init_react_import();
|
@@ -6904,26 +7345,26 @@ var useLoadedOverrides = ({
|
|
6904
7345
|
overrides,
|
6905
7346
|
plugins
|
6906
7347
|
}) => {
|
6907
|
-
return (0,
|
7348
|
+
return (0, import_react47.useMemo)(() => {
|
6908
7349
|
return loadOverrides({ overrides, plugins });
|
6909
7350
|
}, [plugins, overrides]);
|
6910
7351
|
};
|
6911
7352
|
|
6912
7353
|
// components/DefaultOverride/index.tsx
|
6913
7354
|
init_react_import();
|
6914
|
-
var
|
6915
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
7355
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7356
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
6916
7357
|
|
6917
7358
|
// lib/use-inject-css.ts
|
6918
7359
|
init_react_import();
|
6919
|
-
var
|
7360
|
+
var import_react48 = require("react");
|
6920
7361
|
var styles = ``;
|
6921
7362
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6922
|
-
const [el, setEl] = (0,
|
6923
|
-
(0,
|
7363
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7364
|
+
(0, import_react48.useEffect)(() => {
|
6924
7365
|
setEl(document.createElement("style"));
|
6925
7366
|
}, []);
|
6926
|
-
(0,
|
7367
|
+
(0, import_react48.useEffect)(() => {
|
6927
7368
|
var _a;
|
6928
7369
|
if (!el || typeof window === "undefined") {
|
6929
7370
|
return;
|
@@ -6941,8 +7382,35 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
6941
7382
|
return useInjectStyleSheet(styles, iframeEnabled);
|
6942
7383
|
};
|
6943
7384
|
|
7385
|
+
// lib/use-preview-mode-hotkeys.ts
|
7386
|
+
init_react_import();
|
7387
|
+
var import_react49 = require("react");
|
7388
|
+
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7389
|
+
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7390
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7391
|
+
dispatch({
|
7392
|
+
type: "setUi",
|
7393
|
+
ui: (ui) => ({
|
7394
|
+
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
7395
|
+
})
|
7396
|
+
});
|
7397
|
+
}, [dispatch]);
|
7398
|
+
const toggleInteractiveIframe = () => {
|
7399
|
+
if (iframeEnabled) {
|
7400
|
+
toggleInteractive();
|
7401
|
+
}
|
7402
|
+
};
|
7403
|
+
const frame = getFrame();
|
7404
|
+
const resolvedFrame = typeof window !== "undefined" && frame !== document ? frame : void 0;
|
7405
|
+
(0, import_react_hotkeys_hook2.useHotkeys)("meta+i", toggleInteractive, { preventDefault: true });
|
7406
|
+
(0, import_react_hotkeys_hook2.useHotkeys)("meta+i", toggleInteractiveIframe, {
|
7407
|
+
preventDefault: true,
|
7408
|
+
document: resolvedFrame
|
7409
|
+
});
|
7410
|
+
};
|
7411
|
+
|
6944
7412
|
// components/Puck/index.tsx
|
6945
|
-
var
|
7413
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
6946
7414
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
6947
7415
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
6948
7416
|
function Puck({
|
@@ -6971,7 +7439,7 @@ function Puck({
|
|
6971
7439
|
waitForStyles: true
|
6972
7440
|
}, _iframe);
|
6973
7441
|
useInjectGlobalCss(iframe.enabled);
|
6974
|
-
const [generatedAppState] = (0,
|
7442
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
6975
7443
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
6976
7444
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
6977
7445
|
let clientUiState = {};
|
@@ -7043,14 +7511,14 @@ function Puck({
|
|
7043
7511
|
histories,
|
7044
7512
|
index: initialHistoryIndex
|
7045
7513
|
});
|
7046
|
-
const [reducer] = (0,
|
7514
|
+
const [reducer] = (0, import_react50.useState)(
|
7047
7515
|
() => createReducer({
|
7048
7516
|
config,
|
7049
7517
|
record: historyStore.record,
|
7050
7518
|
onAction
|
7051
7519
|
})
|
7052
7520
|
);
|
7053
|
-
const [appState, dispatch] = (0,
|
7521
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7054
7522
|
reducer,
|
7055
7523
|
flushZones(initialAppState)
|
7056
7524
|
);
|
@@ -7061,14 +7529,14 @@ function Puck({
|
|
7061
7529
|
historyStore,
|
7062
7530
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7063
7531
|
});
|
7064
|
-
const [menuOpen, setMenuOpen] = (0,
|
7532
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7065
7533
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7066
7534
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7067
|
-
(0,
|
7535
|
+
(0, import_react50.useEffect)(() => {
|
7068
7536
|
if (onChange) onChange(data);
|
7069
7537
|
}, [data]);
|
7070
7538
|
const rootProps = data.root.props || data.root;
|
7071
|
-
const toggleSidebars = (0,
|
7539
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7072
7540
|
(sidebar) => {
|
7073
7541
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7074
7542
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7082,7 +7550,7 @@ function Puck({
|
|
7082
7550
|
},
|
7083
7551
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7084
7552
|
);
|
7085
|
-
(0,
|
7553
|
+
(0, import_react50.useEffect)(() => {
|
7086
7554
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7087
7555
|
dispatch({
|
7088
7556
|
type: "setUi",
|
@@ -7105,7 +7573,7 @@ function Puck({
|
|
7105
7573
|
window.removeEventListener("resize", handleResize);
|
7106
7574
|
};
|
7107
7575
|
}, []);
|
7108
|
-
const defaultHeaderRender = (0,
|
7576
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7109
7577
|
if (renderHeader) {
|
7110
7578
|
console.warn(
|
7111
7579
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7113,20 +7581,20 @@ function Puck({
|
|
7113
7581
|
const RenderHeader = (_a2) => {
|
7114
7582
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
7115
7583
|
const Comp = renderHeader;
|
7116
|
-
return /* @__PURE__ */ (0,
|
7584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7117
7585
|
};
|
7118
7586
|
return RenderHeader;
|
7119
7587
|
}
|
7120
7588
|
return DefaultOverride;
|
7121
7589
|
}, [renderHeader]);
|
7122
|
-
const defaultHeaderActionsRender = (0,
|
7590
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7123
7591
|
if (renderHeaderActions) {
|
7124
7592
|
console.warn(
|
7125
7593
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7126
7594
|
);
|
7127
7595
|
const RenderHeader = (props) => {
|
7128
7596
|
const Comp = renderHeaderActions;
|
7129
|
-
return /* @__PURE__ */ (0,
|
7597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7130
7598
|
};
|
7131
7599
|
return RenderHeader;
|
7132
7600
|
}
|
@@ -7136,26 +7604,27 @@ function Puck({
|
|
7136
7604
|
overrides,
|
7137
7605
|
plugins
|
7138
7606
|
});
|
7139
|
-
const CustomPuck = (0,
|
7607
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7140
7608
|
() => loadedOverrides.puck || DefaultOverride,
|
7141
7609
|
[loadedOverrides]
|
7142
7610
|
);
|
7143
|
-
const CustomHeader = (0,
|
7611
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7144
7612
|
() => loadedOverrides.header || defaultHeaderRender,
|
7145
7613
|
[loadedOverrides]
|
7146
7614
|
);
|
7147
|
-
const CustomHeaderActions = (0,
|
7615
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7148
7616
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7149
7617
|
[loadedOverrides]
|
7150
7618
|
);
|
7151
|
-
const [mounted, setMounted] = (0,
|
7152
|
-
(0,
|
7619
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7620
|
+
(0, import_react50.useEffect)(() => {
|
7153
7621
|
setMounted(true);
|
7154
7622
|
}, []);
|
7155
7623
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7156
7624
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7157
|
-
|
7158
|
-
|
7625
|
+
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
7627
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7159
7628
|
AppProvider,
|
7160
7629
|
{
|
7161
7630
|
value: {
|
@@ -7177,7 +7646,7 @@ function Puck({
|
|
7177
7646
|
getPermissions: () => ({}),
|
7178
7647
|
refreshPermissions: () => null
|
7179
7648
|
},
|
7180
|
-
children: /* @__PURE__ */ (0,
|
7649
|
+
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
7650
|
"div",
|
7182
7651
|
{
|
7183
7652
|
className: getLayoutClassName({
|
@@ -7186,60 +7655,60 @@ function Puck({
|
|
7186
7655
|
mounted,
|
7187
7656
|
rightSideBarVisible
|
7188
7657
|
}),
|
7189
|
-
children: /* @__PURE__ */ (0,
|
7190
|
-
/* @__PURE__ */ (0,
|
7658
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
7659
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7191
7660
|
CustomHeader,
|
7192
7661
|
{
|
7193
|
-
actions: /* @__PURE__ */ (0,
|
7662
|
+
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
7663
|
Button,
|
7195
7664
|
{
|
7196
7665
|
onClick: () => {
|
7197
7666
|
onPublish && onPublish(data);
|
7198
7667
|
},
|
7199
|
-
icon: /* @__PURE__ */ (0,
|
7668
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7200
7669
|
children: "Publish"
|
7201
7670
|
}
|
7202
7671
|
) }) }),
|
7203
|
-
children: /* @__PURE__ */ (0,
|
7204
|
-
/* @__PURE__ */ (0,
|
7205
|
-
/* @__PURE__ */ (0,
|
7672
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
7673
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
|
7674
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7206
7675
|
"div",
|
7207
7676
|
{
|
7208
7677
|
className: getLayoutClassName("leftSideBarToggle"),
|
7209
|
-
children: /* @__PURE__ */ (0,
|
7678
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7210
7679
|
IconButton,
|
7211
7680
|
{
|
7212
7681
|
onClick: () => {
|
7213
7682
|
toggleSidebars("left");
|
7214
7683
|
},
|
7215
7684
|
title: "Toggle left sidebar",
|
7216
|
-
children: /* @__PURE__ */ (0,
|
7685
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
7217
7686
|
}
|
7218
7687
|
)
|
7219
7688
|
}
|
7220
7689
|
),
|
7221
|
-
/* @__PURE__ */ (0,
|
7690
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7222
7691
|
"div",
|
7223
7692
|
{
|
7224
7693
|
className: getLayoutClassName("rightSideBarToggle"),
|
7225
|
-
children: /* @__PURE__ */ (0,
|
7694
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7226
7695
|
IconButton,
|
7227
7696
|
{
|
7228
7697
|
onClick: () => {
|
7229
7698
|
toggleSidebars("right");
|
7230
7699
|
},
|
7231
7700
|
title: "Toggle right sidebar",
|
7232
|
-
children: /* @__PURE__ */ (0,
|
7701
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
7233
7702
|
}
|
7234
7703
|
)
|
7235
7704
|
}
|
7236
7705
|
)
|
7237
7706
|
] }),
|
7238
|
-
/* @__PURE__ */ (0,
|
7707
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
7239
7708
|
headerTitle || rootProps.title || "Page",
|
7240
|
-
headerPath && /* @__PURE__ */ (0,
|
7709
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
7241
7710
|
" ",
|
7242
|
-
/* @__PURE__ */ (0,
|
7711
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7243
7712
|
"code",
|
7244
7713
|
{
|
7245
7714
|
className: getLayoutClassName("headerPath"),
|
@@ -7248,31 +7717,31 @@ function Puck({
|
|
7248
7717
|
)
|
7249
7718
|
] })
|
7250
7719
|
] }) }),
|
7251
|
-
/* @__PURE__ */ (0,
|
7252
|
-
/* @__PURE__ */ (0,
|
7720
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
|
7721
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7253
7722
|
IconButton,
|
7254
7723
|
{
|
7255
7724
|
onClick: () => {
|
7256
7725
|
return setMenuOpen(!menuOpen);
|
7257
7726
|
},
|
7258
7727
|
title: "Toggle menu bar",
|
7259
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
7728
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
7260
7729
|
}
|
7261
7730
|
) }),
|
7262
|
-
/* @__PURE__ */ (0,
|
7731
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7263
7732
|
MenuBar,
|
7264
7733
|
{
|
7265
7734
|
appState,
|
7266
7735
|
dispatch,
|
7267
7736
|
onPublish,
|
7268
7737
|
menuOpen,
|
7269
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
7738
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7270
7739
|
Button,
|
7271
7740
|
{
|
7272
7741
|
onClick: () => {
|
7273
7742
|
onPublish && onPublish(data);
|
7274
7743
|
},
|
7275
|
-
icon: /* @__PURE__ */ (0,
|
7744
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
7276
7745
|
children: "Publish"
|
7277
7746
|
}
|
7278
7747
|
) }),
|
@@ -7283,19 +7752,19 @@ function Puck({
|
|
7283
7752
|
] }) })
|
7284
7753
|
}
|
7285
7754
|
),
|
7286
|
-
/* @__PURE__ */ (0,
|
7287
|
-
/* @__PURE__ */ (0,
|
7288
|
-
/* @__PURE__ */ (0,
|
7755
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7756
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
|
7757
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
|
7289
7758
|
] }),
|
7290
|
-
/* @__PURE__ */ (0,
|
7291
|
-
/* @__PURE__ */ (0,
|
7759
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
|
7760
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7292
7761
|
SidebarSection,
|
7293
7762
|
{
|
7294
7763
|
noPadding: true,
|
7295
7764
|
noBorderTop: true,
|
7296
7765
|
showBreadcrumbs: true,
|
7297
7766
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7298
|
-
children: /* @__PURE__ */ (0,
|
7767
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
|
7299
7768
|
}
|
7300
7769
|
) })
|
7301
7770
|
] })
|
@@ -7303,69 +7772,13 @@ function Puck({
|
|
7303
7772
|
) }) })
|
7304
7773
|
}
|
7305
7774
|
),
|
7306
|
-
/* @__PURE__ */ (0,
|
7775
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7307
7776
|
] });
|
7308
7777
|
}
|
7309
7778
|
Puck.Components = Components;
|
7310
7779
|
Puck.Fields = Fields;
|
7311
7780
|
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
|
-
}
|
7781
|
+
Puck.Preview = Preview2;
|
7369
7782
|
|
7370
7783
|
// lib/migrate.ts
|
7371
7784
|
init_react_import();
|