@measured/puck 0.18.0-canary.beb05b5 → 0.18.0-canary.c6df5b2
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 +1158 -867
- package/dist/index.mjs +1072 -778
- 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"),
|
@@ -1490,7 +1553,7 @@ import { useEffect as useEffect8 } from "react";
|
|
1490
1553
|
// components/ExternalInput/index.tsx
|
1491
1554
|
init_react_import();
|
1492
1555
|
import {
|
1493
|
-
useMemo,
|
1556
|
+
useMemo as useMemo2,
|
1494
1557
|
useEffect as useEffect7,
|
1495
1558
|
useState as useState9,
|
1496
1559
|
useCallback as useCallback4,
|
@@ -1511,7 +1574,7 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1511
1574
|
|
1512
1575
|
// components/Modal/index.tsx
|
1513
1576
|
import { createPortal } from "react-dom";
|
1514
|
-
import { jsx as
|
1577
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
1515
1578
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1516
1579
|
var Modal = ({
|
1517
1580
|
children,
|
@@ -1523,10 +1586,10 @@ var Modal = ({
|
|
1523
1586
|
setRootEl(document.getElementById("puck-portal-root"));
|
1524
1587
|
}, []);
|
1525
1588
|
if (!rootEl) {
|
1526
|
-
return /* @__PURE__ */
|
1589
|
+
return /* @__PURE__ */ jsx10("div", {});
|
1527
1590
|
}
|
1528
1591
|
return createPortal(
|
1529
|
-
/* @__PURE__ */
|
1592
|
+
/* @__PURE__ */ jsx10("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx10(
|
1530
1593
|
"div",
|
1531
1594
|
{
|
1532
1595
|
className: getClassName7("inner"),
|
@@ -1546,11 +1609,11 @@ init_react_import();
|
|
1546
1609
|
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
1610
|
|
1548
1611
|
// components/Heading/index.tsx
|
1549
|
-
import { jsx as
|
1612
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
1550
1613
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1551
1614
|
var Heading = ({ children, rank, size = "m" }) => {
|
1552
1615
|
const Tag = rank ? `h${rank}` : "span";
|
1553
|
-
return /* @__PURE__ */
|
1616
|
+
return /* @__PURE__ */ jsx11(
|
1554
1617
|
Tag,
|
1555
1618
|
{
|
1556
1619
|
className: getClassName8({
|
@@ -1586,7 +1649,7 @@ var filterDataAttrs = (props) => {
|
|
1586
1649
|
};
|
1587
1650
|
|
1588
1651
|
// components/Button/Button.tsx
|
1589
|
-
import { jsx as
|
1652
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
1590
1653
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1591
1654
|
var Button = (_a) => {
|
1592
1655
|
var _b = _a, {
|
@@ -1645,9 +1708,9 @@ var Button = (_a) => {
|
|
1645
1708
|
href
|
1646
1709
|
}, dataAttrs), {
|
1647
1710
|
children: [
|
1648
|
-
icon && /* @__PURE__ */
|
1711
|
+
icon && /* @__PURE__ */ jsx12("div", { className: getClassName9("icon"), children: icon }),
|
1649
1712
|
children,
|
1650
|
-
loading && /* @__PURE__ */
|
1713
|
+
loading && /* @__PURE__ */ jsx12("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx12(Loader, { size: 14 }) })
|
1651
1714
|
]
|
1652
1715
|
})
|
1653
1716
|
);
|
@@ -1655,7 +1718,7 @@ var Button = (_a) => {
|
|
1655
1718
|
};
|
1656
1719
|
|
1657
1720
|
// components/ExternalInput/index.tsx
|
1658
|
-
import { Fragment as Fragment3, jsx as
|
1721
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
1659
1722
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1660
1723
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1661
1724
|
var dataCache = {};
|
@@ -1678,10 +1741,10 @@ var ExternalInput = ({
|
|
1678
1741
|
const hasFilterFields = !!filterFields;
|
1679
1742
|
const [filters, setFilters] = useState9(field.initialFilters || {});
|
1680
1743
|
const [filtersToggled, setFiltersToggled] = useState9(hasFilterFields);
|
1681
|
-
const mappedData =
|
1744
|
+
const mappedData = useMemo2(() => {
|
1682
1745
|
return data.map(mapRow);
|
1683
1746
|
}, [data]);
|
1684
|
-
const keys =
|
1747
|
+
const keys = useMemo2(() => {
|
1685
1748
|
const validKeys = /* @__PURE__ */ new Set();
|
1686
1749
|
for (const item of mappedData) {
|
1687
1750
|
for (const key of Object.keys(item)) {
|
@@ -1728,7 +1791,7 @@ var ExternalInput = ({
|
|
1728
1791
|
id,
|
1729
1792
|
children: [
|
1730
1793
|
/* @__PURE__ */ jsxs6("div", { className: getClassName10("actions"), children: [
|
1731
|
-
/* @__PURE__ */
|
1794
|
+
/* @__PURE__ */ jsx13(
|
1732
1795
|
"button",
|
1733
1796
|
{
|
1734
1797
|
type: "button",
|
@@ -1736,12 +1799,12 @@ var ExternalInput = ({
|
|
1736
1799
|
className: getClassName10("button"),
|
1737
1800
|
disabled: readOnly,
|
1738
1801
|
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
1739
|
-
/* @__PURE__ */
|
1740
|
-
/* @__PURE__ */
|
1802
|
+
/* @__PURE__ */ jsx13(Link, { size: "16" }),
|
1803
|
+
/* @__PURE__ */ jsx13("span", { children: field.placeholder })
|
1741
1804
|
] })
|
1742
1805
|
}
|
1743
1806
|
),
|
1744
|
-
value && /* @__PURE__ */
|
1807
|
+
value && /* @__PURE__ */ jsx13(
|
1745
1808
|
"button",
|
1746
1809
|
{
|
1747
1810
|
type: "button",
|
@@ -1750,11 +1813,11 @@ var ExternalInput = ({
|
|
1750
1813
|
onChange(null);
|
1751
1814
|
},
|
1752
1815
|
disabled: readOnly,
|
1753
|
-
children: /* @__PURE__ */
|
1816
|
+
children: /* @__PURE__ */ jsx13(LockOpen, { size: 16 })
|
1754
1817
|
}
|
1755
1818
|
)
|
1756
1819
|
] }),
|
1757
|
-
/* @__PURE__ */
|
1820
|
+
/* @__PURE__ */ jsx13(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
|
1758
1821
|
"form",
|
1759
1822
|
{
|
1760
1823
|
className: getClassNameModal({
|
@@ -1768,11 +1831,11 @@ var ExternalInput = ({
|
|
1768
1831
|
search(searchQuery, filters);
|
1769
1832
|
},
|
1770
1833
|
children: [
|
1771
|
-
/* @__PURE__ */
|
1834
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
|
1772
1835
|
/* @__PURE__ */ jsxs6("label", { className: getClassNameModal("search"), children: [
|
1773
|
-
/* @__PURE__ */
|
1774
|
-
/* @__PURE__ */
|
1775
|
-
/* @__PURE__ */
|
1836
|
+
/* @__PURE__ */ jsx13("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
1837
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx13(Search, { size: "18" }) }),
|
1838
|
+
/* @__PURE__ */ jsx13(
|
1776
1839
|
"input",
|
1777
1840
|
{
|
1778
1841
|
className: getClassNameModal("searchInput"),
|
@@ -1788,8 +1851,8 @@ var ExternalInput = ({
|
|
1788
1851
|
)
|
1789
1852
|
] }),
|
1790
1853
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchActions"), children: [
|
1791
|
-
/* @__PURE__ */
|
1792
|
-
hasFilterFields && /* @__PURE__ */
|
1854
|
+
/* @__PURE__ */ jsx13(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
1855
|
+
hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx13(
|
1793
1856
|
IconButton,
|
1794
1857
|
{
|
1795
1858
|
title: "Toggle filters",
|
@@ -1798,15 +1861,15 @@ var ExternalInput = ({
|
|
1798
1861
|
e.stopPropagation();
|
1799
1862
|
setFiltersToggled(!filtersToggled);
|
1800
1863
|
},
|
1801
|
-
children: /* @__PURE__ */
|
1864
|
+
children: /* @__PURE__ */ jsx13(SlidersHorizontal, { size: 20 })
|
1802
1865
|
}
|
1803
1866
|
) })
|
1804
1867
|
] })
|
1805
|
-
] }) : /* @__PURE__ */
|
1868
|
+
] }) : /* @__PURE__ */ jsx13(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
1806
1869
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("grid"), children: [
|
1807
|
-
hasFilterFields && /* @__PURE__ */
|
1870
|
+
hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
1808
1871
|
const filterField = filterFields[fieldName];
|
1809
|
-
return /* @__PURE__ */
|
1872
|
+
return /* @__PURE__ */ jsx13(
|
1810
1873
|
AutoFieldPrivate,
|
1811
1874
|
{
|
1812
1875
|
field: filterField,
|
@@ -1825,7 +1888,7 @@ var ExternalInput = ({
|
|
1825
1888
|
}) }),
|
1826
1889
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("tableWrapper"), children: [
|
1827
1890
|
/* @__PURE__ */ jsxs6("table", { className: getClassNameModal("table"), children: [
|
1828
|
-
/* @__PURE__ */
|
1891
|
+
/* @__PURE__ */ jsx13("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx13("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx13(
|
1829
1892
|
"th",
|
1830
1893
|
{
|
1831
1894
|
className: getClassNameModal("th"),
|
@@ -1834,8 +1897,8 @@ var ExternalInput = ({
|
|
1834
1897
|
},
|
1835
1898
|
key
|
1836
1899
|
)) }) }),
|
1837
|
-
/* @__PURE__ */
|
1838
|
-
return /* @__PURE__ */
|
1900
|
+
/* @__PURE__ */ jsx13("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
1901
|
+
return /* @__PURE__ */ jsx13(
|
1839
1902
|
"tr",
|
1840
1903
|
{
|
1841
1904
|
style: { whiteSpace: "nowrap" },
|
@@ -1844,16 +1907,16 @@ var ExternalInput = ({
|
|
1844
1907
|
onChange(mapProp(data[i]));
|
1845
1908
|
setOpen(false);
|
1846
1909
|
},
|
1847
|
-
children: keys.map((key) => /* @__PURE__ */
|
1910
|
+
children: keys.map((key) => /* @__PURE__ */ jsx13("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
1848
1911
|
},
|
1849
1912
|
i
|
1850
1913
|
);
|
1851
1914
|
}) })
|
1852
1915
|
] }),
|
1853
|
-
/* @__PURE__ */
|
1916
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx13(Loader, { size: 24 }) })
|
1854
1917
|
] })
|
1855
1918
|
] }),
|
1856
|
-
/* @__PURE__ */
|
1919
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx13(Footer, { items: mappedData }) })
|
1857
1920
|
]
|
1858
1921
|
}
|
1859
1922
|
) })
|
@@ -1863,7 +1926,7 @@ var ExternalInput = ({
|
|
1863
1926
|
};
|
1864
1927
|
|
1865
1928
|
// components/AutoField/fields/ExternalField/index.tsx
|
1866
|
-
import { jsx as
|
1929
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
1867
1930
|
var ExternalField = ({
|
1868
1931
|
field,
|
1869
1932
|
onChange,
|
@@ -1887,7 +1950,7 @@ var ExternalField = ({
|
|
1887
1950
|
if (field.type !== "external") {
|
1888
1951
|
return null;
|
1889
1952
|
}
|
1890
|
-
return /* @__PURE__ */
|
1953
|
+
return /* @__PURE__ */ jsx14(Label2, { label: label || name, icon: /* @__PURE__ */ jsx14(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx14(
|
1891
1954
|
ExternalInput,
|
1892
1955
|
{
|
1893
1956
|
name,
|
@@ -1912,7 +1975,7 @@ var ExternalField = ({
|
|
1912
1975
|
|
1913
1976
|
// components/AutoField/fields/RadioField/index.tsx
|
1914
1977
|
init_react_import();
|
1915
|
-
import { useMemo as
|
1978
|
+
import { useMemo as useMemo3 } from "react";
|
1916
1979
|
|
1917
1980
|
// lib/safe-json-parse.ts
|
1918
1981
|
init_react_import();
|
@@ -1926,7 +1989,7 @@ var safeJsonParse = (str) => {
|
|
1926
1989
|
};
|
1927
1990
|
|
1928
1991
|
// components/AutoField/fields/RadioField/index.tsx
|
1929
|
-
import { jsx as
|
1992
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
1930
1993
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
1931
1994
|
var RadioField = ({
|
1932
1995
|
field,
|
@@ -1938,26 +2001,26 @@ var RadioField = ({
|
|
1938
2001
|
label,
|
1939
2002
|
Label: Label2
|
1940
2003
|
}) => {
|
1941
|
-
const flatOptions =
|
2004
|
+
const flatOptions = useMemo3(
|
1942
2005
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
1943
2006
|
[field]
|
1944
2007
|
);
|
1945
2008
|
if (field.type !== "radio" || !field.options) {
|
1946
2009
|
return null;
|
1947
2010
|
}
|
1948
|
-
return /* @__PURE__ */
|
2011
|
+
return /* @__PURE__ */ jsx15(
|
1949
2012
|
Label2,
|
1950
2013
|
{
|
1951
|
-
icon: /* @__PURE__ */
|
2014
|
+
icon: /* @__PURE__ */ jsx15(CircleCheckBig, { size: 16 }),
|
1952
2015
|
label: label || name,
|
1953
2016
|
readOnly,
|
1954
2017
|
el: "div",
|
1955
|
-
children: /* @__PURE__ */
|
2018
|
+
children: /* @__PURE__ */ jsx15("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs7(
|
1956
2019
|
"label",
|
1957
2020
|
{
|
1958
2021
|
className: getClassName11("radio"),
|
1959
2022
|
children: [
|
1960
|
-
/* @__PURE__ */
|
2023
|
+
/* @__PURE__ */ jsx15(
|
1961
2024
|
"input",
|
1962
2025
|
{
|
1963
2026
|
type: "radio",
|
@@ -1977,7 +2040,7 @@ var RadioField = ({
|
|
1977
2040
|
checked: value === option.value
|
1978
2041
|
}
|
1979
2042
|
),
|
1980
|
-
/* @__PURE__ */
|
2043
|
+
/* @__PURE__ */ jsx15("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
1981
2044
|
]
|
1982
2045
|
},
|
1983
2046
|
option.label + option.value
|
@@ -1988,8 +2051,8 @@ var RadioField = ({
|
|
1988
2051
|
|
1989
2052
|
// components/AutoField/fields/SelectField/index.tsx
|
1990
2053
|
init_react_import();
|
1991
|
-
import { useMemo as
|
1992
|
-
import { jsx as
|
2054
|
+
import { useMemo as useMemo4 } from "react";
|
2055
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
1993
2056
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
1994
2057
|
var SelectField = ({
|
1995
2058
|
field,
|
@@ -2001,20 +2064,20 @@ var SelectField = ({
|
|
2001
2064
|
readOnly,
|
2002
2065
|
id
|
2003
2066
|
}) => {
|
2004
|
-
const flatOptions =
|
2067
|
+
const flatOptions = useMemo4(
|
2005
2068
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2006
2069
|
[field]
|
2007
2070
|
);
|
2008
2071
|
if (field.type !== "select" || !field.options) {
|
2009
2072
|
return null;
|
2010
2073
|
}
|
2011
|
-
return /* @__PURE__ */
|
2074
|
+
return /* @__PURE__ */ jsx16(
|
2012
2075
|
Label2,
|
2013
2076
|
{
|
2014
2077
|
label: label || name,
|
2015
|
-
icon: /* @__PURE__ */
|
2078
|
+
icon: /* @__PURE__ */ jsx16(ChevronDown, { size: 16 }),
|
2016
2079
|
readOnly,
|
2017
|
-
children: /* @__PURE__ */
|
2080
|
+
children: /* @__PURE__ */ jsx16(
|
2018
2081
|
"select",
|
2019
2082
|
{
|
2020
2083
|
id,
|
@@ -2031,7 +2094,7 @@ var SelectField = ({
|
|
2031
2094
|
}
|
2032
2095
|
},
|
2033
2096
|
value,
|
2034
|
-
children: field.options.map((option) => /* @__PURE__ */
|
2097
|
+
children: field.options.map((option) => /* @__PURE__ */ jsx16(
|
2035
2098
|
"option",
|
2036
2099
|
{
|
2037
2100
|
label: option.label,
|
@@ -2047,7 +2110,7 @@ var SelectField = ({
|
|
2047
2110
|
|
2048
2111
|
// components/AutoField/fields/TextareaField/index.tsx
|
2049
2112
|
init_react_import();
|
2050
|
-
import { jsx as
|
2113
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
2051
2114
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2052
2115
|
var TextareaField = ({
|
2053
2116
|
onChange,
|
@@ -2058,7 +2121,7 @@ var TextareaField = ({
|
|
2058
2121
|
Label: Label2,
|
2059
2122
|
id
|
2060
2123
|
}) => {
|
2061
|
-
return /* @__PURE__ */
|
2124
|
+
return /* @__PURE__ */ jsx17(Label2, { label: label || name, icon: /* @__PURE__ */ jsx17(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx17(
|
2062
2125
|
"textarea",
|
2063
2126
|
{
|
2064
2127
|
id,
|
@@ -2085,7 +2148,7 @@ init_react_import();
|
|
2085
2148
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2086
2149
|
|
2087
2150
|
// components/AutoField/fields/ObjectField/index.tsx
|
2088
|
-
import { jsx as
|
2151
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
2089
2152
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2090
2153
|
var ObjectField = ({
|
2091
2154
|
field,
|
@@ -2097,43 +2160,54 @@ var ObjectField = ({
|
|
2097
2160
|
readOnly,
|
2098
2161
|
id
|
2099
2162
|
}) => {
|
2100
|
-
const {
|
2163
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2101
2164
|
if (field.type !== "object" || !field.objectFields) {
|
2102
2165
|
return null;
|
2103
2166
|
}
|
2104
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2105
2167
|
const data = value || {};
|
2106
|
-
return /* @__PURE__ */
|
2168
|
+
return /* @__PURE__ */ jsx18(
|
2107
2169
|
Label2,
|
2108
2170
|
{
|
2109
2171
|
label: label || name,
|
2110
|
-
icon: /* @__PURE__ */
|
2172
|
+
icon: /* @__PURE__ */ jsx18(EllipsisVertical, { size: 16 }),
|
2111
2173
|
el: "div",
|
2112
2174
|
readOnly,
|
2113
|
-
children: /* @__PURE__ */
|
2114
|
-
const subField = field.objectFields[
|
2115
|
-
const
|
2116
|
-
const
|
2117
|
-
const subReadOnly = readOnly ? readOnly :
|
2118
|
-
|
2119
|
-
|
2175
|
+
children: /* @__PURE__ */ jsx18("div", { className: getClassName14(), children: /* @__PURE__ */ jsx18("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
2176
|
+
const subField = field.objectFields[subName];
|
2177
|
+
const subPath = `${name}.${subName}`;
|
2178
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2179
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2180
|
+
const label2 = subField.label || subName;
|
2181
|
+
return /* @__PURE__ */ jsx18(
|
2182
|
+
NestedFieldProvider,
|
2120
2183
|
{
|
2121
|
-
name:
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2184
|
+
name: localName || id,
|
2185
|
+
subName,
|
2186
|
+
readOnlyFields,
|
2187
|
+
children: /* @__PURE__ */ jsx18(
|
2188
|
+
AutoFieldPrivate,
|
2189
|
+
{
|
2190
|
+
name: subPath,
|
2191
|
+
label: subPath,
|
2192
|
+
id: `${id}_${subName}`,
|
2193
|
+
readOnly: subReadOnly,
|
2194
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2195
|
+
label: label2
|
2196
|
+
// May be used by custom fields
|
2131
2197
|
}),
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2198
|
+
value: data[subName],
|
2199
|
+
onChange: (val, ui) => {
|
2200
|
+
onChange(
|
2201
|
+
__spreadProps(__spreadValues({}, data), {
|
2202
|
+
[subName]: val
|
2203
|
+
}),
|
2204
|
+
ui
|
2205
|
+
);
|
2206
|
+
}
|
2207
|
+
}
|
2208
|
+
)
|
2135
2209
|
},
|
2136
|
-
|
2210
|
+
subPath
|
2137
2211
|
);
|
2138
2212
|
}) }) })
|
2139
2213
|
}
|
@@ -2159,7 +2233,7 @@ var useSafeId = () => {
|
|
2159
2233
|
};
|
2160
2234
|
|
2161
2235
|
// components/AutoField/index.tsx
|
2162
|
-
import { Fragment as Fragment4, jsx as
|
2236
|
+
import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
2163
2237
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2164
2238
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2165
2239
|
var FieldLabel = ({
|
@@ -2173,14 +2247,14 @@ var FieldLabel = ({
|
|
2173
2247
|
const El = el;
|
2174
2248
|
return /* @__PURE__ */ jsxs8(El, { className, children: [
|
2175
2249
|
/* @__PURE__ */ jsxs8("div", { className: getClassName15("label"), children: [
|
2176
|
-
icon ? /* @__PURE__ */
|
2250
|
+
icon ? /* @__PURE__ */ jsx19("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx19(Fragment4, {}),
|
2177
2251
|
label,
|
2178
|
-
readOnly && /* @__PURE__ */
|
2252
|
+
readOnly && /* @__PURE__ */ jsx19("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx19(Lock, { size: "12" }) })
|
2179
2253
|
] }),
|
2180
2254
|
children
|
2181
2255
|
] });
|
2182
2256
|
};
|
2183
|
-
var
|
2257
|
+
var FieldLabelInternal = ({
|
2184
2258
|
children,
|
2185
2259
|
icon,
|
2186
2260
|
label,
|
@@ -2188,14 +2262,14 @@ var FieldLabelInternal2 = ({
|
|
2188
2262
|
readOnly
|
2189
2263
|
}) => {
|
2190
2264
|
const { overrides } = useAppContext();
|
2191
|
-
const Wrapper =
|
2265
|
+
const Wrapper = useMemo5(
|
2192
2266
|
() => overrides.fieldLabel || FieldLabel,
|
2193
2267
|
[overrides]
|
2194
2268
|
);
|
2195
2269
|
if (!label) {
|
2196
|
-
return /* @__PURE__ */
|
2270
|
+
return /* @__PURE__ */ jsx19(Fragment4, { children });
|
2197
2271
|
}
|
2198
|
-
return /* @__PURE__ */
|
2272
|
+
return /* @__PURE__ */ jsx19(
|
2199
2273
|
Wrapper,
|
2200
2274
|
{
|
2201
2275
|
label,
|
@@ -2209,8 +2283,8 @@ var FieldLabelInternal2 = ({
|
|
2209
2283
|
};
|
2210
2284
|
function AutoFieldInternal(props) {
|
2211
2285
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2212
|
-
const { dispatch, overrides } = useAppContext();
|
2213
|
-
const { id, Label: Label2 =
|
2286
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2287
|
+
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2214
2288
|
const field = props.field;
|
2215
2289
|
const label = field.label;
|
2216
2290
|
const defaultId = useSafeId();
|
@@ -2270,20 +2344,30 @@ function AutoFieldInternal(props) {
|
|
2270
2344
|
return null;
|
2271
2345
|
}
|
2272
2346
|
const CustomField = field.render;
|
2273
|
-
return /* @__PURE__ */
|
2347
|
+
return /* @__PURE__ */ jsx19("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx19("div", { className: getClassName15(), children: /* @__PURE__ */ jsx19(CustomField, __spreadValues({}, mergedProps)) }) });
|
2274
2348
|
}
|
2275
2349
|
const children = defaultFields[field.type](mergedProps);
|
2276
2350
|
const Render2 = render[field.type];
|
2277
|
-
|
2278
|
-
|
2351
|
+
const nestedFieldContext = useContext3(NestedFieldContext);
|
2352
|
+
return /* @__PURE__ */ jsx19(
|
2353
|
+
NestedFieldContext.Provider,
|
2279
2354
|
{
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
onClick: (e) => {
|
2284
|
-
e.stopPropagation();
|
2355
|
+
value: {
|
2356
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2357
|
+
localName: nestedFieldContext.localName
|
2285
2358
|
},
|
2286
|
-
children: /* @__PURE__ */
|
2359
|
+
children: /* @__PURE__ */ jsx19(
|
2360
|
+
"div",
|
2361
|
+
{
|
2362
|
+
className: getClassNameWrapper(),
|
2363
|
+
onFocus,
|
2364
|
+
onBlur,
|
2365
|
+
onClick: (e) => {
|
2366
|
+
e.stopPropagation();
|
2367
|
+
},
|
2368
|
+
children: /* @__PURE__ */ jsx19(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2369
|
+
}
|
2370
|
+
)
|
2287
2371
|
}
|
2288
2372
|
);
|
2289
2373
|
}
|
@@ -2311,11 +2395,11 @@ function AutoFieldPrivate(props) {
|
|
2311
2395
|
value: localValue,
|
2312
2396
|
onChange: onChangeLocal
|
2313
2397
|
};
|
2314
|
-
return /* @__PURE__ */
|
2398
|
+
return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2315
2399
|
}
|
2316
2400
|
function AutoField(props) {
|
2317
|
-
const DefaultLabel =
|
2318
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */
|
2401
|
+
const DefaultLabel = useMemo5(() => {
|
2402
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx19(
|
2319
2403
|
"div",
|
2320
2404
|
__spreadProps(__spreadValues({}, labelProps), {
|
2321
2405
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2323,7 +2407,7 @@ function AutoField(props) {
|
|
2323
2407
|
);
|
2324
2408
|
return DefaultLabel2;
|
2325
2409
|
}, [props.readOnly]);
|
2326
|
-
return /* @__PURE__ */
|
2410
|
+
return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2327
2411
|
}
|
2328
2412
|
|
2329
2413
|
// components/Drawer/index.tsx
|
@@ -2334,18 +2418,19 @@ init_react_import();
|
|
2334
2418
|
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
2419
|
|
2336
2420
|
// components/Drawer/index.tsx
|
2337
|
-
import { useMemo as
|
2421
|
+
import { useMemo as useMemo9, useState as useState18 } from "react";
|
2338
2422
|
|
2339
2423
|
// components/DragDropContext/index.tsx
|
2340
2424
|
init_react_import();
|
2341
2425
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
2342
2426
|
import {
|
2343
|
-
createContext as
|
2344
|
-
useCallback as
|
2345
|
-
useContext as
|
2346
|
-
useEffect as
|
2347
|
-
|
2348
|
-
|
2427
|
+
createContext as createContext4,
|
2428
|
+
useCallback as useCallback11,
|
2429
|
+
useContext as useContext7,
|
2430
|
+
useEffect as useEffect15,
|
2431
|
+
useId,
|
2432
|
+
useRef as useRef4,
|
2433
|
+
useState as useState17
|
2349
2434
|
} from "react";
|
2350
2435
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
2351
2436
|
|
@@ -2353,23 +2438,22 @@ import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
|
2353
2438
|
init_react_import();
|
2354
2439
|
import {
|
2355
2440
|
forwardRef as forwardRef3,
|
2356
|
-
useCallback as
|
2357
|
-
useContext as
|
2358
|
-
useEffect as
|
2359
|
-
useMemo as
|
2360
|
-
useRef as
|
2361
|
-
useState as useState15
|
2441
|
+
useCallback as useCallback10,
|
2442
|
+
useContext as useContext6,
|
2443
|
+
useEffect as useEffect14,
|
2444
|
+
useMemo as useMemo8,
|
2445
|
+
useRef as useRef3
|
2362
2446
|
} from "react";
|
2363
2447
|
|
2364
2448
|
// components/DraggableComponent/index.tsx
|
2365
2449
|
init_react_import();
|
2366
2450
|
import {
|
2367
|
-
useCallback as
|
2368
|
-
useContext as
|
2451
|
+
useCallback as useCallback7,
|
2452
|
+
useContext as useContext5,
|
2369
2453
|
useEffect as useEffect10,
|
2370
|
-
useMemo as
|
2371
|
-
useRef as
|
2372
|
-
useState as
|
2454
|
+
useMemo as useMemo7,
|
2455
|
+
useRef as useRef2,
|
2456
|
+
useState as useState13
|
2373
2457
|
} from "react";
|
2374
2458
|
|
2375
2459
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -2379,18 +2463,18 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
|
|
2379
2463
|
// components/DraggableComponent/index.tsx
|
2380
2464
|
import { createPortal as createPortal2 } from "react-dom";
|
2381
2465
|
|
2382
|
-
//
|
2466
|
+
// lib/dnd/collision/dynamic/index.ts
|
2383
2467
|
init_react_import();
|
2384
2468
|
import {
|
2385
2469
|
CollisionPriority as CollisionPriority7,
|
2386
2470
|
CollisionType as CollisionType7
|
2387
2471
|
} from "@dnd-kit/abstract";
|
2388
2472
|
|
2389
|
-
//
|
2473
|
+
// lib/dnd/collision/directional/index.ts
|
2390
2474
|
init_react_import();
|
2391
2475
|
import { CollisionType } from "@dnd-kit/abstract";
|
2392
2476
|
|
2393
|
-
//
|
2477
|
+
// lib/dnd/collision/collision-debug.ts
|
2394
2478
|
init_react_import();
|
2395
2479
|
var DEBUG = false;
|
2396
2480
|
var debugElements = {};
|
@@ -2439,7 +2523,7 @@ var collisionDebug = (a, b, id, color, label) => {
|
|
2439
2523
|
});
|
2440
2524
|
};
|
2441
2525
|
|
2442
|
-
//
|
2526
|
+
// lib/dnd/collision/directional/index.ts
|
2443
2527
|
var distanceChange = "increasing";
|
2444
2528
|
var directionalCollision = (input, previous) => {
|
2445
2529
|
var _a;
|
@@ -2472,7 +2556,7 @@ var directionalCollision = (input, previous) => {
|
|
2472
2556
|
return null;
|
2473
2557
|
};
|
2474
2558
|
|
2475
|
-
//
|
2559
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
2476
2560
|
init_react_import();
|
2477
2561
|
var getDirection = (dragAxis, delta) => {
|
2478
2562
|
if (dragAxis === "dynamic") {
|
@@ -2487,7 +2571,7 @@ var getDirection = (dragAxis, delta) => {
|
|
2487
2571
|
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2488
2572
|
};
|
2489
2573
|
|
2490
|
-
//
|
2574
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
2491
2575
|
init_react_import();
|
2492
2576
|
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2493
2577
|
const dragRect = dragShape.boundingRectangle;
|
@@ -2506,7 +2590,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2506
2590
|
return dragRect.right - offset >= dropCenter.x;
|
2507
2591
|
};
|
2508
2592
|
|
2509
|
-
//
|
2593
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2510
2594
|
init_react_import();
|
2511
2595
|
import { Point } from "@dnd-kit/geometry";
|
2512
2596
|
var INTERVAL_SENSITIVITY = 10;
|
@@ -2610,7 +2694,14 @@ var closestCorners = (input) => {
|
|
2610
2694
|
};
|
2611
2695
|
};
|
2612
2696
|
|
2613
|
-
//
|
2697
|
+
// lib/dnd/collision/dynamic/store.ts
|
2698
|
+
init_react_import();
|
2699
|
+
import { createStore } from "zustand/vanilla";
|
2700
|
+
var collisionStore = createStore(() => ({
|
2701
|
+
fallbackEnabled: false
|
2702
|
+
}));
|
2703
|
+
|
2704
|
+
// lib/dnd/collision/dynamic/index.ts
|
2614
2705
|
var flushNext = "";
|
2615
2706
|
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2616
2707
|
var _a, _b, _c, _d, _e;
|
@@ -2622,6 +2713,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2622
2713
|
return null;
|
2623
2714
|
}
|
2624
2715
|
const { center: dragCenter } = dragShape;
|
2716
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2625
2717
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2626
2718
|
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2627
2719
|
direction: interval.direction
|
@@ -2667,7 +2759,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2667
2759
|
flushNext = "";
|
2668
2760
|
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2669
2761
|
}
|
2670
|
-
if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2762
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2671
2763
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2672
2764
|
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2673
2765
|
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
@@ -2728,8 +2820,107 @@ function getDeepScrollPosition(element) {
|
|
2728
2820
|
return totalScroll;
|
2729
2821
|
}
|
2730
2822
|
|
2823
|
+
// components/DropZone/context.tsx
|
2824
|
+
init_react_import();
|
2825
|
+
import {
|
2826
|
+
createContext as createContext3,
|
2827
|
+
useCallback as useCallback6,
|
2828
|
+
useMemo as useMemo6,
|
2829
|
+
useState as useState12
|
2830
|
+
} from "react";
|
2831
|
+
import { createStore as createStore2 } from "zustand";
|
2832
|
+
import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
|
2833
|
+
var dropZoneContext = createContext3(null);
|
2834
|
+
var ZoneStoreContext = createContext3(
|
2835
|
+
createStore2(() => ({
|
2836
|
+
zoneDepthIndex: {},
|
2837
|
+
nextZoneDepthIndex: {},
|
2838
|
+
areaDepthIndex: {},
|
2839
|
+
nextAreaDepthIndex: {},
|
2840
|
+
draggedItem: null,
|
2841
|
+
previewIndex: {}
|
2842
|
+
}))
|
2843
|
+
);
|
2844
|
+
var ZoneStoreProvider = ({
|
2845
|
+
children,
|
2846
|
+
store
|
2847
|
+
}) => {
|
2848
|
+
return /* @__PURE__ */ jsx20(ZoneStoreContext.Provider, { value: store, children });
|
2849
|
+
};
|
2850
|
+
var DropZoneProvider = ({
|
2851
|
+
children,
|
2852
|
+
value
|
2853
|
+
}) => {
|
2854
|
+
const [hoveringComponent, setHoveringComponent] = useState12();
|
2855
|
+
const [areasWithZones, setAreasWithZones] = useState12(
|
2856
|
+
{}
|
2857
|
+
);
|
2858
|
+
const [activeZones, setActiveZones] = useState12({});
|
2859
|
+
const { dispatch } = useAppContext();
|
2860
|
+
const registerZoneArea = useCallback6(
|
2861
|
+
(area) => {
|
2862
|
+
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2863
|
+
},
|
2864
|
+
[setAreasWithZones]
|
2865
|
+
);
|
2866
|
+
const registerZone = useCallback6(
|
2867
|
+
(zoneCompound) => {
|
2868
|
+
if (!dispatch) {
|
2869
|
+
return;
|
2870
|
+
}
|
2871
|
+
dispatch({
|
2872
|
+
type: "registerZone",
|
2873
|
+
zone: zoneCompound
|
2874
|
+
});
|
2875
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
2876
|
+
},
|
2877
|
+
[setActiveZones, dispatch]
|
2878
|
+
);
|
2879
|
+
const unregisterZone = useCallback6(
|
2880
|
+
(zoneCompound) => {
|
2881
|
+
if (!dispatch) {
|
2882
|
+
return;
|
2883
|
+
}
|
2884
|
+
dispatch({
|
2885
|
+
type: "unregisterZone",
|
2886
|
+
zone: zoneCompound
|
2887
|
+
});
|
2888
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
2889
|
+
[zoneCompound]: false
|
2890
|
+
}));
|
2891
|
+
},
|
2892
|
+
[setActiveZones, dispatch]
|
2893
|
+
);
|
2894
|
+
const memoValue = useMemo6(
|
2895
|
+
() => __spreadValues({
|
2896
|
+
hoveringComponent,
|
2897
|
+
setHoveringComponent,
|
2898
|
+
registerZoneArea,
|
2899
|
+
areasWithZones,
|
2900
|
+
registerZone,
|
2901
|
+
unregisterZone,
|
2902
|
+
activeZones
|
2903
|
+
}, value),
|
2904
|
+
[value, hoveringComponent, areasWithZones, activeZones]
|
2905
|
+
);
|
2906
|
+
return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
|
2907
|
+
};
|
2908
|
+
|
2909
|
+
// lib/use-context-store.ts
|
2910
|
+
init_react_import();
|
2911
|
+
import { useContext as useContext4 } from "react";
|
2912
|
+
import { useStore } from "zustand";
|
2913
|
+
import { useShallow } from "zustand/react/shallow";
|
2914
|
+
function useContextStore(context, selector) {
|
2915
|
+
const store = useContext4(context);
|
2916
|
+
if (!store) {
|
2917
|
+
throw new Error("useContextStore must be used inside context");
|
2918
|
+
}
|
2919
|
+
return useStore(store, useShallow(selector));
|
2920
|
+
}
|
2921
|
+
|
2731
2922
|
// components/DraggableComponent/index.tsx
|
2732
|
-
import { jsx as
|
2923
|
+
import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
|
2733
2924
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2734
2925
|
var DEBUG2 = false;
|
2735
2926
|
var space = 8;
|
@@ -2743,9 +2934,9 @@ var DefaultActionBar = ({
|
|
2743
2934
|
}) => /* @__PURE__ */ jsxs9(ActionBar, { children: [
|
2744
2935
|
/* @__PURE__ */ jsxs9(ActionBar.Group, { children: [
|
2745
2936
|
parentAction,
|
2746
|
-
label && /* @__PURE__ */
|
2937
|
+
label && /* @__PURE__ */ jsx21(ActionBar.Label, { label })
|
2747
2938
|
] }),
|
2748
|
-
/* @__PURE__ */
|
2939
|
+
/* @__PURE__ */ jsx21(ActionBar.Group, { children })
|
2749
2940
|
] });
|
2750
2941
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
2751
2942
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -2780,9 +2971,9 @@ var DraggableComponent = ({
|
|
2780
2971
|
iframe,
|
2781
2972
|
state
|
2782
2973
|
} = useAppContext();
|
2783
|
-
const ctx =
|
2784
|
-
const [localZones, setLocalZones] =
|
2785
|
-
const registerLocalZone =
|
2974
|
+
const ctx = useContext5(dropZoneContext);
|
2975
|
+
const [localZones, setLocalZones] = useState13({});
|
2976
|
+
const registerLocalZone = useCallback7(
|
2786
2977
|
(zoneCompound2, active) => {
|
2787
2978
|
var _a;
|
2788
2979
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -2792,7 +2983,7 @@ var DraggableComponent = ({
|
|
2792
2983
|
},
|
2793
2984
|
[setLocalZones]
|
2794
2985
|
);
|
2795
|
-
const unregisterLocalZone =
|
2986
|
+
const unregisterLocalZone = useCallback7(
|
2796
2987
|
(zoneCompound2) => {
|
2797
2988
|
var _a;
|
2798
2989
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -2806,7 +2997,7 @@ var DraggableComponent = ({
|
|
2806
2997
|
);
|
2807
2998
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
2808
2999
|
const { path = [] } = ctx || {};
|
2809
|
-
const [canDrag, setCanDrag] =
|
3000
|
+
const [canDrag, setCanDrag] = useState13(false);
|
2810
3001
|
useEffect10(() => {
|
2811
3002
|
var _a;
|
2812
3003
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
@@ -2817,10 +3008,13 @@ var DraggableComponent = ({
|
|
2817
3008
|
setCanDrag((_a = perms.drag) != null ? _a : true);
|
2818
3009
|
}
|
2819
3010
|
}, [state, index, zoneCompound, getPermissions]);
|
2820
|
-
const userIsDragging =
|
3011
|
+
const userIsDragging = useContextStore(
|
3012
|
+
ZoneStoreContext,
|
3013
|
+
(s) => !!s.draggedItem
|
3014
|
+
);
|
2821
3015
|
const canCollide = canDrag || userIsDragging;
|
2822
3016
|
const disabled = !isEnabled || !canCollide;
|
2823
|
-
const [dragAxis, setDragAxis] =
|
3017
|
+
const [dragAxis, setDragAxis] = useState13(userDragAxis || autoDragAxis);
|
2824
3018
|
const { ref: sortableRef, status } = useSortableSafe({
|
2825
3019
|
id,
|
2826
3020
|
index,
|
@@ -2846,8 +3040,8 @@ var DraggableComponent = ({
|
|
2846
3040
|
}
|
2847
3041
|
});
|
2848
3042
|
const thisIsDragging = status === "dragging";
|
2849
|
-
const ref =
|
2850
|
-
const refSetter =
|
3043
|
+
const ref = useRef2(null);
|
3044
|
+
const refSetter = useCallback7(
|
2851
3045
|
(el) => {
|
2852
3046
|
sortableRef(el);
|
2853
3047
|
if (el) {
|
@@ -2856,14 +3050,14 @@ var DraggableComponent = ({
|
|
2856
3050
|
},
|
2857
3051
|
[sortableRef]
|
2858
3052
|
);
|
2859
|
-
const [portalEl, setPortalEl] =
|
3053
|
+
const [portalEl, setPortalEl] = useState13();
|
2860
3054
|
useEffect10(() => {
|
2861
3055
|
var _a, _b, _c;
|
2862
3056
|
setPortalEl(
|
2863
3057
|
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
3058
|
);
|
2865
3059
|
}, [iframe.enabled, ref.current]);
|
2866
|
-
const getStyle =
|
3060
|
+
const getStyle = useCallback7(() => {
|
2867
3061
|
var _a, _b, _c;
|
2868
3062
|
if (!ref.current) return;
|
2869
3063
|
const rect = ref.current.getBoundingClientRect();
|
@@ -2883,8 +3077,8 @@ var DraggableComponent = ({
|
|
2883
3077
|
};
|
2884
3078
|
return style2;
|
2885
3079
|
}, [ref.current]);
|
2886
|
-
const [style, setStyle] =
|
2887
|
-
const sync =
|
3080
|
+
const [style, setStyle] = useState13();
|
3081
|
+
const sync = useCallback7(() => {
|
2888
3082
|
setStyle(getStyle());
|
2889
3083
|
}, [ref.current, iframe]);
|
2890
3084
|
useEffect10(() => {
|
@@ -2897,19 +3091,21 @@ var DraggableComponent = ({
|
|
2897
3091
|
}
|
2898
3092
|
}, [ref.current]);
|
2899
3093
|
useEffect10(() => {
|
2900
|
-
|
2901
|
-
|
2902
|
-
|
2903
|
-
|
3094
|
+
if (isSelected) {
|
3095
|
+
ctx == null ? void 0 : ctx.registerPath({
|
3096
|
+
index,
|
3097
|
+
zone: zoneCompound
|
3098
|
+
});
|
3099
|
+
}
|
2904
3100
|
}, [isSelected]);
|
2905
|
-
const CustomActionBar =
|
3101
|
+
const CustomActionBar = useMemo7(
|
2906
3102
|
() => overrides.actionBar || DefaultActionBar,
|
2907
3103
|
[overrides.actionBar]
|
2908
3104
|
);
|
2909
3105
|
const permissions = getPermissions({
|
2910
3106
|
item: selectedItem
|
2911
3107
|
});
|
2912
|
-
const onClick =
|
3108
|
+
const onClick = useCallback7(
|
2913
3109
|
(e) => {
|
2914
3110
|
e.stopPropagation();
|
2915
3111
|
dispatch({
|
@@ -2921,7 +3117,7 @@ var DraggableComponent = ({
|
|
2921
3117
|
},
|
2922
3118
|
[index, zoneCompound, id]
|
2923
3119
|
);
|
2924
|
-
const onSelectParent =
|
3120
|
+
const onSelectParent = useCallback7(() => {
|
2925
3121
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
2926
3122
|
return;
|
2927
3123
|
}
|
@@ -2939,21 +3135,21 @@ var DraggableComponent = ({
|
|
2939
3135
|
}
|
2940
3136
|
});
|
2941
3137
|
}, [ctx, path]);
|
2942
|
-
const onDuplicate =
|
3138
|
+
const onDuplicate = useCallback7(() => {
|
2943
3139
|
dispatch({
|
2944
3140
|
type: "duplicate",
|
2945
3141
|
sourceIndex: index,
|
2946
3142
|
sourceZone: zoneCompound
|
2947
3143
|
});
|
2948
3144
|
}, [index, zoneCompound]);
|
2949
|
-
const onDelete =
|
3145
|
+
const onDelete = useCallback7(() => {
|
2950
3146
|
dispatch({
|
2951
3147
|
type: "remove",
|
2952
3148
|
index,
|
2953
3149
|
zone: zoneCompound
|
2954
3150
|
});
|
2955
3151
|
}, [index, zoneCompound]);
|
2956
|
-
const [hover, setHover] =
|
3152
|
+
const [hover, setHover] = useState13(false);
|
2957
3153
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
2958
3154
|
useEffect10(() => {
|
2959
3155
|
if (!ref.current) {
|
@@ -3014,7 +3210,7 @@ var DraggableComponent = ({
|
|
3014
3210
|
};
|
3015
3211
|
}
|
3016
3212
|
}, [disabled, ref]);
|
3017
|
-
const [isVisible, setIsVisible] =
|
3213
|
+
const [isVisible, setIsVisible] = useState13(false);
|
3018
3214
|
useEffect10(() => {
|
3019
3215
|
sync();
|
3020
3216
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
@@ -3023,7 +3219,7 @@ var DraggableComponent = ({
|
|
3023
3219
|
setIsVisible(false);
|
3024
3220
|
}
|
3025
3221
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3026
|
-
const syncActionsPosition =
|
3222
|
+
const syncActionsPosition = useCallback7(
|
3027
3223
|
(el) => {
|
3028
3224
|
if (el) {
|
3029
3225
|
const view = el.ownerDocument.defaultView;
|
@@ -3054,7 +3250,7 @@ var DraggableComponent = ({
|
|
3054
3250
|
}
|
3055
3251
|
setDragAxis(autoDragAxis);
|
3056
3252
|
}, [ref, userDragAxis, autoDragAxis]);
|
3057
|
-
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */
|
3253
|
+
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
3254
|
return /* @__PURE__ */ jsxs9(
|
3059
3255
|
DropZoneProvider,
|
3060
3256
|
{
|
@@ -3081,15 +3277,15 @@ var DraggableComponent = ({
|
|
3081
3277
|
"data-puck-overlay": true,
|
3082
3278
|
children: [
|
3083
3279
|
debug,
|
3084
|
-
isLoading && /* @__PURE__ */
|
3085
|
-
/* @__PURE__ */
|
3280
|
+
isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
|
3281
|
+
/* @__PURE__ */ jsx21(
|
3086
3282
|
"div",
|
3087
3283
|
{
|
3088
3284
|
className: getClassName16("actionsOverlay"),
|
3089
3285
|
style: {
|
3090
3286
|
top: actionsOverlayTop / zoomConfig.zoom
|
3091
3287
|
},
|
3092
|
-
children: /* @__PURE__ */
|
3288
|
+
children: /* @__PURE__ */ jsx21(
|
3093
3289
|
"div",
|
3094
3290
|
{
|
3095
3291
|
className: getClassName16("actions"),
|
@@ -3107,8 +3303,8 @@ var DraggableComponent = ({
|
|
3107
3303
|
parentAction,
|
3108
3304
|
label: DEBUG2 ? id : label,
|
3109
3305
|
children: [
|
3110
|
-
permissions.duplicate && /* @__PURE__ */
|
3111
|
-
permissions.delete && /* @__PURE__ */
|
3306
|
+
permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
|
3307
|
+
permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
|
3112
3308
|
]
|
3113
3309
|
}
|
3114
3310
|
)
|
@@ -3116,7 +3312,7 @@ var DraggableComponent = ({
|
|
3116
3312
|
)
|
3117
3313
|
}
|
3118
3314
|
),
|
3119
|
-
/* @__PURE__ */
|
3315
|
+
/* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
|
3120
3316
|
]
|
3121
3317
|
}
|
3122
3318
|
),
|
@@ -3132,98 +3328,26 @@ var DraggableComponent = ({
|
|
3132
3328
|
init_react_import();
|
3133
3329
|
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
3330
|
|
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
|
3331
|
+
// components/DropZone/lib/use-min-empty-height.ts
|
3213
3332
|
init_react_import();
|
3214
3333
|
import { useEffect as useEffect11, useState as useState14 } from "react";
|
3215
3334
|
var useMinEmptyHeight = ({
|
3216
|
-
draggedItem,
|
3217
3335
|
zoneCompound,
|
3218
3336
|
userMinEmptyHeight,
|
3219
3337
|
ref
|
3220
3338
|
}) => {
|
3221
3339
|
const [prevHeight, setPrevHeight] = useState14(0);
|
3222
3340
|
const [isAnimating, setIsAnimating] = useState14(false);
|
3341
|
+
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3342
|
+
var _a, _b;
|
3343
|
+
return {
|
3344
|
+
draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
|
3345
|
+
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3346
|
+
};
|
3347
|
+
});
|
3223
3348
|
useEffect11(() => {
|
3224
3349
|
if (draggedItem && ref.current) {
|
3225
|
-
|
3226
|
-
if (componentData.zone === zoneCompound) {
|
3350
|
+
if (isZone) {
|
3227
3351
|
const rect = ref.current.getBoundingClientRect();
|
3228
3352
|
setPrevHeight(rect.height);
|
3229
3353
|
setIsAnimating(true);
|
@@ -3253,13 +3377,128 @@ function assignRefs(refs, node) {
|
|
3253
3377
|
});
|
3254
3378
|
}
|
3255
3379
|
|
3256
|
-
// components/DropZone/
|
3257
|
-
|
3258
|
-
|
3259
|
-
|
3380
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3381
|
+
init_react_import();
|
3382
|
+
import { useEffect as useEffect12, useState as useState15 } from "react";
|
3383
|
+
|
3384
|
+
// lib/dnd/use-rendered-callback.ts
|
3385
|
+
init_react_import();
|
3386
|
+
import { useDragDropManager } from "@dnd-kit/react";
|
3387
|
+
import { useCallback as useCallback8 } from "react";
|
3388
|
+
function useRenderedCallback(callback, deps) {
|
3389
|
+
const manager = useDragDropManager();
|
3390
|
+
return useCallback8(
|
3391
|
+
(...args) => __async(this, null, function* () {
|
3392
|
+
yield manager == null ? void 0 : manager.renderer.rendering;
|
3393
|
+
return callback(...args);
|
3394
|
+
}),
|
3395
|
+
[...deps, manager]
|
3396
|
+
);
|
3397
|
+
}
|
3398
|
+
|
3399
|
+
// lib/insert.ts
|
3400
|
+
init_react_import();
|
3401
|
+
var insert = (list, index, item) => {
|
3402
|
+
const result = Array.from(list);
|
3403
|
+
result.splice(index, 0, item);
|
3404
|
+
return result;
|
3405
|
+
};
|
3406
|
+
|
3407
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3408
|
+
var useContentWithPreview = (content, zoneCompound) => {
|
3409
|
+
const { draggedItemId, preview, previewExists } = useContextStore(
|
3410
|
+
ZoneStoreContext,
|
3411
|
+
(s) => {
|
3412
|
+
var _a;
|
3413
|
+
return {
|
3414
|
+
draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
|
3415
|
+
preview: s.previewIndex[zoneCompound],
|
3416
|
+
previewExists: Object.keys(s.previewIndex || {}).length > 0
|
3417
|
+
};
|
3418
|
+
}
|
3419
|
+
);
|
3420
|
+
const [contentWithPreview, setContentWithPreview] = useState15(content);
|
3421
|
+
const updateContent = useRenderedCallback(
|
3422
|
+
(content2, preview2) => {
|
3423
|
+
if (preview2) {
|
3424
|
+
if (preview2.type === "insert") {
|
3425
|
+
setContentWithPreview(
|
3426
|
+
insert(
|
3427
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3428
|
+
preview2.index,
|
3429
|
+
{
|
3430
|
+
type: "preview",
|
3431
|
+
props: { id: preview2.props.id }
|
3432
|
+
}
|
3433
|
+
)
|
3434
|
+
);
|
3435
|
+
} else {
|
3436
|
+
setContentWithPreview(
|
3437
|
+
insert(
|
3438
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3439
|
+
preview2.index,
|
3440
|
+
{
|
3441
|
+
type: preview2.componentType,
|
3442
|
+
props: preview2.props
|
3443
|
+
}
|
3444
|
+
)
|
3445
|
+
);
|
3446
|
+
}
|
3447
|
+
} else {
|
3448
|
+
setContentWithPreview(
|
3449
|
+
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3450
|
+
);
|
3451
|
+
}
|
3452
|
+
},
|
3453
|
+
[draggedItemId, previewExists]
|
3454
|
+
);
|
3455
|
+
useEffect12(() => {
|
3456
|
+
updateContent(content, preview);
|
3457
|
+
}, [content, preview]);
|
3458
|
+
return contentWithPreview;
|
3459
|
+
};
|
3460
|
+
|
3461
|
+
// components/DropZone/lib/use-drag-axis.ts
|
3462
|
+
init_react_import();
|
3463
|
+
import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
|
3260
3464
|
var GRID_DRAG_AXIS = "dynamic";
|
3261
3465
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3262
3466
|
var DEFAULT_DRAG_AXIS = "y";
|
3467
|
+
var useDragAxis = (ref, collisionAxis) => {
|
3468
|
+
const { status } = useAppContext();
|
3469
|
+
const [dragAxis, setDragAxis] = useState16(
|
3470
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
3471
|
+
);
|
3472
|
+
const calculateDragAxis = useCallback9(() => {
|
3473
|
+
if (ref.current) {
|
3474
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
3475
|
+
if (computedStyle.display === "grid") {
|
3476
|
+
setDragAxis(GRID_DRAG_AXIS);
|
3477
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3478
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3479
|
+
} else {
|
3480
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
3481
|
+
}
|
3482
|
+
}
|
3483
|
+
}, [ref.current]);
|
3484
|
+
useEffect13(() => {
|
3485
|
+
const onViewportChange = () => {
|
3486
|
+
calculateDragAxis();
|
3487
|
+
};
|
3488
|
+
window.addEventListener("viewportchange", onViewportChange);
|
3489
|
+
return () => {
|
3490
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
3491
|
+
};
|
3492
|
+
}, []);
|
3493
|
+
useEffect13(calculateDragAxis, [status, collisionAxis]);
|
3494
|
+
return [dragAxis, calculateDragAxis];
|
3495
|
+
};
|
3496
|
+
|
3497
|
+
// components/DropZone/index.tsx
|
3498
|
+
import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
|
3499
|
+
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3500
|
+
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3501
|
+
var RENDER_DEBUG = false;
|
3263
3502
|
var DropZoneEdit = forwardRef3(
|
3264
3503
|
function DropZoneEdit2({
|
3265
3504
|
zone,
|
@@ -3271,31 +3510,50 @@ var DropZoneEdit = forwardRef3(
|
|
3271
3510
|
collisionAxis
|
3272
3511
|
}, userRef) {
|
3273
3512
|
const appContext2 = useAppContext();
|
3274
|
-
const ctx =
|
3513
|
+
const ctx = useContext6(dropZoneContext);
|
3275
3514
|
const {
|
3276
3515
|
// These all need setting via context
|
3277
3516
|
data,
|
3278
3517
|
config,
|
3279
3518
|
areaId,
|
3280
|
-
draggedItem,
|
3281
3519
|
registerZoneArea,
|
3282
3520
|
depth,
|
3283
3521
|
registerLocalZone,
|
3284
3522
|
unregisterLocalZone,
|
3285
|
-
deepestZone = rootDroppableId,
|
3286
|
-
deepestArea,
|
3287
|
-
nextDeepestArea,
|
3288
3523
|
path = [],
|
3289
3524
|
activeZones
|
3290
3525
|
} = ctx;
|
3291
|
-
const { itemSelector } = appContext2.state.ui;
|
3292
3526
|
let zoneCompound = rootDroppableId;
|
3293
|
-
|
3527
|
+
if (areaId) {
|
3528
|
+
if (zone !== rootDroppableId) {
|
3529
|
+
zoneCompound = `${areaId}:${zone}`;
|
3530
|
+
}
|
3531
|
+
}
|
3532
|
+
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
3533
|
+
const {
|
3534
|
+
isDeepestZone,
|
3535
|
+
inNextDeepestArea,
|
3536
|
+
draggedComponentType,
|
3537
|
+
userIsDragging,
|
3538
|
+
preview
|
3539
|
+
} = useContextStore(ZoneStoreContext, (s) => {
|
3540
|
+
var _a, _b, _c;
|
3541
|
+
return {
|
3542
|
+
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
3543
|
+
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3544
|
+
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3545
|
+
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3546
|
+
userIsDragging: !!s.draggedItem,
|
3547
|
+
preview: s.previewIndex[zoneCompound]
|
3548
|
+
};
|
3549
|
+
});
|
3550
|
+
const { itemSelector } = appContext2.state.ui;
|
3551
|
+
useEffect14(() => {
|
3294
3552
|
if (areaId && registerZoneArea) {
|
3295
3553
|
registerZoneArea(areaId);
|
3296
3554
|
}
|
3297
3555
|
}, [areaId]);
|
3298
|
-
|
3556
|
+
useEffect14(() => {
|
3299
3557
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3300
3558
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3301
3559
|
}
|
@@ -3305,25 +3563,18 @@ var DropZoneEdit = forwardRef3(
|
|
3305
3563
|
}
|
3306
3564
|
};
|
3307
3565
|
}, []);
|
3308
|
-
|
3309
|
-
if (zone !== rootDroppableId) {
|
3310
|
-
zoneCompound = `${areaId}:${zone}`;
|
3311
|
-
}
|
3312
|
-
}
|
3313
|
-
const content = useMemo7(() => {
|
3566
|
+
const content = useMemo8(() => {
|
3314
3567
|
if (areaId && zone !== rootDroppableId) {
|
3315
3568
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3316
3569
|
}
|
3317
3570
|
return data.content || [];
|
3318
3571
|
}, [data, zoneCompound]);
|
3319
|
-
const ref =
|
3320
|
-
const acceptsTarget =
|
3321
|
-
(
|
3322
|
-
if (!
|
3572
|
+
const ref = useRef3(null);
|
3573
|
+
const acceptsTarget = useCallback10(
|
3574
|
+
(componentType) => {
|
3575
|
+
if (!componentType) {
|
3323
3576
|
return true;
|
3324
3577
|
}
|
3325
|
-
const data2 = target.data;
|
3326
|
-
const { componentType } = data2;
|
3327
3578
|
if (disallow) {
|
3328
3579
|
const defaultedAllow = allow || [];
|
3329
3580
|
const filteredDisallow = (disallow || []).filter(
|
@@ -3341,49 +3592,26 @@ var DropZoneEdit = forwardRef3(
|
|
3341
3592
|
},
|
3342
3593
|
[allow, disallow]
|
3343
3594
|
);
|
3344
|
-
|
3595
|
+
useEffect14(() => {
|
3345
3596
|
if (registerLocalZone) {
|
3346
|
-
registerLocalZone(zoneCompound, acceptsTarget(
|
3597
|
+
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3347
3598
|
}
|
3348
3599
|
return () => {
|
3349
3600
|
if (unregisterLocalZone) {
|
3350
3601
|
unregisterLocalZone(zoneCompound);
|
3351
3602
|
}
|
3352
3603
|
};
|
3353
|
-
}, [
|
3354
|
-
const
|
3355
|
-
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3356
|
-
const userIsDragging = !!draggedItem;
|
3604
|
+
}, [draggedComponentType, zoneCompound]);
|
3605
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
3357
3606
|
let isEnabled = true;
|
3358
|
-
if (
|
3359
|
-
isEnabled =
|
3607
|
+
if (userIsDragging) {
|
3608
|
+
isEnabled = isDeepestZone;
|
3360
3609
|
}
|
3361
3610
|
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);
|
3611
|
+
isEnabled = acceptsTarget(draggedComponentType);
|
3612
|
+
}
|
3613
|
+
const contentWithPreview = useContentWithPreview(content, zoneCompound);
|
3614
|
+
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3387
3615
|
const droppableConfig = {
|
3388
3616
|
id: zoneCompound,
|
3389
3617
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -3393,45 +3621,20 @@ var DropZoneEdit = forwardRef3(
|
|
3393
3621
|
data: {
|
3394
3622
|
areaId,
|
3395
3623
|
depth,
|
3396
|
-
isDroppableTarget: acceptsTarget(
|
3624
|
+
isDroppableTarget: acceptsTarget(draggedComponentType),
|
3397
3625
|
path
|
3398
3626
|
}
|
3399
3627
|
};
|
3400
3628
|
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
3401
3629
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3402
3630
|
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
|
-
}, []);
|
3631
|
+
const [dragAxis] = useDragAxis(ref, collisionAxis);
|
3428
3632
|
const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
|
3429
|
-
draggedItem,
|
3430
3633
|
zoneCompound,
|
3431
3634
|
userMinEmptyHeight,
|
3432
3635
|
ref
|
3433
3636
|
});
|
3434
|
-
return /* @__PURE__ */
|
3637
|
+
return /* @__PURE__ */ jsx22(
|
3435
3638
|
"div",
|
3436
3639
|
{
|
3437
3640
|
className: `${getClassName17({
|
@@ -3451,88 +3654,83 @@ var DropZoneEdit = forwardRef3(
|
|
3451
3654
|
"data-puck-dropzone": zoneCompound,
|
3452
3655
|
"data-puck-dnd": zoneCompound,
|
3453
3656
|
style: __spreadProps(__spreadValues({}, style), {
|
3454
|
-
"--min-empty-height": `${minEmptyHeight}px
|
3657
|
+
"--min-empty-height": `${minEmptyHeight}px`,
|
3658
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3455
3659
|
}),
|
3456
|
-
children:
|
3457
|
-
|
3458
|
-
|
3459
|
-
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3463
|
-
|
3464
|
-
|
3465
|
-
|
3466
|
-
|
3467
|
-
|
3660
|
+
children: contentWithPreview.map((item, i) => {
|
3661
|
+
var _a, _b, _c, _d, _e;
|
3662
|
+
const componentId = item.props.id;
|
3663
|
+
const puckProps = {
|
3664
|
+
renderDropZone: DropZone,
|
3665
|
+
isEditing: true,
|
3666
|
+
dragRef: null
|
3667
|
+
};
|
3668
|
+
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
|
3669
|
+
puck: puckProps,
|
3670
|
+
editMode: true
|
3671
|
+
// DEPRECATED
|
3672
|
+
});
|
3673
|
+
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3674
|
+
let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
|
3675
|
+
"No configuration for ",
|
3676
|
+
item.type
|
3677
|
+
] });
|
3678
|
+
const componentConfig = config.components[item.type];
|
3679
|
+
let componentType = item.type;
|
3680
|
+
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3681
|
+
if (item.type === "preview" && preview) {
|
3682
|
+
let Preview4 = function() {
|
3683
|
+
return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3468
3684
|
};
|
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
|
-
})
|
3685
|
+
var Preview3 = Preview4;
|
3686
|
+
componentType = preview.componentType;
|
3687
|
+
label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
|
3688
|
+
Render2 = Preview4;
|
3689
|
+
}
|
3690
|
+
return /* @__PURE__ */ jsx22(
|
3691
|
+
DropZoneProvider,
|
3692
|
+
{
|
3693
|
+
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3694
|
+
children: /* @__PURE__ */ jsx22(
|
3695
|
+
DraggableComponent,
|
3696
|
+
{
|
3697
|
+
id: componentId,
|
3698
|
+
componentType,
|
3699
|
+
zoneCompound,
|
3700
|
+
depth: depth + 1,
|
3701
|
+
index: i,
|
3702
|
+
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3703
|
+
isSelected,
|
3704
|
+
label,
|
3705
|
+
isEnabled,
|
3706
|
+
autoDragAxis: dragAxis,
|
3707
|
+
userDragAxis: collisionAxis,
|
3708
|
+
inDroppableZone: acceptsTarget(draggedComponentType),
|
3709
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx22(
|
3710
|
+
Render2,
|
3711
|
+
__spreadProps(__spreadValues({}, defaultedProps), {
|
3712
|
+
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3713
|
+
dragRef
|
3516
3714
|
})
|
3517
|
-
|
3518
|
-
}
|
3519
|
-
|
3520
|
-
|
3521
|
-
|
3522
|
-
|
3523
|
-
|
3524
|
-
|
3715
|
+
})
|
3716
|
+
) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
|
3717
|
+
}
|
3718
|
+
)
|
3719
|
+
},
|
3720
|
+
componentId
|
3721
|
+
);
|
3722
|
+
})
|
3525
3723
|
}
|
3526
3724
|
);
|
3527
3725
|
}
|
3528
3726
|
);
|
3529
3727
|
var DropZoneRender = forwardRef3(
|
3530
3728
|
function DropZoneRender2({ className, style, zone }, ref) {
|
3531
|
-
const ctx =
|
3729
|
+
const ctx = useContext6(dropZoneContext);
|
3532
3730
|
const { data, areaId = "root", config } = ctx || {};
|
3533
3731
|
let zoneCompound = rootDroppableId;
|
3534
3732
|
let content = (data == null ? void 0 : data.content) || [];
|
3535
|
-
|
3733
|
+
useEffect14(() => {
|
3536
3734
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3537
3735
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3538
3736
|
}
|
@@ -3549,10 +3747,10 @@ var DropZoneRender = forwardRef3(
|
|
3549
3747
|
zoneCompound = `${areaId}:${zone}`;
|
3550
3748
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3551
3749
|
}
|
3552
|
-
return /* @__PURE__ */
|
3750
|
+
return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
|
3553
3751
|
const Component = config.components[item.type];
|
3554
3752
|
if (Component) {
|
3555
|
-
return /* @__PURE__ */
|
3753
|
+
return /* @__PURE__ */ jsx22(
|
3556
3754
|
DropZoneProvider,
|
3557
3755
|
{
|
3558
3756
|
value: {
|
@@ -3562,7 +3760,7 @@ var DropZoneRender = forwardRef3(
|
|
3562
3760
|
depth: 1,
|
3563
3761
|
path: []
|
3564
3762
|
},
|
3565
|
-
children: /* @__PURE__ */
|
3763
|
+
children: /* @__PURE__ */ jsx22(
|
3566
3764
|
Component.render,
|
3567
3765
|
__spreadProps(__spreadValues({}, item.props), {
|
3568
3766
|
puck: { renderDropZone: DropZoneRender2 }
|
@@ -3578,11 +3776,11 @@ var DropZoneRender = forwardRef3(
|
|
3578
3776
|
);
|
3579
3777
|
var DropZone = forwardRef3(
|
3580
3778
|
function DropZone2(props, ref) {
|
3581
|
-
const ctx =
|
3779
|
+
const ctx = useContext6(dropZoneContext);
|
3582
3780
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3583
|
-
return /* @__PURE__ */
|
3781
|
+
return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3584
3782
|
}
|
3585
|
-
return /* @__PURE__ */
|
3783
|
+
return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3586
3784
|
}
|
3587
3785
|
);
|
3588
3786
|
|
@@ -3598,7 +3796,7 @@ var getZoneId = (zoneCompound) => {
|
|
3598
3796
|
return [rootDroppableId, zoneCompound];
|
3599
3797
|
};
|
3600
3798
|
|
3601
|
-
//
|
3799
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3602
3800
|
init_react_import();
|
3603
3801
|
import { Plugin } from "@dnd-kit/abstract";
|
3604
3802
|
import { effects } from "@dnd-kit/state";
|
@@ -3640,7 +3838,7 @@ var getFrame = () => {
|
|
3640
3838
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3641
3839
|
};
|
3642
3840
|
|
3643
|
-
//
|
3841
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3644
3842
|
var depthSort = (candidates) => {
|
3645
3843
|
return candidates.sort((a, b) => {
|
3646
3844
|
const aData = a.data;
|
@@ -3755,9 +3953,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
|
|
3755
3953
|
area: null
|
3756
3954
|
};
|
3757
3955
|
};
|
3758
|
-
var createNestedDroppablePlugin = ({
|
3759
|
-
onChange
|
3760
|
-
}) => class NestedDroppablePlugin extends Plugin {
|
3956
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
|
3761
3957
|
constructor(manager, options) {
|
3762
3958
|
super(manager);
|
3763
3959
|
if (typeof window === "undefined") {
|
@@ -3771,10 +3967,17 @@ var createNestedDroppablePlugin = ({
|
|
3771
3967
|
};
|
3772
3968
|
const target = event.originalTarget || event.target;
|
3773
3969
|
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
3774
|
-
|
3775
|
-
|
3776
|
-
|
3970
|
+
const elements = document.elementsFromPoint(
|
3971
|
+
event.clientX,
|
3972
|
+
event.clientY
|
3777
3973
|
);
|
3974
|
+
const overEl = elements.some((el) => el.id === id);
|
3975
|
+
if (overEl) {
|
3976
|
+
onChange(
|
3977
|
+
findDeepestCandidate(position, manager, ownerDocument),
|
3978
|
+
manager
|
3979
|
+
);
|
3980
|
+
}
|
3778
3981
|
};
|
3779
3982
|
const handleMoveThrottled = throttle(handleMove, 50);
|
3780
3983
|
const handlePointerMove = (event) => {
|
@@ -4191,7 +4394,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4191
4394
|
import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
|
4192
4395
|
import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
|
4193
4396
|
|
4194
|
-
//
|
4397
|
+
// lib/dnd/PointerSensor.ts
|
4195
4398
|
init_react_import();
|
4196
4399
|
import { batch, effect } from "@dnd-kit/state";
|
4197
4400
|
import { Sensor, configurator } from "@dnd-kit/abstract";
|
@@ -4462,13 +4665,15 @@ function patchWindow(window2) {
|
|
4462
4665
|
}
|
4463
4666
|
|
4464
4667
|
// components/DragDropContext/index.tsx
|
4465
|
-
import {
|
4466
|
-
|
4668
|
+
import { createStore as createStore3 } from "zustand";
|
4669
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
4670
|
+
var DEBUG3 = false;
|
4671
|
+
var dragListenerContext = createContext4({
|
4467
4672
|
dragListeners: {}
|
4468
4673
|
});
|
4469
4674
|
function useDragListener(type, fn, deps = []) {
|
4470
|
-
const { setDragListeners } =
|
4471
|
-
|
4675
|
+
const { setDragListeners } = useContext7(dragListenerContext);
|
4676
|
+
useEffect15(() => {
|
4472
4677
|
if (setDragListeners) {
|
4473
4678
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4474
4679
|
[type]: [...old[type] || [], fn]
|
@@ -4476,80 +4681,147 @@ function useDragListener(type, fn, deps = []) {
|
|
4476
4681
|
}
|
4477
4682
|
}, deps);
|
4478
4683
|
}
|
4479
|
-
var previewContext = createContext3(null);
|
4480
4684
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4685
|
+
var useTempDisableFallback = (timeout3) => {
|
4686
|
+
const lastFallbackDisable = useRef4(null);
|
4687
|
+
return useCallback11((manager) => {
|
4688
|
+
collisionStore.setState({ fallbackEnabled: false });
|
4689
|
+
const fallbackId = generateId();
|
4690
|
+
lastFallbackDisable.current = fallbackId;
|
4691
|
+
setTimeout(() => {
|
4692
|
+
if (lastFallbackDisable.current === fallbackId) {
|
4693
|
+
collisionStore.setState({ fallbackEnabled: true });
|
4694
|
+
manager.collisionObserver.forceUpdate(true);
|
4695
|
+
}
|
4696
|
+
}, timeout3);
|
4697
|
+
}, []);
|
4698
|
+
};
|
4481
4699
|
var DragDropContextClient = ({
|
4482
4700
|
children,
|
4483
4701
|
disableAutoScroll
|
4484
4702
|
}) => {
|
4485
4703
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4486
|
-
const
|
4487
|
-
const previewRef = useRef5(null);
|
4704
|
+
const id = useId();
|
4488
4705
|
const { data } = state;
|
4489
|
-
const
|
4490
|
-
const
|
4491
|
-
const
|
4492
|
-
|
4493
|
-
|
4706
|
+
const debouncedParamsRef = useRef4(null);
|
4707
|
+
const tempDisableFallback = useTempDisableFallback(100);
|
4708
|
+
const [zoneStore] = useState17(
|
4709
|
+
() => createStore3(() => ({
|
4710
|
+
zoneDepthIndex: {},
|
4711
|
+
nextZoneDepthIndex: {},
|
4712
|
+
areaDepthIndex: {},
|
4713
|
+
nextAreaDepthIndex: {},
|
4714
|
+
draggedItem: null,
|
4715
|
+
previewIndex: {}
|
4716
|
+
}))
|
4717
|
+
);
|
4718
|
+
const getChanged2 = useCallback11(
|
4719
|
+
(params, id2) => {
|
4720
|
+
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4721
|
+
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
4722
|
+
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
4723
|
+
let zoneChanged = false;
|
4724
|
+
let areaChanged = false;
|
4725
|
+
if (params.zone && !zoneDepthIndex[params.zone]) {
|
4726
|
+
zoneChanged = true;
|
4727
|
+
} else if (!params.zone && stateHasZone) {
|
4728
|
+
zoneChanged = true;
|
4729
|
+
}
|
4730
|
+
if (params.area && !areaDepthIndex[params.area]) {
|
4731
|
+
areaChanged = true;
|
4732
|
+
} else if (!params.area && stateHasArea) {
|
4733
|
+
areaChanged = true;
|
4734
|
+
}
|
4735
|
+
return { zoneChanged, areaChanged };
|
4736
|
+
},
|
4737
|
+
[zoneStore]
|
4738
|
+
);
|
4739
|
+
const setDeepestAndCollide = useCallback11(
|
4494
4740
|
(params, manager) => {
|
4495
|
-
|
4741
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4742
|
+
if (!zoneChanged && !areaChanged) return;
|
4743
|
+
zoneStore.setState({
|
4744
|
+
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
4745
|
+
areaDepthIndex: params.area ? { [params.area]: true } : {}
|
4746
|
+
});
|
4747
|
+
tempDisableFallback(manager);
|
4496
4748
|
setTimeout(() => {
|
4497
4749
|
manager.collisionObserver.forceUpdate(true);
|
4498
4750
|
}, 50);
|
4499
4751
|
debouncedParamsRef.current = null;
|
4500
4752
|
},
|
4501
|
-
[]
|
4753
|
+
[zoneStore]
|
4502
4754
|
);
|
4503
4755
|
const setDeepestDb = useDebouncedCallback2(
|
4504
4756
|
setDeepestAndCollide,
|
4505
4757
|
AREA_CHANGE_DEBOUNCE_MS
|
4506
4758
|
);
|
4507
|
-
useEffect13(() => {
|
4508
|
-
deepestRef.current = deepest;
|
4509
|
-
}, [deepest]);
|
4510
4759
|
const cancelDb = () => {
|
4511
4760
|
setDeepestDb.cancel();
|
4512
4761
|
debouncedParamsRef.current = null;
|
4513
4762
|
};
|
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;
|
4763
|
+
useEffect15(() => {
|
4764
|
+
if (DEBUG3) {
|
4765
|
+
zoneStore.subscribe(
|
4766
|
+
(s) => {
|
4767
|
+
var _a, _b;
|
4768
|
+
return console.log(
|
4769
|
+
s.previewIndex,
|
4770
|
+
(_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
|
4771
|
+
(_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
|
4772
|
+
);
|
4529
4773
|
}
|
4530
|
-
|
4531
|
-
|
4532
|
-
|
4533
|
-
|
4534
|
-
|
4774
|
+
);
|
4775
|
+
}
|
4776
|
+
}, []);
|
4777
|
+
const [plugins] = useState17(() => [
|
4778
|
+
...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
|
4779
|
+
createNestedDroppablePlugin(
|
4780
|
+
{
|
4781
|
+
onChange: (params, manager) => {
|
4782
|
+
const state2 = zoneStore.getState();
|
4783
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4784
|
+
const isDragging = manager.dragOperation.status.dragging;
|
4785
|
+
if (areaChanged || zoneChanged) {
|
4786
|
+
let nextZoneDepthIndex = {};
|
4787
|
+
let nextAreaDepthIndex = {};
|
4788
|
+
if (params.zone) {
|
4789
|
+
nextZoneDepthIndex = { [params.zone]: true };
|
4790
|
+
}
|
4791
|
+
if (params.area) {
|
4792
|
+
nextAreaDepthIndex = { [params.area]: true };
|
4793
|
+
}
|
4794
|
+
zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
|
4795
|
+
}
|
4796
|
+
if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
|
4797
|
+
setDeepestAndCollide(params, manager);
|
4798
|
+
return;
|
4799
|
+
}
|
4800
|
+
if (areaChanged) {
|
4801
|
+
if (isDragging) {
|
4802
|
+
const debouncedParams = debouncedParamsRef.current;
|
4803
|
+
const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
|
4804
|
+
if (!isSameParams) {
|
4805
|
+
cancelDb();
|
4806
|
+
setDeepestDb(params, manager);
|
4807
|
+
debouncedParamsRef.current = params;
|
4808
|
+
}
|
4809
|
+
} else {
|
4535
4810
|
cancelDb();
|
4536
|
-
|
4537
|
-
debouncedParamsRef.current = params;
|
4811
|
+
setDeepestAndCollide(params, manager);
|
4538
4812
|
}
|
4539
|
-
|
4540
|
-
|
4813
|
+
return;
|
4814
|
+
}
|
4815
|
+
if (zoneChanged) {
|
4541
4816
|
setDeepestAndCollide(params, manager);
|
4542
4817
|
}
|
4543
|
-
|
4544
|
-
}
|
4545
|
-
if (zoneChanged) {
|
4546
|
-
setDeepestAndCollide(params, manager);
|
4818
|
+
cancelDb();
|
4547
4819
|
}
|
4548
|
-
|
4549
|
-
|
4550
|
-
|
4820
|
+
},
|
4821
|
+
id
|
4822
|
+
)
|
4551
4823
|
]);
|
4552
|
-
const [sensors] =
|
4824
|
+
const [sensors] = useState17(() => [
|
4553
4825
|
PointerSensor.configure({
|
4554
4826
|
activationConstraints(event, source) {
|
4555
4827
|
var _a;
|
@@ -4568,11 +4840,10 @@ var DragDropContextClient = ({
|
|
4568
4840
|
}
|
4569
4841
|
})
|
4570
4842
|
]);
|
4571
|
-
const [
|
4572
|
-
const [
|
4573
|
-
const
|
4574
|
-
const
|
4575
|
-
const registerPath = useCallback9(
|
4843
|
+
const [dragListeners, setDragListeners] = useState17({});
|
4844
|
+
const [pathData, setPathData] = useState17();
|
4845
|
+
const dragMode = useRef4(null);
|
4846
|
+
const registerPath = useCallback11(
|
4576
4847
|
(selector) => {
|
4577
4848
|
const item = getItem(selector, data);
|
4578
4849
|
if (!item) {
|
@@ -4594,41 +4865,41 @@ var DragDropContextClient = ({
|
|
4594
4865
|
},
|
4595
4866
|
[data, setPathData]
|
4596
4867
|
);
|
4597
|
-
const initialSelector =
|
4598
|
-
return /* @__PURE__ */
|
4868
|
+
const initialSelector = useRef4(void 0);
|
4869
|
+
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
4599
4870
|
dragListenerContext.Provider,
|
4600
4871
|
{
|
4601
4872
|
value: {
|
4602
4873
|
dragListeners,
|
4603
4874
|
setDragListeners
|
4604
4875
|
},
|
4605
|
-
children: /* @__PURE__ */
|
4876
|
+
children: /* @__PURE__ */ jsx23(
|
4606
4877
|
DragDropProvider2,
|
4607
4878
|
{
|
4608
4879
|
plugins,
|
4609
4880
|
sensors,
|
4610
4881
|
onDragEnd: (event, manager) => {
|
4882
|
+
var _a;
|
4611
4883
|
const { source, target } = event.operation;
|
4612
|
-
deepestRef.current = null;
|
4613
4884
|
if (!source) {
|
4614
|
-
|
4885
|
+
zoneStore.setState({ draggedItem: null });
|
4615
4886
|
return;
|
4616
4887
|
}
|
4617
4888
|
const { zone, index } = source.data;
|
4618
|
-
const
|
4619
|
-
|
4889
|
+
const { previewIndex = {} } = zoneStore.getState() || {};
|
4890
|
+
const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
|
4620
4891
|
setTimeout(() => {
|
4621
|
-
var
|
4622
|
-
|
4892
|
+
var _a2, _b;
|
4893
|
+
zoneStore.setState({ draggedItem: null });
|
4623
4894
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4624
|
-
|
4625
|
-
(
|
4895
|
+
zoneStore.setState({ previewIndex: {} });
|
4896
|
+
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
4626
4897
|
fn(event, manager);
|
4627
4898
|
});
|
4628
4899
|
return;
|
4629
4900
|
}
|
4630
4901
|
if (thisPreview) {
|
4631
|
-
|
4902
|
+
zoneStore.setState({ previewIndex: {} });
|
4632
4903
|
if (thisPreview.type === "insert") {
|
4633
4904
|
insertComponent(
|
4634
4905
|
thisPreview.componentType,
|
@@ -4663,8 +4934,9 @@ var DragDropContextClient = ({
|
|
4663
4934
|
}, 250);
|
4664
4935
|
},
|
4665
4936
|
onDragOver: (event, manager) => {
|
4666
|
-
var _a, _b, _c, _d;
|
4937
|
+
var _a, _b, _c, _d, _e;
|
4667
4938
|
event.preventDefault();
|
4939
|
+
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
4668
4940
|
if (!draggedItem) return;
|
4669
4941
|
cancelDb();
|
4670
4942
|
const { source, target } = event.operation;
|
@@ -4680,7 +4952,7 @@ var DragDropContextClient = ({
|
|
4680
4952
|
const targetData = target.data;
|
4681
4953
|
targetZone = targetData.zone;
|
4682
4954
|
targetIndex = targetData.index;
|
4683
|
-
const collisionData = (
|
4955
|
+
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
4684
4956
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4685
4957
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4686
4958
|
targetIndex = targetIndex - 1;
|
@@ -4692,23 +4964,26 @@ var DragDropContextClient = ({
|
|
4692
4964
|
targetZone = target.id.toString();
|
4693
4965
|
targetIndex = 0;
|
4694
4966
|
}
|
4695
|
-
if (targetId === sourceId || ((
|
4967
|
+
if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
|
4696
4968
|
const [pathId] = path.split(":");
|
4697
4969
|
return pathId === sourceId;
|
4698
4970
|
}))) {
|
4699
4971
|
return;
|
4700
4972
|
}
|
4701
4973
|
if (dragMode.current === "new") {
|
4702
|
-
|
4703
|
-
|
4704
|
-
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
4974
|
+
zoneStore.setState({
|
4975
|
+
previewIndex: {
|
4976
|
+
[targetZone]: {
|
4977
|
+
componentType: sourceData.componentType,
|
4978
|
+
type: "insert",
|
4979
|
+
index: targetIndex,
|
4980
|
+
zone: targetZone,
|
4981
|
+
props: {
|
4982
|
+
id: source.id.toString()
|
4983
|
+
}
|
4984
|
+
}
|
4709
4985
|
}
|
4710
|
-
};
|
4711
|
-
setPreview(previewRef.current);
|
4986
|
+
});
|
4712
4987
|
} else {
|
4713
4988
|
if (!initialSelector.current) {
|
4714
4989
|
initialSelector.current = {
|
@@ -4718,17 +4993,20 @@ var DragDropContextClient = ({
|
|
4718
4993
|
}
|
4719
4994
|
const item = getItem(initialSelector.current, data);
|
4720
4995
|
if (item) {
|
4721
|
-
|
4722
|
-
|
4723
|
-
|
4724
|
-
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
4996
|
+
zoneStore.setState({
|
4997
|
+
previewIndex: {
|
4998
|
+
[targetZone]: {
|
4999
|
+
componentType: sourceData.componentType,
|
5000
|
+
type: "move",
|
5001
|
+
index: targetIndex,
|
5002
|
+
zone: targetZone,
|
5003
|
+
props: item.props
|
5004
|
+
}
|
5005
|
+
}
|
5006
|
+
});
|
4729
5007
|
}
|
4730
5008
|
}
|
4731
|
-
(
|
5009
|
+
(_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
|
4732
5010
|
fn(event, manager);
|
4733
5011
|
});
|
4734
5012
|
},
|
@@ -4738,45 +5016,61 @@ var DragDropContextClient = ({
|
|
4738
5016
|
type: "setUi",
|
4739
5017
|
ui: { itemSelector: null, isDragging: true }
|
4740
5018
|
});
|
5019
|
+
const { source } = event.operation;
|
5020
|
+
if (source && source.type !== "void") {
|
5021
|
+
const sourceData = source.data;
|
5022
|
+
const item = getItem(
|
5023
|
+
{
|
5024
|
+
zone: sourceData.zone,
|
5025
|
+
index: sourceData.index
|
5026
|
+
},
|
5027
|
+
data
|
5028
|
+
);
|
5029
|
+
if (item) {
|
5030
|
+
zoneStore.setState({
|
5031
|
+
previewIndex: {
|
5032
|
+
[sourceData.zone]: {
|
5033
|
+
componentType: sourceData.componentType,
|
5034
|
+
type: "move",
|
5035
|
+
index: sourceData.index,
|
5036
|
+
zone: sourceData.zone,
|
5037
|
+
props: item.props
|
5038
|
+
}
|
5039
|
+
}
|
5040
|
+
});
|
5041
|
+
}
|
5042
|
+
}
|
4741
5043
|
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4742
5044
|
fn(event, manager);
|
4743
5045
|
});
|
4744
5046
|
},
|
4745
5047
|
onBeforeDragStart: (event) => {
|
4746
5048
|
var _a;
|
4747
|
-
if (draggedItem) {
|
4748
|
-
console.warn("New drag started before previous drag cleaned up");
|
4749
|
-
}
|
4750
5049
|
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4751
5050
|
dragMode.current = isNewComponent ? "new" : "existing";
|
4752
5051
|
initialSelector.current = void 0;
|
4753
|
-
|
5052
|
+
zoneStore.setState({ draggedItem: event.operation.source });
|
4754
5053
|
},
|
4755
|
-
children: /* @__PURE__ */
|
5054
|
+
children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
|
4756
5055
|
DropZoneProvider,
|
4757
5056
|
{
|
4758
5057
|
value: {
|
4759
5058
|
data,
|
4760
5059
|
config,
|
4761
|
-
draggedItem,
|
4762
5060
|
mode: "edit",
|
4763
5061
|
areaId: "root",
|
4764
5062
|
depth: 0,
|
4765
5063
|
registerPath,
|
4766
5064
|
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
5065
|
path: []
|
4772
5066
|
},
|
4773
5067
|
children
|
4774
5068
|
}
|
4775
|
-
)
|
5069
|
+
) })
|
4776
5070
|
}
|
4777
|
-
)
|
5071
|
+
)
|
4778
5072
|
}
|
4779
|
-
);
|
5073
|
+
) });
|
4780
5074
|
};
|
4781
5075
|
var DragDropContext = ({
|
4782
5076
|
children,
|
@@ -4786,11 +5080,11 @@ var DragDropContext = ({
|
|
4786
5080
|
if (status === "LOADING") {
|
4787
5081
|
return children;
|
4788
5082
|
}
|
4789
|
-
return /* @__PURE__ */
|
5083
|
+
return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
|
4790
5084
|
};
|
4791
5085
|
|
4792
5086
|
// components/Drawer/index.tsx
|
4793
|
-
import { jsx as
|
5087
|
+
import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
|
4794
5088
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
4795
5089
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
4796
5090
|
var DrawerItemInner = ({
|
@@ -4800,11 +5094,11 @@ var DrawerItemInner = ({
|
|
4800
5094
|
dragRef,
|
4801
5095
|
isDragDisabled
|
4802
5096
|
}) => {
|
4803
|
-
const CustomInner =
|
4804
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */
|
5097
|
+
const CustomInner = useMemo9(
|
5098
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
|
4805
5099
|
[children]
|
4806
5100
|
);
|
4807
|
-
return /* @__PURE__ */
|
5101
|
+
return /* @__PURE__ */ jsx24(
|
4808
5102
|
"div",
|
4809
5103
|
{
|
4810
5104
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -4812,9 +5106,9 @@ var DrawerItemInner = ({
|
|
4812
5106
|
onMouseDown: (e) => e.preventDefault(),
|
4813
5107
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
4814
5108
|
"data-puck-drawer-item": true,
|
4815
|
-
children: /* @__PURE__ */
|
4816
|
-
/* @__PURE__ */
|
4817
|
-
/* @__PURE__ */
|
5109
|
+
children: /* @__PURE__ */ jsx24(CustomInner, { name, children: /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
|
5110
|
+
/* @__PURE__ */ jsx24("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
5111
|
+
/* @__PURE__ */ jsx24("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx24(DragIcon, {}) })
|
4818
5112
|
] }) }) })
|
4819
5113
|
}
|
4820
5114
|
);
|
@@ -4832,8 +5126,8 @@ var DrawerItemDraggable = ({
|
|
4832
5126
|
disabled: isDragDisabled
|
4833
5127
|
});
|
4834
5128
|
return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
|
4835
|
-
/* @__PURE__ */
|
4836
|
-
/* @__PURE__ */
|
5129
|
+
/* @__PURE__ */ jsx24("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx24(DrawerItemInner, { name, label, children }) }),
|
5130
|
+
/* @__PURE__ */ jsx24("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx24(
|
4837
5131
|
DrawerItemInner,
|
4838
5132
|
{
|
4839
5133
|
name,
|
@@ -4854,7 +5148,7 @@ var DrawerItem = ({
|
|
4854
5148
|
isDragDisabled
|
4855
5149
|
}) => {
|
4856
5150
|
const resolvedId = id || name;
|
4857
|
-
const [dynamicId, setDynamicId] =
|
5151
|
+
const [dynamicId, setDynamicId] = useState18(generateId(resolvedId));
|
4858
5152
|
if (typeof index !== "undefined") {
|
4859
5153
|
console.error(
|
4860
5154
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -4867,7 +5161,7 @@ var DrawerItem = ({
|
|
4867
5161
|
},
|
4868
5162
|
[resolvedId]
|
4869
5163
|
);
|
4870
|
-
return /* @__PURE__ */
|
5164
|
+
return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
|
4871
5165
|
DrawerItemDraggable,
|
4872
5166
|
{
|
4873
5167
|
name,
|
@@ -4893,14 +5187,14 @@ var Drawer = ({
|
|
4893
5187
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
4894
5188
|
);
|
4895
5189
|
}
|
4896
|
-
const [id] =
|
5190
|
+
const [id] = useState18(generateId());
|
4897
5191
|
const { ref } = useDroppableSafe({
|
4898
5192
|
id,
|
4899
5193
|
type: "void",
|
4900
5194
|
collisionPriority: 0
|
4901
5195
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
4902
5196
|
});
|
4903
|
-
return /* @__PURE__ */
|
5197
|
+
return /* @__PURE__ */ jsx24(
|
4904
5198
|
"div",
|
4905
5199
|
{
|
4906
5200
|
className: getClassName18(),
|
@@ -4916,11 +5210,11 @@ Drawer.Item = DrawerItem;
|
|
4916
5210
|
// components/Puck/index.tsx
|
4917
5211
|
init_react_import();
|
4918
5212
|
import {
|
4919
|
-
useCallback as
|
4920
|
-
useEffect as
|
4921
|
-
useMemo as
|
5213
|
+
useCallback as useCallback17,
|
5214
|
+
useEffect as useEffect23,
|
5215
|
+
useMemo as useMemo18,
|
4922
5216
|
useReducer,
|
4923
|
-
useState as
|
5217
|
+
useState as useState26
|
4924
5218
|
} from "react";
|
4925
5219
|
|
4926
5220
|
// components/SidebarSection/index.tsx
|
@@ -4932,7 +5226,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
4932
5226
|
|
4933
5227
|
// lib/use-breadcrumbs.ts
|
4934
5228
|
init_react_import();
|
4935
|
-
import { useContext as
|
5229
|
+
import { useContext as useContext8, useMemo as useMemo10 } from "react";
|
4936
5230
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
4937
5231
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
4938
5232
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -4982,8 +5276,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
4982
5276
|
state: { data },
|
4983
5277
|
selectedItem
|
4984
5278
|
} = useAppContext();
|
4985
|
-
const dzContext =
|
4986
|
-
return
|
5279
|
+
const dzContext = useContext8(dropZoneContext);
|
5280
|
+
return useMemo10(() => {
|
4987
5281
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
4988
5282
|
selectedItem,
|
4989
5283
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -4997,7 +5291,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
4997
5291
|
};
|
4998
5292
|
|
4999
5293
|
// components/SidebarSection/index.tsx
|
5000
|
-
import { jsx as
|
5294
|
+
import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
5001
5295
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5002
5296
|
var SidebarSection = ({
|
5003
5297
|
children,
|
@@ -5016,9 +5310,9 @@ var SidebarSection = ({
|
|
5016
5310
|
className: getClassName19({ noBorderTop, noPadding }),
|
5017
5311
|
style: { background },
|
5018
5312
|
children: [
|
5019
|
-
/* @__PURE__ */
|
5313
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
|
5020
5314
|
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
|
5021
|
-
/* @__PURE__ */
|
5315
|
+
/* @__PURE__ */ jsx25(
|
5022
5316
|
"button",
|
5023
5317
|
{
|
5024
5318
|
type: "button",
|
@@ -5027,12 +5321,12 @@ var SidebarSection = ({
|
|
5027
5321
|
children: breadcrumb.label
|
5028
5322
|
}
|
5029
5323
|
),
|
5030
|
-
/* @__PURE__ */
|
5324
|
+
/* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
|
5031
5325
|
] }, i)) : null,
|
5032
|
-
/* @__PURE__ */
|
5326
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
|
5033
5327
|
] }) }),
|
5034
|
-
/* @__PURE__ */
|
5035
|
-
isLoading && /* @__PURE__ */
|
5328
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
|
5329
|
+
isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
|
5036
5330
|
]
|
5037
5331
|
}
|
5038
5332
|
);
|
@@ -5063,7 +5357,7 @@ init_react_import();
|
|
5063
5357
|
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
5358
|
|
5065
5359
|
// components/MenuBar/index.tsx
|
5066
|
-
import { Fragment as Fragment7, jsx as
|
5360
|
+
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
|
5067
5361
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5068
5362
|
function MenuBar({
|
5069
5363
|
appState,
|
@@ -5077,7 +5371,7 @@ function MenuBar({
|
|
5077
5371
|
history: { back, forward, historyStore }
|
5078
5372
|
} = useAppContext();
|
5079
5373
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5080
|
-
return /* @__PURE__ */
|
5374
|
+
return /* @__PURE__ */ jsx26(
|
5081
5375
|
"div",
|
5082
5376
|
{
|
5083
5377
|
className: getClassName20({ menuOpen }),
|
@@ -5093,10 +5387,10 @@ function MenuBar({
|
|
5093
5387
|
},
|
5094
5388
|
children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
|
5095
5389
|
/* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
|
5096
|
-
/* @__PURE__ */
|
5097
|
-
/* @__PURE__ */
|
5390
|
+
/* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
|
5391
|
+
/* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
|
5098
5392
|
] }),
|
5099
|
-
/* @__PURE__ */
|
5393
|
+
/* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
|
5100
5394
|
state: appState,
|
5101
5395
|
dispatch
|
5102
5396
|
}) })
|
@@ -5107,7 +5401,7 @@ function MenuBar({
|
|
5107
5401
|
|
5108
5402
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5109
5403
|
init_react_import();
|
5110
|
-
var styles_module_default15 = { "Puck": "
|
5404
|
+
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
5405
|
|
5112
5406
|
// components/Puck/components/Fields/index.tsx
|
5113
5407
|
init_react_import();
|
@@ -5117,15 +5411,15 @@ init_react_import();
|
|
5117
5411
|
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
5412
|
|
5119
5413
|
// components/Puck/components/Fields/index.tsx
|
5120
|
-
import { useCallback as
|
5414
|
+
import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo11, useState as useState19 } from "react";
|
5121
5415
|
|
5122
5416
|
// lib/use-parent.ts
|
5123
5417
|
init_react_import();
|
5124
|
-
import { useContext as
|
5418
|
+
import { useContext as useContext9 } from "react";
|
5125
5419
|
var useParent = (itemSelector) => {
|
5126
5420
|
var _a;
|
5127
5421
|
const { selectedItem, state } = useAppContext();
|
5128
|
-
const { pathData } =
|
5422
|
+
const { pathData } = useContext9(dropZoneContext) || {};
|
5129
5423
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
5130
5424
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5131
5425
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -5134,7 +5428,7 @@ var useParent = (itemSelector) => {
|
|
5134
5428
|
};
|
5135
5429
|
|
5136
5430
|
// components/Puck/components/Fields/index.tsx
|
5137
|
-
import { Fragment as Fragment8, jsx as
|
5431
|
+
import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
5138
5432
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5139
5433
|
var defaultPageFields = {
|
5140
5434
|
title: { type: "text" }
|
@@ -5142,7 +5436,7 @@ var defaultPageFields = {
|
|
5142
5436
|
var DefaultFields = ({
|
5143
5437
|
children
|
5144
5438
|
}) => {
|
5145
|
-
return /* @__PURE__ */
|
5439
|
+
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5146
5440
|
};
|
5147
5441
|
var useResolvedFields = () => {
|
5148
5442
|
var _a, _b;
|
@@ -5151,20 +5445,20 @@ var useResolvedFields = () => {
|
|
5151
5445
|
const { data } = state;
|
5152
5446
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5153
5447
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5154
|
-
const defaultFields =
|
5448
|
+
const defaultFields = useMemo11(
|
5155
5449
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5156
5450
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5157
5451
|
);
|
5158
5452
|
const rootProps = data.root.props || data.root;
|
5159
|
-
const [lastSelectedData, setLastSelectedData] =
|
5160
|
-
const [resolvedFields, setResolvedFields] =
|
5161
|
-
const [fieldsLoading, setFieldsLoading] =
|
5453
|
+
const [lastSelectedData, setLastSelectedData] = useState19({});
|
5454
|
+
const [resolvedFields, setResolvedFields] = useState19(defaultFields);
|
5455
|
+
const [fieldsLoading, setFieldsLoading] = useState19(false);
|
5162
5456
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5163
5457
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5164
5458
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5165
5459
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5166
5460
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5167
|
-
const resolveFields =
|
5461
|
+
const resolveFields = useCallback12(
|
5168
5462
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5169
5463
|
var _a2;
|
5170
5464
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5202,7 +5496,7 @@ var useResolvedFields = () => {
|
|
5202
5496
|
}),
|
5203
5497
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
5204
5498
|
);
|
5205
|
-
|
5499
|
+
useEffect16(() => {
|
5206
5500
|
if (hasResolver) {
|
5207
5501
|
setFieldsLoading(true);
|
5208
5502
|
resolveFields(defaultFields).then((fields) => {
|
@@ -5233,7 +5527,7 @@ var Fields = () => {
|
|
5233
5527
|
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
5528
|
const isLoading = fieldsResolving || componentResolving;
|
5235
5529
|
const rootProps = data.root.props || data.root;
|
5236
|
-
const Wrapper =
|
5530
|
+
const Wrapper = useMemo11(() => overrides.fields || DefaultFields, [overrides]);
|
5237
5531
|
return /* @__PURE__ */ jsxs14(
|
5238
5532
|
"form",
|
5239
5533
|
{
|
@@ -5242,7 +5536,7 @@ var Fields = () => {
|
|
5242
5536
|
e.preventDefault();
|
5243
5537
|
},
|
5244
5538
|
children: [
|
5245
|
-
/* @__PURE__ */
|
5539
|
+
/* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5246
5540
|
const field = fields[fieldName];
|
5247
5541
|
if (!(field == null ? void 0 : field.type)) return null;
|
5248
5542
|
const onChange = (value, updatedUi) => {
|
@@ -5313,7 +5607,7 @@ var Fields = () => {
|
|
5313
5607
|
item: selectedItem
|
5314
5608
|
});
|
5315
5609
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5316
|
-
return /* @__PURE__ */
|
5610
|
+
return /* @__PURE__ */ jsx27(
|
5317
5611
|
AutoFieldPrivate,
|
5318
5612
|
{
|
5319
5613
|
field,
|
@@ -5331,7 +5625,7 @@ var Fields = () => {
|
|
5331
5625
|
root: true
|
5332
5626
|
});
|
5333
5627
|
const id = `root_${field.type}_${fieldName}`;
|
5334
|
-
return /* @__PURE__ */
|
5628
|
+
return /* @__PURE__ */ jsx27(
|
5335
5629
|
AutoFieldPrivate,
|
5336
5630
|
{
|
5337
5631
|
field,
|
@@ -5345,7 +5639,7 @@ var Fields = () => {
|
|
5345
5639
|
);
|
5346
5640
|
}
|
5347
5641
|
}) }),
|
5348
|
-
isLoading && /* @__PURE__ */
|
5642
|
+
isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
|
5349
5643
|
]
|
5350
5644
|
}
|
5351
5645
|
);
|
@@ -5356,7 +5650,7 @@ init_react_import();
|
|
5356
5650
|
|
5357
5651
|
// lib/use-component-list.tsx
|
5358
5652
|
init_react_import();
|
5359
|
-
import { useEffect as
|
5653
|
+
import { useEffect as useEffect17, useState as useState20 } from "react";
|
5360
5654
|
|
5361
5655
|
// components/ComponentList/index.tsx
|
5362
5656
|
init_react_import();
|
@@ -5366,7 +5660,7 @@ init_react_import();
|
|
5366
5660
|
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
5661
|
|
5368
5662
|
// components/ComponentList/index.tsx
|
5369
|
-
import { jsx as
|
5663
|
+
import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
|
5370
5664
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5371
5665
|
var ComponentListItem = ({
|
5372
5666
|
name,
|
@@ -5376,7 +5670,7 @@ var ComponentListItem = ({
|
|
5376
5670
|
const canInsert = getPermissions({
|
5377
5671
|
type: name
|
5378
5672
|
}).insert;
|
5379
|
-
return /* @__PURE__ */
|
5673
|
+
return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5380
5674
|
};
|
5381
5675
|
var ComponentList = ({
|
5382
5676
|
children,
|
@@ -5400,14 +5694,14 @@ var ComponentList = ({
|
|
5400
5694
|
}),
|
5401
5695
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5402
5696
|
children: [
|
5403
|
-
/* @__PURE__ */
|
5404
|
-
/* @__PURE__ */
|
5697
|
+
/* @__PURE__ */ jsx28("div", { children: title }),
|
5698
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
|
5405
5699
|
]
|
5406
5700
|
}
|
5407
5701
|
),
|
5408
|
-
/* @__PURE__ */
|
5702
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
5409
5703
|
var _a;
|
5410
|
-
return /* @__PURE__ */
|
5704
|
+
return /* @__PURE__ */ jsx28(
|
5411
5705
|
ComponentListItem,
|
5412
5706
|
{
|
5413
5707
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5421,10 +5715,10 @@ var ComponentList = ({
|
|
5421
5715
|
ComponentList.Item = ComponentListItem;
|
5422
5716
|
|
5423
5717
|
// lib/use-component-list.tsx
|
5424
|
-
import { jsx as
|
5718
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
5425
5719
|
var useComponentList = (config, ui) => {
|
5426
|
-
const [componentList, setComponentList] =
|
5427
|
-
|
5720
|
+
const [componentList, setComponentList] = useState20();
|
5721
|
+
useEffect17(() => {
|
5428
5722
|
var _a, _b, _c;
|
5429
5723
|
if (Object.keys(ui.componentList).length > 0) {
|
5430
5724
|
const matchedComponents = [];
|
@@ -5434,7 +5728,7 @@ var useComponentList = (config, ui) => {
|
|
5434
5728
|
if (category.visible === false || !category.components) {
|
5435
5729
|
return null;
|
5436
5730
|
}
|
5437
|
-
return /* @__PURE__ */
|
5731
|
+
return /* @__PURE__ */ jsx29(
|
5438
5732
|
ComponentList,
|
5439
5733
|
{
|
5440
5734
|
id: categoryKey,
|
@@ -5443,7 +5737,7 @@ var useComponentList = (config, ui) => {
|
|
5443
5737
|
var _a2;
|
5444
5738
|
matchedComponents.push(componentName);
|
5445
5739
|
const componentConf = config.components[componentName] || {};
|
5446
|
-
return /* @__PURE__ */
|
5740
|
+
return /* @__PURE__ */ jsx29(
|
5447
5741
|
ComponentList.Item,
|
5448
5742
|
{
|
5449
5743
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5463,7 +5757,7 @@ var useComponentList = (config, ui) => {
|
|
5463
5757
|
);
|
5464
5758
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5465
5759
|
_componentList.push(
|
5466
|
-
/* @__PURE__ */
|
5760
|
+
/* @__PURE__ */ jsx29(
|
5467
5761
|
ComponentList,
|
5468
5762
|
{
|
5469
5763
|
id: "other",
|
@@ -5471,7 +5765,7 @@ var useComponentList = (config, ui) => {
|
|
5471
5765
|
children: remainingComponents.map((componentName, i) => {
|
5472
5766
|
var _a2;
|
5473
5767
|
const componentConf = config.components[componentName] || {};
|
5474
|
-
return /* @__PURE__ */
|
5768
|
+
return /* @__PURE__ */ jsx29(
|
5475
5769
|
ComponentList.Item,
|
5476
5770
|
{
|
5477
5771
|
name: componentName,
|
@@ -5493,30 +5787,30 @@ var useComponentList = (config, ui) => {
|
|
5493
5787
|
};
|
5494
5788
|
|
5495
5789
|
// components/Puck/components/Components/index.tsx
|
5496
|
-
import { useMemo as
|
5497
|
-
import { jsx as
|
5790
|
+
import { useMemo as useMemo12 } from "react";
|
5791
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
5498
5792
|
var Components = () => {
|
5499
5793
|
const { config, state, overrides } = useAppContext();
|
5500
5794
|
const componentList = useComponentList(config, state.ui);
|
5501
|
-
const Wrapper =
|
5502
|
-
return /* @__PURE__ */
|
5795
|
+
const Wrapper = useMemo12(() => overrides.components || "div", [overrides]);
|
5796
|
+
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
5503
5797
|
};
|
5504
5798
|
|
5505
5799
|
// components/Puck/components/Preview/index.tsx
|
5506
5800
|
init_react_import();
|
5507
|
-
import { useCallback as
|
5801
|
+
import { useCallback as useCallback13, useEffect as useEffect19, useRef as useRef6, useMemo as useMemo13 } from "react";
|
5508
5802
|
|
5509
5803
|
// components/AutoFrame/index.tsx
|
5510
5804
|
init_react_import();
|
5511
5805
|
import {
|
5512
|
-
createContext as
|
5513
|
-
useContext as
|
5514
|
-
useEffect as
|
5515
|
-
useState as
|
5806
|
+
createContext as createContext5,
|
5807
|
+
useContext as useContext10,
|
5808
|
+
useEffect as useEffect18,
|
5809
|
+
useState as useState21
|
5516
5810
|
} from "react";
|
5517
5811
|
import hash from "object-hash";
|
5518
5812
|
import { createPortal as createPortal3 } from "react-dom";
|
5519
|
-
import { Fragment as Fragment9, jsx as
|
5813
|
+
import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
|
5520
5814
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5521
5815
|
var collectStyles = (doc) => {
|
5522
5816
|
const collected = [];
|
@@ -5559,7 +5853,7 @@ var CopyHostStyles = ({
|
|
5559
5853
|
onStylesLoaded = () => null
|
5560
5854
|
}) => {
|
5561
5855
|
const { document: doc, window: win } = useFrame();
|
5562
|
-
|
5856
|
+
useEffect18(() => {
|
5563
5857
|
if (!win || !doc) {
|
5564
5858
|
return () => {
|
5565
5859
|
};
|
@@ -5716,10 +6010,10 @@ var CopyHostStyles = ({
|
|
5716
6010
|
observer.disconnect();
|
5717
6011
|
};
|
5718
6012
|
}, []);
|
5719
|
-
return /* @__PURE__ */
|
6013
|
+
return /* @__PURE__ */ jsx31(Fragment9, { children });
|
5720
6014
|
};
|
5721
|
-
var autoFrameContext =
|
5722
|
-
var useFrame = () =>
|
6015
|
+
var autoFrameContext = createContext5({});
|
6016
|
+
var useFrame = () => useContext10(autoFrameContext);
|
5723
6017
|
function AutoFrame(_a) {
|
5724
6018
|
var _b = _a, {
|
5725
6019
|
children,
|
@@ -5736,10 +6030,10 @@ function AutoFrame(_a) {
|
|
5736
6030
|
"onStylesLoaded",
|
5737
6031
|
"frameRef"
|
5738
6032
|
]);
|
5739
|
-
const [loaded, setLoaded] =
|
5740
|
-
const [ctx, setCtx] =
|
5741
|
-
const [mountTarget, setMountTarget] =
|
5742
|
-
|
6033
|
+
const [loaded, setLoaded] = useState21(false);
|
6034
|
+
const [ctx, setCtx] = useState21({});
|
6035
|
+
const [mountTarget, setMountTarget] = useState21();
|
6036
|
+
useEffect18(() => {
|
5743
6037
|
var _a2;
|
5744
6038
|
if (frameRef.current) {
|
5745
6039
|
setCtx({
|
@@ -5751,7 +6045,7 @@ function AutoFrame(_a) {
|
|
5751
6045
|
);
|
5752
6046
|
}
|
5753
6047
|
}, [frameRef, loaded]);
|
5754
|
-
return /* @__PURE__ */
|
6048
|
+
return /* @__PURE__ */ jsx31(
|
5755
6049
|
"iframe",
|
5756
6050
|
__spreadProps(__spreadValues({}, props), {
|
5757
6051
|
className,
|
@@ -5761,7 +6055,7 @@ function AutoFrame(_a) {
|
|
5761
6055
|
onLoad: () => {
|
5762
6056
|
setLoaded(true);
|
5763
6057
|
},
|
5764
|
-
children: /* @__PURE__ */
|
6058
|
+
children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
|
5765
6059
|
})
|
5766
6060
|
);
|
5767
6061
|
}
|
@@ -5774,7 +6068,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
|
|
5774
6068
|
|
5775
6069
|
// components/Render/index.tsx
|
5776
6070
|
init_react_import();
|
5777
|
-
import { jsx as
|
6071
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
5778
6072
|
function Render({
|
5779
6073
|
config,
|
5780
6074
|
data
|
@@ -5787,7 +6081,7 @@ function Render({
|
|
5787
6081
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
5788
6082
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
5789
6083
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5790
|
-
return /* @__PURE__ */
|
6084
|
+
return /* @__PURE__ */ jsx32(
|
5791
6085
|
DropZoneProvider,
|
5792
6086
|
{
|
5793
6087
|
value: {
|
@@ -5797,7 +6091,7 @@ function Render({
|
|
5797
6091
|
depth: 0,
|
5798
6092
|
path: []
|
5799
6093
|
},
|
5800
|
-
children: /* @__PURE__ */
|
6094
|
+
children: /* @__PURE__ */ jsx32(
|
5801
6095
|
config.root.render,
|
5802
6096
|
__spreadProps(__spreadValues({}, rootProps), {
|
5803
6097
|
puck: {
|
@@ -5807,13 +6101,13 @@ function Render({
|
|
5807
6101
|
title,
|
5808
6102
|
editMode: false,
|
5809
6103
|
id: "puck-root",
|
5810
|
-
children: /* @__PURE__ */
|
6104
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
5811
6105
|
})
|
5812
6106
|
)
|
5813
6107
|
}
|
5814
6108
|
);
|
5815
6109
|
}
|
5816
|
-
return /* @__PURE__ */
|
6110
|
+
return /* @__PURE__ */ jsx32(
|
5817
6111
|
DropZoneProvider,
|
5818
6112
|
{
|
5819
6113
|
value: {
|
@@ -5823,17 +6117,17 @@ function Render({
|
|
5823
6117
|
depth: 0,
|
5824
6118
|
path: []
|
5825
6119
|
},
|
5826
|
-
children: /* @__PURE__ */
|
6120
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
5827
6121
|
}
|
5828
6122
|
);
|
5829
6123
|
}
|
5830
6124
|
|
5831
6125
|
// components/Puck/components/Preview/index.tsx
|
5832
|
-
import { Fragment as Fragment10, jsx as
|
6126
|
+
import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
|
5833
6127
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5834
6128
|
var useBubbleIframeEvents = (ref) => {
|
5835
6129
|
const { status } = useAppContext();
|
5836
|
-
|
6130
|
+
useEffect19(() => {
|
5837
6131
|
var _a;
|
5838
6132
|
if (ref.current && status === "READY") {
|
5839
6133
|
const iframe = ref.current;
|
@@ -5870,22 +6164,22 @@ var useBubbleIframeEvents = (ref) => {
|
|
5870
6164
|
}
|
5871
6165
|
}, [status]);
|
5872
6166
|
};
|
5873
|
-
var
|
6167
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
5874
6168
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
5875
|
-
const Page =
|
6169
|
+
const Page = useCallback13(
|
5876
6170
|
(pageProps) => {
|
5877
6171
|
var _a, _b;
|
5878
6172
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
5879
6173
|
id: "puck-root"
|
5880
|
-
}, pageProps)) : /* @__PURE__ */
|
6174
|
+
}, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
|
5881
6175
|
},
|
5882
6176
|
[config.root]
|
5883
6177
|
);
|
5884
|
-
const Frame =
|
6178
|
+
const Frame = useMemo13(() => overrides.iframe, [overrides]);
|
5885
6179
|
const rootProps = state.data.root.props || state.data.root;
|
5886
|
-
const ref =
|
6180
|
+
const ref = useRef6(null);
|
5887
6181
|
useBubbleIframeEvents(ref);
|
5888
|
-
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */
|
6182
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
|
5889
6183
|
Page,
|
5890
6184
|
__spreadProps(__spreadValues({}, rootProps), {
|
5891
6185
|
puck: {
|
@@ -5894,10 +6188,10 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5894
6188
|
dragRef: null
|
5895
6189
|
},
|
5896
6190
|
editMode: true,
|
5897
|
-
children: /* @__PURE__ */
|
6191
|
+
children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
|
5898
6192
|
})
|
5899
|
-
) : /* @__PURE__ */
|
5900
|
-
return /* @__PURE__ */
|
6193
|
+
) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
|
6194
|
+
return /* @__PURE__ */ jsx33(
|
5901
6195
|
"div",
|
5902
6196
|
{
|
5903
6197
|
className: getClassName23(),
|
@@ -5906,7 +6200,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5906
6200
|
onClick: () => {
|
5907
6201
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
5908
6202
|
},
|
5909
|
-
children: iframe.enabled ? /* @__PURE__ */
|
6203
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx33(
|
5910
6204
|
AutoFrame_default,
|
5911
6205
|
{
|
5912
6206
|
id: "preview-frame",
|
@@ -5916,14 +6210,14 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5916
6210
|
setStatus("READY");
|
5917
6211
|
},
|
5918
6212
|
frameRef: ref,
|
5919
|
-
children: /* @__PURE__ */
|
6213
|
+
children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
5920
6214
|
if (Frame) {
|
5921
|
-
return /* @__PURE__ */
|
6215
|
+
return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
|
5922
6216
|
}
|
5923
6217
|
return inner;
|
5924
6218
|
} })
|
5925
6219
|
}
|
5926
|
-
) : /* @__PURE__ */
|
6220
|
+
) : /* @__PURE__ */ jsx33(
|
5927
6221
|
"div",
|
5928
6222
|
{
|
5929
6223
|
id: "preview-frame",
|
@@ -5980,7 +6274,7 @@ var scrollIntoView = (el) => {
|
|
5980
6274
|
};
|
5981
6275
|
|
5982
6276
|
// components/LayerTree/index.tsx
|
5983
|
-
import { useContext as
|
6277
|
+
import { useContext as useContext11 } from "react";
|
5984
6278
|
|
5985
6279
|
// lib/is-child-of-zone.ts
|
5986
6280
|
init_react_import();
|
@@ -6013,7 +6307,7 @@ var onScrollEnd = (frame, cb) => {
|
|
6013
6307
|
};
|
6014
6308
|
|
6015
6309
|
// components/LayerTree/index.tsx
|
6016
|
-
import { Fragment as Fragment11, jsx as
|
6310
|
+
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
|
6017
6311
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6018
6312
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6019
6313
|
var LayerTree = ({
|
@@ -6026,15 +6320,15 @@ var LayerTree = ({
|
|
6026
6320
|
label
|
6027
6321
|
}) => {
|
6028
6322
|
const zones = data.zones || {};
|
6029
|
-
const ctx =
|
6323
|
+
const ctx = useContext11(dropZoneContext);
|
6030
6324
|
return /* @__PURE__ */ jsxs16(Fragment11, { children: [
|
6031
6325
|
label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
|
6032
|
-
/* @__PURE__ */
|
6326
|
+
/* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
|
6033
6327
|
" ",
|
6034
6328
|
label
|
6035
6329
|
] }),
|
6036
6330
|
/* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
|
6037
|
-
zoneContent.length === 0 && /* @__PURE__ */
|
6331
|
+
zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
|
6038
6332
|
zoneContent.map((item, i) => {
|
6039
6333
|
var _a;
|
6040
6334
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6057,7 +6351,7 @@ var LayerTree = ({
|
|
6057
6351
|
childIsSelected
|
6058
6352
|
}),
|
6059
6353
|
children: [
|
6060
|
-
/* @__PURE__ */
|
6354
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
|
6061
6355
|
"button",
|
6062
6356
|
{
|
6063
6357
|
type: "button",
|
@@ -6096,22 +6390,22 @@ var LayerTree = ({
|
|
6096
6390
|
setHoveringComponent(null);
|
6097
6391
|
},
|
6098
6392
|
children: [
|
6099
|
-
containsZone && /* @__PURE__ */
|
6393
|
+
containsZone && /* @__PURE__ */ jsx34(
|
6100
6394
|
"div",
|
6101
6395
|
{
|
6102
6396
|
className: getClassNameLayer("chevron"),
|
6103
6397
|
title: isSelected ? "Collapse" : "Expand",
|
6104
|
-
children: /* @__PURE__ */
|
6398
|
+
children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
|
6105
6399
|
}
|
6106
6400
|
),
|
6107
6401
|
/* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
|
6108
|
-
/* @__PURE__ */
|
6109
|
-
/* @__PURE__ */
|
6402
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
|
6403
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
|
6110
6404
|
] })
|
6111
6405
|
]
|
6112
6406
|
}
|
6113
6407
|
) }),
|
6114
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */
|
6408
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
|
6115
6409
|
LayerTree,
|
6116
6410
|
{
|
6117
6411
|
config,
|
@@ -6133,13 +6427,13 @@ var LayerTree = ({
|
|
6133
6427
|
};
|
6134
6428
|
|
6135
6429
|
// components/Puck/components/Outline/index.tsx
|
6136
|
-
import { useCallback as
|
6137
|
-
import { Fragment as Fragment12, jsx as
|
6430
|
+
import { useCallback as useCallback14, useMemo as useMemo14 } from "react";
|
6431
|
+
import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
|
6138
6432
|
var Outline = () => {
|
6139
6433
|
const { dispatch, state, overrides, config } = useAppContext();
|
6140
6434
|
const { data, ui } = state;
|
6141
6435
|
const { itemSelector } = ui;
|
6142
|
-
const setItemSelector =
|
6436
|
+
const setItemSelector = useCallback14(
|
6143
6437
|
(newItemSelector) => {
|
6144
6438
|
dispatch({
|
6145
6439
|
type: "setUi",
|
@@ -6148,9 +6442,9 @@ var Outline = () => {
|
|
6148
6442
|
},
|
6149
6443
|
[]
|
6150
6444
|
);
|
6151
|
-
const Wrapper =
|
6152
|
-
return /* @__PURE__ */
|
6153
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */
|
6445
|
+
const Wrapper = useMemo14(() => overrides.outline || "div", [overrides]);
|
6446
|
+
return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
|
6447
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
|
6154
6448
|
LayerTree,
|
6155
6449
|
{
|
6156
6450
|
config,
|
@@ -6163,7 +6457,7 @@ var Outline = () => {
|
|
6163
6457
|
),
|
6164
6458
|
Object.entries(findZonesForArea(data, "root")).map(
|
6165
6459
|
([zoneKey, zone]) => {
|
6166
|
-
return /* @__PURE__ */
|
6460
|
+
return /* @__PURE__ */ jsx35(
|
6167
6461
|
LayerTree,
|
6168
6462
|
{
|
6169
6463
|
config,
|
@@ -6262,19 +6556,19 @@ function usePuckHistory({
|
|
6262
6556
|
|
6263
6557
|
// lib/use-history-store.ts
|
6264
6558
|
init_react_import();
|
6265
|
-
import { useState as
|
6559
|
+
import { useState as useState22 } from "react";
|
6266
6560
|
import { useDebouncedCallback as useDebouncedCallback3 } from "use-debounce";
|
6267
6561
|
var EMPTY_HISTORY_INDEX = 0;
|
6268
6562
|
function useHistoryStore(initialHistory) {
|
6269
6563
|
var _a, _b;
|
6270
|
-
const [histories, setHistories] =
|
6564
|
+
const [histories, setHistories] = useState22(
|
6271
6565
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6272
6566
|
);
|
6273
6567
|
const updateHistories = (histories2) => {
|
6274
6568
|
setHistories(histories2);
|
6275
6569
|
setIndex(histories2.length - 1);
|
6276
6570
|
};
|
6277
|
-
const [index, setIndex] =
|
6571
|
+
const [index, setIndex] = useState22(
|
6278
6572
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6279
6573
|
);
|
6280
6574
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6435,27 +6729,27 @@ var getBox = function getBox2(el) {
|
|
6435
6729
|
|
6436
6730
|
// components/Puck/components/Canvas/index.tsx
|
6437
6731
|
import {
|
6438
|
-
useCallback as
|
6439
|
-
useEffect as
|
6440
|
-
useMemo as
|
6441
|
-
useRef as
|
6442
|
-
useState as
|
6732
|
+
useCallback as useCallback15,
|
6733
|
+
useEffect as useEffect21,
|
6734
|
+
useMemo as useMemo16,
|
6735
|
+
useRef as useRef7,
|
6736
|
+
useState as useState24
|
6443
6737
|
} from "react";
|
6444
6738
|
|
6445
6739
|
// components/ViewportControls/index.tsx
|
6446
6740
|
init_react_import();
|
6447
|
-
import { useEffect as
|
6741
|
+
import { useEffect as useEffect20, useMemo as useMemo15, useState as useState23 } from "react";
|
6448
6742
|
|
6449
6743
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6450
6744
|
init_react_import();
|
6451
6745
|
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
6746
|
|
6453
6747
|
// components/ViewportControls/index.tsx
|
6454
|
-
import { jsx as
|
6748
|
+
import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
|
6455
6749
|
var icons = {
|
6456
|
-
Smartphone: /* @__PURE__ */
|
6457
|
-
Tablet: /* @__PURE__ */
|
6458
|
-
Monitor: /* @__PURE__ */
|
6750
|
+
Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
|
6751
|
+
Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
|
6752
|
+
Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
|
6459
6753
|
};
|
6460
6754
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6461
6755
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6467,11 +6761,11 @@ var ViewportButton = ({
|
|
6467
6761
|
onClick
|
6468
6762
|
}) => {
|
6469
6763
|
const { state } = useAppContext();
|
6470
|
-
const [isActive, setIsActive] =
|
6471
|
-
|
6764
|
+
const [isActive, setIsActive] = useState23(false);
|
6765
|
+
useEffect20(() => {
|
6472
6766
|
setIsActive(width === state.ui.viewports.current.width);
|
6473
6767
|
}, [width, state.ui.viewports.current.width]);
|
6474
|
-
return /* @__PURE__ */
|
6768
|
+
return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
|
6475
6769
|
IconButton,
|
6476
6770
|
{
|
6477
6771
|
title,
|
@@ -6480,7 +6774,7 @@ var ViewportButton = ({
|
|
6480
6774
|
e.stopPropagation();
|
6481
6775
|
onClick({ width, height });
|
6482
6776
|
},
|
6483
|
-
children: /* @__PURE__ */
|
6777
|
+
children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
|
6484
6778
|
}
|
6485
6779
|
) });
|
6486
6780
|
};
|
@@ -6504,7 +6798,7 @@ var ViewportControls = ({
|
|
6504
6798
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6505
6799
|
(option) => option.value === autoZoom
|
6506
6800
|
);
|
6507
|
-
const zoomOptions =
|
6801
|
+
const zoomOptions = useMemo15(
|
6508
6802
|
() => [
|
6509
6803
|
...defaultZoomOptions,
|
6510
6804
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6517,7 +6811,7 @@ var ViewportControls = ({
|
|
6517
6811
|
[autoZoom]
|
6518
6812
|
);
|
6519
6813
|
return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
|
6520
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
6814
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
|
6521
6815
|
ViewportButton,
|
6522
6816
|
{
|
6523
6817
|
height: viewport.height,
|
@@ -6528,8 +6822,8 @@ var ViewportControls = ({
|
|
6528
6822
|
},
|
6529
6823
|
i
|
6530
6824
|
)),
|
6531
|
-
/* @__PURE__ */
|
6532
|
-
/* @__PURE__ */
|
6825
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6826
|
+
/* @__PURE__ */ jsx36(
|
6533
6827
|
IconButton,
|
6534
6828
|
{
|
6535
6829
|
title: "Zoom viewport out",
|
@@ -6543,10 +6837,10 @@ var ViewportControls = ({
|
|
6543
6837
|
)].value
|
6544
6838
|
);
|
6545
6839
|
},
|
6546
|
-
children: /* @__PURE__ */
|
6840
|
+
children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
|
6547
6841
|
}
|
6548
6842
|
),
|
6549
|
-
/* @__PURE__ */
|
6843
|
+
/* @__PURE__ */ jsx36(
|
6550
6844
|
IconButton,
|
6551
6845
|
{
|
6552
6846
|
title: "Zoom viewport in",
|
@@ -6560,11 +6854,11 @@ var ViewportControls = ({
|
|
6560
6854
|
)].value
|
6561
6855
|
);
|
6562
6856
|
},
|
6563
|
-
children: /* @__PURE__ */
|
6857
|
+
children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
|
6564
6858
|
}
|
6565
6859
|
),
|
6566
|
-
/* @__PURE__ */
|
6567
|
-
/* @__PURE__ */
|
6860
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6861
|
+
/* @__PURE__ */ jsx36(
|
6568
6862
|
"select",
|
6569
6863
|
{
|
6570
6864
|
className: getClassName25("zoomSelect"),
|
@@ -6572,7 +6866,7 @@ var ViewportControls = ({
|
|
6572
6866
|
onChange: (e) => {
|
6573
6867
|
onZoom(parseFloat(e.currentTarget.value));
|
6574
6868
|
},
|
6575
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
6869
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
|
6576
6870
|
"option",
|
6577
6871
|
{
|
6578
6872
|
value: option.value,
|
@@ -6620,24 +6914,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6620
6914
|
};
|
6621
6915
|
|
6622
6916
|
// components/Puck/components/Canvas/index.tsx
|
6623
|
-
import { Fragment as Fragment13, jsx as
|
6917
|
+
import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
|
6624
6918
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6625
6919
|
var ZOOM_ON_CHANGE = true;
|
6626
6920
|
var Canvas = () => {
|
6627
6921
|
const { status, iframe } = useAppContext();
|
6628
6922
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6629
6923
|
const { ui } = state;
|
6630
|
-
const frameRef =
|
6631
|
-
const [showTransition, setShowTransition] =
|
6632
|
-
const defaultRender =
|
6633
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
6924
|
+
const frameRef = useRef7(null);
|
6925
|
+
const [showTransition, setShowTransition] = useState24(false);
|
6926
|
+
const defaultRender = useMemo16(() => {
|
6927
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
|
6634
6928
|
return PuckDefault;
|
6635
6929
|
}, []);
|
6636
|
-
const CustomPreview =
|
6930
|
+
const CustomPreview = useMemo16(
|
6637
6931
|
() => overrides.preview || defaultRender,
|
6638
6932
|
[overrides]
|
6639
6933
|
);
|
6640
|
-
const getFrameDimensions =
|
6934
|
+
const getFrameDimensions = useCallback15(() => {
|
6641
6935
|
if (frameRef.current) {
|
6642
6936
|
const frame = frameRef.current;
|
6643
6937
|
const box = getBox(frame);
|
@@ -6645,7 +6939,7 @@ var Canvas = () => {
|
|
6645
6939
|
}
|
6646
6940
|
return { width: 0, height: 0 };
|
6647
6941
|
}, [frameRef]);
|
6648
|
-
const resetAutoZoom =
|
6942
|
+
const resetAutoZoom = useCallback15(
|
6649
6943
|
(ui2 = state.ui) => {
|
6650
6944
|
if (frameRef.current) {
|
6651
6945
|
setZoomConfig(
|
@@ -6655,11 +6949,11 @@ var Canvas = () => {
|
|
6655
6949
|
},
|
6656
6950
|
[frameRef, zoomConfig, state.ui]
|
6657
6951
|
);
|
6658
|
-
|
6952
|
+
useEffect21(() => {
|
6659
6953
|
setShowTransition(false);
|
6660
6954
|
resetAutoZoom();
|
6661
6955
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6662
|
-
|
6956
|
+
useEffect21(() => {
|
6663
6957
|
const { height: frameHeight } = getFrameDimensions();
|
6664
6958
|
if (ui.viewports.current.height === "auto") {
|
6665
6959
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6667,13 +6961,13 @@ var Canvas = () => {
|
|
6667
6961
|
}));
|
6668
6962
|
}
|
6669
6963
|
}, [zoomConfig.zoom]);
|
6670
|
-
|
6964
|
+
useEffect21(() => {
|
6671
6965
|
if (ZOOM_ON_CHANGE) {
|
6672
6966
|
setShowTransition(true);
|
6673
6967
|
resetAutoZoom(ui);
|
6674
6968
|
}
|
6675
6969
|
}, [ui.viewports.current.width]);
|
6676
|
-
|
6970
|
+
useEffect21(() => {
|
6677
6971
|
const cb = () => {
|
6678
6972
|
setShowTransition(false);
|
6679
6973
|
resetAutoZoom();
|
@@ -6683,8 +6977,8 @@ var Canvas = () => {
|
|
6683
6977
|
window.removeEventListener("resize", cb);
|
6684
6978
|
};
|
6685
6979
|
}, []);
|
6686
|
-
const [showLoader, setShowLoader] =
|
6687
|
-
|
6980
|
+
const [showLoader, setShowLoader] = useState24(false);
|
6981
|
+
useEffect21(() => {
|
6688
6982
|
setTimeout(() => {
|
6689
6983
|
setShowLoader(true);
|
6690
6984
|
}, 500);
|
@@ -6702,7 +6996,7 @@ var Canvas = () => {
|
|
6702
6996
|
recordHistory: true
|
6703
6997
|
}),
|
6704
6998
|
children: [
|
6705
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
6999
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
|
6706
7000
|
ViewportControls,
|
6707
7001
|
{
|
6708
7002
|
autoZoom: zoomConfig.autoZoom,
|
@@ -6729,7 +7023,7 @@ var Canvas = () => {
|
|
6729
7023
|
}
|
6730
7024
|
) }),
|
6731
7025
|
/* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
6732
|
-
/* @__PURE__ */
|
7026
|
+
/* @__PURE__ */ jsx37(
|
6733
7027
|
"div",
|
6734
7028
|
{
|
6735
7029
|
className: getClassName26("root"),
|
@@ -6750,10 +7044,10 @@ var Canvas = () => {
|
|
6750
7044
|
})
|
6751
7045
|
);
|
6752
7046
|
},
|
6753
|
-
children: /* @__PURE__ */
|
7047
|
+
children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
|
6754
7048
|
}
|
6755
7049
|
),
|
6756
|
-
/* @__PURE__ */
|
7050
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
|
6757
7051
|
] })
|
6758
7052
|
]
|
6759
7053
|
}
|
@@ -6762,7 +7056,7 @@ var Canvas = () => {
|
|
6762
7056
|
|
6763
7057
|
// lib/use-loaded-overrides.ts
|
6764
7058
|
init_react_import();
|
6765
|
-
import { useMemo as
|
7059
|
+
import { useMemo as useMemo17 } from "react";
|
6766
7060
|
|
6767
7061
|
// lib/load-overrides.ts
|
6768
7062
|
init_react_import();
|
@@ -6801,26 +7095,26 @@ var useLoadedOverrides = ({
|
|
6801
7095
|
overrides,
|
6802
7096
|
plugins
|
6803
7097
|
}) => {
|
6804
|
-
return
|
7098
|
+
return useMemo17(() => {
|
6805
7099
|
return loadOverrides({ overrides, plugins });
|
6806
7100
|
}, [plugins, overrides]);
|
6807
7101
|
};
|
6808
7102
|
|
6809
7103
|
// components/DefaultOverride/index.tsx
|
6810
7104
|
init_react_import();
|
6811
|
-
import { Fragment as Fragment14, jsx as
|
6812
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */
|
7105
|
+
import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
|
7106
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
|
6813
7107
|
|
6814
7108
|
// lib/use-inject-css.ts
|
6815
7109
|
init_react_import();
|
6816
|
-
import { useEffect as
|
7110
|
+
import { useEffect as useEffect22, useState as useState25 } from "react";
|
6817
7111
|
var styles = ``;
|
6818
7112
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6819
|
-
const [el, setEl] =
|
6820
|
-
|
7113
|
+
const [el, setEl] = useState25();
|
7114
|
+
useEffect22(() => {
|
6821
7115
|
setEl(document.createElement("style"));
|
6822
7116
|
}, []);
|
6823
|
-
|
7117
|
+
useEffect22(() => {
|
6824
7118
|
var _a;
|
6825
7119
|
if (!el || typeof window === "undefined") {
|
6826
7120
|
return;
|
@@ -6840,10 +7134,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
6840
7134
|
|
6841
7135
|
// lib/use-preview-mode-hotkeys.ts
|
6842
7136
|
init_react_import();
|
6843
|
-
import { useCallback as
|
7137
|
+
import { useCallback as useCallback16 } from "react";
|
6844
7138
|
import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
|
6845
7139
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
6846
|
-
const toggleInteractive =
|
7140
|
+
const toggleInteractive = useCallback16(() => {
|
6847
7141
|
dispatch({
|
6848
7142
|
type: "setUi",
|
6849
7143
|
ui: (ui) => ({
|
@@ -6866,7 +7160,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
|
6866
7160
|
};
|
6867
7161
|
|
6868
7162
|
// components/Puck/index.tsx
|
6869
|
-
import { Fragment as Fragment15, jsx as
|
7163
|
+
import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
|
6870
7164
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
6871
7165
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
6872
7166
|
function Puck({
|
@@ -6895,7 +7189,7 @@ function Puck({
|
|
6895
7189
|
waitForStyles: true
|
6896
7190
|
}, _iframe);
|
6897
7191
|
useInjectGlobalCss(iframe.enabled);
|
6898
|
-
const [generatedAppState] =
|
7192
|
+
const [generatedAppState] = useState26(() => {
|
6899
7193
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
6900
7194
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
6901
7195
|
let clientUiState = {};
|
@@ -6967,7 +7261,7 @@ function Puck({
|
|
6967
7261
|
histories,
|
6968
7262
|
index: initialHistoryIndex
|
6969
7263
|
});
|
6970
|
-
const [reducer] =
|
7264
|
+
const [reducer] = useState26(
|
6971
7265
|
() => createReducer({
|
6972
7266
|
config,
|
6973
7267
|
record: historyStore.record,
|
@@ -6985,14 +7279,14 @@ function Puck({
|
|
6985
7279
|
historyStore,
|
6986
7280
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
6987
7281
|
});
|
6988
|
-
const [menuOpen, setMenuOpen] =
|
7282
|
+
const [menuOpen, setMenuOpen] = useState26(false);
|
6989
7283
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
6990
7284
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
6991
|
-
|
7285
|
+
useEffect23(() => {
|
6992
7286
|
if (onChange) onChange(data);
|
6993
7287
|
}, [data]);
|
6994
7288
|
const rootProps = data.root.props || data.root;
|
6995
|
-
const toggleSidebars =
|
7289
|
+
const toggleSidebars = useCallback17(
|
6996
7290
|
(sidebar) => {
|
6997
7291
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
6998
7292
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7006,7 +7300,7 @@ function Puck({
|
|
7006
7300
|
},
|
7007
7301
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7008
7302
|
);
|
7009
|
-
|
7303
|
+
useEffect23(() => {
|
7010
7304
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7011
7305
|
dispatch({
|
7012
7306
|
type: "setUi",
|
@@ -7029,7 +7323,7 @@ function Puck({
|
|
7029
7323
|
window.removeEventListener("resize", handleResize);
|
7030
7324
|
};
|
7031
7325
|
}, []);
|
7032
|
-
const defaultHeaderRender =
|
7326
|
+
const defaultHeaderRender = useMemo18(() => {
|
7033
7327
|
if (renderHeader) {
|
7034
7328
|
console.warn(
|
7035
7329
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7037,20 +7331,20 @@ function Puck({
|
|
7037
7331
|
const RenderHeader = (_a2) => {
|
7038
7332
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
7039
7333
|
const Comp = renderHeader;
|
7040
|
-
return /* @__PURE__ */
|
7334
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7041
7335
|
};
|
7042
7336
|
return RenderHeader;
|
7043
7337
|
}
|
7044
7338
|
return DefaultOverride;
|
7045
7339
|
}, [renderHeader]);
|
7046
|
-
const defaultHeaderActionsRender =
|
7340
|
+
const defaultHeaderActionsRender = useMemo18(() => {
|
7047
7341
|
if (renderHeaderActions) {
|
7048
7342
|
console.warn(
|
7049
7343
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7050
7344
|
);
|
7051
7345
|
const RenderHeader = (props) => {
|
7052
7346
|
const Comp = renderHeaderActions;
|
7053
|
-
return /* @__PURE__ */
|
7347
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7054
7348
|
};
|
7055
7349
|
return RenderHeader;
|
7056
7350
|
}
|
@@ -7060,27 +7354,27 @@ function Puck({
|
|
7060
7354
|
overrides,
|
7061
7355
|
plugins
|
7062
7356
|
});
|
7063
|
-
const CustomPuck =
|
7357
|
+
const CustomPuck = useMemo18(
|
7064
7358
|
() => loadedOverrides.puck || DefaultOverride,
|
7065
7359
|
[loadedOverrides]
|
7066
7360
|
);
|
7067
|
-
const CustomHeader =
|
7361
|
+
const CustomHeader = useMemo18(
|
7068
7362
|
() => loadedOverrides.header || defaultHeaderRender,
|
7069
7363
|
[loadedOverrides]
|
7070
7364
|
);
|
7071
|
-
const CustomHeaderActions =
|
7365
|
+
const CustomHeaderActions = useMemo18(
|
7072
7366
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7073
7367
|
[loadedOverrides]
|
7074
7368
|
);
|
7075
|
-
const [mounted, setMounted] =
|
7076
|
-
|
7369
|
+
const [mounted, setMounted] = useState26(false);
|
7370
|
+
useEffect23(() => {
|
7077
7371
|
setMounted(true);
|
7078
7372
|
}, []);
|
7079
7373
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7080
7374
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7081
7375
|
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7082
7376
|
return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
|
7083
|
-
/* @__PURE__ */
|
7377
|
+
/* @__PURE__ */ jsx39(
|
7084
7378
|
AppProvider,
|
7085
7379
|
{
|
7086
7380
|
value: {
|
@@ -7102,7 +7396,7 @@ function Puck({
|
|
7102
7396
|
getPermissions: () => ({}),
|
7103
7397
|
refreshPermissions: () => null
|
7104
7398
|
},
|
7105
|
-
children: /* @__PURE__ */
|
7399
|
+
children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
|
7106
7400
|
"div",
|
7107
7401
|
{
|
7108
7402
|
className: getLayoutClassName({
|
@@ -7112,59 +7406,59 @@ function Puck({
|
|
7112
7406
|
rightSideBarVisible
|
7113
7407
|
}),
|
7114
7408
|
children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
|
7115
|
-
/* @__PURE__ */
|
7409
|
+
/* @__PURE__ */ jsx39(
|
7116
7410
|
CustomHeader,
|
7117
7411
|
{
|
7118
|
-
actions: /* @__PURE__ */
|
7412
|
+
actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7119
7413
|
Button,
|
7120
7414
|
{
|
7121
7415
|
onClick: () => {
|
7122
7416
|
onPublish && onPublish(data);
|
7123
7417
|
},
|
7124
|
-
icon: /* @__PURE__ */
|
7418
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7125
7419
|
children: "Publish"
|
7126
7420
|
}
|
7127
7421
|
) }) }),
|
7128
|
-
children: /* @__PURE__ */
|
7422
|
+
children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
|
7129
7423
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
|
7130
|
-
/* @__PURE__ */
|
7424
|
+
/* @__PURE__ */ jsx39(
|
7131
7425
|
"div",
|
7132
7426
|
{
|
7133
7427
|
className: getLayoutClassName("leftSideBarToggle"),
|
7134
|
-
children: /* @__PURE__ */
|
7428
|
+
children: /* @__PURE__ */ jsx39(
|
7135
7429
|
IconButton,
|
7136
7430
|
{
|
7137
7431
|
onClick: () => {
|
7138
7432
|
toggleSidebars("left");
|
7139
7433
|
},
|
7140
7434
|
title: "Toggle left sidebar",
|
7141
|
-
children: /* @__PURE__ */
|
7435
|
+
children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
|
7142
7436
|
}
|
7143
7437
|
)
|
7144
7438
|
}
|
7145
7439
|
),
|
7146
|
-
/* @__PURE__ */
|
7440
|
+
/* @__PURE__ */ jsx39(
|
7147
7441
|
"div",
|
7148
7442
|
{
|
7149
7443
|
className: getLayoutClassName("rightSideBarToggle"),
|
7150
|
-
children: /* @__PURE__ */
|
7444
|
+
children: /* @__PURE__ */ jsx39(
|
7151
7445
|
IconButton,
|
7152
7446
|
{
|
7153
7447
|
onClick: () => {
|
7154
7448
|
toggleSidebars("right");
|
7155
7449
|
},
|
7156
7450
|
title: "Toggle right sidebar",
|
7157
|
-
children: /* @__PURE__ */
|
7451
|
+
children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
|
7158
7452
|
}
|
7159
7453
|
)
|
7160
7454
|
}
|
7161
7455
|
)
|
7162
7456
|
] }),
|
7163
|
-
/* @__PURE__ */
|
7457
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
|
7164
7458
|
headerTitle || rootProps.title || "Page",
|
7165
7459
|
headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
|
7166
7460
|
" ",
|
7167
|
-
/* @__PURE__ */
|
7461
|
+
/* @__PURE__ */ jsx39(
|
7168
7462
|
"code",
|
7169
7463
|
{
|
7170
7464
|
className: getLayoutClassName("headerPath"),
|
@@ -7174,30 +7468,30 @@ function Puck({
|
|
7174
7468
|
] })
|
7175
7469
|
] }) }),
|
7176
7470
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
|
7177
|
-
/* @__PURE__ */
|
7471
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
|
7178
7472
|
IconButton,
|
7179
7473
|
{
|
7180
7474
|
onClick: () => {
|
7181
7475
|
return setMenuOpen(!menuOpen);
|
7182
7476
|
},
|
7183
7477
|
title: "Toggle menu bar",
|
7184
|
-
children: menuOpen ? /* @__PURE__ */
|
7478
|
+
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
7185
7479
|
}
|
7186
7480
|
) }),
|
7187
|
-
/* @__PURE__ */
|
7481
|
+
/* @__PURE__ */ jsx39(
|
7188
7482
|
MenuBar,
|
7189
7483
|
{
|
7190
7484
|
appState,
|
7191
7485
|
dispatch,
|
7192
7486
|
onPublish,
|
7193
7487
|
menuOpen,
|
7194
|
-
renderHeaderActions: () => /* @__PURE__ */
|
7488
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7195
7489
|
Button,
|
7196
7490
|
{
|
7197
7491
|
onClick: () => {
|
7198
7492
|
onPublish && onPublish(data);
|
7199
7493
|
},
|
7200
|
-
icon: /* @__PURE__ */
|
7494
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7201
7495
|
children: "Publish"
|
7202
7496
|
}
|
7203
7497
|
) }),
|
@@ -7209,18 +7503,18 @@ function Puck({
|
|
7209
7503
|
}
|
7210
7504
|
),
|
7211
7505
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7212
|
-
/* @__PURE__ */
|
7213
|
-
/* @__PURE__ */
|
7506
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
|
7507
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
|
7214
7508
|
] }),
|
7215
|
-
/* @__PURE__ */
|
7216
|
-
/* @__PURE__ */
|
7509
|
+
/* @__PURE__ */ jsx39(Canvas, {}),
|
7510
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
|
7217
7511
|
SidebarSection,
|
7218
7512
|
{
|
7219
7513
|
noPadding: true,
|
7220
7514
|
noBorderTop: true,
|
7221
7515
|
showBreadcrumbs: true,
|
7222
7516
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7223
|
-
children: /* @__PURE__ */
|
7517
|
+
children: /* @__PURE__ */ jsx39(Fields, {})
|
7224
7518
|
}
|
7225
7519
|
) })
|
7226
7520
|
] })
|
@@ -7228,13 +7522,13 @@ function Puck({
|
|
7228
7522
|
) }) })
|
7229
7523
|
}
|
7230
7524
|
),
|
7231
|
-
/* @__PURE__ */
|
7525
|
+
/* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7232
7526
|
] });
|
7233
7527
|
}
|
7234
7528
|
Puck.Components = Components;
|
7235
7529
|
Puck.Fields = Fields;
|
7236
7530
|
Puck.Outline = Outline;
|
7237
|
-
Puck.Preview =
|
7531
|
+
Puck.Preview = Preview2;
|
7238
7532
|
|
7239
7533
|
// lib/migrate.ts
|
7240
7534
|
init_react_import();
|