@measured/puck 0.18.0-canary.e6e29ad → 0.18.0-canary.f27871b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EXKSBUY5.mjs → chunk-CHWFBYEM.mjs} +2 -4
- package/dist/index.css +27 -34
- package/dist/index.d.mts +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +1239 -883
- package/dist/index.mjs +1171 -812
- package/dist/rsc.js +2 -4
- package/dist/rsc.mjs +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
@@ -16,7 +16,7 @@ import {
|
|
16
16
|
resolveRootData,
|
17
17
|
rootDroppableId,
|
18
18
|
setupZone
|
19
|
-
} from "./chunk-
|
19
|
+
} from "./chunk-CHWFBYEM.mjs";
|
20
20
|
|
21
21
|
// ../../node_modules/classnames/index.js
|
22
22
|
var require_classnames = __commonJS({
|
@@ -210,8 +210,9 @@ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input":
|
|
210
210
|
// components/AutoField/index.tsx
|
211
211
|
import {
|
212
212
|
useCallback as useCallback5,
|
213
|
+
useContext as useContext3,
|
213
214
|
useEffect as useEffect9,
|
214
|
-
useMemo as
|
215
|
+
useMemo as useMemo5,
|
215
216
|
useState as useState11
|
216
217
|
} from "react";
|
217
218
|
|
@@ -1085,7 +1086,7 @@ init_react_import();
|
|
1085
1086
|
import { DragDropProvider } from "@dnd-kit/react";
|
1086
1087
|
import { useState as useState5 } from "react";
|
1087
1088
|
|
1088
|
-
// lib/dnd-kit/safe.ts
|
1089
|
+
// lib/dnd/dnd-kit/safe.ts
|
1089
1090
|
init_react_import();
|
1090
1091
|
import {
|
1091
1092
|
useDraggable,
|
@@ -1165,8 +1166,53 @@ var Sortable = ({
|
|
1165
1166
|
return children({ status, ref: sortableRef });
|
1166
1167
|
};
|
1167
1168
|
|
1169
|
+
// components/AutoField/context.tsx
|
1170
|
+
init_react_import();
|
1171
|
+
import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
|
1172
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
1173
|
+
var NestedFieldContext = createContext2({});
|
1174
|
+
var useNestedFieldContext = () => {
|
1175
|
+
const context = useContext2(NestedFieldContext);
|
1176
|
+
return __spreadProps(__spreadValues({}, context), {
|
1177
|
+
readOnlyFields: context.readOnlyFields || {}
|
1178
|
+
});
|
1179
|
+
};
|
1180
|
+
var NestedFieldProvider = ({
|
1181
|
+
children,
|
1182
|
+
name,
|
1183
|
+
subName,
|
1184
|
+
wildcardName = name,
|
1185
|
+
readOnlyFields
|
1186
|
+
}) => {
|
1187
|
+
const subPath = `${name}.${subName}`;
|
1188
|
+
const wildcardSubPath = `${wildcardName}.${subName}`;
|
1189
|
+
const subReadOnlyFields = useMemo(
|
1190
|
+
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
1191
|
+
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
1192
|
+
if (isLocal) {
|
1193
|
+
const subPathPattern = new RegExp(
|
1194
|
+
`^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
|
1195
|
+
);
|
1196
|
+
const localName = readOnlyKey.replace(subPathPattern, "");
|
1197
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1198
|
+
[localName]: readOnlyFields[readOnlyKey]
|
1199
|
+
});
|
1200
|
+
}
|
1201
|
+
return acc;
|
1202
|
+
}, {}),
|
1203
|
+
[name, subName, wildcardName, readOnlyFields]
|
1204
|
+
);
|
1205
|
+
return /* @__PURE__ */ jsx7(
|
1206
|
+
NestedFieldContext.Provider,
|
1207
|
+
{
|
1208
|
+
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
1209
|
+
children
|
1210
|
+
}
|
1211
|
+
);
|
1212
|
+
};
|
1213
|
+
|
1168
1214
|
// components/AutoField/fields/ArrayField/index.tsx
|
1169
|
-
import { jsx as
|
1215
|
+
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
1170
1216
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
1171
1217
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
1172
1218
|
var ArrayField = ({
|
@@ -1177,10 +1223,10 @@ var ArrayField = ({
|
|
1177
1223
|
label,
|
1178
1224
|
readOnly,
|
1179
1225
|
id,
|
1180
|
-
Label: Label2 = (props) => /* @__PURE__ */
|
1226
|
+
Label: Label2 = (props) => /* @__PURE__ */ jsx8("div", __spreadValues({}, props))
|
1181
1227
|
}) => {
|
1182
1228
|
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
1183
|
-
const readOnlyFields =
|
1229
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
1184
1230
|
const value = _value;
|
1185
1231
|
const arrayState = state.ui.arrayState[id] || {
|
1186
1232
|
items: Array.from(value || []).map((item, idx) => {
|
@@ -1240,14 +1286,14 @@ var ArrayField = ({
|
|
1240
1286
|
return null;
|
1241
1287
|
}
|
1242
1288
|
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
1243
|
-
return /* @__PURE__ */
|
1289
|
+
return /* @__PURE__ */ jsx8(
|
1244
1290
|
Label2,
|
1245
1291
|
{
|
1246
1292
|
label: label || name,
|
1247
|
-
icon: /* @__PURE__ */
|
1293
|
+
icon: /* @__PURE__ */ jsx8(List, { size: 16 }),
|
1248
1294
|
el: "div",
|
1249
1295
|
readOnly,
|
1250
|
-
children: /* @__PURE__ */
|
1296
|
+
children: /* @__PURE__ */ jsx8(
|
1251
1297
|
SortableProvider,
|
1252
1298
|
{
|
1253
1299
|
onMove: (move) => {
|
@@ -1283,7 +1329,7 @@ var ArrayField = ({
|
|
1283
1329
|
localState.arrayState.items.map((item, i) => {
|
1284
1330
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
1285
1331
|
const data = Array.from(localState.value || [])[i] || {};
|
1286
|
-
return /* @__PURE__ */
|
1332
|
+
return /* @__PURE__ */ jsx8(
|
1287
1333
|
Sortable,
|
1288
1334
|
{
|
1289
1335
|
id: _arrayId,
|
@@ -1324,7 +1370,7 @@ var ArrayField = ({
|
|
1324
1370
|
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
1325
1371
|
/* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
|
1326
1372
|
!readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
|
1327
|
-
/* @__PURE__ */
|
1373
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
1328
1374
|
IconButton,
|
1329
1375
|
{
|
1330
1376
|
type: "button",
|
@@ -1341,10 +1387,10 @@ var ArrayField = ({
|
|
1341
1387
|
);
|
1342
1388
|
},
|
1343
1389
|
title: "Duplicate",
|
1344
|
-
children: /* @__PURE__ */
|
1390
|
+
children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
|
1345
1391
|
}
|
1346
1392
|
) }),
|
1347
|
-
/* @__PURE__ */
|
1393
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
1348
1394
|
IconButton,
|
1349
1395
|
{
|
1350
1396
|
type: "button",
|
@@ -1365,39 +1411,56 @@ var ArrayField = ({
|
|
1365
1411
|
);
|
1366
1412
|
},
|
1367
1413
|
title: "Delete",
|
1368
|
-
children: /* @__PURE__ */
|
1414
|
+
children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
|
1369
1415
|
}
|
1370
1416
|
) })
|
1371
1417
|
] }),
|
1372
|
-
/* @__PURE__ */
|
1418
|
+
/* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(DragIcon, {}) })
|
1373
1419
|
] })
|
1374
1420
|
]
|
1375
1421
|
}
|
1376
1422
|
),
|
1377
|
-
/* @__PURE__ */
|
1378
|
-
const subField = field.arrayFields[
|
1379
|
-
const
|
1380
|
-
const
|
1381
|
-
const
|
1382
|
-
|
1383
|
-
|
1423
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
1424
|
+
const subField = field.arrayFields[subName];
|
1425
|
+
const indexName = `${name}[${i}]`;
|
1426
|
+
const subPath = `${indexName}.${subName}`;
|
1427
|
+
const localIndexName = `${localName}[${i}]`;
|
1428
|
+
const localWildcardName = `${localName}[*]`;
|
1429
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
1430
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
1431
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
1432
|
+
const label2 = subField.label || subName;
|
1433
|
+
return /* @__PURE__ */ jsx8(
|
1434
|
+
NestedFieldProvider,
|
1384
1435
|
{
|
1385
|
-
name:
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1436
|
+
name: localIndexName,
|
1437
|
+
wildcardName: localWildcardName,
|
1438
|
+
subName,
|
1439
|
+
readOnlyFields,
|
1440
|
+
children: /* @__PURE__ */ jsx8(
|
1441
|
+
AutoFieldPrivate,
|
1442
|
+
{
|
1443
|
+
name: subPath,
|
1444
|
+
label: label2,
|
1445
|
+
id: `${_arrayId}_${subName}`,
|
1446
|
+
readOnly: subReadOnly,
|
1447
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
1448
|
+
label: label2
|
1449
|
+
// May be used by custom fields
|
1450
|
+
}),
|
1451
|
+
value: data[subName],
|
1452
|
+
onChange: (val, ui) => {
|
1453
|
+
onChange(
|
1454
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
1455
|
+
[subName]: val
|
1456
|
+
})),
|
1457
|
+
ui
|
1458
|
+
);
|
1459
|
+
}
|
1460
|
+
}
|
1461
|
+
)
|
1399
1462
|
},
|
1400
|
-
|
1463
|
+
subPath
|
1401
1464
|
);
|
1402
1465
|
}) }) })
|
1403
1466
|
]
|
@@ -1407,7 +1470,7 @@ var ArrayField = ({
|
|
1407
1470
|
_arrayId
|
1408
1471
|
);
|
1409
1472
|
}),
|
1410
|
-
!addDisabled && /* @__PURE__ */
|
1473
|
+
!addDisabled && /* @__PURE__ */ jsx8(
|
1411
1474
|
"button",
|
1412
1475
|
{
|
1413
1476
|
type: "button",
|
@@ -1421,7 +1484,7 @@ var ArrayField = ({
|
|
1421
1484
|
const newArrayState = regenerateArrayState(newValue);
|
1422
1485
|
onChange(newValue, mapArrayStateToUi(newArrayState));
|
1423
1486
|
},
|
1424
|
-
children: /* @__PURE__ */
|
1487
|
+
children: /* @__PURE__ */ jsx8(Plus, { size: 21 })
|
1425
1488
|
}
|
1426
1489
|
)
|
1427
1490
|
]
|
@@ -1435,7 +1498,7 @@ var ArrayField = ({
|
|
1435
1498
|
|
1436
1499
|
// components/AutoField/fields/DefaultField/index.tsx
|
1437
1500
|
init_react_import();
|
1438
|
-
import { Fragment as Fragment2, jsx as
|
1501
|
+
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
1439
1502
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
1440
1503
|
var DefaultField = ({
|
1441
1504
|
field,
|
@@ -1447,16 +1510,16 @@ var DefaultField = ({
|
|
1447
1510
|
Label: Label2,
|
1448
1511
|
id
|
1449
1512
|
}) => {
|
1450
|
-
return /* @__PURE__ */
|
1513
|
+
return /* @__PURE__ */ jsx9(
|
1451
1514
|
Label2,
|
1452
1515
|
{
|
1453
1516
|
label: label || name,
|
1454
1517
|
icon: /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
1455
|
-
field.type === "text" && /* @__PURE__ */
|
1456
|
-
field.type === "number" && /* @__PURE__ */
|
1518
|
+
field.type === "text" && /* @__PURE__ */ jsx9(Type, { size: 16 }),
|
1519
|
+
field.type === "number" && /* @__PURE__ */ jsx9(Hash, { size: 16 })
|
1457
1520
|
] }),
|
1458
1521
|
readOnly,
|
1459
|
-
children: /* @__PURE__ */
|
1522
|
+
children: /* @__PURE__ */ jsx9(
|
1460
1523
|
"input",
|
1461
1524
|
{
|
1462
1525
|
className: getClassName6("input"),
|
@@ -1467,7 +1530,14 @@ var DefaultField = ({
|
|
1467
1530
|
value: typeof value === "undefined" ? "" : value.toString(),
|
1468
1531
|
onChange: (e) => {
|
1469
1532
|
if (field.type === "number") {
|
1470
|
-
|
1533
|
+
const numberValue = Number(e.currentTarget.value);
|
1534
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
1535
|
+
return;
|
1536
|
+
}
|
1537
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
1538
|
+
return;
|
1539
|
+
}
|
1540
|
+
onChange(numberValue);
|
1471
1541
|
} else {
|
1472
1542
|
onChange(e.currentTarget.value);
|
1473
1543
|
}
|
@@ -1490,7 +1560,7 @@ import { useEffect as useEffect8 } from "react";
|
|
1490
1560
|
// components/ExternalInput/index.tsx
|
1491
1561
|
init_react_import();
|
1492
1562
|
import {
|
1493
|
-
useMemo,
|
1563
|
+
useMemo as useMemo2,
|
1494
1564
|
useEffect as useEffect7,
|
1495
1565
|
useState as useState9,
|
1496
1566
|
useCallback as useCallback4,
|
@@ -1511,7 +1581,7 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1511
1581
|
|
1512
1582
|
// components/Modal/index.tsx
|
1513
1583
|
import { createPortal } from "react-dom";
|
1514
|
-
import { jsx as
|
1584
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
1515
1585
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1516
1586
|
var Modal = ({
|
1517
1587
|
children,
|
@@ -1523,10 +1593,10 @@ var Modal = ({
|
|
1523
1593
|
setRootEl(document.getElementById("puck-portal-root"));
|
1524
1594
|
}, []);
|
1525
1595
|
if (!rootEl) {
|
1526
|
-
return /* @__PURE__ */
|
1596
|
+
return /* @__PURE__ */ jsx10("div", {});
|
1527
1597
|
}
|
1528
1598
|
return createPortal(
|
1529
|
-
/* @__PURE__ */
|
1599
|
+
/* @__PURE__ */ jsx10("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx10(
|
1530
1600
|
"div",
|
1531
1601
|
{
|
1532
1602
|
className: getClassName7("inner"),
|
@@ -1546,11 +1616,11 @@ init_react_import();
|
|
1546
1616
|
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" };
|
1547
1617
|
|
1548
1618
|
// components/Heading/index.tsx
|
1549
|
-
import { jsx as
|
1619
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
1550
1620
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1551
1621
|
var Heading = ({ children, rank, size = "m" }) => {
|
1552
1622
|
const Tag = rank ? `h${rank}` : "span";
|
1553
|
-
return /* @__PURE__ */
|
1623
|
+
return /* @__PURE__ */ jsx11(
|
1554
1624
|
Tag,
|
1555
1625
|
{
|
1556
1626
|
className: getClassName8({
|
@@ -1586,7 +1656,7 @@ var filterDataAttrs = (props) => {
|
|
1586
1656
|
};
|
1587
1657
|
|
1588
1658
|
// components/Button/Button.tsx
|
1589
|
-
import { jsx as
|
1659
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
1590
1660
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1591
1661
|
var Button = (_a) => {
|
1592
1662
|
var _b = _a, {
|
@@ -1645,9 +1715,9 @@ var Button = (_a) => {
|
|
1645
1715
|
href
|
1646
1716
|
}, dataAttrs), {
|
1647
1717
|
children: [
|
1648
|
-
icon && /* @__PURE__ */
|
1718
|
+
icon && /* @__PURE__ */ jsx12("div", { className: getClassName9("icon"), children: icon }),
|
1649
1719
|
children,
|
1650
|
-
loading && /* @__PURE__ */
|
1720
|
+
loading && /* @__PURE__ */ jsx12("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx12(Loader, { size: 14 }) })
|
1651
1721
|
]
|
1652
1722
|
})
|
1653
1723
|
);
|
@@ -1655,7 +1725,7 @@ var Button = (_a) => {
|
|
1655
1725
|
};
|
1656
1726
|
|
1657
1727
|
// components/ExternalInput/index.tsx
|
1658
|
-
import { Fragment as Fragment3, jsx as
|
1728
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
1659
1729
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1660
1730
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1661
1731
|
var dataCache = {};
|
@@ -1678,10 +1748,10 @@ var ExternalInput = ({
|
|
1678
1748
|
const hasFilterFields = !!filterFields;
|
1679
1749
|
const [filters, setFilters] = useState9(field.initialFilters || {});
|
1680
1750
|
const [filtersToggled, setFiltersToggled] = useState9(hasFilterFields);
|
1681
|
-
const mappedData =
|
1751
|
+
const mappedData = useMemo2(() => {
|
1682
1752
|
return data.map(mapRow);
|
1683
1753
|
}, [data]);
|
1684
|
-
const keys =
|
1754
|
+
const keys = useMemo2(() => {
|
1685
1755
|
const validKeys = /* @__PURE__ */ new Set();
|
1686
1756
|
for (const item of mappedData) {
|
1687
1757
|
for (const key of Object.keys(item)) {
|
@@ -1728,7 +1798,7 @@ var ExternalInput = ({
|
|
1728
1798
|
id,
|
1729
1799
|
children: [
|
1730
1800
|
/* @__PURE__ */ jsxs6("div", { className: getClassName10("actions"), children: [
|
1731
|
-
/* @__PURE__ */
|
1801
|
+
/* @__PURE__ */ jsx13(
|
1732
1802
|
"button",
|
1733
1803
|
{
|
1734
1804
|
type: "button",
|
@@ -1736,12 +1806,12 @@ var ExternalInput = ({
|
|
1736
1806
|
className: getClassName10("button"),
|
1737
1807
|
disabled: readOnly,
|
1738
1808
|
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
1739
|
-
/* @__PURE__ */
|
1740
|
-
/* @__PURE__ */
|
1809
|
+
/* @__PURE__ */ jsx13(Link, { size: "16" }),
|
1810
|
+
/* @__PURE__ */ jsx13("span", { children: field.placeholder })
|
1741
1811
|
] })
|
1742
1812
|
}
|
1743
1813
|
),
|
1744
|
-
value && /* @__PURE__ */
|
1814
|
+
value && /* @__PURE__ */ jsx13(
|
1745
1815
|
"button",
|
1746
1816
|
{
|
1747
1817
|
type: "button",
|
@@ -1750,11 +1820,11 @@ var ExternalInput = ({
|
|
1750
1820
|
onChange(null);
|
1751
1821
|
},
|
1752
1822
|
disabled: readOnly,
|
1753
|
-
children: /* @__PURE__ */
|
1823
|
+
children: /* @__PURE__ */ jsx13(LockOpen, { size: 16 })
|
1754
1824
|
}
|
1755
1825
|
)
|
1756
1826
|
] }),
|
1757
|
-
/* @__PURE__ */
|
1827
|
+
/* @__PURE__ */ jsx13(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
|
1758
1828
|
"form",
|
1759
1829
|
{
|
1760
1830
|
className: getClassNameModal({
|
@@ -1768,11 +1838,11 @@ var ExternalInput = ({
|
|
1768
1838
|
search(searchQuery, filters);
|
1769
1839
|
},
|
1770
1840
|
children: [
|
1771
|
-
/* @__PURE__ */
|
1841
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
|
1772
1842
|
/* @__PURE__ */ jsxs6("label", { className: getClassNameModal("search"), children: [
|
1773
|
-
/* @__PURE__ */
|
1774
|
-
/* @__PURE__ */
|
1775
|
-
/* @__PURE__ */
|
1843
|
+
/* @__PURE__ */ jsx13("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
1844
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx13(Search, { size: "18" }) }),
|
1845
|
+
/* @__PURE__ */ jsx13(
|
1776
1846
|
"input",
|
1777
1847
|
{
|
1778
1848
|
className: getClassNameModal("searchInput"),
|
@@ -1788,8 +1858,8 @@ var ExternalInput = ({
|
|
1788
1858
|
)
|
1789
1859
|
] }),
|
1790
1860
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchActions"), children: [
|
1791
|
-
/* @__PURE__ */
|
1792
|
-
hasFilterFields && /* @__PURE__ */
|
1861
|
+
/* @__PURE__ */ jsx13(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
1862
|
+
hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx13(
|
1793
1863
|
IconButton,
|
1794
1864
|
{
|
1795
1865
|
title: "Toggle filters",
|
@@ -1798,15 +1868,15 @@ var ExternalInput = ({
|
|
1798
1868
|
e.stopPropagation();
|
1799
1869
|
setFiltersToggled(!filtersToggled);
|
1800
1870
|
},
|
1801
|
-
children: /* @__PURE__ */
|
1871
|
+
children: /* @__PURE__ */ jsx13(SlidersHorizontal, { size: 20 })
|
1802
1872
|
}
|
1803
1873
|
) })
|
1804
1874
|
] })
|
1805
|
-
] }) : /* @__PURE__ */
|
1875
|
+
] }) : /* @__PURE__ */ jsx13(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
1806
1876
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("grid"), children: [
|
1807
|
-
hasFilterFields && /* @__PURE__ */
|
1877
|
+
hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
1808
1878
|
const filterField = filterFields[fieldName];
|
1809
|
-
return /* @__PURE__ */
|
1879
|
+
return /* @__PURE__ */ jsx13(
|
1810
1880
|
AutoFieldPrivate,
|
1811
1881
|
{
|
1812
1882
|
field: filterField,
|
@@ -1825,7 +1895,7 @@ var ExternalInput = ({
|
|
1825
1895
|
}) }),
|
1826
1896
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("tableWrapper"), children: [
|
1827
1897
|
/* @__PURE__ */ jsxs6("table", { className: getClassNameModal("table"), children: [
|
1828
|
-
/* @__PURE__ */
|
1898
|
+
/* @__PURE__ */ jsx13("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx13("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx13(
|
1829
1899
|
"th",
|
1830
1900
|
{
|
1831
1901
|
className: getClassNameModal("th"),
|
@@ -1834,8 +1904,8 @@ var ExternalInput = ({
|
|
1834
1904
|
},
|
1835
1905
|
key
|
1836
1906
|
)) }) }),
|
1837
|
-
/* @__PURE__ */
|
1838
|
-
return /* @__PURE__ */
|
1907
|
+
/* @__PURE__ */ jsx13("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
1908
|
+
return /* @__PURE__ */ jsx13(
|
1839
1909
|
"tr",
|
1840
1910
|
{
|
1841
1911
|
style: { whiteSpace: "nowrap" },
|
@@ -1844,16 +1914,16 @@ var ExternalInput = ({
|
|
1844
1914
|
onChange(mapProp(data[i]));
|
1845
1915
|
setOpen(false);
|
1846
1916
|
},
|
1847
|
-
children: keys.map((key) => /* @__PURE__ */
|
1917
|
+
children: keys.map((key) => /* @__PURE__ */ jsx13("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
1848
1918
|
},
|
1849
1919
|
i
|
1850
1920
|
);
|
1851
1921
|
}) })
|
1852
1922
|
] }),
|
1853
|
-
/* @__PURE__ */
|
1923
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx13(Loader, { size: 24 }) })
|
1854
1924
|
] })
|
1855
1925
|
] }),
|
1856
|
-
/* @__PURE__ */
|
1926
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx13(Footer, { items: mappedData }) })
|
1857
1927
|
]
|
1858
1928
|
}
|
1859
1929
|
) })
|
@@ -1863,7 +1933,7 @@ var ExternalInput = ({
|
|
1863
1933
|
};
|
1864
1934
|
|
1865
1935
|
// components/AutoField/fields/ExternalField/index.tsx
|
1866
|
-
import { jsx as
|
1936
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
1867
1937
|
var ExternalField = ({
|
1868
1938
|
field,
|
1869
1939
|
onChange,
|
@@ -1887,7 +1957,7 @@ var ExternalField = ({
|
|
1887
1957
|
if (field.type !== "external") {
|
1888
1958
|
return null;
|
1889
1959
|
}
|
1890
|
-
return /* @__PURE__ */
|
1960
|
+
return /* @__PURE__ */ jsx14(Label2, { label: label || name, icon: /* @__PURE__ */ jsx14(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx14(
|
1891
1961
|
ExternalInput,
|
1892
1962
|
{
|
1893
1963
|
name,
|
@@ -1912,7 +1982,7 @@ var ExternalField = ({
|
|
1912
1982
|
|
1913
1983
|
// components/AutoField/fields/RadioField/index.tsx
|
1914
1984
|
init_react_import();
|
1915
|
-
import { useMemo as
|
1985
|
+
import { useMemo as useMemo3 } from "react";
|
1916
1986
|
|
1917
1987
|
// lib/safe-json-parse.ts
|
1918
1988
|
init_react_import();
|
@@ -1926,7 +1996,7 @@ var safeJsonParse = (str) => {
|
|
1926
1996
|
};
|
1927
1997
|
|
1928
1998
|
// components/AutoField/fields/RadioField/index.tsx
|
1929
|
-
import { jsx as
|
1999
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
1930
2000
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
1931
2001
|
var RadioField = ({
|
1932
2002
|
field,
|
@@ -1938,26 +2008,26 @@ var RadioField = ({
|
|
1938
2008
|
label,
|
1939
2009
|
Label: Label2
|
1940
2010
|
}) => {
|
1941
|
-
const flatOptions =
|
2011
|
+
const flatOptions = useMemo3(
|
1942
2012
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
1943
2013
|
[field]
|
1944
2014
|
);
|
1945
2015
|
if (field.type !== "radio" || !field.options) {
|
1946
2016
|
return null;
|
1947
2017
|
}
|
1948
|
-
return /* @__PURE__ */
|
2018
|
+
return /* @__PURE__ */ jsx15(
|
1949
2019
|
Label2,
|
1950
2020
|
{
|
1951
|
-
icon: /* @__PURE__ */
|
2021
|
+
icon: /* @__PURE__ */ jsx15(CircleCheckBig, { size: 16 }),
|
1952
2022
|
label: label || name,
|
1953
2023
|
readOnly,
|
1954
2024
|
el: "div",
|
1955
|
-
children: /* @__PURE__ */
|
2025
|
+
children: /* @__PURE__ */ jsx15("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs7(
|
1956
2026
|
"label",
|
1957
2027
|
{
|
1958
2028
|
className: getClassName11("radio"),
|
1959
2029
|
children: [
|
1960
|
-
/* @__PURE__ */
|
2030
|
+
/* @__PURE__ */ jsx15(
|
1961
2031
|
"input",
|
1962
2032
|
{
|
1963
2033
|
type: "radio",
|
@@ -1977,7 +2047,7 @@ var RadioField = ({
|
|
1977
2047
|
checked: value === option.value
|
1978
2048
|
}
|
1979
2049
|
),
|
1980
|
-
/* @__PURE__ */
|
2050
|
+
/* @__PURE__ */ jsx15("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
1981
2051
|
]
|
1982
2052
|
},
|
1983
2053
|
option.label + option.value
|
@@ -1988,8 +2058,8 @@ var RadioField = ({
|
|
1988
2058
|
|
1989
2059
|
// components/AutoField/fields/SelectField/index.tsx
|
1990
2060
|
init_react_import();
|
1991
|
-
import { useMemo as
|
1992
|
-
import { jsx as
|
2061
|
+
import { useMemo as useMemo4 } from "react";
|
2062
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
1993
2063
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
1994
2064
|
var SelectField = ({
|
1995
2065
|
field,
|
@@ -2001,20 +2071,20 @@ var SelectField = ({
|
|
2001
2071
|
readOnly,
|
2002
2072
|
id
|
2003
2073
|
}) => {
|
2004
|
-
const flatOptions =
|
2074
|
+
const flatOptions = useMemo4(
|
2005
2075
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2006
2076
|
[field]
|
2007
2077
|
);
|
2008
2078
|
if (field.type !== "select" || !field.options) {
|
2009
2079
|
return null;
|
2010
2080
|
}
|
2011
|
-
return /* @__PURE__ */
|
2081
|
+
return /* @__PURE__ */ jsx16(
|
2012
2082
|
Label2,
|
2013
2083
|
{
|
2014
2084
|
label: label || name,
|
2015
|
-
icon: /* @__PURE__ */
|
2085
|
+
icon: /* @__PURE__ */ jsx16(ChevronDown, { size: 16 }),
|
2016
2086
|
readOnly,
|
2017
|
-
children: /* @__PURE__ */
|
2087
|
+
children: /* @__PURE__ */ jsx16(
|
2018
2088
|
"select",
|
2019
2089
|
{
|
2020
2090
|
id,
|
@@ -2031,7 +2101,7 @@ var SelectField = ({
|
|
2031
2101
|
}
|
2032
2102
|
},
|
2033
2103
|
value,
|
2034
|
-
children: field.options.map((option) => /* @__PURE__ */
|
2104
|
+
children: field.options.map((option) => /* @__PURE__ */ jsx16(
|
2035
2105
|
"option",
|
2036
2106
|
{
|
2037
2107
|
label: option.label,
|
@@ -2047,7 +2117,7 @@ var SelectField = ({
|
|
2047
2117
|
|
2048
2118
|
// components/AutoField/fields/TextareaField/index.tsx
|
2049
2119
|
init_react_import();
|
2050
|
-
import { jsx as
|
2120
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
2051
2121
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2052
2122
|
var TextareaField = ({
|
2053
2123
|
onChange,
|
@@ -2058,7 +2128,7 @@ var TextareaField = ({
|
|
2058
2128
|
Label: Label2,
|
2059
2129
|
id
|
2060
2130
|
}) => {
|
2061
|
-
return /* @__PURE__ */
|
2131
|
+
return /* @__PURE__ */ jsx17(Label2, { label: label || name, icon: /* @__PURE__ */ jsx17(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx17(
|
2062
2132
|
"textarea",
|
2063
2133
|
{
|
2064
2134
|
id,
|
@@ -2085,7 +2155,7 @@ init_react_import();
|
|
2085
2155
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2086
2156
|
|
2087
2157
|
// components/AutoField/fields/ObjectField/index.tsx
|
2088
|
-
import { jsx as
|
2158
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
2089
2159
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2090
2160
|
var ObjectField = ({
|
2091
2161
|
field,
|
@@ -2097,43 +2167,54 @@ var ObjectField = ({
|
|
2097
2167
|
readOnly,
|
2098
2168
|
id
|
2099
2169
|
}) => {
|
2100
|
-
const {
|
2170
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2101
2171
|
if (field.type !== "object" || !field.objectFields) {
|
2102
2172
|
return null;
|
2103
2173
|
}
|
2104
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2105
2174
|
const data = value || {};
|
2106
|
-
return /* @__PURE__ */
|
2175
|
+
return /* @__PURE__ */ jsx18(
|
2107
2176
|
Label2,
|
2108
2177
|
{
|
2109
2178
|
label: label || name,
|
2110
|
-
icon: /* @__PURE__ */
|
2179
|
+
icon: /* @__PURE__ */ jsx18(EllipsisVertical, { size: 16 }),
|
2111
2180
|
el: "div",
|
2112
2181
|
readOnly,
|
2113
|
-
children: /* @__PURE__ */
|
2114
|
-
const subField = field.objectFields[
|
2115
|
-
const
|
2116
|
-
const
|
2117
|
-
const subReadOnly = readOnly ? readOnly :
|
2118
|
-
|
2119
|
-
|
2182
|
+
children: /* @__PURE__ */ jsx18("div", { className: getClassName14(), children: /* @__PURE__ */ jsx18("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
2183
|
+
const subField = field.objectFields[subName];
|
2184
|
+
const subPath = `${name}.${subName}`;
|
2185
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2186
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2187
|
+
const label2 = subField.label || subName;
|
2188
|
+
return /* @__PURE__ */ jsx18(
|
2189
|
+
NestedFieldProvider,
|
2120
2190
|
{
|
2121
|
-
name:
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2191
|
+
name: localName || id,
|
2192
|
+
subName,
|
2193
|
+
readOnlyFields,
|
2194
|
+
children: /* @__PURE__ */ jsx18(
|
2195
|
+
AutoFieldPrivate,
|
2196
|
+
{
|
2197
|
+
name: subPath,
|
2198
|
+
label: subPath,
|
2199
|
+
id: `${id}_${subName}`,
|
2200
|
+
readOnly: subReadOnly,
|
2201
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2202
|
+
label: label2
|
2203
|
+
// May be used by custom fields
|
2131
2204
|
}),
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2205
|
+
value: data[subName],
|
2206
|
+
onChange: (val, ui) => {
|
2207
|
+
onChange(
|
2208
|
+
__spreadProps(__spreadValues({}, data), {
|
2209
|
+
[subName]: val
|
2210
|
+
}),
|
2211
|
+
ui
|
2212
|
+
);
|
2213
|
+
}
|
2214
|
+
}
|
2215
|
+
)
|
2135
2216
|
},
|
2136
|
-
|
2217
|
+
subPath
|
2137
2218
|
);
|
2138
2219
|
}) }) })
|
2139
2220
|
}
|
@@ -2159,7 +2240,7 @@ var useSafeId = () => {
|
|
2159
2240
|
};
|
2160
2241
|
|
2161
2242
|
// components/AutoField/index.tsx
|
2162
|
-
import { Fragment as Fragment4, jsx as
|
2243
|
+
import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
2163
2244
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2164
2245
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2165
2246
|
var FieldLabel = ({
|
@@ -2173,14 +2254,14 @@ var FieldLabel = ({
|
|
2173
2254
|
const El = el;
|
2174
2255
|
return /* @__PURE__ */ jsxs8(El, { className, children: [
|
2175
2256
|
/* @__PURE__ */ jsxs8("div", { className: getClassName15("label"), children: [
|
2176
|
-
icon ? /* @__PURE__ */
|
2257
|
+
icon ? /* @__PURE__ */ jsx19("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx19(Fragment4, {}),
|
2177
2258
|
label,
|
2178
|
-
readOnly && /* @__PURE__ */
|
2259
|
+
readOnly && /* @__PURE__ */ jsx19("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx19(Lock, { size: "12" }) })
|
2179
2260
|
] }),
|
2180
2261
|
children
|
2181
2262
|
] });
|
2182
2263
|
};
|
2183
|
-
var
|
2264
|
+
var FieldLabelInternal = ({
|
2184
2265
|
children,
|
2185
2266
|
icon,
|
2186
2267
|
label,
|
@@ -2188,14 +2269,14 @@ var FieldLabelInternal2 = ({
|
|
2188
2269
|
readOnly
|
2189
2270
|
}) => {
|
2190
2271
|
const { overrides } = useAppContext();
|
2191
|
-
const Wrapper =
|
2272
|
+
const Wrapper = useMemo5(
|
2192
2273
|
() => overrides.fieldLabel || FieldLabel,
|
2193
2274
|
[overrides]
|
2194
2275
|
);
|
2195
2276
|
if (!label) {
|
2196
|
-
return /* @__PURE__ */
|
2277
|
+
return /* @__PURE__ */ jsx19(Fragment4, { children });
|
2197
2278
|
}
|
2198
|
-
return /* @__PURE__ */
|
2279
|
+
return /* @__PURE__ */ jsx19(
|
2199
2280
|
Wrapper,
|
2200
2281
|
{
|
2201
2282
|
label,
|
@@ -2209,8 +2290,9 @@ var FieldLabelInternal2 = ({
|
|
2209
2290
|
};
|
2210
2291
|
function AutoFieldInternal(props) {
|
2211
2292
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2212
|
-
const { dispatch, overrides } = useAppContext();
|
2213
|
-
const
|
2293
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2294
|
+
const nestedFieldContext = useContext3(NestedFieldContext);
|
2295
|
+
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2214
2296
|
const field = props.field;
|
2215
2297
|
const label = field.label;
|
2216
2298
|
const defaultId = useSafeId();
|
@@ -2270,20 +2352,29 @@ function AutoFieldInternal(props) {
|
|
2270
2352
|
return null;
|
2271
2353
|
}
|
2272
2354
|
const CustomField = field.render;
|
2273
|
-
return /* @__PURE__ */
|
2355
|
+
return /* @__PURE__ */ jsx19("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx19("div", { className: getClassName15(), children: /* @__PURE__ */ jsx19(CustomField, __spreadValues({}, mergedProps)) }) });
|
2274
2356
|
}
|
2275
2357
|
const children = defaultFields[field.type](mergedProps);
|
2276
2358
|
const Render2 = render[field.type];
|
2277
|
-
return /* @__PURE__ */
|
2278
|
-
|
2359
|
+
return /* @__PURE__ */ jsx19(
|
2360
|
+
NestedFieldContext.Provider,
|
2279
2361
|
{
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
onClick: (e) => {
|
2284
|
-
e.stopPropagation();
|
2362
|
+
value: {
|
2363
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2364
|
+
localName: nestedFieldContext.localName
|
2285
2365
|
},
|
2286
|
-
children: /* @__PURE__ */
|
2366
|
+
children: /* @__PURE__ */ jsx19(
|
2367
|
+
"div",
|
2368
|
+
{
|
2369
|
+
className: getClassNameWrapper(),
|
2370
|
+
onFocus,
|
2371
|
+
onBlur,
|
2372
|
+
onClick: (e) => {
|
2373
|
+
e.stopPropagation();
|
2374
|
+
},
|
2375
|
+
children: /* @__PURE__ */ jsx19(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2376
|
+
}
|
2377
|
+
)
|
2287
2378
|
}
|
2288
2379
|
);
|
2289
2380
|
}
|
@@ -2311,11 +2402,11 @@ function AutoFieldPrivate(props) {
|
|
2311
2402
|
value: localValue,
|
2312
2403
|
onChange: onChangeLocal
|
2313
2404
|
};
|
2314
|
-
return /* @__PURE__ */
|
2405
|
+
return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2315
2406
|
}
|
2316
2407
|
function AutoField(props) {
|
2317
|
-
const DefaultLabel =
|
2318
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */
|
2408
|
+
const DefaultLabel = useMemo5(() => {
|
2409
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx19(
|
2319
2410
|
"div",
|
2320
2411
|
__spreadProps(__spreadValues({}, labelProps), {
|
2321
2412
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2323,7 +2414,7 @@ function AutoField(props) {
|
|
2323
2414
|
);
|
2324
2415
|
return DefaultLabel2;
|
2325
2416
|
}, [props.readOnly]);
|
2326
|
-
return /* @__PURE__ */
|
2417
|
+
return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2327
2418
|
}
|
2328
2419
|
|
2329
2420
|
// components/Drawer/index.tsx
|
@@ -2334,18 +2425,19 @@ init_react_import();
|
|
2334
2425
|
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" };
|
2335
2426
|
|
2336
2427
|
// components/Drawer/index.tsx
|
2337
|
-
import { useMemo as
|
2428
|
+
import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
|
2338
2429
|
|
2339
2430
|
// components/DragDropContext/index.tsx
|
2340
2431
|
init_react_import();
|
2341
2432
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
2342
2433
|
import {
|
2343
|
-
createContext as
|
2344
|
-
useCallback as
|
2345
|
-
useContext as
|
2346
|
-
useEffect as
|
2347
|
-
|
2348
|
-
|
2434
|
+
createContext as createContext4,
|
2435
|
+
useCallback as useCallback11,
|
2436
|
+
useContext as useContext7,
|
2437
|
+
useEffect as useEffect15,
|
2438
|
+
useId,
|
2439
|
+
useRef as useRef4,
|
2440
|
+
useState as useState17
|
2349
2441
|
} from "react";
|
2350
2442
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
2351
2443
|
|
@@ -2353,23 +2445,22 @@ import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
|
2353
2445
|
init_react_import();
|
2354
2446
|
import {
|
2355
2447
|
forwardRef as forwardRef3,
|
2356
|
-
useCallback as
|
2357
|
-
useContext as
|
2358
|
-
useEffect as
|
2359
|
-
useMemo as
|
2360
|
-
useRef as
|
2361
|
-
useState as useState15
|
2448
|
+
useCallback as useCallback10,
|
2449
|
+
useContext as useContext6,
|
2450
|
+
useEffect as useEffect14,
|
2451
|
+
useMemo as useMemo8,
|
2452
|
+
useRef as useRef3
|
2362
2453
|
} from "react";
|
2363
2454
|
|
2364
2455
|
// components/DraggableComponent/index.tsx
|
2365
2456
|
init_react_import();
|
2366
2457
|
import {
|
2367
|
-
useCallback as
|
2368
|
-
useContext as
|
2458
|
+
useCallback as useCallback7,
|
2459
|
+
useContext as useContext5,
|
2369
2460
|
useEffect as useEffect10,
|
2370
|
-
useMemo as
|
2371
|
-
useRef as
|
2372
|
-
useState as
|
2461
|
+
useMemo as useMemo7,
|
2462
|
+
useRef as useRef2,
|
2463
|
+
useState as useState13
|
2373
2464
|
} from "react";
|
2374
2465
|
|
2375
2466
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -2379,18 +2470,18 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
|
|
2379
2470
|
// components/DraggableComponent/index.tsx
|
2380
2471
|
import { createPortal as createPortal2 } from "react-dom";
|
2381
2472
|
|
2382
|
-
//
|
2473
|
+
// lib/dnd/collision/dynamic/index.ts
|
2383
2474
|
init_react_import();
|
2384
2475
|
import {
|
2385
2476
|
CollisionPriority as CollisionPriority7,
|
2386
2477
|
CollisionType as CollisionType7
|
2387
2478
|
} from "@dnd-kit/abstract";
|
2388
2479
|
|
2389
|
-
//
|
2480
|
+
// lib/dnd/collision/directional/index.ts
|
2390
2481
|
init_react_import();
|
2391
2482
|
import { CollisionType } from "@dnd-kit/abstract";
|
2392
2483
|
|
2393
|
-
//
|
2484
|
+
// lib/dnd/collision/collision-debug.ts
|
2394
2485
|
init_react_import();
|
2395
2486
|
var DEBUG = false;
|
2396
2487
|
var debugElements = {};
|
@@ -2439,7 +2530,7 @@ var collisionDebug = (a, b, id, color, label) => {
|
|
2439
2530
|
});
|
2440
2531
|
};
|
2441
2532
|
|
2442
|
-
//
|
2533
|
+
// lib/dnd/collision/directional/index.ts
|
2443
2534
|
var distanceChange = "increasing";
|
2444
2535
|
var directionalCollision = (input, previous) => {
|
2445
2536
|
var _a;
|
@@ -2472,7 +2563,7 @@ var directionalCollision = (input, previous) => {
|
|
2472
2563
|
return null;
|
2473
2564
|
};
|
2474
2565
|
|
2475
|
-
//
|
2566
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
2476
2567
|
init_react_import();
|
2477
2568
|
var getDirection = (dragAxis, delta) => {
|
2478
2569
|
if (dragAxis === "dynamic") {
|
@@ -2487,7 +2578,7 @@ var getDirection = (dragAxis, delta) => {
|
|
2487
2578
|
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2488
2579
|
};
|
2489
2580
|
|
2490
|
-
//
|
2581
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
2491
2582
|
init_react_import();
|
2492
2583
|
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2493
2584
|
const dragRect = dragShape.boundingRectangle;
|
@@ -2506,7 +2597,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2506
2597
|
return dragRect.right - offset >= dropCenter.x;
|
2507
2598
|
};
|
2508
2599
|
|
2509
|
-
//
|
2600
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2510
2601
|
init_react_import();
|
2511
2602
|
import { Point } from "@dnd-kit/geometry";
|
2512
2603
|
var INTERVAL_SENSITIVITY = 10;
|
@@ -2610,7 +2701,14 @@ var closestCorners = (input) => {
|
|
2610
2701
|
};
|
2611
2702
|
};
|
2612
2703
|
|
2613
|
-
//
|
2704
|
+
// lib/dnd/collision/dynamic/store.ts
|
2705
|
+
init_react_import();
|
2706
|
+
import { createStore } from "zustand/vanilla";
|
2707
|
+
var collisionStore = createStore(() => ({
|
2708
|
+
fallbackEnabled: false
|
2709
|
+
}));
|
2710
|
+
|
2711
|
+
// lib/dnd/collision/dynamic/index.ts
|
2614
2712
|
var flushNext = "";
|
2615
2713
|
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2616
2714
|
var _a, _b, _c, _d, _e;
|
@@ -2622,6 +2720,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2622
2720
|
return null;
|
2623
2721
|
}
|
2624
2722
|
const { center: dragCenter } = dragShape;
|
2723
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2625
2724
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2626
2725
|
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2627
2726
|
direction: interval.direction
|
@@ -2667,7 +2766,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2667
2766
|
flushNext = "";
|
2668
2767
|
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2669
2768
|
}
|
2670
|
-
if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2769
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2671
2770
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2672
2771
|
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2673
2772
|
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
@@ -2728,8 +2827,107 @@ function getDeepScrollPosition(element) {
|
|
2728
2827
|
return totalScroll;
|
2729
2828
|
}
|
2730
2829
|
|
2830
|
+
// components/DropZone/context.tsx
|
2831
|
+
init_react_import();
|
2832
|
+
import {
|
2833
|
+
createContext as createContext3,
|
2834
|
+
useCallback as useCallback6,
|
2835
|
+
useMemo as useMemo6,
|
2836
|
+
useState as useState12
|
2837
|
+
} from "react";
|
2838
|
+
import { createStore as createStore2 } from "zustand";
|
2839
|
+
import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
|
2840
|
+
var dropZoneContext = createContext3(null);
|
2841
|
+
var ZoneStoreContext = createContext3(
|
2842
|
+
createStore2(() => ({
|
2843
|
+
zoneDepthIndex: {},
|
2844
|
+
nextZoneDepthIndex: {},
|
2845
|
+
areaDepthIndex: {},
|
2846
|
+
nextAreaDepthIndex: {},
|
2847
|
+
draggedItem: null,
|
2848
|
+
previewIndex: {}
|
2849
|
+
}))
|
2850
|
+
);
|
2851
|
+
var ZoneStoreProvider = ({
|
2852
|
+
children,
|
2853
|
+
store
|
2854
|
+
}) => {
|
2855
|
+
return /* @__PURE__ */ jsx20(ZoneStoreContext.Provider, { value: store, children });
|
2856
|
+
};
|
2857
|
+
var DropZoneProvider = ({
|
2858
|
+
children,
|
2859
|
+
value
|
2860
|
+
}) => {
|
2861
|
+
const [hoveringComponent, setHoveringComponent] = useState12();
|
2862
|
+
const [areasWithZones, setAreasWithZones] = useState12(
|
2863
|
+
{}
|
2864
|
+
);
|
2865
|
+
const [activeZones, setActiveZones] = useState12({});
|
2866
|
+
const { dispatch } = useAppContext();
|
2867
|
+
const registerZoneArea = useCallback6(
|
2868
|
+
(area) => {
|
2869
|
+
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2870
|
+
},
|
2871
|
+
[setAreasWithZones]
|
2872
|
+
);
|
2873
|
+
const registerZone = useCallback6(
|
2874
|
+
(zoneCompound) => {
|
2875
|
+
if (!dispatch) {
|
2876
|
+
return;
|
2877
|
+
}
|
2878
|
+
dispatch({
|
2879
|
+
type: "registerZone",
|
2880
|
+
zone: zoneCompound
|
2881
|
+
});
|
2882
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
2883
|
+
},
|
2884
|
+
[setActiveZones, dispatch]
|
2885
|
+
);
|
2886
|
+
const unregisterZone = useCallback6(
|
2887
|
+
(zoneCompound) => {
|
2888
|
+
if (!dispatch) {
|
2889
|
+
return;
|
2890
|
+
}
|
2891
|
+
dispatch({
|
2892
|
+
type: "unregisterZone",
|
2893
|
+
zone: zoneCompound
|
2894
|
+
});
|
2895
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
2896
|
+
[zoneCompound]: false
|
2897
|
+
}));
|
2898
|
+
},
|
2899
|
+
[setActiveZones, dispatch]
|
2900
|
+
);
|
2901
|
+
const memoValue = useMemo6(
|
2902
|
+
() => __spreadValues({
|
2903
|
+
hoveringComponent,
|
2904
|
+
setHoveringComponent,
|
2905
|
+
registerZoneArea,
|
2906
|
+
areasWithZones,
|
2907
|
+
registerZone,
|
2908
|
+
unregisterZone,
|
2909
|
+
activeZones
|
2910
|
+
}, value),
|
2911
|
+
[value, hoveringComponent, areasWithZones, activeZones]
|
2912
|
+
);
|
2913
|
+
return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
|
2914
|
+
};
|
2915
|
+
|
2916
|
+
// lib/use-context-store.ts
|
2917
|
+
init_react_import();
|
2918
|
+
import { useContext as useContext4 } from "react";
|
2919
|
+
import { useStore } from "zustand";
|
2920
|
+
import { useShallow } from "zustand/react/shallow";
|
2921
|
+
function useContextStore(context, selector) {
|
2922
|
+
const store = useContext4(context);
|
2923
|
+
if (!store) {
|
2924
|
+
throw new Error("useContextStore must be used inside context");
|
2925
|
+
}
|
2926
|
+
return useStore(store, useShallow(selector));
|
2927
|
+
}
|
2928
|
+
|
2731
2929
|
// components/DraggableComponent/index.tsx
|
2732
|
-
import { jsx as
|
2930
|
+
import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
|
2733
2931
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2734
2932
|
var DEBUG2 = false;
|
2735
2933
|
var space = 8;
|
@@ -2743,9 +2941,9 @@ var DefaultActionBar = ({
|
|
2743
2941
|
}) => /* @__PURE__ */ jsxs9(ActionBar, { children: [
|
2744
2942
|
/* @__PURE__ */ jsxs9(ActionBar.Group, { children: [
|
2745
2943
|
parentAction,
|
2746
|
-
label && /* @__PURE__ */
|
2944
|
+
label && /* @__PURE__ */ jsx21(ActionBar.Label, { label })
|
2747
2945
|
] }),
|
2748
|
-
/* @__PURE__ */
|
2946
|
+
/* @__PURE__ */ jsx21(ActionBar.Group, { children })
|
2749
2947
|
] });
|
2750
2948
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
2751
2949
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -2780,9 +2978,9 @@ var DraggableComponent = ({
|
|
2780
2978
|
iframe,
|
2781
2979
|
state
|
2782
2980
|
} = useAppContext();
|
2783
|
-
const ctx =
|
2784
|
-
const [localZones, setLocalZones] =
|
2785
|
-
const registerLocalZone =
|
2981
|
+
const ctx = useContext5(dropZoneContext);
|
2982
|
+
const [localZones, setLocalZones] = useState13({});
|
2983
|
+
const registerLocalZone = useCallback7(
|
2786
2984
|
(zoneCompound2, active) => {
|
2787
2985
|
var _a;
|
2788
2986
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -2792,7 +2990,7 @@ var DraggableComponent = ({
|
|
2792
2990
|
},
|
2793
2991
|
[setLocalZones]
|
2794
2992
|
);
|
2795
|
-
const unregisterLocalZone =
|
2993
|
+
const unregisterLocalZone = useCallback7(
|
2796
2994
|
(zoneCompound2) => {
|
2797
2995
|
var _a;
|
2798
2996
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -2806,7 +3004,7 @@ var DraggableComponent = ({
|
|
2806
3004
|
);
|
2807
3005
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
2808
3006
|
const { path = [] } = ctx || {};
|
2809
|
-
const [canDrag, setCanDrag] =
|
3007
|
+
const [canDrag, setCanDrag] = useState13(false);
|
2810
3008
|
useEffect10(() => {
|
2811
3009
|
var _a;
|
2812
3010
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
@@ -2817,10 +3015,13 @@ var DraggableComponent = ({
|
|
2817
3015
|
setCanDrag((_a = perms.drag) != null ? _a : true);
|
2818
3016
|
}
|
2819
3017
|
}, [state, index, zoneCompound, getPermissions]);
|
2820
|
-
const userIsDragging =
|
3018
|
+
const userIsDragging = useContextStore(
|
3019
|
+
ZoneStoreContext,
|
3020
|
+
(s) => !!s.draggedItem
|
3021
|
+
);
|
2821
3022
|
const canCollide = canDrag || userIsDragging;
|
2822
3023
|
const disabled = !isEnabled || !canCollide;
|
2823
|
-
const [dragAxis, setDragAxis] =
|
3024
|
+
const [dragAxis, setDragAxis] = useState13(userDragAxis || autoDragAxis);
|
2824
3025
|
const { ref: sortableRef, status } = useSortableSafe({
|
2825
3026
|
id,
|
2826
3027
|
index,
|
@@ -2846,8 +3047,8 @@ var DraggableComponent = ({
|
|
2846
3047
|
}
|
2847
3048
|
});
|
2848
3049
|
const thisIsDragging = status === "dragging";
|
2849
|
-
const ref =
|
2850
|
-
const refSetter =
|
3050
|
+
const ref = useRef2(null);
|
3051
|
+
const refSetter = useCallback7(
|
2851
3052
|
(el) => {
|
2852
3053
|
sortableRef(el);
|
2853
3054
|
if (el) {
|
@@ -2856,14 +3057,14 @@ var DraggableComponent = ({
|
|
2856
3057
|
},
|
2857
3058
|
[sortableRef]
|
2858
3059
|
);
|
2859
|
-
const [portalEl, setPortalEl] =
|
3060
|
+
const [portalEl, setPortalEl] = useState13();
|
2860
3061
|
useEffect10(() => {
|
2861
3062
|
var _a, _b, _c;
|
2862
3063
|
setPortalEl(
|
2863
3064
|
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
|
2864
3065
|
);
|
2865
3066
|
}, [iframe.enabled, ref.current]);
|
2866
|
-
const getStyle =
|
3067
|
+
const getStyle = useCallback7(() => {
|
2867
3068
|
var _a, _b, _c;
|
2868
3069
|
if (!ref.current) return;
|
2869
3070
|
const rect = ref.current.getBoundingClientRect();
|
@@ -2883,8 +3084,8 @@ var DraggableComponent = ({
|
|
2883
3084
|
};
|
2884
3085
|
return style2;
|
2885
3086
|
}, [ref.current]);
|
2886
|
-
const [style, setStyle] =
|
2887
|
-
const sync =
|
3087
|
+
const [style, setStyle] = useState13();
|
3088
|
+
const sync = useCallback7(() => {
|
2888
3089
|
setStyle(getStyle());
|
2889
3090
|
}, [ref.current, iframe]);
|
2890
3091
|
useEffect10(() => {
|
@@ -2897,19 +3098,21 @@ var DraggableComponent = ({
|
|
2897
3098
|
}
|
2898
3099
|
}, [ref.current]);
|
2899
3100
|
useEffect10(() => {
|
2900
|
-
|
2901
|
-
|
2902
|
-
|
2903
|
-
|
3101
|
+
if (isSelected) {
|
3102
|
+
ctx == null ? void 0 : ctx.registerPath({
|
3103
|
+
index,
|
3104
|
+
zone: zoneCompound
|
3105
|
+
});
|
3106
|
+
}
|
2904
3107
|
}, [isSelected]);
|
2905
|
-
const CustomActionBar =
|
3108
|
+
const CustomActionBar = useMemo7(
|
2906
3109
|
() => overrides.actionBar || DefaultActionBar,
|
2907
3110
|
[overrides.actionBar]
|
2908
3111
|
);
|
2909
3112
|
const permissions = getPermissions({
|
2910
3113
|
item: selectedItem
|
2911
3114
|
});
|
2912
|
-
const onClick =
|
3115
|
+
const onClick = useCallback7(
|
2913
3116
|
(e) => {
|
2914
3117
|
e.stopPropagation();
|
2915
3118
|
dispatch({
|
@@ -2921,7 +3124,7 @@ var DraggableComponent = ({
|
|
2921
3124
|
},
|
2922
3125
|
[index, zoneCompound, id]
|
2923
3126
|
);
|
2924
|
-
const onSelectParent =
|
3127
|
+
const onSelectParent = useCallback7(() => {
|
2925
3128
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
2926
3129
|
return;
|
2927
3130
|
}
|
@@ -2939,21 +3142,21 @@ var DraggableComponent = ({
|
|
2939
3142
|
}
|
2940
3143
|
});
|
2941
3144
|
}, [ctx, path]);
|
2942
|
-
const onDuplicate =
|
3145
|
+
const onDuplicate = useCallback7(() => {
|
2943
3146
|
dispatch({
|
2944
3147
|
type: "duplicate",
|
2945
3148
|
sourceIndex: index,
|
2946
3149
|
sourceZone: zoneCompound
|
2947
3150
|
});
|
2948
3151
|
}, [index, zoneCompound]);
|
2949
|
-
const onDelete =
|
3152
|
+
const onDelete = useCallback7(() => {
|
2950
3153
|
dispatch({
|
2951
3154
|
type: "remove",
|
2952
3155
|
index,
|
2953
3156
|
zone: zoneCompound
|
2954
3157
|
});
|
2955
3158
|
}, [index, zoneCompound]);
|
2956
|
-
const [hover, setHover] =
|
3159
|
+
const [hover, setHover] = useState13(false);
|
2957
3160
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
2958
3161
|
useEffect10(() => {
|
2959
3162
|
if (!ref.current) {
|
@@ -3014,7 +3217,7 @@ var DraggableComponent = ({
|
|
3014
3217
|
};
|
3015
3218
|
}
|
3016
3219
|
}, [disabled, ref]);
|
3017
|
-
const [isVisible, setIsVisible] =
|
3220
|
+
const [isVisible, setIsVisible] = useState13(false);
|
3018
3221
|
useEffect10(() => {
|
3019
3222
|
sync();
|
3020
3223
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
@@ -3023,7 +3226,7 @@ var DraggableComponent = ({
|
|
3023
3226
|
setIsVisible(false);
|
3024
3227
|
}
|
3025
3228
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3026
|
-
const syncActionsPosition =
|
3229
|
+
const syncActionsPosition = useCallback7(
|
3027
3230
|
(el) => {
|
3028
3231
|
if (el) {
|
3029
3232
|
const view = el.ownerDocument.defaultView;
|
@@ -3054,7 +3257,7 @@ var DraggableComponent = ({
|
|
3054
3257
|
}
|
3055
3258
|
setDragAxis(autoDragAxis);
|
3056
3259
|
}, [ref, userDragAxis, autoDragAxis]);
|
3057
|
-
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */
|
3260
|
+
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx21(CornerLeftUp, { size: 16 }) });
|
3058
3261
|
return /* @__PURE__ */ jsxs9(
|
3059
3262
|
DropZoneProvider,
|
3060
3263
|
{
|
@@ -3081,15 +3284,15 @@ var DraggableComponent = ({
|
|
3081
3284
|
"data-puck-overlay": true,
|
3082
3285
|
children: [
|
3083
3286
|
debug,
|
3084
|
-
isLoading && /* @__PURE__ */
|
3085
|
-
/* @__PURE__ */
|
3287
|
+
isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
|
3288
|
+
/* @__PURE__ */ jsx21(
|
3086
3289
|
"div",
|
3087
3290
|
{
|
3088
3291
|
className: getClassName16("actionsOverlay"),
|
3089
3292
|
style: {
|
3090
3293
|
top: actionsOverlayTop / zoomConfig.zoom
|
3091
3294
|
},
|
3092
|
-
children: /* @__PURE__ */
|
3295
|
+
children: /* @__PURE__ */ jsx21(
|
3093
3296
|
"div",
|
3094
3297
|
{
|
3095
3298
|
className: getClassName16("actions"),
|
@@ -3107,8 +3310,8 @@ var DraggableComponent = ({
|
|
3107
3310
|
parentAction,
|
3108
3311
|
label: DEBUG2 ? id : label,
|
3109
3312
|
children: [
|
3110
|
-
permissions.duplicate && /* @__PURE__ */
|
3111
|
-
permissions.delete && /* @__PURE__ */
|
3313
|
+
permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
|
3314
|
+
permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
|
3112
3315
|
]
|
3113
3316
|
}
|
3114
3317
|
)
|
@@ -3116,7 +3319,7 @@ var DraggableComponent = ({
|
|
3116
3319
|
)
|
3117
3320
|
}
|
3118
3321
|
),
|
3119
|
-
/* @__PURE__ */
|
3322
|
+
/* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
|
3120
3323
|
]
|
3121
3324
|
}
|
3122
3325
|
),
|
@@ -3132,98 +3335,26 @@ var DraggableComponent = ({
|
|
3132
3335
|
init_react_import();
|
3133
3336
|
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" };
|
3134
3337
|
|
3135
|
-
// components/DropZone/
|
3136
|
-
init_react_import();
|
3137
|
-
import {
|
3138
|
-
createContext as createContext2,
|
3139
|
-
useCallback as useCallback7,
|
3140
|
-
useMemo as useMemo6,
|
3141
|
-
useState as useState13
|
3142
|
-
} from "react";
|
3143
|
-
import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
|
3144
|
-
var dropZoneContext = createContext2(null);
|
3145
|
-
var DropZoneProvider = ({
|
3146
|
-
children,
|
3147
|
-
value
|
3148
|
-
}) => {
|
3149
|
-
const [hoveringComponent, setHoveringComponent] = useState13();
|
3150
|
-
const [areasWithZones, setAreasWithZones] = useState13(
|
3151
|
-
{}
|
3152
|
-
);
|
3153
|
-
const [activeZones, setActiveZones] = useState13({});
|
3154
|
-
const { dispatch } = useAppContext();
|
3155
|
-
const registerZoneArea = useCallback7(
|
3156
|
-
(area) => {
|
3157
|
-
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3158
|
-
},
|
3159
|
-
[setAreasWithZones]
|
3160
|
-
);
|
3161
|
-
const registerZone = useCallback7(
|
3162
|
-
(zoneCompound) => {
|
3163
|
-
if (!dispatch) {
|
3164
|
-
return;
|
3165
|
-
}
|
3166
|
-
dispatch({
|
3167
|
-
type: "registerZone",
|
3168
|
-
zone: zoneCompound
|
3169
|
-
});
|
3170
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
3171
|
-
},
|
3172
|
-
[setActiveZones, dispatch]
|
3173
|
-
);
|
3174
|
-
const unregisterZone = useCallback7(
|
3175
|
-
(zoneCompound) => {
|
3176
|
-
if (!dispatch) {
|
3177
|
-
return;
|
3178
|
-
}
|
3179
|
-
dispatch({
|
3180
|
-
type: "unregisterZone",
|
3181
|
-
zone: zoneCompound
|
3182
|
-
});
|
3183
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
3184
|
-
[zoneCompound]: false
|
3185
|
-
}));
|
3186
|
-
},
|
3187
|
-
[setActiveZones, dispatch]
|
3188
|
-
);
|
3189
|
-
const memoValue = useMemo6(
|
3190
|
-
() => __spreadValues({
|
3191
|
-
hoveringComponent,
|
3192
|
-
setHoveringComponent,
|
3193
|
-
registerZoneArea,
|
3194
|
-
areasWithZones,
|
3195
|
-
registerZone,
|
3196
|
-
unregisterZone,
|
3197
|
-
activeZones
|
3198
|
-
}, value),
|
3199
|
-
[value, hoveringComponent, areasWithZones, activeZones]
|
3200
|
-
);
|
3201
|
-
return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
|
3202
|
-
};
|
3203
|
-
|
3204
|
-
// lib/insert.ts
|
3205
|
-
init_react_import();
|
3206
|
-
var insert = (list, index, item) => {
|
3207
|
-
const result = Array.from(list);
|
3208
|
-
result.splice(index, 0, item);
|
3209
|
-
return result;
|
3210
|
-
};
|
3211
|
-
|
3212
|
-
// components/DropZone/use-min-empty-height.ts
|
3338
|
+
// components/DropZone/lib/use-min-empty-height.ts
|
3213
3339
|
init_react_import();
|
3214
3340
|
import { useEffect as useEffect11, useState as useState14 } from "react";
|
3215
3341
|
var useMinEmptyHeight = ({
|
3216
|
-
draggedItem,
|
3217
3342
|
zoneCompound,
|
3218
3343
|
userMinEmptyHeight,
|
3219
3344
|
ref
|
3220
3345
|
}) => {
|
3221
3346
|
const [prevHeight, setPrevHeight] = useState14(0);
|
3222
3347
|
const [isAnimating, setIsAnimating] = useState14(false);
|
3348
|
+
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3349
|
+
var _a, _b;
|
3350
|
+
return {
|
3351
|
+
draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
|
3352
|
+
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3353
|
+
};
|
3354
|
+
});
|
3223
3355
|
useEffect11(() => {
|
3224
3356
|
if (draggedItem && ref.current) {
|
3225
|
-
|
3226
|
-
if (componentData.zone === zoneCompound) {
|
3357
|
+
if (isZone) {
|
3227
3358
|
const rect = ref.current.getBoundingClientRect();
|
3228
3359
|
setPrevHeight(rect.height);
|
3229
3360
|
setIsAnimating(true);
|
@@ -3253,15 +3384,131 @@ function assignRefs(refs, node) {
|
|
3253
3384
|
});
|
3254
3385
|
}
|
3255
3386
|
|
3256
|
-
// components/DropZone/
|
3257
|
-
|
3258
|
-
|
3259
|
-
|
3387
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3388
|
+
init_react_import();
|
3389
|
+
import { useEffect as useEffect12, useState as useState15 } from "react";
|
3390
|
+
|
3391
|
+
// lib/dnd/use-rendered-callback.ts
|
3392
|
+
init_react_import();
|
3393
|
+
import { useDragDropManager } from "@dnd-kit/react";
|
3394
|
+
import { useCallback as useCallback8 } from "react";
|
3395
|
+
function useRenderedCallback(callback, deps) {
|
3396
|
+
const manager = useDragDropManager();
|
3397
|
+
return useCallback8(
|
3398
|
+
(...args) => __async(this, null, function* () {
|
3399
|
+
yield manager == null ? void 0 : manager.renderer.rendering;
|
3400
|
+
return callback(...args);
|
3401
|
+
}),
|
3402
|
+
[...deps, manager]
|
3403
|
+
);
|
3404
|
+
}
|
3405
|
+
|
3406
|
+
// lib/insert.ts
|
3407
|
+
init_react_import();
|
3408
|
+
var insert = (list, index, item) => {
|
3409
|
+
const result = Array.from(list);
|
3410
|
+
result.splice(index, 0, item);
|
3411
|
+
return result;
|
3412
|
+
};
|
3413
|
+
|
3414
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3415
|
+
var useContentWithPreview = (content, zoneCompound) => {
|
3416
|
+
const { draggedItemId, preview, previewExists } = useContextStore(
|
3417
|
+
ZoneStoreContext,
|
3418
|
+
(s) => {
|
3419
|
+
var _a;
|
3420
|
+
return {
|
3421
|
+
draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
|
3422
|
+
preview: s.previewIndex[zoneCompound],
|
3423
|
+
previewExists: Object.keys(s.previewIndex || {}).length > 0
|
3424
|
+
};
|
3425
|
+
}
|
3426
|
+
);
|
3427
|
+
const [contentWithPreview, setContentWithPreview] = useState15(content);
|
3428
|
+
const updateContent = useRenderedCallback(
|
3429
|
+
(content2, preview2) => {
|
3430
|
+
if (preview2) {
|
3431
|
+
if (preview2.type === "insert") {
|
3432
|
+
setContentWithPreview(
|
3433
|
+
insert(
|
3434
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3435
|
+
preview2.index,
|
3436
|
+
{
|
3437
|
+
type: "preview",
|
3438
|
+
props: { id: preview2.props.id }
|
3439
|
+
}
|
3440
|
+
)
|
3441
|
+
);
|
3442
|
+
} else {
|
3443
|
+
setContentWithPreview(
|
3444
|
+
insert(
|
3445
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3446
|
+
preview2.index,
|
3447
|
+
{
|
3448
|
+
type: preview2.componentType,
|
3449
|
+
props: preview2.props
|
3450
|
+
}
|
3451
|
+
)
|
3452
|
+
);
|
3453
|
+
}
|
3454
|
+
} else {
|
3455
|
+
setContentWithPreview(
|
3456
|
+
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3457
|
+
);
|
3458
|
+
}
|
3459
|
+
},
|
3460
|
+
[draggedItemId, previewExists]
|
3461
|
+
);
|
3462
|
+
useEffect12(() => {
|
3463
|
+
updateContent(content, preview);
|
3464
|
+
}, [content, preview]);
|
3465
|
+
return contentWithPreview;
|
3466
|
+
};
|
3467
|
+
|
3468
|
+
// components/DropZone/lib/use-drag-axis.ts
|
3469
|
+
init_react_import();
|
3470
|
+
import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
|
3260
3471
|
var GRID_DRAG_AXIS = "dynamic";
|
3261
3472
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3262
3473
|
var DEFAULT_DRAG_AXIS = "y";
|
3474
|
+
var useDragAxis = (ref, collisionAxis) => {
|
3475
|
+
const { status } = useAppContext();
|
3476
|
+
const [dragAxis, setDragAxis] = useState16(
|
3477
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
3478
|
+
);
|
3479
|
+
const calculateDragAxis = useCallback9(() => {
|
3480
|
+
if (ref.current) {
|
3481
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
3482
|
+
if (computedStyle.display === "grid") {
|
3483
|
+
setDragAxis(GRID_DRAG_AXIS);
|
3484
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3485
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3486
|
+
} else {
|
3487
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
3488
|
+
}
|
3489
|
+
}
|
3490
|
+
}, [ref.current]);
|
3491
|
+
useEffect13(() => {
|
3492
|
+
const onViewportChange = () => {
|
3493
|
+
calculateDragAxis();
|
3494
|
+
};
|
3495
|
+
window.addEventListener("viewportchange", onViewportChange);
|
3496
|
+
return () => {
|
3497
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
3498
|
+
};
|
3499
|
+
}, []);
|
3500
|
+
useEffect13(calculateDragAxis, [status, collisionAxis]);
|
3501
|
+
return [dragAxis, calculateDragAxis];
|
3502
|
+
};
|
3503
|
+
|
3504
|
+
// components/DropZone/index.tsx
|
3505
|
+
import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
|
3506
|
+
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3507
|
+
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3508
|
+
var RENDER_DEBUG = false;
|
3509
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
|
3263
3510
|
var DropZoneEdit = forwardRef3(
|
3264
|
-
function
|
3511
|
+
function DropZoneEditInternal({
|
3265
3512
|
zone,
|
3266
3513
|
allow,
|
3267
3514
|
disallow,
|
@@ -3271,31 +3518,50 @@ var DropZoneEdit = forwardRef3(
|
|
3271
3518
|
collisionAxis
|
3272
3519
|
}, userRef) {
|
3273
3520
|
const appContext2 = useAppContext();
|
3274
|
-
const ctx =
|
3521
|
+
const ctx = useContext6(dropZoneContext);
|
3275
3522
|
const {
|
3276
3523
|
// These all need setting via context
|
3277
3524
|
data,
|
3278
3525
|
config,
|
3279
3526
|
areaId,
|
3280
|
-
draggedItem,
|
3281
3527
|
registerZoneArea,
|
3282
3528
|
depth,
|
3283
3529
|
registerLocalZone,
|
3284
3530
|
unregisterLocalZone,
|
3285
|
-
deepestZone = rootDroppableId,
|
3286
|
-
deepestArea,
|
3287
|
-
nextDeepestArea,
|
3288
3531
|
path = [],
|
3289
3532
|
activeZones
|
3290
3533
|
} = ctx;
|
3291
|
-
const { itemSelector } = appContext2.state.ui;
|
3292
3534
|
let zoneCompound = rootDroppableId;
|
3293
|
-
|
3535
|
+
if (areaId) {
|
3536
|
+
if (zone !== rootDroppableId) {
|
3537
|
+
zoneCompound = `${areaId}:${zone}`;
|
3538
|
+
}
|
3539
|
+
}
|
3540
|
+
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
3541
|
+
const {
|
3542
|
+
isDeepestZone,
|
3543
|
+
inNextDeepestArea,
|
3544
|
+
draggedComponentType,
|
3545
|
+
userIsDragging,
|
3546
|
+
preview
|
3547
|
+
} = useContextStore(ZoneStoreContext, (s) => {
|
3548
|
+
var _a, _b, _c;
|
3549
|
+
return {
|
3550
|
+
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
3551
|
+
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3552
|
+
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3553
|
+
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3554
|
+
userIsDragging: !!s.draggedItem,
|
3555
|
+
preview: s.previewIndex[zoneCompound]
|
3556
|
+
};
|
3557
|
+
});
|
3558
|
+
const { itemSelector } = appContext2.state.ui;
|
3559
|
+
useEffect14(() => {
|
3294
3560
|
if (areaId && registerZoneArea) {
|
3295
3561
|
registerZoneArea(areaId);
|
3296
3562
|
}
|
3297
3563
|
}, [areaId]);
|
3298
|
-
|
3564
|
+
useEffect14(() => {
|
3299
3565
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3300
3566
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3301
3567
|
}
|
@@ -3305,25 +3571,18 @@ var DropZoneEdit = forwardRef3(
|
|
3305
3571
|
}
|
3306
3572
|
};
|
3307
3573
|
}, []);
|
3308
|
-
|
3309
|
-
if (zone !== rootDroppableId) {
|
3310
|
-
zoneCompound = `${areaId}:${zone}`;
|
3311
|
-
}
|
3312
|
-
}
|
3313
|
-
const content = useMemo7(() => {
|
3574
|
+
const content = useMemo8(() => {
|
3314
3575
|
if (areaId && zone !== rootDroppableId) {
|
3315
3576
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3316
3577
|
}
|
3317
3578
|
return data.content || [];
|
3318
3579
|
}, [data, zoneCompound]);
|
3319
|
-
const ref =
|
3320
|
-
const acceptsTarget =
|
3321
|
-
(
|
3322
|
-
if (!
|
3580
|
+
const ref = useRef3(null);
|
3581
|
+
const acceptsTarget = useCallback10(
|
3582
|
+
(componentType) => {
|
3583
|
+
if (!componentType) {
|
3323
3584
|
return true;
|
3324
3585
|
}
|
3325
|
-
const data2 = target.data;
|
3326
|
-
const { componentType } = data2;
|
3327
3586
|
if (disallow) {
|
3328
3587
|
const defaultedAllow = allow || [];
|
3329
3588
|
const filteredDisallow = (disallow || []).filter(
|
@@ -3341,49 +3600,26 @@ var DropZoneEdit = forwardRef3(
|
|
3341
3600
|
},
|
3342
3601
|
[allow, disallow]
|
3343
3602
|
);
|
3344
|
-
|
3603
|
+
useEffect14(() => {
|
3345
3604
|
if (registerLocalZone) {
|
3346
|
-
registerLocalZone(zoneCompound, acceptsTarget(
|
3605
|
+
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3347
3606
|
}
|
3348
3607
|
return () => {
|
3349
3608
|
if (unregisterLocalZone) {
|
3350
3609
|
unregisterLocalZone(zoneCompound);
|
3351
3610
|
}
|
3352
3611
|
};
|
3353
|
-
}, [
|
3354
|
-
const
|
3355
|
-
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3356
|
-
const userIsDragging = !!draggedItem;
|
3612
|
+
}, [draggedComponentType, zoneCompound]);
|
3613
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
3357
3614
|
let isEnabled = true;
|
3358
|
-
if (
|
3359
|
-
isEnabled =
|
3615
|
+
if (userIsDragging) {
|
3616
|
+
isEnabled = isDeepestZone;
|
3360
3617
|
}
|
3361
3618
|
if (isEnabled) {
|
3362
|
-
isEnabled = acceptsTarget(
|
3363
|
-
}
|
3364
|
-
const
|
3365
|
-
const
|
3366
|
-
const contentWithPreview = useMemo7(() => {
|
3367
|
-
let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
|
3368
|
-
if (previewInZone) {
|
3369
|
-
contentWithPreview2 = content.filter(
|
3370
|
-
(item) => item.props.id !== preview.props.id
|
3371
|
-
);
|
3372
|
-
if (preview.type === "insert") {
|
3373
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3374
|
-
type: "preview",
|
3375
|
-
props: { id: preview.props.id }
|
3376
|
-
});
|
3377
|
-
} else {
|
3378
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3379
|
-
type: preview.componentType,
|
3380
|
-
props: preview.props
|
3381
|
-
});
|
3382
|
-
}
|
3383
|
-
}
|
3384
|
-
return contentWithPreview2;
|
3385
|
-
}, [preview, content]);
|
3386
|
-
const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3619
|
+
isEnabled = acceptsTarget(draggedComponentType);
|
3620
|
+
}
|
3621
|
+
const contentWithPreview = useContentWithPreview(content, zoneCompound);
|
3622
|
+
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3387
3623
|
const droppableConfig = {
|
3388
3624
|
id: zoneCompound,
|
3389
3625
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -3393,45 +3629,20 @@ var DropZoneEdit = forwardRef3(
|
|
3393
3629
|
data: {
|
3394
3630
|
areaId,
|
3395
3631
|
depth,
|
3396
|
-
isDroppableTarget: acceptsTarget(
|
3632
|
+
isDroppableTarget: acceptsTarget(draggedComponentType),
|
3397
3633
|
path
|
3398
3634
|
}
|
3399
3635
|
};
|
3400
3636
|
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
3401
3637
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3402
3638
|
const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
|
3403
|
-
const [dragAxis
|
3404
|
-
collisionAxis || DEFAULT_DRAG_AXIS
|
3405
|
-
);
|
3406
|
-
const calculateDragAxis = useCallback8(() => {
|
3407
|
-
if (ref.current) {
|
3408
|
-
const computedStyle = window.getComputedStyle(ref.current);
|
3409
|
-
if (computedStyle.display === "grid") {
|
3410
|
-
setDragAxis(GRID_DRAG_AXIS);
|
3411
|
-
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3412
|
-
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3413
|
-
} else {
|
3414
|
-
setDragAxis(DEFAULT_DRAG_AXIS);
|
3415
|
-
}
|
3416
|
-
}
|
3417
|
-
}, [ref.current]);
|
3418
|
-
useEffect12(calculateDragAxis, [appContext2.status, collisionAxis]);
|
3419
|
-
useEffect12(() => {
|
3420
|
-
const onViewportChange = () => {
|
3421
|
-
calculateDragAxis();
|
3422
|
-
};
|
3423
|
-
window.addEventListener("viewportchange", onViewportChange);
|
3424
|
-
return () => {
|
3425
|
-
window.removeEventListener("viewportchange", onViewportChange);
|
3426
|
-
};
|
3427
|
-
}, []);
|
3639
|
+
const [dragAxis] = useDragAxis(ref, collisionAxis);
|
3428
3640
|
const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
|
3429
|
-
draggedItem,
|
3430
3641
|
zoneCompound,
|
3431
3642
|
userMinEmptyHeight,
|
3432
3643
|
ref
|
3433
3644
|
});
|
3434
|
-
return /* @__PURE__ */
|
3645
|
+
return /* @__PURE__ */ jsx22(
|
3435
3646
|
"div",
|
3436
3647
|
{
|
3437
3648
|
className: `${getClassName17({
|
@@ -3451,88 +3662,84 @@ var DropZoneEdit = forwardRef3(
|
|
3451
3662
|
"data-puck-dropzone": zoneCompound,
|
3452
3663
|
"data-puck-dnd": zoneCompound,
|
3453
3664
|
style: __spreadProps(__spreadValues({}, style), {
|
3454
|
-
"--min-empty-height": `${minEmptyHeight}px
|
3665
|
+
"--min-empty-height": `${minEmptyHeight}px`,
|
3666
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3455
3667
|
}),
|
3456
|
-
children:
|
3457
|
-
|
3458
|
-
|
3459
|
-
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3463
|
-
|
3464
|
-
|
3465
|
-
|
3466
|
-
|
3467
|
-
|
3668
|
+
children: contentWithPreview.map((item, i) => {
|
3669
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3670
|
+
const componentId = item.props.id;
|
3671
|
+
const puckProps = {
|
3672
|
+
renderDropZone: DropZoneEditPure,
|
3673
|
+
isEditing: true,
|
3674
|
+
dragRef: null
|
3675
|
+
};
|
3676
|
+
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
|
3677
|
+
puck: puckProps,
|
3678
|
+
editMode: true
|
3679
|
+
// DEPRECATED
|
3680
|
+
});
|
3681
|
+
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3682
|
+
let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
|
3683
|
+
"No configuration for ",
|
3684
|
+
item.type
|
3685
|
+
] });
|
3686
|
+
const componentConfig = config.components[item.type];
|
3687
|
+
let componentType = item.type;
|
3688
|
+
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3689
|
+
if (item.type === "preview") {
|
3690
|
+
let Preview4 = function() {
|
3691
|
+
return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3468
3692
|
};
|
3469
|
-
|
3470
|
-
|
3471
|
-
|
3472
|
-
|
3473
|
-
|
3474
|
-
|
3475
|
-
|
3476
|
-
|
3477
|
-
|
3478
|
-
|
3479
|
-
|
3480
|
-
|
3481
|
-
|
3482
|
-
|
3483
|
-
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
|
3488
|
-
|
3489
|
-
|
3490
|
-
|
3491
|
-
|
3492
|
-
|
3493
|
-
|
3494
|
-
|
3495
|
-
|
3496
|
-
|
3497
|
-
|
3498
|
-
id: componentId,
|
3499
|
-
componentType,
|
3500
|
-
zoneCompound,
|
3501
|
-
depth: depth + 1,
|
3502
|
-
index: i,
|
3503
|
-
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3504
|
-
isSelected,
|
3505
|
-
label,
|
3506
|
-
isEnabled,
|
3507
|
-
autoDragAxis: dragAxis,
|
3508
|
-
userDragAxis: collisionAxis,
|
3509
|
-
inDroppableZone: acceptsTarget(draggedItem),
|
3510
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx21(
|
3511
|
-
Render2,
|
3512
|
-
__spreadProps(__spreadValues({}, defaultedProps), {
|
3513
|
-
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3514
|
-
dragRef
|
3515
|
-
})
|
3693
|
+
var Preview3 = Preview4;
|
3694
|
+
componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
|
3695
|
+
label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
|
3696
|
+
Render2 = Preview4;
|
3697
|
+
}
|
3698
|
+
return /* @__PURE__ */ jsx22(
|
3699
|
+
DropZoneProvider,
|
3700
|
+
{
|
3701
|
+
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3702
|
+
children: /* @__PURE__ */ jsx22(
|
3703
|
+
DraggableComponent,
|
3704
|
+
{
|
3705
|
+
id: componentId,
|
3706
|
+
componentType,
|
3707
|
+
zoneCompound,
|
3708
|
+
depth: depth + 1,
|
3709
|
+
index: i,
|
3710
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3711
|
+
isSelected,
|
3712
|
+
label,
|
3713
|
+
isEnabled,
|
3714
|
+
autoDragAxis: dragAxis,
|
3715
|
+
userDragAxis: collisionAxis,
|
3716
|
+
inDroppableZone: acceptsTarget(draggedComponentType),
|
3717
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx22(
|
3718
|
+
Render2,
|
3719
|
+
__spreadProps(__spreadValues({}, defaultedProps), {
|
3720
|
+
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3721
|
+
dragRef
|
3516
3722
|
})
|
3517
|
-
|
3518
|
-
}
|
3519
|
-
|
3520
|
-
|
3521
|
-
|
3522
|
-
|
3523
|
-
|
3524
|
-
|
3723
|
+
})
|
3724
|
+
) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
|
3725
|
+
}
|
3726
|
+
)
|
3727
|
+
},
|
3728
|
+
componentId
|
3729
|
+
);
|
3730
|
+
})
|
3525
3731
|
}
|
3526
3732
|
);
|
3527
3733
|
}
|
3528
3734
|
);
|
3735
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
|
3529
3736
|
var DropZoneRender = forwardRef3(
|
3530
|
-
function
|
3531
|
-
const ctx =
|
3737
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3738
|
+
const ctx = useContext6(dropZoneContext);
|
3532
3739
|
const { data, areaId = "root", config } = ctx || {};
|
3533
3740
|
let zoneCompound = rootDroppableId;
|
3534
3741
|
let content = (data == null ? void 0 : data.content) || [];
|
3535
|
-
|
3742
|
+
useEffect14(() => {
|
3536
3743
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3537
3744
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3538
3745
|
}
|
@@ -3549,10 +3756,10 @@ var DropZoneRender = forwardRef3(
|
|
3549
3756
|
zoneCompound = `${areaId}:${zone}`;
|
3550
3757
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3551
3758
|
}
|
3552
|
-
return /* @__PURE__ */
|
3759
|
+
return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
|
3553
3760
|
const Component = config.components[item.type];
|
3554
3761
|
if (Component) {
|
3555
|
-
return /* @__PURE__ */
|
3762
|
+
return /* @__PURE__ */ jsx22(
|
3556
3763
|
DropZoneProvider,
|
3557
3764
|
{
|
3558
3765
|
value: {
|
@@ -3562,10 +3769,12 @@ var DropZoneRender = forwardRef3(
|
|
3562
3769
|
depth: 1,
|
3563
3770
|
path: []
|
3564
3771
|
},
|
3565
|
-
children: /* @__PURE__ */
|
3772
|
+
children: /* @__PURE__ */ jsx22(
|
3566
3773
|
Component.render,
|
3567
3774
|
__spreadProps(__spreadValues({}, item.props), {
|
3568
|
-
puck: {
|
3775
|
+
puck: {
|
3776
|
+
renderDropZone: DropZoneRenderPure
|
3777
|
+
}
|
3569
3778
|
})
|
3570
3779
|
)
|
3571
3780
|
},
|
@@ -3578,11 +3787,11 @@ var DropZoneRender = forwardRef3(
|
|
3578
3787
|
);
|
3579
3788
|
var DropZone = forwardRef3(
|
3580
3789
|
function DropZone2(props, ref) {
|
3581
|
-
const ctx =
|
3790
|
+
const ctx = useContext6(dropZoneContext);
|
3582
3791
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3583
|
-
return /* @__PURE__ */
|
3792
|
+
return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3584
3793
|
}
|
3585
|
-
return /* @__PURE__ */
|
3794
|
+
return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3586
3795
|
}
|
3587
3796
|
);
|
3588
3797
|
|
@@ -3598,7 +3807,7 @@ var getZoneId = (zoneCompound) => {
|
|
3598
3807
|
return [rootDroppableId, zoneCompound];
|
3599
3808
|
};
|
3600
3809
|
|
3601
|
-
//
|
3810
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3602
3811
|
init_react_import();
|
3603
3812
|
import { Plugin } from "@dnd-kit/abstract";
|
3604
3813
|
import { effects } from "@dnd-kit/state";
|
@@ -3640,7 +3849,49 @@ var getFrame = () => {
|
|
3640
3849
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3641
3850
|
};
|
3642
3851
|
|
3643
|
-
//
|
3852
|
+
// lib/global-position.ts
|
3853
|
+
init_react_import();
|
3854
|
+
var GlobalPosition = class {
|
3855
|
+
constructor(target, original) {
|
3856
|
+
this.scaleFactor = 1;
|
3857
|
+
this.frameEl = null;
|
3858
|
+
this.frameRect = null;
|
3859
|
+
var _a;
|
3860
|
+
this.target = target;
|
3861
|
+
this.original = original;
|
3862
|
+
this.frameEl = document.querySelector("iframe");
|
3863
|
+
if (this.frameEl) {
|
3864
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
3865
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
3866
|
+
}
|
3867
|
+
}
|
3868
|
+
get x() {
|
3869
|
+
return this.original.x;
|
3870
|
+
}
|
3871
|
+
get y() {
|
3872
|
+
return this.original.y;
|
3873
|
+
}
|
3874
|
+
get global() {
|
3875
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
3876
|
+
return {
|
3877
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
3878
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
3879
|
+
};
|
3880
|
+
}
|
3881
|
+
return this.original;
|
3882
|
+
}
|
3883
|
+
get frame() {
|
3884
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
3885
|
+
return {
|
3886
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
3887
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
3888
|
+
};
|
3889
|
+
}
|
3890
|
+
return this.original;
|
3891
|
+
}
|
3892
|
+
};
|
3893
|
+
|
3894
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3644
3895
|
var depthSort = (candidates) => {
|
3645
3896
|
return candidates.sort((a, b) => {
|
3646
3897
|
const aData = a.data;
|
@@ -3669,10 +3920,12 @@ var getZoneId2 = (candidate) => {
|
|
3669
3920
|
}
|
3670
3921
|
return id;
|
3671
3922
|
};
|
3672
|
-
var getPointerCollisions = (position, manager
|
3673
|
-
var _a;
|
3923
|
+
var getPointerCollisions = (position, manager) => {
|
3674
3924
|
const candidates = [];
|
3675
|
-
let elements = ownerDocument.elementsFromPoint(
|
3925
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
3926
|
+
position.x,
|
3927
|
+
position.y
|
3928
|
+
);
|
3676
3929
|
const previewFrame = elements.find(
|
3677
3930
|
(el) => el.getAttribute("data-puck-preview")
|
3678
3931
|
);
|
@@ -3681,17 +3934,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3681
3934
|
elements = [drawer];
|
3682
3935
|
}
|
3683
3936
|
if (previewFrame) {
|
3684
|
-
const
|
3685
|
-
if (
|
3686
|
-
|
3687
|
-
const frame = getFrame();
|
3688
|
-
if (frame) {
|
3689
|
-
const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
3690
|
-
elements = frame.elementsFromPoint(
|
3691
|
-
(position.x - rect.left) / scaleFactor,
|
3692
|
-
(position.y - rect.top) / scaleFactor
|
3693
|
-
);
|
3694
|
-
}
|
3937
|
+
const frame = getFrame();
|
3938
|
+
if (frame) {
|
3939
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
3695
3940
|
}
|
3696
3941
|
}
|
3697
3942
|
if (elements) {
|
@@ -3708,9 +3953,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3708
3953
|
}
|
3709
3954
|
return candidates;
|
3710
3955
|
};
|
3711
|
-
var findDeepestCandidate = (position, manager
|
3956
|
+
var findDeepestCandidate = (position, manager) => {
|
3712
3957
|
var _a;
|
3713
|
-
const candidates = getPointerCollisions(position, manager
|
3958
|
+
const candidates = getPointerCollisions(position, manager);
|
3714
3959
|
if (candidates.length > 0) {
|
3715
3960
|
const sortedCandidates = depthSort(candidates);
|
3716
3961
|
const draggable = manager.dragOperation.source;
|
@@ -3755,9 +4000,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
|
|
3755
4000
|
area: null
|
3756
4001
|
};
|
3757
4002
|
};
|
3758
|
-
var createNestedDroppablePlugin = ({
|
3759
|
-
onChange
|
3760
|
-
}) => class NestedDroppablePlugin extends Plugin {
|
4003
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
|
3761
4004
|
constructor(manager, options) {
|
3762
4005
|
super(manager);
|
3763
4006
|
if (typeof window === "undefined") {
|
@@ -3765,16 +4008,19 @@ var createNestedDroppablePlugin = ({
|
|
3765
4008
|
}
|
3766
4009
|
const cleanupEffect = effects(() => {
|
3767
4010
|
const handleMove = (event) => {
|
3768
|
-
const
|
4011
|
+
const target = event.originalTarget || event.target;
|
4012
|
+
const position = new GlobalPosition(target, {
|
3769
4013
|
x: event.clientX,
|
3770
4014
|
y: event.clientY
|
3771
|
-
};
|
3772
|
-
const
|
3773
|
-
|
3774
|
-
|
3775
|
-
findDeepestCandidate(position, manager, ownerDocument),
|
3776
|
-
manager
|
4015
|
+
});
|
4016
|
+
const elements = document.elementsFromPoint(
|
4017
|
+
position.global.x,
|
4018
|
+
position.global.y
|
3777
4019
|
);
|
4020
|
+
const overEl = elements.some((el) => el.id === id);
|
4021
|
+
if (overEl) {
|
4022
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
4023
|
+
}
|
3778
4024
|
};
|
3779
4025
|
const handleMoveThrottled = throttle(handleMove, 50);
|
3780
4026
|
const handlePointerMove = (event) => {
|
@@ -4104,6 +4350,11 @@ var reduceUi = (ui, action) => {
|
|
4104
4350
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4105
4351
|
});
|
4106
4352
|
}
|
4353
|
+
if (action.type === "remove") {
|
4354
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4355
|
+
itemSelector: null
|
4356
|
+
});
|
4357
|
+
}
|
4107
4358
|
return ui;
|
4108
4359
|
};
|
4109
4360
|
|
@@ -4191,7 +4442,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4191
4442
|
import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
|
4192
4443
|
import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
|
4193
4444
|
|
4194
|
-
//
|
4445
|
+
// lib/dnd/PointerSensor.ts
|
4195
4446
|
init_react_import();
|
4196
4447
|
import { batch, effect } from "@dnd-kit/state";
|
4197
4448
|
import { Sensor, configurator } from "@dnd-kit/abstract";
|
@@ -4363,6 +4614,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
4363
4614
|
}
|
4364
4615
|
}
|
4365
4616
|
handlePointerUp(event) {
|
4617
|
+
if (!this.source) {
|
4618
|
+
return;
|
4619
|
+
}
|
4366
4620
|
event.preventDefault();
|
4367
4621
|
event.stopPropagation();
|
4368
4622
|
const { status } = this.manager.dragOperation;
|
@@ -4462,13 +4716,15 @@ function patchWindow(window2) {
|
|
4462
4716
|
}
|
4463
4717
|
|
4464
4718
|
// components/DragDropContext/index.tsx
|
4465
|
-
import {
|
4466
|
-
|
4719
|
+
import { createStore as createStore3 } from "zustand";
|
4720
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
4721
|
+
var DEBUG3 = false;
|
4722
|
+
var dragListenerContext = createContext4({
|
4467
4723
|
dragListeners: {}
|
4468
4724
|
});
|
4469
4725
|
function useDragListener(type, fn, deps = []) {
|
4470
|
-
const { setDragListeners } =
|
4471
|
-
|
4726
|
+
const { setDragListeners } = useContext7(dragListenerContext);
|
4727
|
+
useEffect15(() => {
|
4472
4728
|
if (setDragListeners) {
|
4473
4729
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4474
4730
|
[type]: [...old[type] || [], fn]
|
@@ -4476,80 +4732,147 @@ function useDragListener(type, fn, deps = []) {
|
|
4476
4732
|
}
|
4477
4733
|
}, deps);
|
4478
4734
|
}
|
4479
|
-
var previewContext = createContext3(null);
|
4480
4735
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4736
|
+
var useTempDisableFallback = (timeout3) => {
|
4737
|
+
const lastFallbackDisable = useRef4(null);
|
4738
|
+
return useCallback11((manager) => {
|
4739
|
+
collisionStore.setState({ fallbackEnabled: false });
|
4740
|
+
const fallbackId = generateId();
|
4741
|
+
lastFallbackDisable.current = fallbackId;
|
4742
|
+
setTimeout(() => {
|
4743
|
+
if (lastFallbackDisable.current === fallbackId) {
|
4744
|
+
collisionStore.setState({ fallbackEnabled: true });
|
4745
|
+
manager.collisionObserver.forceUpdate(true);
|
4746
|
+
}
|
4747
|
+
}, timeout3);
|
4748
|
+
}, []);
|
4749
|
+
};
|
4481
4750
|
var DragDropContextClient = ({
|
4482
4751
|
children,
|
4483
4752
|
disableAutoScroll
|
4484
4753
|
}) => {
|
4485
4754
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4486
|
-
const
|
4487
|
-
const previewRef = useRef5(null);
|
4755
|
+
const id = useId();
|
4488
4756
|
const { data } = state;
|
4489
|
-
const
|
4490
|
-
const
|
4491
|
-
const
|
4492
|
-
|
4493
|
-
|
4757
|
+
const debouncedParamsRef = useRef4(null);
|
4758
|
+
const tempDisableFallback = useTempDisableFallback(100);
|
4759
|
+
const [zoneStore] = useState17(
|
4760
|
+
() => createStore3(() => ({
|
4761
|
+
zoneDepthIndex: {},
|
4762
|
+
nextZoneDepthIndex: {},
|
4763
|
+
areaDepthIndex: {},
|
4764
|
+
nextAreaDepthIndex: {},
|
4765
|
+
draggedItem: null,
|
4766
|
+
previewIndex: {}
|
4767
|
+
}))
|
4768
|
+
);
|
4769
|
+
const getChanged2 = useCallback11(
|
4770
|
+
(params, id2) => {
|
4771
|
+
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4772
|
+
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
4773
|
+
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
4774
|
+
let zoneChanged = false;
|
4775
|
+
let areaChanged = false;
|
4776
|
+
if (params.zone && !zoneDepthIndex[params.zone]) {
|
4777
|
+
zoneChanged = true;
|
4778
|
+
} else if (!params.zone && stateHasZone) {
|
4779
|
+
zoneChanged = true;
|
4780
|
+
}
|
4781
|
+
if (params.area && !areaDepthIndex[params.area]) {
|
4782
|
+
areaChanged = true;
|
4783
|
+
} else if (!params.area && stateHasArea) {
|
4784
|
+
areaChanged = true;
|
4785
|
+
}
|
4786
|
+
return { zoneChanged, areaChanged };
|
4787
|
+
},
|
4788
|
+
[zoneStore]
|
4789
|
+
);
|
4790
|
+
const setDeepestAndCollide = useCallback11(
|
4494
4791
|
(params, manager) => {
|
4495
|
-
|
4792
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4793
|
+
if (!zoneChanged && !areaChanged) return;
|
4794
|
+
zoneStore.setState({
|
4795
|
+
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
4796
|
+
areaDepthIndex: params.area ? { [params.area]: true } : {}
|
4797
|
+
});
|
4798
|
+
tempDisableFallback(manager);
|
4496
4799
|
setTimeout(() => {
|
4497
4800
|
manager.collisionObserver.forceUpdate(true);
|
4498
4801
|
}, 50);
|
4499
4802
|
debouncedParamsRef.current = null;
|
4500
4803
|
},
|
4501
|
-
[]
|
4804
|
+
[zoneStore]
|
4502
4805
|
);
|
4503
4806
|
const setDeepestDb = useDebouncedCallback2(
|
4504
4807
|
setDeepestAndCollide,
|
4505
4808
|
AREA_CHANGE_DEBOUNCE_MS
|
4506
4809
|
);
|
4507
|
-
useEffect13(() => {
|
4508
|
-
deepestRef.current = deepest;
|
4509
|
-
}, [deepest]);
|
4510
4810
|
const cancelDb = () => {
|
4511
4811
|
setDeepestDb.cancel();
|
4512
4812
|
debouncedParamsRef.current = null;
|
4513
4813
|
};
|
4514
|
-
|
4515
|
-
|
4516
|
-
|
4517
|
-
|
4518
|
-
|
4519
|
-
|
4520
|
-
|
4521
|
-
|
4522
|
-
|
4523
|
-
|
4524
|
-
}
|
4525
|
-
if (params.zone !== "void" && (lastParams == null ? void 0 : lastParams.zone) === "void") {
|
4526
|
-
setDeepest(params);
|
4527
|
-
manager.collisionObserver.forceUpdate(true);
|
4528
|
-
return;
|
4814
|
+
useEffect15(() => {
|
4815
|
+
if (DEBUG3) {
|
4816
|
+
zoneStore.subscribe(
|
4817
|
+
(s) => {
|
4818
|
+
var _a, _b;
|
4819
|
+
return console.log(
|
4820
|
+
s.previewIndex,
|
4821
|
+
(_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
|
4822
|
+
(_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
|
4823
|
+
);
|
4529
4824
|
}
|
4530
|
-
|
4531
|
-
|
4532
|
-
|
4533
|
-
|
4534
|
-
|
4825
|
+
);
|
4826
|
+
}
|
4827
|
+
}, []);
|
4828
|
+
const [plugins] = useState17(() => [
|
4829
|
+
...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
|
4830
|
+
createNestedDroppablePlugin(
|
4831
|
+
{
|
4832
|
+
onChange: (params, manager) => {
|
4833
|
+
const state2 = zoneStore.getState();
|
4834
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4835
|
+
const isDragging = manager.dragOperation.status.dragging;
|
4836
|
+
if (areaChanged || zoneChanged) {
|
4837
|
+
let nextZoneDepthIndex = {};
|
4838
|
+
let nextAreaDepthIndex = {};
|
4839
|
+
if (params.zone) {
|
4840
|
+
nextZoneDepthIndex = { [params.zone]: true };
|
4841
|
+
}
|
4842
|
+
if (params.area) {
|
4843
|
+
nextAreaDepthIndex = { [params.area]: true };
|
4844
|
+
}
|
4845
|
+
zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
|
4846
|
+
}
|
4847
|
+
if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
|
4848
|
+
setDeepestAndCollide(params, manager);
|
4849
|
+
return;
|
4850
|
+
}
|
4851
|
+
if (areaChanged) {
|
4852
|
+
if (isDragging) {
|
4853
|
+
const debouncedParams = debouncedParamsRef.current;
|
4854
|
+
const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
|
4855
|
+
if (!isSameParams) {
|
4856
|
+
cancelDb();
|
4857
|
+
setDeepestDb(params, manager);
|
4858
|
+
debouncedParamsRef.current = params;
|
4859
|
+
}
|
4860
|
+
} else {
|
4535
4861
|
cancelDb();
|
4536
|
-
|
4537
|
-
debouncedParamsRef.current = params;
|
4862
|
+
setDeepestAndCollide(params, manager);
|
4538
4863
|
}
|
4539
|
-
|
4540
|
-
|
4864
|
+
return;
|
4865
|
+
}
|
4866
|
+
if (zoneChanged) {
|
4541
4867
|
setDeepestAndCollide(params, manager);
|
4542
4868
|
}
|
4543
|
-
|
4544
|
-
}
|
4545
|
-
if (zoneChanged) {
|
4546
|
-
setDeepestAndCollide(params, manager);
|
4869
|
+
cancelDb();
|
4547
4870
|
}
|
4548
|
-
|
4549
|
-
|
4550
|
-
|
4871
|
+
},
|
4872
|
+
id
|
4873
|
+
)
|
4551
4874
|
]);
|
4552
|
-
const [sensors] =
|
4875
|
+
const [sensors] = useState17(() => [
|
4553
4876
|
PointerSensor.configure({
|
4554
4877
|
activationConstraints(event, source) {
|
4555
4878
|
var _a;
|
@@ -4568,11 +4891,10 @@ var DragDropContextClient = ({
|
|
4568
4891
|
}
|
4569
4892
|
})
|
4570
4893
|
]);
|
4571
|
-
const [
|
4572
|
-
const [
|
4573
|
-
const
|
4574
|
-
const
|
4575
|
-
const registerPath = useCallback9(
|
4894
|
+
const [dragListeners, setDragListeners] = useState17({});
|
4895
|
+
const [pathData, setPathData] = useState17();
|
4896
|
+
const dragMode = useRef4(null);
|
4897
|
+
const registerPath = useCallback11(
|
4576
4898
|
(selector) => {
|
4577
4899
|
const item = getItem(selector, data);
|
4578
4900
|
if (!item) {
|
@@ -4594,41 +4916,41 @@ var DragDropContextClient = ({
|
|
4594
4916
|
},
|
4595
4917
|
[data, setPathData]
|
4596
4918
|
);
|
4597
|
-
const initialSelector =
|
4598
|
-
return /* @__PURE__ */
|
4919
|
+
const initialSelector = useRef4(void 0);
|
4920
|
+
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
4599
4921
|
dragListenerContext.Provider,
|
4600
4922
|
{
|
4601
4923
|
value: {
|
4602
4924
|
dragListeners,
|
4603
4925
|
setDragListeners
|
4604
4926
|
},
|
4605
|
-
children: /* @__PURE__ */
|
4927
|
+
children: /* @__PURE__ */ jsx23(
|
4606
4928
|
DragDropProvider2,
|
4607
4929
|
{
|
4608
4930
|
plugins,
|
4609
4931
|
sensors,
|
4610
4932
|
onDragEnd: (event, manager) => {
|
4933
|
+
var _a;
|
4611
4934
|
const { source, target } = event.operation;
|
4612
|
-
deepestRef.current = null;
|
4613
4935
|
if (!source) {
|
4614
|
-
|
4936
|
+
zoneStore.setState({ draggedItem: null });
|
4615
4937
|
return;
|
4616
4938
|
}
|
4617
4939
|
const { zone, index } = source.data;
|
4618
|
-
const
|
4619
|
-
|
4940
|
+
const { previewIndex = {} } = zoneStore.getState() || {};
|
4941
|
+
const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
|
4620
4942
|
setTimeout(() => {
|
4621
|
-
var
|
4622
|
-
|
4943
|
+
var _a2, _b;
|
4944
|
+
zoneStore.setState({ draggedItem: null });
|
4623
4945
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4624
|
-
|
4625
|
-
(
|
4946
|
+
zoneStore.setState({ previewIndex: {} });
|
4947
|
+
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
4626
4948
|
fn(event, manager);
|
4627
4949
|
});
|
4628
4950
|
return;
|
4629
4951
|
}
|
4630
4952
|
if (thisPreview) {
|
4631
|
-
|
4953
|
+
zoneStore.setState({ previewIndex: {} });
|
4632
4954
|
if (thisPreview.type === "insert") {
|
4633
4955
|
insertComponent(
|
4634
4956
|
thisPreview.componentType,
|
@@ -4663,8 +4985,9 @@ var DragDropContextClient = ({
|
|
4663
4985
|
}, 250);
|
4664
4986
|
},
|
4665
4987
|
onDragOver: (event, manager) => {
|
4666
|
-
var _a, _b, _c, _d;
|
4988
|
+
var _a, _b, _c, _d, _e;
|
4667
4989
|
event.preventDefault();
|
4990
|
+
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
4668
4991
|
if (!draggedItem) return;
|
4669
4992
|
cancelDb();
|
4670
4993
|
const { source, target } = event.operation;
|
@@ -4680,7 +5003,7 @@ var DragDropContextClient = ({
|
|
4680
5003
|
const targetData = target.data;
|
4681
5004
|
targetZone = targetData.zone;
|
4682
5005
|
targetIndex = targetData.index;
|
4683
|
-
const collisionData = (
|
5006
|
+
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
4684
5007
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4685
5008
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4686
5009
|
targetIndex = targetIndex - 1;
|
@@ -4692,23 +5015,26 @@ var DragDropContextClient = ({
|
|
4692
5015
|
targetZone = target.id.toString();
|
4693
5016
|
targetIndex = 0;
|
4694
5017
|
}
|
4695
|
-
if (targetId === sourceId || ((
|
5018
|
+
if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
|
4696
5019
|
const [pathId] = path.split(":");
|
4697
5020
|
return pathId === sourceId;
|
4698
5021
|
}))) {
|
4699
5022
|
return;
|
4700
5023
|
}
|
4701
5024
|
if (dragMode.current === "new") {
|
4702
|
-
|
4703
|
-
|
4704
|
-
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
5025
|
+
zoneStore.setState({
|
5026
|
+
previewIndex: {
|
5027
|
+
[targetZone]: {
|
5028
|
+
componentType: sourceData.componentType,
|
5029
|
+
type: "insert",
|
5030
|
+
index: targetIndex,
|
5031
|
+
zone: targetZone,
|
5032
|
+
props: {
|
5033
|
+
id: source.id.toString()
|
5034
|
+
}
|
5035
|
+
}
|
4709
5036
|
}
|
4710
|
-
};
|
4711
|
-
setPreview(previewRef.current);
|
5037
|
+
});
|
4712
5038
|
} else {
|
4713
5039
|
if (!initialSelector.current) {
|
4714
5040
|
initialSelector.current = {
|
@@ -4718,17 +5044,20 @@ var DragDropContextClient = ({
|
|
4718
5044
|
}
|
4719
5045
|
const item = getItem(initialSelector.current, data);
|
4720
5046
|
if (item) {
|
4721
|
-
|
4722
|
-
|
4723
|
-
|
4724
|
-
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
5047
|
+
zoneStore.setState({
|
5048
|
+
previewIndex: {
|
5049
|
+
[targetZone]: {
|
5050
|
+
componentType: sourceData.componentType,
|
5051
|
+
type: "move",
|
5052
|
+
index: targetIndex,
|
5053
|
+
zone: targetZone,
|
5054
|
+
props: item.props
|
5055
|
+
}
|
5056
|
+
}
|
5057
|
+
});
|
4729
5058
|
}
|
4730
5059
|
}
|
4731
|
-
(
|
5060
|
+
(_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
|
4732
5061
|
fn(event, manager);
|
4733
5062
|
});
|
4734
5063
|
},
|
@@ -4738,45 +5067,61 @@ var DragDropContextClient = ({
|
|
4738
5067
|
type: "setUi",
|
4739
5068
|
ui: { itemSelector: null, isDragging: true }
|
4740
5069
|
});
|
5070
|
+
const { source } = event.operation;
|
5071
|
+
if (source && source.type !== "void") {
|
5072
|
+
const sourceData = source.data;
|
5073
|
+
const item = getItem(
|
5074
|
+
{
|
5075
|
+
zone: sourceData.zone,
|
5076
|
+
index: sourceData.index
|
5077
|
+
},
|
5078
|
+
data
|
5079
|
+
);
|
5080
|
+
if (item) {
|
5081
|
+
zoneStore.setState({
|
5082
|
+
previewIndex: {
|
5083
|
+
[sourceData.zone]: {
|
5084
|
+
componentType: sourceData.componentType,
|
5085
|
+
type: "move",
|
5086
|
+
index: sourceData.index,
|
5087
|
+
zone: sourceData.zone,
|
5088
|
+
props: item.props
|
5089
|
+
}
|
5090
|
+
}
|
5091
|
+
});
|
5092
|
+
}
|
5093
|
+
}
|
4741
5094
|
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4742
5095
|
fn(event, manager);
|
4743
5096
|
});
|
4744
5097
|
},
|
4745
5098
|
onBeforeDragStart: (event) => {
|
4746
5099
|
var _a;
|
4747
|
-
if (draggedItem) {
|
4748
|
-
console.warn("New drag started before previous drag cleaned up");
|
4749
|
-
}
|
4750
5100
|
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4751
5101
|
dragMode.current = isNewComponent ? "new" : "existing";
|
4752
5102
|
initialSelector.current = void 0;
|
4753
|
-
|
5103
|
+
zoneStore.setState({ draggedItem: event.operation.source });
|
4754
5104
|
},
|
4755
|
-
children: /* @__PURE__ */
|
5105
|
+
children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
|
4756
5106
|
DropZoneProvider,
|
4757
5107
|
{
|
4758
5108
|
value: {
|
4759
5109
|
data,
|
4760
5110
|
config,
|
4761
|
-
draggedItem,
|
4762
5111
|
mode: "edit",
|
4763
5112
|
areaId: "root",
|
4764
5113
|
depth: 0,
|
4765
5114
|
registerPath,
|
4766
5115
|
pathData,
|
4767
|
-
deepestZone: deepest == null ? void 0 : deepest.zone,
|
4768
|
-
deepestArea: deepest == null ? void 0 : deepest.area,
|
4769
|
-
nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
|
4770
|
-
nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
|
4771
5116
|
path: []
|
4772
5117
|
},
|
4773
5118
|
children
|
4774
5119
|
}
|
4775
|
-
)
|
5120
|
+
) })
|
4776
5121
|
}
|
4777
|
-
)
|
5122
|
+
)
|
4778
5123
|
}
|
4779
|
-
);
|
5124
|
+
) });
|
4780
5125
|
};
|
4781
5126
|
var DragDropContext = ({
|
4782
5127
|
children,
|
@@ -4786,11 +5131,11 @@ var DragDropContext = ({
|
|
4786
5131
|
if (status === "LOADING") {
|
4787
5132
|
return children;
|
4788
5133
|
}
|
4789
|
-
return /* @__PURE__ */
|
5134
|
+
return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
|
4790
5135
|
};
|
4791
5136
|
|
4792
5137
|
// components/Drawer/index.tsx
|
4793
|
-
import { jsx as
|
5138
|
+
import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
|
4794
5139
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
4795
5140
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
4796
5141
|
var DrawerItemInner = ({
|
@@ -4800,11 +5145,11 @@ var DrawerItemInner = ({
|
|
4800
5145
|
dragRef,
|
4801
5146
|
isDragDisabled
|
4802
5147
|
}) => {
|
4803
|
-
const CustomInner =
|
4804
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */
|
5148
|
+
const CustomInner = useMemo9(
|
5149
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
|
4805
5150
|
[children]
|
4806
5151
|
);
|
4807
|
-
return /* @__PURE__ */
|
5152
|
+
return /* @__PURE__ */ jsx24(
|
4808
5153
|
"div",
|
4809
5154
|
{
|
4810
5155
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -4812,9 +5157,9 @@ var DrawerItemInner = ({
|
|
4812
5157
|
onMouseDown: (e) => e.preventDefault(),
|
4813
5158
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
4814
5159
|
"data-puck-drawer-item": true,
|
4815
|
-
children: /* @__PURE__ */
|
4816
|
-
/* @__PURE__ */
|
4817
|
-
/* @__PURE__ */
|
5160
|
+
children: /* @__PURE__ */ jsx24(CustomInner, { name, children: /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
|
5161
|
+
/* @__PURE__ */ jsx24("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
5162
|
+
/* @__PURE__ */ jsx24("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx24(DragIcon, {}) })
|
4818
5163
|
] }) }) })
|
4819
5164
|
}
|
4820
5165
|
);
|
@@ -4832,8 +5177,8 @@ var DrawerItemDraggable = ({
|
|
4832
5177
|
disabled: isDragDisabled
|
4833
5178
|
});
|
4834
5179
|
return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
|
4835
|
-
/* @__PURE__ */
|
4836
|
-
/* @__PURE__ */
|
5180
|
+
/* @__PURE__ */ jsx24("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx24(DrawerItemInner, { name, label, children }) }),
|
5181
|
+
/* @__PURE__ */ jsx24("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx24(
|
4837
5182
|
DrawerItemInner,
|
4838
5183
|
{
|
4839
5184
|
name,
|
@@ -4854,7 +5199,7 @@ var DrawerItem = ({
|
|
4854
5199
|
isDragDisabled
|
4855
5200
|
}) => {
|
4856
5201
|
const resolvedId = id || name;
|
4857
|
-
const [dynamicId, setDynamicId] =
|
5202
|
+
const [dynamicId, setDynamicId] = useState18(generateId(resolvedId));
|
4858
5203
|
if (typeof index !== "undefined") {
|
4859
5204
|
console.error(
|
4860
5205
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -4867,7 +5212,7 @@ var DrawerItem = ({
|
|
4867
5212
|
},
|
4868
5213
|
[resolvedId]
|
4869
5214
|
);
|
4870
|
-
return /* @__PURE__ */
|
5215
|
+
return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
|
4871
5216
|
DrawerItemDraggable,
|
4872
5217
|
{
|
4873
5218
|
name,
|
@@ -4893,14 +5238,14 @@ var Drawer = ({
|
|
4893
5238
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
4894
5239
|
);
|
4895
5240
|
}
|
4896
|
-
const
|
5241
|
+
const id = useId2();
|
4897
5242
|
const { ref } = useDroppableSafe({
|
4898
5243
|
id,
|
4899
5244
|
type: "void",
|
4900
5245
|
collisionPriority: 0
|
4901
5246
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
4902
5247
|
});
|
4903
|
-
return /* @__PURE__ */
|
5248
|
+
return /* @__PURE__ */ jsx24(
|
4904
5249
|
"div",
|
4905
5250
|
{
|
4906
5251
|
className: getClassName18(),
|
@@ -4916,11 +5261,11 @@ Drawer.Item = DrawerItem;
|
|
4916
5261
|
// components/Puck/index.tsx
|
4917
5262
|
init_react_import();
|
4918
5263
|
import {
|
4919
|
-
useCallback as
|
4920
|
-
useEffect as
|
4921
|
-
useMemo as
|
5264
|
+
useCallback as useCallback17,
|
5265
|
+
useEffect as useEffect23,
|
5266
|
+
useMemo as useMemo18,
|
4922
5267
|
useReducer,
|
4923
|
-
useState as
|
5268
|
+
useState as useState26
|
4924
5269
|
} from "react";
|
4925
5270
|
|
4926
5271
|
// components/SidebarSection/index.tsx
|
@@ -4932,7 +5277,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
4932
5277
|
|
4933
5278
|
// lib/use-breadcrumbs.ts
|
4934
5279
|
init_react_import();
|
4935
|
-
import { useContext as
|
5280
|
+
import { useContext as useContext8, useMemo as useMemo10 } from "react";
|
4936
5281
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
4937
5282
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
4938
5283
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -4982,8 +5327,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
4982
5327
|
state: { data },
|
4983
5328
|
selectedItem
|
4984
5329
|
} = useAppContext();
|
4985
|
-
const dzContext =
|
4986
|
-
return
|
5330
|
+
const dzContext = useContext8(dropZoneContext);
|
5331
|
+
return useMemo10(() => {
|
4987
5332
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
4988
5333
|
selectedItem,
|
4989
5334
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -4997,7 +5342,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
4997
5342
|
};
|
4998
5343
|
|
4999
5344
|
// components/SidebarSection/index.tsx
|
5000
|
-
import { jsx as
|
5345
|
+
import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
5001
5346
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5002
5347
|
var SidebarSection = ({
|
5003
5348
|
children,
|
@@ -5016,9 +5361,9 @@ var SidebarSection = ({
|
|
5016
5361
|
className: getClassName19({ noBorderTop, noPadding }),
|
5017
5362
|
style: { background },
|
5018
5363
|
children: [
|
5019
|
-
/* @__PURE__ */
|
5364
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
|
5020
5365
|
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
|
5021
|
-
/* @__PURE__ */
|
5366
|
+
/* @__PURE__ */ jsx25(
|
5022
5367
|
"button",
|
5023
5368
|
{
|
5024
5369
|
type: "button",
|
@@ -5027,12 +5372,12 @@ var SidebarSection = ({
|
|
5027
5372
|
children: breadcrumb.label
|
5028
5373
|
}
|
5029
5374
|
),
|
5030
|
-
/* @__PURE__ */
|
5375
|
+
/* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
|
5031
5376
|
] }, i)) : null,
|
5032
|
-
/* @__PURE__ */
|
5377
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
|
5033
5378
|
] }) }),
|
5034
|
-
/* @__PURE__ */
|
5035
|
-
isLoading && /* @__PURE__ */
|
5379
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
|
5380
|
+
isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
|
5036
5381
|
]
|
5037
5382
|
}
|
5038
5383
|
);
|
@@ -5063,7 +5408,7 @@ init_react_import();
|
|
5063
5408
|
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" };
|
5064
5409
|
|
5065
5410
|
// components/MenuBar/index.tsx
|
5066
|
-
import { Fragment as Fragment7, jsx as
|
5411
|
+
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
|
5067
5412
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5068
5413
|
function MenuBar({
|
5069
5414
|
appState,
|
@@ -5077,7 +5422,7 @@ function MenuBar({
|
|
5077
5422
|
history: { back, forward, historyStore }
|
5078
5423
|
} = useAppContext();
|
5079
5424
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5080
|
-
return /* @__PURE__ */
|
5425
|
+
return /* @__PURE__ */ jsx26(
|
5081
5426
|
"div",
|
5082
5427
|
{
|
5083
5428
|
className: getClassName20({ menuOpen }),
|
@@ -5093,10 +5438,10 @@ function MenuBar({
|
|
5093
5438
|
},
|
5094
5439
|
children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
|
5095
5440
|
/* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
|
5096
|
-
/* @__PURE__ */
|
5097
|
-
/* @__PURE__ */
|
5441
|
+
/* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
|
5442
|
+
/* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
|
5098
5443
|
] }),
|
5099
|
-
/* @__PURE__ */
|
5444
|
+
/* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
|
5100
5445
|
state: appState,
|
5101
5446
|
dispatch
|
5102
5447
|
}) })
|
@@ -5107,7 +5452,7 @@ function MenuBar({
|
|
5107
5452
|
|
5108
5453
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5109
5454
|
init_react_import();
|
5110
|
-
var styles_module_default15 = { "Puck": "
|
5455
|
+
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" };
|
5111
5456
|
|
5112
5457
|
// components/Puck/components/Fields/index.tsx
|
5113
5458
|
init_react_import();
|
@@ -5117,15 +5462,15 @@ init_react_import();
|
|
5117
5462
|
var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
|
5118
5463
|
|
5119
5464
|
// components/Puck/components/Fields/index.tsx
|
5120
|
-
import { useCallback as
|
5465
|
+
import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo11, useState as useState19 } from "react";
|
5121
5466
|
|
5122
5467
|
// lib/use-parent.ts
|
5123
5468
|
init_react_import();
|
5124
|
-
import { useContext as
|
5469
|
+
import { useContext as useContext9 } from "react";
|
5125
5470
|
var useParent = (itemSelector) => {
|
5126
5471
|
var _a;
|
5127
5472
|
const { selectedItem, state } = useAppContext();
|
5128
|
-
const { pathData } =
|
5473
|
+
const { pathData } = useContext9(dropZoneContext) || {};
|
5129
5474
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
5130
5475
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5131
5476
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -5134,7 +5479,7 @@ var useParent = (itemSelector) => {
|
|
5134
5479
|
};
|
5135
5480
|
|
5136
5481
|
// components/Puck/components/Fields/index.tsx
|
5137
|
-
import { Fragment as Fragment8, jsx as
|
5482
|
+
import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
5138
5483
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5139
5484
|
var defaultPageFields = {
|
5140
5485
|
title: { type: "text" }
|
@@ -5142,7 +5487,7 @@ var defaultPageFields = {
|
|
5142
5487
|
var DefaultFields = ({
|
5143
5488
|
children
|
5144
5489
|
}) => {
|
5145
|
-
return /* @__PURE__ */
|
5490
|
+
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5146
5491
|
};
|
5147
5492
|
var useResolvedFields = () => {
|
5148
5493
|
var _a, _b;
|
@@ -5151,20 +5496,20 @@ var useResolvedFields = () => {
|
|
5151
5496
|
const { data } = state;
|
5152
5497
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5153
5498
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5154
|
-
const defaultFields =
|
5499
|
+
const defaultFields = useMemo11(
|
5155
5500
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5156
5501
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5157
5502
|
);
|
5158
5503
|
const rootProps = data.root.props || data.root;
|
5159
|
-
const [lastSelectedData, setLastSelectedData] =
|
5160
|
-
const [resolvedFields, setResolvedFields] =
|
5161
|
-
const [fieldsLoading, setFieldsLoading] =
|
5504
|
+
const [lastSelectedData, setLastSelectedData] = useState19({});
|
5505
|
+
const [resolvedFields, setResolvedFields] = useState19(defaultFields);
|
5506
|
+
const [fieldsLoading, setFieldsLoading] = useState19(false);
|
5162
5507
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5163
5508
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5164
5509
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5165
5510
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5166
5511
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5167
|
-
const resolveFields =
|
5512
|
+
const resolveFields = useCallback12(
|
5168
5513
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5169
5514
|
var _a2;
|
5170
5515
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5200,19 +5545,33 @@ var useResolvedFields = () => {
|
|
5200
5545
|
lastData
|
5201
5546
|
});
|
5202
5547
|
}),
|
5203
|
-
[data, config, componentData, selectedItem, resolvedFields, state]
|
5548
|
+
[data, config, componentData, selectedItem, resolvedFields, state, parent]
|
5204
5549
|
);
|
5205
|
-
|
5206
|
-
|
5207
|
-
|
5208
|
-
|
5209
|
-
|
5210
|
-
|
5211
|
-
|
5212
|
-
|
5213
|
-
|
5550
|
+
const [hasParent, setHasParent] = useState19(false);
|
5551
|
+
useEffect16(() => {
|
5552
|
+
setHasParent(!!parent);
|
5553
|
+
}, [parent]);
|
5554
|
+
useEffect16(() => {
|
5555
|
+
var _a2, _b2;
|
5556
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || hasParent) {
|
5557
|
+
if (hasResolver) {
|
5558
|
+
setFieldsLoading(true);
|
5559
|
+
resolveFields(defaultFields).then((fields) => {
|
5560
|
+
setResolvedFields(fields || {});
|
5561
|
+
setFieldsLoading(false);
|
5562
|
+
});
|
5563
|
+
} else {
|
5564
|
+
setResolvedFields(defaultFields);
|
5565
|
+
}
|
5214
5566
|
}
|
5215
|
-
}, [
|
5567
|
+
}, [
|
5568
|
+
data,
|
5569
|
+
defaultFields,
|
5570
|
+
state.ui.itemSelector,
|
5571
|
+
selectedItem,
|
5572
|
+
hasResolver,
|
5573
|
+
hasParent
|
5574
|
+
]);
|
5216
5575
|
return [resolvedFields, fieldsLoading];
|
5217
5576
|
};
|
5218
5577
|
var Fields = () => {
|
@@ -5233,7 +5592,7 @@ var Fields = () => {
|
|
5233
5592
|
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;
|
5234
5593
|
const isLoading = fieldsResolving || componentResolving;
|
5235
5594
|
const rootProps = data.root.props || data.root;
|
5236
|
-
const Wrapper =
|
5595
|
+
const Wrapper = useMemo11(() => overrides.fields || DefaultFields, [overrides]);
|
5237
5596
|
return /* @__PURE__ */ jsxs14(
|
5238
5597
|
"form",
|
5239
5598
|
{
|
@@ -5242,7 +5601,7 @@ var Fields = () => {
|
|
5242
5601
|
e.preventDefault();
|
5243
5602
|
},
|
5244
5603
|
children: [
|
5245
|
-
/* @__PURE__ */
|
5604
|
+
/* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5246
5605
|
const field = fields[fieldName];
|
5247
5606
|
if (!(field == null ? void 0 : field.type)) return null;
|
5248
5607
|
const onChange = (value, updatedUi) => {
|
@@ -5313,7 +5672,7 @@ var Fields = () => {
|
|
5313
5672
|
item: selectedItem
|
5314
5673
|
});
|
5315
5674
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5316
|
-
return /* @__PURE__ */
|
5675
|
+
return /* @__PURE__ */ jsx27(
|
5317
5676
|
AutoFieldPrivate,
|
5318
5677
|
{
|
5319
5678
|
field,
|
@@ -5331,7 +5690,7 @@ var Fields = () => {
|
|
5331
5690
|
root: true
|
5332
5691
|
});
|
5333
5692
|
const id = `root_${field.type}_${fieldName}`;
|
5334
|
-
return /* @__PURE__ */
|
5693
|
+
return /* @__PURE__ */ jsx27(
|
5335
5694
|
AutoFieldPrivate,
|
5336
5695
|
{
|
5337
5696
|
field,
|
@@ -5345,7 +5704,7 @@ var Fields = () => {
|
|
5345
5704
|
);
|
5346
5705
|
}
|
5347
5706
|
}) }),
|
5348
|
-
isLoading && /* @__PURE__ */
|
5707
|
+
isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
|
5349
5708
|
]
|
5350
5709
|
}
|
5351
5710
|
);
|
@@ -5356,7 +5715,7 @@ init_react_import();
|
|
5356
5715
|
|
5357
5716
|
// lib/use-component-list.tsx
|
5358
5717
|
init_react_import();
|
5359
|
-
import { useEffect as
|
5718
|
+
import { useEffect as useEffect17, useState as useState20 } from "react";
|
5360
5719
|
|
5361
5720
|
// components/ComponentList/index.tsx
|
5362
5721
|
init_react_import();
|
@@ -5366,7 +5725,7 @@ init_react_import();
|
|
5366
5725
|
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" };
|
5367
5726
|
|
5368
5727
|
// components/ComponentList/index.tsx
|
5369
|
-
import { jsx as
|
5728
|
+
import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
|
5370
5729
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5371
5730
|
var ComponentListItem = ({
|
5372
5731
|
name,
|
@@ -5376,7 +5735,7 @@ var ComponentListItem = ({
|
|
5376
5735
|
const canInsert = getPermissions({
|
5377
5736
|
type: name
|
5378
5737
|
}).insert;
|
5379
|
-
return /* @__PURE__ */
|
5738
|
+
return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5380
5739
|
};
|
5381
5740
|
var ComponentList = ({
|
5382
5741
|
children,
|
@@ -5400,14 +5759,14 @@ var ComponentList = ({
|
|
5400
5759
|
}),
|
5401
5760
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5402
5761
|
children: [
|
5403
|
-
/* @__PURE__ */
|
5404
|
-
/* @__PURE__ */
|
5762
|
+
/* @__PURE__ */ jsx28("div", { children: title }),
|
5763
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
|
5405
5764
|
]
|
5406
5765
|
}
|
5407
5766
|
),
|
5408
|
-
/* @__PURE__ */
|
5767
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
5409
5768
|
var _a;
|
5410
|
-
return /* @__PURE__ */
|
5769
|
+
return /* @__PURE__ */ jsx28(
|
5411
5770
|
ComponentListItem,
|
5412
5771
|
{
|
5413
5772
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5421,10 +5780,10 @@ var ComponentList = ({
|
|
5421
5780
|
ComponentList.Item = ComponentListItem;
|
5422
5781
|
|
5423
5782
|
// lib/use-component-list.tsx
|
5424
|
-
import { jsx as
|
5783
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
5425
5784
|
var useComponentList = (config, ui) => {
|
5426
|
-
const [componentList, setComponentList] =
|
5427
|
-
|
5785
|
+
const [componentList, setComponentList] = useState20();
|
5786
|
+
useEffect17(() => {
|
5428
5787
|
var _a, _b, _c;
|
5429
5788
|
if (Object.keys(ui.componentList).length > 0) {
|
5430
5789
|
const matchedComponents = [];
|
@@ -5434,7 +5793,7 @@ var useComponentList = (config, ui) => {
|
|
5434
5793
|
if (category.visible === false || !category.components) {
|
5435
5794
|
return null;
|
5436
5795
|
}
|
5437
|
-
return /* @__PURE__ */
|
5796
|
+
return /* @__PURE__ */ jsx29(
|
5438
5797
|
ComponentList,
|
5439
5798
|
{
|
5440
5799
|
id: categoryKey,
|
@@ -5443,7 +5802,7 @@ var useComponentList = (config, ui) => {
|
|
5443
5802
|
var _a2;
|
5444
5803
|
matchedComponents.push(componentName);
|
5445
5804
|
const componentConf = config.components[componentName] || {};
|
5446
|
-
return /* @__PURE__ */
|
5805
|
+
return /* @__PURE__ */ jsx29(
|
5447
5806
|
ComponentList.Item,
|
5448
5807
|
{
|
5449
5808
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5463,7 +5822,7 @@ var useComponentList = (config, ui) => {
|
|
5463
5822
|
);
|
5464
5823
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5465
5824
|
_componentList.push(
|
5466
|
-
/* @__PURE__ */
|
5825
|
+
/* @__PURE__ */ jsx29(
|
5467
5826
|
ComponentList,
|
5468
5827
|
{
|
5469
5828
|
id: "other",
|
@@ -5471,7 +5830,7 @@ var useComponentList = (config, ui) => {
|
|
5471
5830
|
children: remainingComponents.map((componentName, i) => {
|
5472
5831
|
var _a2;
|
5473
5832
|
const componentConf = config.components[componentName] || {};
|
5474
|
-
return /* @__PURE__ */
|
5833
|
+
return /* @__PURE__ */ jsx29(
|
5475
5834
|
ComponentList.Item,
|
5476
5835
|
{
|
5477
5836
|
name: componentName,
|
@@ -5493,30 +5852,30 @@ var useComponentList = (config, ui) => {
|
|
5493
5852
|
};
|
5494
5853
|
|
5495
5854
|
// components/Puck/components/Components/index.tsx
|
5496
|
-
import { useMemo as
|
5497
|
-
import { jsx as
|
5855
|
+
import { useMemo as useMemo12 } from "react";
|
5856
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
5498
5857
|
var Components = () => {
|
5499
5858
|
const { config, state, overrides } = useAppContext();
|
5500
5859
|
const componentList = useComponentList(config, state.ui);
|
5501
|
-
const Wrapper =
|
5502
|
-
return /* @__PURE__ */
|
5860
|
+
const Wrapper = useMemo12(() => overrides.components || "div", [overrides]);
|
5861
|
+
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
5503
5862
|
};
|
5504
5863
|
|
5505
5864
|
// components/Puck/components/Preview/index.tsx
|
5506
5865
|
init_react_import();
|
5507
|
-
import { useCallback as
|
5866
|
+
import { useCallback as useCallback13, useEffect as useEffect19, useRef as useRef6, useMemo as useMemo13 } from "react";
|
5508
5867
|
|
5509
5868
|
// components/AutoFrame/index.tsx
|
5510
5869
|
init_react_import();
|
5511
5870
|
import {
|
5512
|
-
createContext as
|
5513
|
-
useContext as
|
5514
|
-
useEffect as
|
5515
|
-
useState as
|
5871
|
+
createContext as createContext5,
|
5872
|
+
useContext as useContext10,
|
5873
|
+
useEffect as useEffect18,
|
5874
|
+
useState as useState21
|
5516
5875
|
} from "react";
|
5517
5876
|
import hash from "object-hash";
|
5518
5877
|
import { createPortal as createPortal3 } from "react-dom";
|
5519
|
-
import { Fragment as Fragment9, jsx as
|
5878
|
+
import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
|
5520
5879
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5521
5880
|
var collectStyles = (doc) => {
|
5522
5881
|
const collected = [];
|
@@ -5559,7 +5918,7 @@ var CopyHostStyles = ({
|
|
5559
5918
|
onStylesLoaded = () => null
|
5560
5919
|
}) => {
|
5561
5920
|
const { document: doc, window: win } = useFrame();
|
5562
|
-
|
5921
|
+
useEffect18(() => {
|
5563
5922
|
if (!win || !doc) {
|
5564
5923
|
return () => {
|
5565
5924
|
};
|
@@ -5716,10 +6075,10 @@ var CopyHostStyles = ({
|
|
5716
6075
|
observer.disconnect();
|
5717
6076
|
};
|
5718
6077
|
}, []);
|
5719
|
-
return /* @__PURE__ */
|
6078
|
+
return /* @__PURE__ */ jsx31(Fragment9, { children });
|
5720
6079
|
};
|
5721
|
-
var autoFrameContext =
|
5722
|
-
var useFrame = () =>
|
6080
|
+
var autoFrameContext = createContext5({});
|
6081
|
+
var useFrame = () => useContext10(autoFrameContext);
|
5723
6082
|
function AutoFrame(_a) {
|
5724
6083
|
var _b = _a, {
|
5725
6084
|
children,
|
@@ -5736,10 +6095,10 @@ function AutoFrame(_a) {
|
|
5736
6095
|
"onStylesLoaded",
|
5737
6096
|
"frameRef"
|
5738
6097
|
]);
|
5739
|
-
const [loaded, setLoaded] =
|
5740
|
-
const [ctx, setCtx] =
|
5741
|
-
const [mountTarget, setMountTarget] =
|
5742
|
-
|
6098
|
+
const [loaded, setLoaded] = useState21(false);
|
6099
|
+
const [ctx, setCtx] = useState21({});
|
6100
|
+
const [mountTarget, setMountTarget] = useState21();
|
6101
|
+
useEffect18(() => {
|
5743
6102
|
var _a2;
|
5744
6103
|
if (frameRef.current) {
|
5745
6104
|
setCtx({
|
@@ -5751,7 +6110,7 @@ function AutoFrame(_a) {
|
|
5751
6110
|
);
|
5752
6111
|
}
|
5753
6112
|
}, [frameRef, loaded]);
|
5754
|
-
return /* @__PURE__ */
|
6113
|
+
return /* @__PURE__ */ jsx31(
|
5755
6114
|
"iframe",
|
5756
6115
|
__spreadProps(__spreadValues({}, props), {
|
5757
6116
|
className,
|
@@ -5761,7 +6120,7 @@ function AutoFrame(_a) {
|
|
5761
6120
|
onLoad: () => {
|
5762
6121
|
setLoaded(true);
|
5763
6122
|
},
|
5764
|
-
children: /* @__PURE__ */
|
6123
|
+
children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
|
5765
6124
|
})
|
5766
6125
|
);
|
5767
6126
|
}
|
@@ -5774,7 +6133,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
|
|
5774
6133
|
|
5775
6134
|
// components/Render/index.tsx
|
5776
6135
|
init_react_import();
|
5777
|
-
import { jsx as
|
6136
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
5778
6137
|
function Render({
|
5779
6138
|
config,
|
5780
6139
|
data
|
@@ -5787,7 +6146,7 @@ function Render({
|
|
5787
6146
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
5788
6147
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
5789
6148
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5790
|
-
return /* @__PURE__ */
|
6149
|
+
return /* @__PURE__ */ jsx32(
|
5791
6150
|
DropZoneProvider,
|
5792
6151
|
{
|
5793
6152
|
value: {
|
@@ -5797,7 +6156,7 @@ function Render({
|
|
5797
6156
|
depth: 0,
|
5798
6157
|
path: []
|
5799
6158
|
},
|
5800
|
-
children: /* @__PURE__ */
|
6159
|
+
children: /* @__PURE__ */ jsx32(
|
5801
6160
|
config.root.render,
|
5802
6161
|
__spreadProps(__spreadValues({}, rootProps), {
|
5803
6162
|
puck: {
|
@@ -5807,13 +6166,13 @@ function Render({
|
|
5807
6166
|
title,
|
5808
6167
|
editMode: false,
|
5809
6168
|
id: "puck-root",
|
5810
|
-
children: /* @__PURE__ */
|
6169
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
5811
6170
|
})
|
5812
6171
|
)
|
5813
6172
|
}
|
5814
6173
|
);
|
5815
6174
|
}
|
5816
|
-
return /* @__PURE__ */
|
6175
|
+
return /* @__PURE__ */ jsx32(
|
5817
6176
|
DropZoneProvider,
|
5818
6177
|
{
|
5819
6178
|
value: {
|
@@ -5823,17 +6182,17 @@ function Render({
|
|
5823
6182
|
depth: 0,
|
5824
6183
|
path: []
|
5825
6184
|
},
|
5826
|
-
children: /* @__PURE__ */
|
6185
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
5827
6186
|
}
|
5828
6187
|
);
|
5829
6188
|
}
|
5830
6189
|
|
5831
6190
|
// components/Puck/components/Preview/index.tsx
|
5832
|
-
import { Fragment as Fragment10, jsx as
|
6191
|
+
import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
|
5833
6192
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5834
6193
|
var useBubbleIframeEvents = (ref) => {
|
5835
6194
|
const { status } = useAppContext();
|
5836
|
-
|
6195
|
+
useEffect19(() => {
|
5837
6196
|
var _a;
|
5838
6197
|
if (ref.current && status === "READY") {
|
5839
6198
|
const iframe = ref.current;
|
@@ -5870,22 +6229,22 @@ var useBubbleIframeEvents = (ref) => {
|
|
5870
6229
|
}
|
5871
6230
|
}, [status]);
|
5872
6231
|
};
|
5873
|
-
var
|
6232
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
5874
6233
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
5875
|
-
const Page =
|
6234
|
+
const Page = useCallback13(
|
5876
6235
|
(pageProps) => {
|
5877
6236
|
var _a, _b;
|
5878
6237
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
5879
6238
|
id: "puck-root"
|
5880
|
-
}, pageProps)) : /* @__PURE__ */
|
6239
|
+
}, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
|
5881
6240
|
},
|
5882
6241
|
[config.root]
|
5883
6242
|
);
|
5884
|
-
const Frame =
|
6243
|
+
const Frame = useMemo13(() => overrides.iframe, [overrides]);
|
5885
6244
|
const rootProps = state.data.root.props || state.data.root;
|
5886
|
-
const ref =
|
6245
|
+
const ref = useRef6(null);
|
5887
6246
|
useBubbleIframeEvents(ref);
|
5888
|
-
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */
|
6247
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
|
5889
6248
|
Page,
|
5890
6249
|
__spreadProps(__spreadValues({}, rootProps), {
|
5891
6250
|
puck: {
|
@@ -5894,10 +6253,10 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5894
6253
|
dragRef: null
|
5895
6254
|
},
|
5896
6255
|
editMode: true,
|
5897
|
-
children: /* @__PURE__ */
|
6256
|
+
children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
|
5898
6257
|
})
|
5899
|
-
) : /* @__PURE__ */
|
5900
|
-
return /* @__PURE__ */
|
6258
|
+
) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
|
6259
|
+
return /* @__PURE__ */ jsx33(
|
5901
6260
|
"div",
|
5902
6261
|
{
|
5903
6262
|
className: getClassName23(),
|
@@ -5906,7 +6265,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5906
6265
|
onClick: () => {
|
5907
6266
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
5908
6267
|
},
|
5909
|
-
children: iframe.enabled ? /* @__PURE__ */
|
6268
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx33(
|
5910
6269
|
AutoFrame_default,
|
5911
6270
|
{
|
5912
6271
|
id: "preview-frame",
|
@@ -5916,14 +6275,14 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5916
6275
|
setStatus("READY");
|
5917
6276
|
},
|
5918
6277
|
frameRef: ref,
|
5919
|
-
children: /* @__PURE__ */
|
6278
|
+
children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
5920
6279
|
if (Frame) {
|
5921
|
-
return /* @__PURE__ */
|
6280
|
+
return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
|
5922
6281
|
}
|
5923
6282
|
return inner;
|
5924
6283
|
} })
|
5925
6284
|
}
|
5926
|
-
) : /* @__PURE__ */
|
6285
|
+
) : /* @__PURE__ */ jsx33(
|
5927
6286
|
"div",
|
5928
6287
|
{
|
5929
6288
|
id: "preview-frame",
|
@@ -5980,7 +6339,7 @@ var scrollIntoView = (el) => {
|
|
5980
6339
|
};
|
5981
6340
|
|
5982
6341
|
// components/LayerTree/index.tsx
|
5983
|
-
import { useContext as
|
6342
|
+
import { useContext as useContext11 } from "react";
|
5984
6343
|
|
5985
6344
|
// lib/is-child-of-zone.ts
|
5986
6345
|
init_react_import();
|
@@ -6013,7 +6372,7 @@ var onScrollEnd = (frame, cb) => {
|
|
6013
6372
|
};
|
6014
6373
|
|
6015
6374
|
// components/LayerTree/index.tsx
|
6016
|
-
import { Fragment as Fragment11, jsx as
|
6375
|
+
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
|
6017
6376
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6018
6377
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6019
6378
|
var LayerTree = ({
|
@@ -6026,15 +6385,15 @@ var LayerTree = ({
|
|
6026
6385
|
label
|
6027
6386
|
}) => {
|
6028
6387
|
const zones = data.zones || {};
|
6029
|
-
const ctx =
|
6388
|
+
const ctx = useContext11(dropZoneContext);
|
6030
6389
|
return /* @__PURE__ */ jsxs16(Fragment11, { children: [
|
6031
6390
|
label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
|
6032
|
-
/* @__PURE__ */
|
6391
|
+
/* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
|
6033
6392
|
" ",
|
6034
6393
|
label
|
6035
6394
|
] }),
|
6036
6395
|
/* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
|
6037
|
-
zoneContent.length === 0 && /* @__PURE__ */
|
6396
|
+
zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
|
6038
6397
|
zoneContent.map((item, i) => {
|
6039
6398
|
var _a;
|
6040
6399
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6057,7 +6416,7 @@ var LayerTree = ({
|
|
6057
6416
|
childIsSelected
|
6058
6417
|
}),
|
6059
6418
|
children: [
|
6060
|
-
/* @__PURE__ */
|
6419
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
|
6061
6420
|
"button",
|
6062
6421
|
{
|
6063
6422
|
type: "button",
|
@@ -6096,22 +6455,22 @@ var LayerTree = ({
|
|
6096
6455
|
setHoveringComponent(null);
|
6097
6456
|
},
|
6098
6457
|
children: [
|
6099
|
-
containsZone && /* @__PURE__ */
|
6458
|
+
containsZone && /* @__PURE__ */ jsx34(
|
6100
6459
|
"div",
|
6101
6460
|
{
|
6102
6461
|
className: getClassNameLayer("chevron"),
|
6103
6462
|
title: isSelected ? "Collapse" : "Expand",
|
6104
|
-
children: /* @__PURE__ */
|
6463
|
+
children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
|
6105
6464
|
}
|
6106
6465
|
),
|
6107
6466
|
/* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
|
6108
|
-
/* @__PURE__ */
|
6109
|
-
/* @__PURE__ */
|
6467
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
|
6468
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
|
6110
6469
|
] })
|
6111
6470
|
]
|
6112
6471
|
}
|
6113
6472
|
) }),
|
6114
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */
|
6473
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
|
6115
6474
|
LayerTree,
|
6116
6475
|
{
|
6117
6476
|
config,
|
@@ -6133,13 +6492,13 @@ var LayerTree = ({
|
|
6133
6492
|
};
|
6134
6493
|
|
6135
6494
|
// components/Puck/components/Outline/index.tsx
|
6136
|
-
import { useCallback as
|
6137
|
-
import { Fragment as Fragment12, jsx as
|
6495
|
+
import { useCallback as useCallback14, useMemo as useMemo14 } from "react";
|
6496
|
+
import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
|
6138
6497
|
var Outline = () => {
|
6139
6498
|
const { dispatch, state, overrides, config } = useAppContext();
|
6140
6499
|
const { data, ui } = state;
|
6141
6500
|
const { itemSelector } = ui;
|
6142
|
-
const setItemSelector =
|
6501
|
+
const setItemSelector = useCallback14(
|
6143
6502
|
(newItemSelector) => {
|
6144
6503
|
dispatch({
|
6145
6504
|
type: "setUi",
|
@@ -6148,9 +6507,9 @@ var Outline = () => {
|
|
6148
6507
|
},
|
6149
6508
|
[]
|
6150
6509
|
);
|
6151
|
-
const Wrapper =
|
6152
|
-
return /* @__PURE__ */
|
6153
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */
|
6510
|
+
const Wrapper = useMemo14(() => overrides.outline || "div", [overrides]);
|
6511
|
+
return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
|
6512
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
|
6154
6513
|
LayerTree,
|
6155
6514
|
{
|
6156
6515
|
config,
|
@@ -6163,7 +6522,7 @@ var Outline = () => {
|
|
6163
6522
|
),
|
6164
6523
|
Object.entries(findZonesForArea(data, "root")).map(
|
6165
6524
|
([zoneKey, zone]) => {
|
6166
|
-
return /* @__PURE__ */
|
6525
|
+
return /* @__PURE__ */ jsx35(
|
6167
6526
|
LayerTree,
|
6168
6527
|
{
|
6169
6528
|
config,
|
@@ -6262,19 +6621,19 @@ function usePuckHistory({
|
|
6262
6621
|
|
6263
6622
|
// lib/use-history-store.ts
|
6264
6623
|
init_react_import();
|
6265
|
-
import { useState as
|
6624
|
+
import { useState as useState22 } from "react";
|
6266
6625
|
import { useDebouncedCallback as useDebouncedCallback3 } from "use-debounce";
|
6267
6626
|
var EMPTY_HISTORY_INDEX = 0;
|
6268
6627
|
function useHistoryStore(initialHistory) {
|
6269
6628
|
var _a, _b;
|
6270
|
-
const [histories, setHistories] =
|
6629
|
+
const [histories, setHistories] = useState22(
|
6271
6630
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6272
6631
|
);
|
6273
6632
|
const updateHistories = (histories2) => {
|
6274
6633
|
setHistories(histories2);
|
6275
6634
|
setIndex(histories2.length - 1);
|
6276
6635
|
};
|
6277
|
-
const [index, setIndex] =
|
6636
|
+
const [index, setIndex] = useState22(
|
6278
6637
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6279
6638
|
);
|
6280
6639
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6435,27 +6794,27 @@ var getBox = function getBox2(el) {
|
|
6435
6794
|
|
6436
6795
|
// components/Puck/components/Canvas/index.tsx
|
6437
6796
|
import {
|
6438
|
-
useCallback as
|
6439
|
-
useEffect as
|
6440
|
-
useMemo as
|
6441
|
-
useRef as
|
6442
|
-
useState as
|
6797
|
+
useCallback as useCallback15,
|
6798
|
+
useEffect as useEffect21,
|
6799
|
+
useMemo as useMemo16,
|
6800
|
+
useRef as useRef7,
|
6801
|
+
useState as useState24
|
6443
6802
|
} from "react";
|
6444
6803
|
|
6445
6804
|
// components/ViewportControls/index.tsx
|
6446
6805
|
init_react_import();
|
6447
|
-
import { useEffect as
|
6806
|
+
import { useEffect as useEffect20, useMemo as useMemo15, useState as useState23 } from "react";
|
6448
6807
|
|
6449
6808
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6450
6809
|
init_react_import();
|
6451
6810
|
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" };
|
6452
6811
|
|
6453
6812
|
// components/ViewportControls/index.tsx
|
6454
|
-
import { jsx as
|
6813
|
+
import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
|
6455
6814
|
var icons = {
|
6456
|
-
Smartphone: /* @__PURE__ */
|
6457
|
-
Tablet: /* @__PURE__ */
|
6458
|
-
Monitor: /* @__PURE__ */
|
6815
|
+
Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
|
6816
|
+
Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
|
6817
|
+
Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
|
6459
6818
|
};
|
6460
6819
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6461
6820
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6467,11 +6826,11 @@ var ViewportButton = ({
|
|
6467
6826
|
onClick
|
6468
6827
|
}) => {
|
6469
6828
|
const { state } = useAppContext();
|
6470
|
-
const [isActive, setIsActive] =
|
6471
|
-
|
6829
|
+
const [isActive, setIsActive] = useState23(false);
|
6830
|
+
useEffect20(() => {
|
6472
6831
|
setIsActive(width === state.ui.viewports.current.width);
|
6473
6832
|
}, [width, state.ui.viewports.current.width]);
|
6474
|
-
return /* @__PURE__ */
|
6833
|
+
return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
|
6475
6834
|
IconButton,
|
6476
6835
|
{
|
6477
6836
|
title,
|
@@ -6480,7 +6839,7 @@ var ViewportButton = ({
|
|
6480
6839
|
e.stopPropagation();
|
6481
6840
|
onClick({ width, height });
|
6482
6841
|
},
|
6483
|
-
children: /* @__PURE__ */
|
6842
|
+
children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
|
6484
6843
|
}
|
6485
6844
|
) });
|
6486
6845
|
};
|
@@ -6504,7 +6863,7 @@ var ViewportControls = ({
|
|
6504
6863
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6505
6864
|
(option) => option.value === autoZoom
|
6506
6865
|
);
|
6507
|
-
const zoomOptions =
|
6866
|
+
const zoomOptions = useMemo15(
|
6508
6867
|
() => [
|
6509
6868
|
...defaultZoomOptions,
|
6510
6869
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6517,7 +6876,7 @@ var ViewportControls = ({
|
|
6517
6876
|
[autoZoom]
|
6518
6877
|
);
|
6519
6878
|
return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
|
6520
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
6879
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
|
6521
6880
|
ViewportButton,
|
6522
6881
|
{
|
6523
6882
|
height: viewport.height,
|
@@ -6528,8 +6887,8 @@ var ViewportControls = ({
|
|
6528
6887
|
},
|
6529
6888
|
i
|
6530
6889
|
)),
|
6531
|
-
/* @__PURE__ */
|
6532
|
-
/* @__PURE__ */
|
6890
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6891
|
+
/* @__PURE__ */ jsx36(
|
6533
6892
|
IconButton,
|
6534
6893
|
{
|
6535
6894
|
title: "Zoom viewport out",
|
@@ -6543,10 +6902,10 @@ var ViewportControls = ({
|
|
6543
6902
|
)].value
|
6544
6903
|
);
|
6545
6904
|
},
|
6546
|
-
children: /* @__PURE__ */
|
6905
|
+
children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
|
6547
6906
|
}
|
6548
6907
|
),
|
6549
|
-
/* @__PURE__ */
|
6908
|
+
/* @__PURE__ */ jsx36(
|
6550
6909
|
IconButton,
|
6551
6910
|
{
|
6552
6911
|
title: "Zoom viewport in",
|
@@ -6560,11 +6919,11 @@ var ViewportControls = ({
|
|
6560
6919
|
)].value
|
6561
6920
|
);
|
6562
6921
|
},
|
6563
|
-
children: /* @__PURE__ */
|
6922
|
+
children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
|
6564
6923
|
}
|
6565
6924
|
),
|
6566
|
-
/* @__PURE__ */
|
6567
|
-
/* @__PURE__ */
|
6925
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6926
|
+
/* @__PURE__ */ jsx36(
|
6568
6927
|
"select",
|
6569
6928
|
{
|
6570
6929
|
className: getClassName25("zoomSelect"),
|
@@ -6572,7 +6931,7 @@ var ViewportControls = ({
|
|
6572
6931
|
onChange: (e) => {
|
6573
6932
|
onZoom(parseFloat(e.currentTarget.value));
|
6574
6933
|
},
|
6575
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
6934
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
|
6576
6935
|
"option",
|
6577
6936
|
{
|
6578
6937
|
value: option.value,
|
@@ -6620,24 +6979,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6620
6979
|
};
|
6621
6980
|
|
6622
6981
|
// components/Puck/components/Canvas/index.tsx
|
6623
|
-
import { Fragment as Fragment13, jsx as
|
6982
|
+
import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
|
6624
6983
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6625
6984
|
var ZOOM_ON_CHANGE = true;
|
6626
6985
|
var Canvas = () => {
|
6627
6986
|
const { status, iframe } = useAppContext();
|
6628
6987
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6629
6988
|
const { ui } = state;
|
6630
|
-
const frameRef =
|
6631
|
-
const [showTransition, setShowTransition] =
|
6632
|
-
const defaultRender =
|
6633
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
6989
|
+
const frameRef = useRef7(null);
|
6990
|
+
const [showTransition, setShowTransition] = useState24(false);
|
6991
|
+
const defaultRender = useMemo16(() => {
|
6992
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
|
6634
6993
|
return PuckDefault;
|
6635
6994
|
}, []);
|
6636
|
-
const CustomPreview =
|
6995
|
+
const CustomPreview = useMemo16(
|
6637
6996
|
() => overrides.preview || defaultRender,
|
6638
6997
|
[overrides]
|
6639
6998
|
);
|
6640
|
-
const getFrameDimensions =
|
6999
|
+
const getFrameDimensions = useCallback15(() => {
|
6641
7000
|
if (frameRef.current) {
|
6642
7001
|
const frame = frameRef.current;
|
6643
7002
|
const box = getBox(frame);
|
@@ -6645,7 +7004,7 @@ var Canvas = () => {
|
|
6645
7004
|
}
|
6646
7005
|
return { width: 0, height: 0 };
|
6647
7006
|
}, [frameRef]);
|
6648
|
-
const resetAutoZoom =
|
7007
|
+
const resetAutoZoom = useCallback15(
|
6649
7008
|
(ui2 = state.ui) => {
|
6650
7009
|
if (frameRef.current) {
|
6651
7010
|
setZoomConfig(
|
@@ -6655,11 +7014,11 @@ var Canvas = () => {
|
|
6655
7014
|
},
|
6656
7015
|
[frameRef, zoomConfig, state.ui]
|
6657
7016
|
);
|
6658
|
-
|
7017
|
+
useEffect21(() => {
|
6659
7018
|
setShowTransition(false);
|
6660
7019
|
resetAutoZoom();
|
6661
7020
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6662
|
-
|
7021
|
+
useEffect21(() => {
|
6663
7022
|
const { height: frameHeight } = getFrameDimensions();
|
6664
7023
|
if (ui.viewports.current.height === "auto") {
|
6665
7024
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6667,13 +7026,13 @@ var Canvas = () => {
|
|
6667
7026
|
}));
|
6668
7027
|
}
|
6669
7028
|
}, [zoomConfig.zoom]);
|
6670
|
-
|
7029
|
+
useEffect21(() => {
|
6671
7030
|
if (ZOOM_ON_CHANGE) {
|
6672
7031
|
setShowTransition(true);
|
6673
7032
|
resetAutoZoom(ui);
|
6674
7033
|
}
|
6675
7034
|
}, [ui.viewports.current.width]);
|
6676
|
-
|
7035
|
+
useEffect21(() => {
|
6677
7036
|
const cb = () => {
|
6678
7037
|
setShowTransition(false);
|
6679
7038
|
resetAutoZoom();
|
@@ -6683,8 +7042,8 @@ var Canvas = () => {
|
|
6683
7042
|
window.removeEventListener("resize", cb);
|
6684
7043
|
};
|
6685
7044
|
}, []);
|
6686
|
-
const [showLoader, setShowLoader] =
|
6687
|
-
|
7045
|
+
const [showLoader, setShowLoader] = useState24(false);
|
7046
|
+
useEffect21(() => {
|
6688
7047
|
setTimeout(() => {
|
6689
7048
|
setShowLoader(true);
|
6690
7049
|
}, 500);
|
@@ -6702,7 +7061,7 @@ var Canvas = () => {
|
|
6702
7061
|
recordHistory: true
|
6703
7062
|
}),
|
6704
7063
|
children: [
|
6705
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
7064
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
|
6706
7065
|
ViewportControls,
|
6707
7066
|
{
|
6708
7067
|
autoZoom: zoomConfig.autoZoom,
|
@@ -6729,7 +7088,7 @@ var Canvas = () => {
|
|
6729
7088
|
}
|
6730
7089
|
) }),
|
6731
7090
|
/* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
6732
|
-
/* @__PURE__ */
|
7091
|
+
/* @__PURE__ */ jsx37(
|
6733
7092
|
"div",
|
6734
7093
|
{
|
6735
7094
|
className: getClassName26("root"),
|
@@ -6750,10 +7109,10 @@ var Canvas = () => {
|
|
6750
7109
|
})
|
6751
7110
|
);
|
6752
7111
|
},
|
6753
|
-
children: /* @__PURE__ */
|
7112
|
+
children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
|
6754
7113
|
}
|
6755
7114
|
),
|
6756
|
-
/* @__PURE__ */
|
7115
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
|
6757
7116
|
] })
|
6758
7117
|
]
|
6759
7118
|
}
|
@@ -6762,7 +7121,7 @@ var Canvas = () => {
|
|
6762
7121
|
|
6763
7122
|
// lib/use-loaded-overrides.ts
|
6764
7123
|
init_react_import();
|
6765
|
-
import { useMemo as
|
7124
|
+
import { useMemo as useMemo17 } from "react";
|
6766
7125
|
|
6767
7126
|
// lib/load-overrides.ts
|
6768
7127
|
init_react_import();
|
@@ -6801,26 +7160,26 @@ var useLoadedOverrides = ({
|
|
6801
7160
|
overrides,
|
6802
7161
|
plugins
|
6803
7162
|
}) => {
|
6804
|
-
return
|
7163
|
+
return useMemo17(() => {
|
6805
7164
|
return loadOverrides({ overrides, plugins });
|
6806
7165
|
}, [plugins, overrides]);
|
6807
7166
|
};
|
6808
7167
|
|
6809
7168
|
// components/DefaultOverride/index.tsx
|
6810
7169
|
init_react_import();
|
6811
|
-
import { Fragment as Fragment14, jsx as
|
6812
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */
|
7170
|
+
import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
|
7171
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
|
6813
7172
|
|
6814
7173
|
// lib/use-inject-css.ts
|
6815
7174
|
init_react_import();
|
6816
|
-
import { useEffect as
|
7175
|
+
import { useEffect as useEffect22, useState as useState25 } from "react";
|
6817
7176
|
var styles = ``;
|
6818
7177
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6819
|
-
const [el, setEl] =
|
6820
|
-
|
7178
|
+
const [el, setEl] = useState25();
|
7179
|
+
useEffect22(() => {
|
6821
7180
|
setEl(document.createElement("style"));
|
6822
7181
|
}, []);
|
6823
|
-
|
7182
|
+
useEffect22(() => {
|
6824
7183
|
var _a;
|
6825
7184
|
if (!el || typeof window === "undefined") {
|
6826
7185
|
return;
|
@@ -6840,10 +7199,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
6840
7199
|
|
6841
7200
|
// lib/use-preview-mode-hotkeys.ts
|
6842
7201
|
init_react_import();
|
6843
|
-
import { useCallback as
|
7202
|
+
import { useCallback as useCallback16 } from "react";
|
6844
7203
|
import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
|
6845
7204
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
6846
|
-
const toggleInteractive =
|
7205
|
+
const toggleInteractive = useCallback16(() => {
|
6847
7206
|
dispatch({
|
6848
7207
|
type: "setUi",
|
6849
7208
|
ui: (ui) => ({
|
@@ -6866,7 +7225,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
|
6866
7225
|
};
|
6867
7226
|
|
6868
7227
|
// components/Puck/index.tsx
|
6869
|
-
import { Fragment as Fragment15, jsx as
|
7228
|
+
import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
|
6870
7229
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
6871
7230
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
6872
7231
|
function Puck({
|
@@ -6895,7 +7254,7 @@ function Puck({
|
|
6895
7254
|
waitForStyles: true
|
6896
7255
|
}, _iframe);
|
6897
7256
|
useInjectGlobalCss(iframe.enabled);
|
6898
|
-
const [generatedAppState] =
|
7257
|
+
const [generatedAppState] = useState26(() => {
|
6899
7258
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
6900
7259
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
6901
7260
|
let clientUiState = {};
|
@@ -6967,7 +7326,7 @@ function Puck({
|
|
6967
7326
|
histories,
|
6968
7327
|
index: initialHistoryIndex
|
6969
7328
|
});
|
6970
|
-
const [reducer] =
|
7329
|
+
const [reducer] = useState26(
|
6971
7330
|
() => createReducer({
|
6972
7331
|
config,
|
6973
7332
|
record: historyStore.record,
|
@@ -6985,14 +7344,14 @@ function Puck({
|
|
6985
7344
|
historyStore,
|
6986
7345
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
6987
7346
|
});
|
6988
|
-
const [menuOpen, setMenuOpen] =
|
7347
|
+
const [menuOpen, setMenuOpen] = useState26(false);
|
6989
7348
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
6990
7349
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
6991
|
-
|
7350
|
+
useEffect23(() => {
|
6992
7351
|
if (onChange) onChange(data);
|
6993
7352
|
}, [data]);
|
6994
7353
|
const rootProps = data.root.props || data.root;
|
6995
|
-
const toggleSidebars =
|
7354
|
+
const toggleSidebars = useCallback17(
|
6996
7355
|
(sidebar) => {
|
6997
7356
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
6998
7357
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7006,7 +7365,7 @@ function Puck({
|
|
7006
7365
|
},
|
7007
7366
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7008
7367
|
);
|
7009
|
-
|
7368
|
+
useEffect23(() => {
|
7010
7369
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7011
7370
|
dispatch({
|
7012
7371
|
type: "setUi",
|
@@ -7029,7 +7388,7 @@ function Puck({
|
|
7029
7388
|
window.removeEventListener("resize", handleResize);
|
7030
7389
|
};
|
7031
7390
|
}, []);
|
7032
|
-
const defaultHeaderRender =
|
7391
|
+
const defaultHeaderRender = useMemo18(() => {
|
7033
7392
|
if (renderHeader) {
|
7034
7393
|
console.warn(
|
7035
7394
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7037,20 +7396,20 @@ function Puck({
|
|
7037
7396
|
const RenderHeader = (_a2) => {
|
7038
7397
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
7039
7398
|
const Comp = renderHeader;
|
7040
|
-
return /* @__PURE__ */
|
7399
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7041
7400
|
};
|
7042
7401
|
return RenderHeader;
|
7043
7402
|
}
|
7044
7403
|
return DefaultOverride;
|
7045
7404
|
}, [renderHeader]);
|
7046
|
-
const defaultHeaderActionsRender =
|
7405
|
+
const defaultHeaderActionsRender = useMemo18(() => {
|
7047
7406
|
if (renderHeaderActions) {
|
7048
7407
|
console.warn(
|
7049
7408
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7050
7409
|
);
|
7051
7410
|
const RenderHeader = (props) => {
|
7052
7411
|
const Comp = renderHeaderActions;
|
7053
|
-
return /* @__PURE__ */
|
7412
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7054
7413
|
};
|
7055
7414
|
return RenderHeader;
|
7056
7415
|
}
|
@@ -7060,27 +7419,27 @@ function Puck({
|
|
7060
7419
|
overrides,
|
7061
7420
|
plugins
|
7062
7421
|
});
|
7063
|
-
const CustomPuck =
|
7422
|
+
const CustomPuck = useMemo18(
|
7064
7423
|
() => loadedOverrides.puck || DefaultOverride,
|
7065
7424
|
[loadedOverrides]
|
7066
7425
|
);
|
7067
|
-
const CustomHeader =
|
7426
|
+
const CustomHeader = useMemo18(
|
7068
7427
|
() => loadedOverrides.header || defaultHeaderRender,
|
7069
7428
|
[loadedOverrides]
|
7070
7429
|
);
|
7071
|
-
const CustomHeaderActions =
|
7430
|
+
const CustomHeaderActions = useMemo18(
|
7072
7431
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7073
7432
|
[loadedOverrides]
|
7074
7433
|
);
|
7075
|
-
const [mounted, setMounted] =
|
7076
|
-
|
7434
|
+
const [mounted, setMounted] = useState26(false);
|
7435
|
+
useEffect23(() => {
|
7077
7436
|
setMounted(true);
|
7078
7437
|
}, []);
|
7079
7438
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7080
7439
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7081
7440
|
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7082
7441
|
return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
|
7083
|
-
/* @__PURE__ */
|
7442
|
+
/* @__PURE__ */ jsx39(
|
7084
7443
|
AppProvider,
|
7085
7444
|
{
|
7086
7445
|
value: {
|
@@ -7102,7 +7461,7 @@ function Puck({
|
|
7102
7461
|
getPermissions: () => ({}),
|
7103
7462
|
refreshPermissions: () => null
|
7104
7463
|
},
|
7105
|
-
children: /* @__PURE__ */
|
7464
|
+
children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
|
7106
7465
|
"div",
|
7107
7466
|
{
|
7108
7467
|
className: getLayoutClassName({
|
@@ -7112,59 +7471,59 @@ function Puck({
|
|
7112
7471
|
rightSideBarVisible
|
7113
7472
|
}),
|
7114
7473
|
children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
|
7115
|
-
/* @__PURE__ */
|
7474
|
+
/* @__PURE__ */ jsx39(
|
7116
7475
|
CustomHeader,
|
7117
7476
|
{
|
7118
|
-
actions: /* @__PURE__ */
|
7477
|
+
actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7119
7478
|
Button,
|
7120
7479
|
{
|
7121
7480
|
onClick: () => {
|
7122
7481
|
onPublish && onPublish(data);
|
7123
7482
|
},
|
7124
|
-
icon: /* @__PURE__ */
|
7483
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7125
7484
|
children: "Publish"
|
7126
7485
|
}
|
7127
7486
|
) }) }),
|
7128
|
-
children: /* @__PURE__ */
|
7487
|
+
children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
|
7129
7488
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
|
7130
|
-
/* @__PURE__ */
|
7489
|
+
/* @__PURE__ */ jsx39(
|
7131
7490
|
"div",
|
7132
7491
|
{
|
7133
7492
|
className: getLayoutClassName("leftSideBarToggle"),
|
7134
|
-
children: /* @__PURE__ */
|
7493
|
+
children: /* @__PURE__ */ jsx39(
|
7135
7494
|
IconButton,
|
7136
7495
|
{
|
7137
7496
|
onClick: () => {
|
7138
7497
|
toggleSidebars("left");
|
7139
7498
|
},
|
7140
7499
|
title: "Toggle left sidebar",
|
7141
|
-
children: /* @__PURE__ */
|
7500
|
+
children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
|
7142
7501
|
}
|
7143
7502
|
)
|
7144
7503
|
}
|
7145
7504
|
),
|
7146
|
-
/* @__PURE__ */
|
7505
|
+
/* @__PURE__ */ jsx39(
|
7147
7506
|
"div",
|
7148
7507
|
{
|
7149
7508
|
className: getLayoutClassName("rightSideBarToggle"),
|
7150
|
-
children: /* @__PURE__ */
|
7509
|
+
children: /* @__PURE__ */ jsx39(
|
7151
7510
|
IconButton,
|
7152
7511
|
{
|
7153
7512
|
onClick: () => {
|
7154
7513
|
toggleSidebars("right");
|
7155
7514
|
},
|
7156
7515
|
title: "Toggle right sidebar",
|
7157
|
-
children: /* @__PURE__ */
|
7516
|
+
children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
|
7158
7517
|
}
|
7159
7518
|
)
|
7160
7519
|
}
|
7161
7520
|
)
|
7162
7521
|
] }),
|
7163
|
-
/* @__PURE__ */
|
7522
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
|
7164
7523
|
headerTitle || rootProps.title || "Page",
|
7165
7524
|
headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
|
7166
7525
|
" ",
|
7167
|
-
/* @__PURE__ */
|
7526
|
+
/* @__PURE__ */ jsx39(
|
7168
7527
|
"code",
|
7169
7528
|
{
|
7170
7529
|
className: getLayoutClassName("headerPath"),
|
@@ -7174,30 +7533,30 @@ function Puck({
|
|
7174
7533
|
] })
|
7175
7534
|
] }) }),
|
7176
7535
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
|
7177
|
-
/* @__PURE__ */
|
7536
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
|
7178
7537
|
IconButton,
|
7179
7538
|
{
|
7180
7539
|
onClick: () => {
|
7181
7540
|
return setMenuOpen(!menuOpen);
|
7182
7541
|
},
|
7183
7542
|
title: "Toggle menu bar",
|
7184
|
-
children: menuOpen ? /* @__PURE__ */
|
7543
|
+
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
7185
7544
|
}
|
7186
7545
|
) }),
|
7187
|
-
/* @__PURE__ */
|
7546
|
+
/* @__PURE__ */ jsx39(
|
7188
7547
|
MenuBar,
|
7189
7548
|
{
|
7190
7549
|
appState,
|
7191
7550
|
dispatch,
|
7192
7551
|
onPublish,
|
7193
7552
|
menuOpen,
|
7194
|
-
renderHeaderActions: () => /* @__PURE__ */
|
7553
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7195
7554
|
Button,
|
7196
7555
|
{
|
7197
7556
|
onClick: () => {
|
7198
7557
|
onPublish && onPublish(data);
|
7199
7558
|
},
|
7200
|
-
icon: /* @__PURE__ */
|
7559
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7201
7560
|
children: "Publish"
|
7202
7561
|
}
|
7203
7562
|
) }),
|
@@ -7209,18 +7568,18 @@ function Puck({
|
|
7209
7568
|
}
|
7210
7569
|
),
|
7211
7570
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7212
|
-
/* @__PURE__ */
|
7213
|
-
/* @__PURE__ */
|
7571
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
|
7572
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
|
7214
7573
|
] }),
|
7215
|
-
/* @__PURE__ */
|
7216
|
-
/* @__PURE__ */
|
7574
|
+
/* @__PURE__ */ jsx39(Canvas, {}),
|
7575
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
|
7217
7576
|
SidebarSection,
|
7218
7577
|
{
|
7219
7578
|
noPadding: true,
|
7220
7579
|
noBorderTop: true,
|
7221
7580
|
showBreadcrumbs: true,
|
7222
7581
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7223
|
-
children: /* @__PURE__ */
|
7582
|
+
children: /* @__PURE__ */ jsx39(Fields, {})
|
7224
7583
|
}
|
7225
7584
|
) })
|
7226
7585
|
] })
|
@@ -7228,13 +7587,13 @@ function Puck({
|
|
7228
7587
|
) }) })
|
7229
7588
|
}
|
7230
7589
|
),
|
7231
|
-
/* @__PURE__ */
|
7590
|
+
/* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7232
7591
|
] });
|
7233
7592
|
}
|
7234
7593
|
Puck.Components = Components;
|
7235
7594
|
Puck.Fields = Fields;
|
7236
7595
|
Puck.Outline = Outline;
|
7237
|
-
Puck.Preview =
|
7596
|
+
Puck.Preview = Preview2;
|
7238
7597
|
|
7239
7598
|
// lib/migrate.ts
|
7240
7599
|
init_react_import();
|