@measured/puck 0.18.0-canary.b355ddd → 0.18.0-canary.c6df5b2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-EXKSBUY5.mjs → chunk-CHWFBYEM.mjs} +2 -4
- package/dist/index.css +27 -34
- package/dist/index.d.mts +2 -9
- package/dist/index.d.ts +2 -9
- package/dist/index.js +1244 -954
- package/dist/index.mjs +1146 -853
- package/dist/{resolve-all-data-GYzT3ont.d.mts → resolve-all-data-DzJEE28m.d.mts} +2 -1
- package/dist/{resolve-all-data-GYzT3ont.d.ts → resolve-all-data-DzJEE28m.d.ts} +2 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +2 -4
- package/dist/rsc.mjs +1 -1
- package/package.json +3 -4
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
|
|
@@ -962,6 +963,7 @@ var defaultAppState = {
|
|
962
963
|
itemSelector: null,
|
963
964
|
componentList: {},
|
964
965
|
isDragging: false,
|
966
|
+
previewMode: "edit",
|
965
967
|
viewports: {
|
966
968
|
current: {
|
967
969
|
width: defaultViewports[0].width,
|
@@ -1084,7 +1086,7 @@ init_react_import();
|
|
1084
1086
|
import { DragDropProvider } from "@dnd-kit/react";
|
1085
1087
|
import { useState as useState5 } from "react";
|
1086
1088
|
|
1087
|
-
// lib/dnd-kit/safe.ts
|
1089
|
+
// lib/dnd/dnd-kit/safe.ts
|
1088
1090
|
init_react_import();
|
1089
1091
|
import {
|
1090
1092
|
useDraggable,
|
@@ -1164,8 +1166,53 @@ var Sortable = ({
|
|
1164
1166
|
return children({ status, ref: sortableRef });
|
1165
1167
|
};
|
1166
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
|
+
|
1167
1214
|
// components/AutoField/fields/ArrayField/index.tsx
|
1168
|
-
import { jsx as
|
1215
|
+
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
1169
1216
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
1170
1217
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
1171
1218
|
var ArrayField = ({
|
@@ -1176,10 +1223,10 @@ var ArrayField = ({
|
|
1176
1223
|
label,
|
1177
1224
|
readOnly,
|
1178
1225
|
id,
|
1179
|
-
Label: Label2 = (props) => /* @__PURE__ */
|
1226
|
+
Label: Label2 = (props) => /* @__PURE__ */ jsx8("div", __spreadValues({}, props))
|
1180
1227
|
}) => {
|
1181
1228
|
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
1182
|
-
const readOnlyFields =
|
1229
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
1183
1230
|
const value = _value;
|
1184
1231
|
const arrayState = state.ui.arrayState[id] || {
|
1185
1232
|
items: Array.from(value || []).map((item, idx) => {
|
@@ -1239,14 +1286,14 @@ var ArrayField = ({
|
|
1239
1286
|
return null;
|
1240
1287
|
}
|
1241
1288
|
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
1242
|
-
return /* @__PURE__ */
|
1289
|
+
return /* @__PURE__ */ jsx8(
|
1243
1290
|
Label2,
|
1244
1291
|
{
|
1245
1292
|
label: label || name,
|
1246
|
-
icon: /* @__PURE__ */
|
1293
|
+
icon: /* @__PURE__ */ jsx8(List, { size: 16 }),
|
1247
1294
|
el: "div",
|
1248
1295
|
readOnly,
|
1249
|
-
children: /* @__PURE__ */
|
1296
|
+
children: /* @__PURE__ */ jsx8(
|
1250
1297
|
SortableProvider,
|
1251
1298
|
{
|
1252
1299
|
onMove: (move) => {
|
@@ -1282,7 +1329,7 @@ var ArrayField = ({
|
|
1282
1329
|
localState.arrayState.items.map((item, i) => {
|
1283
1330
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
1284
1331
|
const data = Array.from(localState.value || [])[i] || {};
|
1285
|
-
return /* @__PURE__ */
|
1332
|
+
return /* @__PURE__ */ jsx8(
|
1286
1333
|
Sortable,
|
1287
1334
|
{
|
1288
1335
|
id: _arrayId,
|
@@ -1323,7 +1370,7 @@ var ArrayField = ({
|
|
1323
1370
|
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
1324
1371
|
/* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
|
1325
1372
|
!readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
|
1326
|
-
/* @__PURE__ */
|
1373
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
1327
1374
|
IconButton,
|
1328
1375
|
{
|
1329
1376
|
type: "button",
|
@@ -1340,10 +1387,10 @@ var ArrayField = ({
|
|
1340
1387
|
);
|
1341
1388
|
},
|
1342
1389
|
title: "Duplicate",
|
1343
|
-
children: /* @__PURE__ */
|
1390
|
+
children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
|
1344
1391
|
}
|
1345
1392
|
) }),
|
1346
|
-
/* @__PURE__ */
|
1393
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
1347
1394
|
IconButton,
|
1348
1395
|
{
|
1349
1396
|
type: "button",
|
@@ -1364,39 +1411,56 @@ var ArrayField = ({
|
|
1364
1411
|
);
|
1365
1412
|
},
|
1366
1413
|
title: "Delete",
|
1367
|
-
children: /* @__PURE__ */
|
1414
|
+
children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
|
1368
1415
|
}
|
1369
1416
|
) })
|
1370
1417
|
] }),
|
1371
|
-
/* @__PURE__ */
|
1418
|
+
/* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(DragIcon, {}) })
|
1372
1419
|
] })
|
1373
1420
|
]
|
1374
1421
|
}
|
1375
1422
|
),
|
1376
|
-
/* @__PURE__ */
|
1377
|
-
const subField = field.arrayFields[
|
1378
|
-
const
|
1379
|
-
const
|
1380
|
-
const
|
1381
|
-
|
1382
|
-
|
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,
|
1383
1435
|
{
|
1384
|
-
name:
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
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
|
+
)
|
1398
1462
|
},
|
1399
|
-
|
1463
|
+
subPath
|
1400
1464
|
);
|
1401
1465
|
}) }) })
|
1402
1466
|
]
|
@@ -1406,7 +1470,7 @@ var ArrayField = ({
|
|
1406
1470
|
_arrayId
|
1407
1471
|
);
|
1408
1472
|
}),
|
1409
|
-
!addDisabled && /* @__PURE__ */
|
1473
|
+
!addDisabled && /* @__PURE__ */ jsx8(
|
1410
1474
|
"button",
|
1411
1475
|
{
|
1412
1476
|
type: "button",
|
@@ -1420,7 +1484,7 @@ var ArrayField = ({
|
|
1420
1484
|
const newArrayState = regenerateArrayState(newValue);
|
1421
1485
|
onChange(newValue, mapArrayStateToUi(newArrayState));
|
1422
1486
|
},
|
1423
|
-
children: /* @__PURE__ */
|
1487
|
+
children: /* @__PURE__ */ jsx8(Plus, { size: 21 })
|
1424
1488
|
}
|
1425
1489
|
)
|
1426
1490
|
]
|
@@ -1434,7 +1498,7 @@ var ArrayField = ({
|
|
1434
1498
|
|
1435
1499
|
// components/AutoField/fields/DefaultField/index.tsx
|
1436
1500
|
init_react_import();
|
1437
|
-
import { Fragment as Fragment2, jsx as
|
1501
|
+
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
1438
1502
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
1439
1503
|
var DefaultField = ({
|
1440
1504
|
field,
|
@@ -1446,16 +1510,16 @@ var DefaultField = ({
|
|
1446
1510
|
Label: Label2,
|
1447
1511
|
id
|
1448
1512
|
}) => {
|
1449
|
-
return /* @__PURE__ */
|
1513
|
+
return /* @__PURE__ */ jsx9(
|
1450
1514
|
Label2,
|
1451
1515
|
{
|
1452
1516
|
label: label || name,
|
1453
1517
|
icon: /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
1454
|
-
field.type === "text" && /* @__PURE__ */
|
1455
|
-
field.type === "number" && /* @__PURE__ */
|
1518
|
+
field.type === "text" && /* @__PURE__ */ jsx9(Type, { size: 16 }),
|
1519
|
+
field.type === "number" && /* @__PURE__ */ jsx9(Hash, { size: 16 })
|
1456
1520
|
] }),
|
1457
1521
|
readOnly,
|
1458
|
-
children: /* @__PURE__ */
|
1522
|
+
children: /* @__PURE__ */ jsx9(
|
1459
1523
|
"input",
|
1460
1524
|
{
|
1461
1525
|
className: getClassName6("input"),
|
@@ -1489,7 +1553,7 @@ import { useEffect as useEffect8 } from "react";
|
|
1489
1553
|
// components/ExternalInput/index.tsx
|
1490
1554
|
init_react_import();
|
1491
1555
|
import {
|
1492
|
-
useMemo,
|
1556
|
+
useMemo as useMemo2,
|
1493
1557
|
useEffect as useEffect7,
|
1494
1558
|
useState as useState9,
|
1495
1559
|
useCallback as useCallback4,
|
@@ -1510,7 +1574,7 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1510
1574
|
|
1511
1575
|
// components/Modal/index.tsx
|
1512
1576
|
import { createPortal } from "react-dom";
|
1513
|
-
import { jsx as
|
1577
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
1514
1578
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1515
1579
|
var Modal = ({
|
1516
1580
|
children,
|
@@ -1522,10 +1586,10 @@ var Modal = ({
|
|
1522
1586
|
setRootEl(document.getElementById("puck-portal-root"));
|
1523
1587
|
}, []);
|
1524
1588
|
if (!rootEl) {
|
1525
|
-
return /* @__PURE__ */
|
1589
|
+
return /* @__PURE__ */ jsx10("div", {});
|
1526
1590
|
}
|
1527
1591
|
return createPortal(
|
1528
|
-
/* @__PURE__ */
|
1592
|
+
/* @__PURE__ */ jsx10("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx10(
|
1529
1593
|
"div",
|
1530
1594
|
{
|
1531
1595
|
className: getClassName7("inner"),
|
@@ -1545,11 +1609,11 @@ init_react_import();
|
|
1545
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" };
|
1546
1610
|
|
1547
1611
|
// components/Heading/index.tsx
|
1548
|
-
import { jsx as
|
1612
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
1549
1613
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1550
1614
|
var Heading = ({ children, rank, size = "m" }) => {
|
1551
1615
|
const Tag = rank ? `h${rank}` : "span";
|
1552
|
-
return /* @__PURE__ */
|
1616
|
+
return /* @__PURE__ */ jsx11(
|
1553
1617
|
Tag,
|
1554
1618
|
{
|
1555
1619
|
className: getClassName8({
|
@@ -1585,7 +1649,7 @@ var filterDataAttrs = (props) => {
|
|
1585
1649
|
};
|
1586
1650
|
|
1587
1651
|
// components/Button/Button.tsx
|
1588
|
-
import { jsx as
|
1652
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
1589
1653
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1590
1654
|
var Button = (_a) => {
|
1591
1655
|
var _b = _a, {
|
@@ -1644,9 +1708,9 @@ var Button = (_a) => {
|
|
1644
1708
|
href
|
1645
1709
|
}, dataAttrs), {
|
1646
1710
|
children: [
|
1647
|
-
icon && /* @__PURE__ */
|
1711
|
+
icon && /* @__PURE__ */ jsx12("div", { className: getClassName9("icon"), children: icon }),
|
1648
1712
|
children,
|
1649
|
-
loading && /* @__PURE__ */
|
1713
|
+
loading && /* @__PURE__ */ jsx12("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx12(Loader, { size: 14 }) })
|
1650
1714
|
]
|
1651
1715
|
})
|
1652
1716
|
);
|
@@ -1654,7 +1718,7 @@ var Button = (_a) => {
|
|
1654
1718
|
};
|
1655
1719
|
|
1656
1720
|
// components/ExternalInput/index.tsx
|
1657
|
-
import { Fragment as Fragment3, jsx as
|
1721
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
1658
1722
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1659
1723
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1660
1724
|
var dataCache = {};
|
@@ -1677,10 +1741,10 @@ var ExternalInput = ({
|
|
1677
1741
|
const hasFilterFields = !!filterFields;
|
1678
1742
|
const [filters, setFilters] = useState9(field.initialFilters || {});
|
1679
1743
|
const [filtersToggled, setFiltersToggled] = useState9(hasFilterFields);
|
1680
|
-
const mappedData =
|
1744
|
+
const mappedData = useMemo2(() => {
|
1681
1745
|
return data.map(mapRow);
|
1682
1746
|
}, [data]);
|
1683
|
-
const keys =
|
1747
|
+
const keys = useMemo2(() => {
|
1684
1748
|
const validKeys = /* @__PURE__ */ new Set();
|
1685
1749
|
for (const item of mappedData) {
|
1686
1750
|
for (const key of Object.keys(item)) {
|
@@ -1727,7 +1791,7 @@ var ExternalInput = ({
|
|
1727
1791
|
id,
|
1728
1792
|
children: [
|
1729
1793
|
/* @__PURE__ */ jsxs6("div", { className: getClassName10("actions"), children: [
|
1730
|
-
/* @__PURE__ */
|
1794
|
+
/* @__PURE__ */ jsx13(
|
1731
1795
|
"button",
|
1732
1796
|
{
|
1733
1797
|
type: "button",
|
@@ -1735,12 +1799,12 @@ var ExternalInput = ({
|
|
1735
1799
|
className: getClassName10("button"),
|
1736
1800
|
disabled: readOnly,
|
1737
1801
|
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
1738
|
-
/* @__PURE__ */
|
1739
|
-
/* @__PURE__ */
|
1802
|
+
/* @__PURE__ */ jsx13(Link, { size: "16" }),
|
1803
|
+
/* @__PURE__ */ jsx13("span", { children: field.placeholder })
|
1740
1804
|
] })
|
1741
1805
|
}
|
1742
1806
|
),
|
1743
|
-
value && /* @__PURE__ */
|
1807
|
+
value && /* @__PURE__ */ jsx13(
|
1744
1808
|
"button",
|
1745
1809
|
{
|
1746
1810
|
type: "button",
|
@@ -1749,11 +1813,11 @@ var ExternalInput = ({
|
|
1749
1813
|
onChange(null);
|
1750
1814
|
},
|
1751
1815
|
disabled: readOnly,
|
1752
|
-
children: /* @__PURE__ */
|
1816
|
+
children: /* @__PURE__ */ jsx13(LockOpen, { size: 16 })
|
1753
1817
|
}
|
1754
1818
|
)
|
1755
1819
|
] }),
|
1756
|
-
/* @__PURE__ */
|
1820
|
+
/* @__PURE__ */ jsx13(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
|
1757
1821
|
"form",
|
1758
1822
|
{
|
1759
1823
|
className: getClassNameModal({
|
@@ -1767,11 +1831,11 @@ var ExternalInput = ({
|
|
1767
1831
|
search(searchQuery, filters);
|
1768
1832
|
},
|
1769
1833
|
children: [
|
1770
|
-
/* @__PURE__ */
|
1834
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
|
1771
1835
|
/* @__PURE__ */ jsxs6("label", { className: getClassNameModal("search"), children: [
|
1772
|
-
/* @__PURE__ */
|
1773
|
-
/* @__PURE__ */
|
1774
|
-
/* @__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(
|
1775
1839
|
"input",
|
1776
1840
|
{
|
1777
1841
|
className: getClassNameModal("searchInput"),
|
@@ -1787,8 +1851,8 @@ var ExternalInput = ({
|
|
1787
1851
|
)
|
1788
1852
|
] }),
|
1789
1853
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchActions"), children: [
|
1790
|
-
/* @__PURE__ */
|
1791
|
-
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(
|
1792
1856
|
IconButton,
|
1793
1857
|
{
|
1794
1858
|
title: "Toggle filters",
|
@@ -1797,15 +1861,15 @@ var ExternalInput = ({
|
|
1797
1861
|
e.stopPropagation();
|
1798
1862
|
setFiltersToggled(!filtersToggled);
|
1799
1863
|
},
|
1800
|
-
children: /* @__PURE__ */
|
1864
|
+
children: /* @__PURE__ */ jsx13(SlidersHorizontal, { size: 20 })
|
1801
1865
|
}
|
1802
1866
|
) })
|
1803
1867
|
] })
|
1804
|
-
] }) : /* @__PURE__ */
|
1868
|
+
] }) : /* @__PURE__ */ jsx13(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
1805
1869
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("grid"), children: [
|
1806
|
-
hasFilterFields && /* @__PURE__ */
|
1870
|
+
hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
1807
1871
|
const filterField = filterFields[fieldName];
|
1808
|
-
return /* @__PURE__ */
|
1872
|
+
return /* @__PURE__ */ jsx13(
|
1809
1873
|
AutoFieldPrivate,
|
1810
1874
|
{
|
1811
1875
|
field: filterField,
|
@@ -1824,7 +1888,7 @@ var ExternalInput = ({
|
|
1824
1888
|
}) }),
|
1825
1889
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("tableWrapper"), children: [
|
1826
1890
|
/* @__PURE__ */ jsxs6("table", { className: getClassNameModal("table"), children: [
|
1827
|
-
/* @__PURE__ */
|
1891
|
+
/* @__PURE__ */ jsx13("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx13("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx13(
|
1828
1892
|
"th",
|
1829
1893
|
{
|
1830
1894
|
className: getClassNameModal("th"),
|
@@ -1833,8 +1897,8 @@ var ExternalInput = ({
|
|
1833
1897
|
},
|
1834
1898
|
key
|
1835
1899
|
)) }) }),
|
1836
|
-
/* @__PURE__ */
|
1837
|
-
return /* @__PURE__ */
|
1900
|
+
/* @__PURE__ */ jsx13("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
1901
|
+
return /* @__PURE__ */ jsx13(
|
1838
1902
|
"tr",
|
1839
1903
|
{
|
1840
1904
|
style: { whiteSpace: "nowrap" },
|
@@ -1843,16 +1907,16 @@ var ExternalInput = ({
|
|
1843
1907
|
onChange(mapProp(data[i]));
|
1844
1908
|
setOpen(false);
|
1845
1909
|
},
|
1846
|
-
children: keys.map((key) => /* @__PURE__ */
|
1910
|
+
children: keys.map((key) => /* @__PURE__ */ jsx13("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
1847
1911
|
},
|
1848
1912
|
i
|
1849
1913
|
);
|
1850
1914
|
}) })
|
1851
1915
|
] }),
|
1852
|
-
/* @__PURE__ */
|
1916
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx13(Loader, { size: 24 }) })
|
1853
1917
|
] })
|
1854
1918
|
] }),
|
1855
|
-
/* @__PURE__ */
|
1919
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx13(Footer, { items: mappedData }) })
|
1856
1920
|
]
|
1857
1921
|
}
|
1858
1922
|
) })
|
@@ -1862,7 +1926,7 @@ var ExternalInput = ({
|
|
1862
1926
|
};
|
1863
1927
|
|
1864
1928
|
// components/AutoField/fields/ExternalField/index.tsx
|
1865
|
-
import { jsx as
|
1929
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
1866
1930
|
var ExternalField = ({
|
1867
1931
|
field,
|
1868
1932
|
onChange,
|
@@ -1886,7 +1950,7 @@ var ExternalField = ({
|
|
1886
1950
|
if (field.type !== "external") {
|
1887
1951
|
return null;
|
1888
1952
|
}
|
1889
|
-
return /* @__PURE__ */
|
1953
|
+
return /* @__PURE__ */ jsx14(Label2, { label: label || name, icon: /* @__PURE__ */ jsx14(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx14(
|
1890
1954
|
ExternalInput,
|
1891
1955
|
{
|
1892
1956
|
name,
|
@@ -1911,7 +1975,7 @@ var ExternalField = ({
|
|
1911
1975
|
|
1912
1976
|
// components/AutoField/fields/RadioField/index.tsx
|
1913
1977
|
init_react_import();
|
1914
|
-
import { useMemo as
|
1978
|
+
import { useMemo as useMemo3 } from "react";
|
1915
1979
|
|
1916
1980
|
// lib/safe-json-parse.ts
|
1917
1981
|
init_react_import();
|
@@ -1925,7 +1989,7 @@ var safeJsonParse = (str) => {
|
|
1925
1989
|
};
|
1926
1990
|
|
1927
1991
|
// components/AutoField/fields/RadioField/index.tsx
|
1928
|
-
import { jsx as
|
1992
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
1929
1993
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
1930
1994
|
var RadioField = ({
|
1931
1995
|
field,
|
@@ -1937,26 +2001,26 @@ var RadioField = ({
|
|
1937
2001
|
label,
|
1938
2002
|
Label: Label2
|
1939
2003
|
}) => {
|
1940
|
-
const flatOptions =
|
2004
|
+
const flatOptions = useMemo3(
|
1941
2005
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
1942
2006
|
[field]
|
1943
2007
|
);
|
1944
2008
|
if (field.type !== "radio" || !field.options) {
|
1945
2009
|
return null;
|
1946
2010
|
}
|
1947
|
-
return /* @__PURE__ */
|
2011
|
+
return /* @__PURE__ */ jsx15(
|
1948
2012
|
Label2,
|
1949
2013
|
{
|
1950
|
-
icon: /* @__PURE__ */
|
2014
|
+
icon: /* @__PURE__ */ jsx15(CircleCheckBig, { size: 16 }),
|
1951
2015
|
label: label || name,
|
1952
2016
|
readOnly,
|
1953
2017
|
el: "div",
|
1954
|
-
children: /* @__PURE__ */
|
2018
|
+
children: /* @__PURE__ */ jsx15("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs7(
|
1955
2019
|
"label",
|
1956
2020
|
{
|
1957
2021
|
className: getClassName11("radio"),
|
1958
2022
|
children: [
|
1959
|
-
/* @__PURE__ */
|
2023
|
+
/* @__PURE__ */ jsx15(
|
1960
2024
|
"input",
|
1961
2025
|
{
|
1962
2026
|
type: "radio",
|
@@ -1976,7 +2040,7 @@ var RadioField = ({
|
|
1976
2040
|
checked: value === option.value
|
1977
2041
|
}
|
1978
2042
|
),
|
1979
|
-
/* @__PURE__ */
|
2043
|
+
/* @__PURE__ */ jsx15("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
1980
2044
|
]
|
1981
2045
|
},
|
1982
2046
|
option.label + option.value
|
@@ -1987,8 +2051,8 @@ var RadioField = ({
|
|
1987
2051
|
|
1988
2052
|
// components/AutoField/fields/SelectField/index.tsx
|
1989
2053
|
init_react_import();
|
1990
|
-
import { useMemo as
|
1991
|
-
import { jsx as
|
2054
|
+
import { useMemo as useMemo4 } from "react";
|
2055
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
1992
2056
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
1993
2057
|
var SelectField = ({
|
1994
2058
|
field,
|
@@ -2000,20 +2064,20 @@ var SelectField = ({
|
|
2000
2064
|
readOnly,
|
2001
2065
|
id
|
2002
2066
|
}) => {
|
2003
|
-
const flatOptions =
|
2067
|
+
const flatOptions = useMemo4(
|
2004
2068
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2005
2069
|
[field]
|
2006
2070
|
);
|
2007
2071
|
if (field.type !== "select" || !field.options) {
|
2008
2072
|
return null;
|
2009
2073
|
}
|
2010
|
-
return /* @__PURE__ */
|
2074
|
+
return /* @__PURE__ */ jsx16(
|
2011
2075
|
Label2,
|
2012
2076
|
{
|
2013
2077
|
label: label || name,
|
2014
|
-
icon: /* @__PURE__ */
|
2078
|
+
icon: /* @__PURE__ */ jsx16(ChevronDown, { size: 16 }),
|
2015
2079
|
readOnly,
|
2016
|
-
children: /* @__PURE__ */
|
2080
|
+
children: /* @__PURE__ */ jsx16(
|
2017
2081
|
"select",
|
2018
2082
|
{
|
2019
2083
|
id,
|
@@ -2030,7 +2094,7 @@ var SelectField = ({
|
|
2030
2094
|
}
|
2031
2095
|
},
|
2032
2096
|
value,
|
2033
|
-
children: field.options.map((option) => /* @__PURE__ */
|
2097
|
+
children: field.options.map((option) => /* @__PURE__ */ jsx16(
|
2034
2098
|
"option",
|
2035
2099
|
{
|
2036
2100
|
label: option.label,
|
@@ -2046,7 +2110,7 @@ var SelectField = ({
|
|
2046
2110
|
|
2047
2111
|
// components/AutoField/fields/TextareaField/index.tsx
|
2048
2112
|
init_react_import();
|
2049
|
-
import { jsx as
|
2113
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
2050
2114
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2051
2115
|
var TextareaField = ({
|
2052
2116
|
onChange,
|
@@ -2057,7 +2121,7 @@ var TextareaField = ({
|
|
2057
2121
|
Label: Label2,
|
2058
2122
|
id
|
2059
2123
|
}) => {
|
2060
|
-
return /* @__PURE__ */
|
2124
|
+
return /* @__PURE__ */ jsx17(Label2, { label: label || name, icon: /* @__PURE__ */ jsx17(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx17(
|
2061
2125
|
"textarea",
|
2062
2126
|
{
|
2063
2127
|
id,
|
@@ -2084,7 +2148,7 @@ init_react_import();
|
|
2084
2148
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2085
2149
|
|
2086
2150
|
// components/AutoField/fields/ObjectField/index.tsx
|
2087
|
-
import { jsx as
|
2151
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
2088
2152
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2089
2153
|
var ObjectField = ({
|
2090
2154
|
field,
|
@@ -2096,43 +2160,54 @@ var ObjectField = ({
|
|
2096
2160
|
readOnly,
|
2097
2161
|
id
|
2098
2162
|
}) => {
|
2099
|
-
const {
|
2163
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2100
2164
|
if (field.type !== "object" || !field.objectFields) {
|
2101
2165
|
return null;
|
2102
2166
|
}
|
2103
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2104
2167
|
const data = value || {};
|
2105
|
-
return /* @__PURE__ */
|
2168
|
+
return /* @__PURE__ */ jsx18(
|
2106
2169
|
Label2,
|
2107
2170
|
{
|
2108
2171
|
label: label || name,
|
2109
|
-
icon: /* @__PURE__ */
|
2172
|
+
icon: /* @__PURE__ */ jsx18(EllipsisVertical, { size: 16 }),
|
2110
2173
|
el: "div",
|
2111
2174
|
readOnly,
|
2112
|
-
children: /* @__PURE__ */
|
2113
|
-
const subField = field.objectFields[
|
2114
|
-
const
|
2115
|
-
const
|
2116
|
-
const subReadOnly = readOnly ? readOnly :
|
2117
|
-
|
2118
|
-
|
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,
|
2119
2183
|
{
|
2120
|
-
name:
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
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
|
2130
2197
|
}),
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2198
|
+
value: data[subName],
|
2199
|
+
onChange: (val, ui) => {
|
2200
|
+
onChange(
|
2201
|
+
__spreadProps(__spreadValues({}, data), {
|
2202
|
+
[subName]: val
|
2203
|
+
}),
|
2204
|
+
ui
|
2205
|
+
);
|
2206
|
+
}
|
2207
|
+
}
|
2208
|
+
)
|
2134
2209
|
},
|
2135
|
-
|
2210
|
+
subPath
|
2136
2211
|
);
|
2137
2212
|
}) }) })
|
2138
2213
|
}
|
@@ -2158,7 +2233,7 @@ var useSafeId = () => {
|
|
2158
2233
|
};
|
2159
2234
|
|
2160
2235
|
// components/AutoField/index.tsx
|
2161
|
-
import { Fragment as Fragment4, jsx as
|
2236
|
+
import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
2162
2237
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2163
2238
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2164
2239
|
var FieldLabel = ({
|
@@ -2172,14 +2247,14 @@ var FieldLabel = ({
|
|
2172
2247
|
const El = el;
|
2173
2248
|
return /* @__PURE__ */ jsxs8(El, { className, children: [
|
2174
2249
|
/* @__PURE__ */ jsxs8("div", { className: getClassName15("label"), children: [
|
2175
|
-
icon ? /* @__PURE__ */
|
2250
|
+
icon ? /* @__PURE__ */ jsx19("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx19(Fragment4, {}),
|
2176
2251
|
label,
|
2177
|
-
readOnly && /* @__PURE__ */
|
2252
|
+
readOnly && /* @__PURE__ */ jsx19("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx19(Lock, { size: "12" }) })
|
2178
2253
|
] }),
|
2179
2254
|
children
|
2180
2255
|
] });
|
2181
2256
|
};
|
2182
|
-
var
|
2257
|
+
var FieldLabelInternal = ({
|
2183
2258
|
children,
|
2184
2259
|
icon,
|
2185
2260
|
label,
|
@@ -2187,14 +2262,14 @@ var FieldLabelInternal2 = ({
|
|
2187
2262
|
readOnly
|
2188
2263
|
}) => {
|
2189
2264
|
const { overrides } = useAppContext();
|
2190
|
-
const Wrapper =
|
2265
|
+
const Wrapper = useMemo5(
|
2191
2266
|
() => overrides.fieldLabel || FieldLabel,
|
2192
2267
|
[overrides]
|
2193
2268
|
);
|
2194
2269
|
if (!label) {
|
2195
|
-
return /* @__PURE__ */
|
2270
|
+
return /* @__PURE__ */ jsx19(Fragment4, { children });
|
2196
2271
|
}
|
2197
|
-
return /* @__PURE__ */
|
2272
|
+
return /* @__PURE__ */ jsx19(
|
2198
2273
|
Wrapper,
|
2199
2274
|
{
|
2200
2275
|
label,
|
@@ -2208,8 +2283,8 @@ var FieldLabelInternal2 = ({
|
|
2208
2283
|
};
|
2209
2284
|
function AutoFieldInternal(props) {
|
2210
2285
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2211
|
-
const { dispatch, overrides } = useAppContext();
|
2212
|
-
const { id, Label: Label2 =
|
2286
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2287
|
+
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2213
2288
|
const field = props.field;
|
2214
2289
|
const label = field.label;
|
2215
2290
|
const defaultId = useSafeId();
|
@@ -2269,20 +2344,30 @@ function AutoFieldInternal(props) {
|
|
2269
2344
|
return null;
|
2270
2345
|
}
|
2271
2346
|
const CustomField = field.render;
|
2272
|
-
return /* @__PURE__ */
|
2347
|
+
return /* @__PURE__ */ jsx19("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx19("div", { className: getClassName15(), children: /* @__PURE__ */ jsx19(CustomField, __spreadValues({}, mergedProps)) }) });
|
2273
2348
|
}
|
2274
2349
|
const children = defaultFields[field.type](mergedProps);
|
2275
2350
|
const Render2 = render[field.type];
|
2276
|
-
|
2277
|
-
|
2351
|
+
const nestedFieldContext = useContext3(NestedFieldContext);
|
2352
|
+
return /* @__PURE__ */ jsx19(
|
2353
|
+
NestedFieldContext.Provider,
|
2278
2354
|
{
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
onClick: (e) => {
|
2283
|
-
e.stopPropagation();
|
2355
|
+
value: {
|
2356
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2357
|
+
localName: nestedFieldContext.localName
|
2284
2358
|
},
|
2285
|
-
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
|
+
)
|
2286
2371
|
}
|
2287
2372
|
);
|
2288
2373
|
}
|
@@ -2310,11 +2395,11 @@ function AutoFieldPrivate(props) {
|
|
2310
2395
|
value: localValue,
|
2311
2396
|
onChange: onChangeLocal
|
2312
2397
|
};
|
2313
|
-
return /* @__PURE__ */
|
2398
|
+
return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2314
2399
|
}
|
2315
2400
|
function AutoField(props) {
|
2316
|
-
const DefaultLabel =
|
2317
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */
|
2401
|
+
const DefaultLabel = useMemo5(() => {
|
2402
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx19(
|
2318
2403
|
"div",
|
2319
2404
|
__spreadProps(__spreadValues({}, labelProps), {
|
2320
2405
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2322,7 +2407,7 @@ function AutoField(props) {
|
|
2322
2407
|
);
|
2323
2408
|
return DefaultLabel2;
|
2324
2409
|
}, [props.readOnly]);
|
2325
|
-
return /* @__PURE__ */
|
2410
|
+
return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2326
2411
|
}
|
2327
2412
|
|
2328
2413
|
// components/Drawer/index.tsx
|
@@ -2333,17 +2418,18 @@ init_react_import();
|
|
2333
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" };
|
2334
2419
|
|
2335
2420
|
// components/Drawer/index.tsx
|
2336
|
-
import { useMemo as
|
2421
|
+
import { useMemo as useMemo9, useState as useState18 } from "react";
|
2337
2422
|
|
2338
2423
|
// components/DragDropContext/index.tsx
|
2339
2424
|
init_react_import();
|
2340
2425
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
2341
2426
|
import {
|
2342
|
-
createContext as
|
2343
|
-
useCallback as
|
2344
|
-
useContext as
|
2345
|
-
useEffect as
|
2346
|
-
|
2427
|
+
createContext as createContext4,
|
2428
|
+
useCallback as useCallback11,
|
2429
|
+
useContext as useContext7,
|
2430
|
+
useEffect as useEffect15,
|
2431
|
+
useId,
|
2432
|
+
useRef as useRef4,
|
2347
2433
|
useState as useState17
|
2348
2434
|
} from "react";
|
2349
2435
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
@@ -2352,22 +2438,21 @@ import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
|
2352
2438
|
init_react_import();
|
2353
2439
|
import {
|
2354
2440
|
forwardRef as forwardRef3,
|
2355
|
-
useCallback as
|
2356
|
-
useContext as
|
2357
|
-
useEffect as
|
2358
|
-
useMemo as
|
2359
|
-
useRef as
|
2360
|
-
useState as useState16
|
2441
|
+
useCallback as useCallback10,
|
2442
|
+
useContext as useContext6,
|
2443
|
+
useEffect as useEffect14,
|
2444
|
+
useMemo as useMemo8,
|
2445
|
+
useRef as useRef3
|
2361
2446
|
} from "react";
|
2362
2447
|
|
2363
2448
|
// components/DraggableComponent/index.tsx
|
2364
2449
|
init_react_import();
|
2365
2450
|
import {
|
2366
|
-
useCallback as
|
2367
|
-
useContext as
|
2368
|
-
useEffect as
|
2369
|
-
useMemo as
|
2370
|
-
useRef as
|
2451
|
+
useCallback as useCallback7,
|
2452
|
+
useContext as useContext5,
|
2453
|
+
useEffect as useEffect10,
|
2454
|
+
useMemo as useMemo7,
|
2455
|
+
useRef as useRef2,
|
2371
2456
|
useState as useState13
|
2372
2457
|
} from "react";
|
2373
2458
|
|
@@ -2375,47 +2460,21 @@ import {
|
|
2375
2460
|
init_react_import();
|
2376
2461
|
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
|
2377
2462
|
|
2378
|
-
// lib/use-modifier-held.ts
|
2379
|
-
init_react_import();
|
2380
|
-
import { useEffect as useEffect10, useState as useState12 } from "react";
|
2381
|
-
var useModifierHeld = (modifier) => {
|
2382
|
-
const [modifierHeld, setModifierHeld] = useState12(false);
|
2383
|
-
useEffect10(() => {
|
2384
|
-
function downHandler({ key }) {
|
2385
|
-
if (key === modifier) {
|
2386
|
-
setModifierHeld(true);
|
2387
|
-
}
|
2388
|
-
}
|
2389
|
-
function upHandler({ key }) {
|
2390
|
-
if (key === modifier) {
|
2391
|
-
setModifierHeld(false);
|
2392
|
-
}
|
2393
|
-
}
|
2394
|
-
window.addEventListener("keydown", downHandler);
|
2395
|
-
window.addEventListener("keyup", upHandler);
|
2396
|
-
return () => {
|
2397
|
-
window.removeEventListener("keydown", downHandler);
|
2398
|
-
window.removeEventListener("keyup", upHandler);
|
2399
|
-
};
|
2400
|
-
}, [modifier]);
|
2401
|
-
return modifierHeld;
|
2402
|
-
};
|
2403
|
-
|
2404
2463
|
// components/DraggableComponent/index.tsx
|
2405
2464
|
import { createPortal as createPortal2 } from "react-dom";
|
2406
2465
|
|
2407
|
-
//
|
2466
|
+
// lib/dnd/collision/dynamic/index.ts
|
2408
2467
|
init_react_import();
|
2409
2468
|
import {
|
2410
2469
|
CollisionPriority as CollisionPriority7,
|
2411
2470
|
CollisionType as CollisionType7
|
2412
2471
|
} from "@dnd-kit/abstract";
|
2413
2472
|
|
2414
|
-
//
|
2473
|
+
// lib/dnd/collision/directional/index.ts
|
2415
2474
|
init_react_import();
|
2416
2475
|
import { CollisionType } from "@dnd-kit/abstract";
|
2417
2476
|
|
2418
|
-
//
|
2477
|
+
// lib/dnd/collision/collision-debug.ts
|
2419
2478
|
init_react_import();
|
2420
2479
|
var DEBUG = false;
|
2421
2480
|
var debugElements = {};
|
@@ -2464,7 +2523,7 @@ var collisionDebug = (a, b, id, color, label) => {
|
|
2464
2523
|
});
|
2465
2524
|
};
|
2466
2525
|
|
2467
|
-
//
|
2526
|
+
// lib/dnd/collision/directional/index.ts
|
2468
2527
|
var distanceChange = "increasing";
|
2469
2528
|
var directionalCollision = (input, previous) => {
|
2470
2529
|
var _a;
|
@@ -2497,7 +2556,7 @@ var directionalCollision = (input, previous) => {
|
|
2497
2556
|
return null;
|
2498
2557
|
};
|
2499
2558
|
|
2500
|
-
//
|
2559
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
2501
2560
|
init_react_import();
|
2502
2561
|
var getDirection = (dragAxis, delta) => {
|
2503
2562
|
if (dragAxis === "dynamic") {
|
@@ -2512,7 +2571,7 @@ var getDirection = (dragAxis, delta) => {
|
|
2512
2571
|
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2513
2572
|
};
|
2514
2573
|
|
2515
|
-
//
|
2574
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
2516
2575
|
init_react_import();
|
2517
2576
|
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2518
2577
|
const dragRect = dragShape.boundingRectangle;
|
@@ -2531,7 +2590,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2531
2590
|
return dragRect.right - offset >= dropCenter.x;
|
2532
2591
|
};
|
2533
2592
|
|
2534
|
-
//
|
2593
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2535
2594
|
init_react_import();
|
2536
2595
|
import { Point } from "@dnd-kit/geometry";
|
2537
2596
|
var INTERVAL_SENSITIVITY = 10;
|
@@ -2635,7 +2694,14 @@ var closestCorners = (input) => {
|
|
2635
2694
|
};
|
2636
2695
|
};
|
2637
2696
|
|
2638
|
-
//
|
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
|
2639
2705
|
var flushNext = "";
|
2640
2706
|
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2641
2707
|
var _a, _b, _c, _d, _e;
|
@@ -2647,6 +2713,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2647
2713
|
return null;
|
2648
2714
|
}
|
2649
2715
|
const { center: dragCenter } = dragShape;
|
2716
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2650
2717
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2651
2718
|
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2652
2719
|
direction: interval.direction
|
@@ -2692,7 +2759,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2692
2759
|
flushNext = "";
|
2693
2760
|
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2694
2761
|
}
|
2695
|
-
if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2762
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2696
2763
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2697
2764
|
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2698
2765
|
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
@@ -2753,8 +2820,107 @@ function getDeepScrollPosition(element) {
|
|
2753
2820
|
return totalScroll;
|
2754
2821
|
}
|
2755
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
|
+
|
2756
2922
|
// components/DraggableComponent/index.tsx
|
2757
|
-
import { jsx as
|
2923
|
+
import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
|
2758
2924
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2759
2925
|
var DEBUG2 = false;
|
2760
2926
|
var space = 8;
|
@@ -2768,9 +2934,9 @@ var DefaultActionBar = ({
|
|
2768
2934
|
}) => /* @__PURE__ */ jsxs9(ActionBar, { children: [
|
2769
2935
|
/* @__PURE__ */ jsxs9(ActionBar.Group, { children: [
|
2770
2936
|
parentAction,
|
2771
|
-
label && /* @__PURE__ */
|
2937
|
+
label && /* @__PURE__ */ jsx21(ActionBar.Label, { label })
|
2772
2938
|
] }),
|
2773
|
-
/* @__PURE__ */
|
2939
|
+
/* @__PURE__ */ jsx21(ActionBar.Group, { children })
|
2774
2940
|
] });
|
2775
2941
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
2776
2942
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -2805,10 +2971,9 @@ var DraggableComponent = ({
|
|
2805
2971
|
iframe,
|
2806
2972
|
state
|
2807
2973
|
} = useAppContext();
|
2808
|
-
const
|
2809
|
-
const ctx = useContext2(dropZoneContext);
|
2974
|
+
const ctx = useContext5(dropZoneContext);
|
2810
2975
|
const [localZones, setLocalZones] = useState13({});
|
2811
|
-
const registerLocalZone =
|
2976
|
+
const registerLocalZone = useCallback7(
|
2812
2977
|
(zoneCompound2, active) => {
|
2813
2978
|
var _a;
|
2814
2979
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -2818,7 +2983,7 @@ var DraggableComponent = ({
|
|
2818
2983
|
},
|
2819
2984
|
[setLocalZones]
|
2820
2985
|
);
|
2821
|
-
const unregisterLocalZone =
|
2986
|
+
const unregisterLocalZone = useCallback7(
|
2822
2987
|
(zoneCompound2) => {
|
2823
2988
|
var _a;
|
2824
2989
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -2833,7 +2998,7 @@ var DraggableComponent = ({
|
|
2833
2998
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
2834
2999
|
const { path = [] } = ctx || {};
|
2835
3000
|
const [canDrag, setCanDrag] = useState13(false);
|
2836
|
-
|
3001
|
+
useEffect10(() => {
|
2837
3002
|
var _a;
|
2838
3003
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
2839
3004
|
if (item) {
|
@@ -2843,7 +3008,10 @@ var DraggableComponent = ({
|
|
2843
3008
|
setCanDrag((_a = perms.drag) != null ? _a : true);
|
2844
3009
|
}
|
2845
3010
|
}, [state, index, zoneCompound, getPermissions]);
|
2846
|
-
const userIsDragging =
|
3011
|
+
const userIsDragging = useContextStore(
|
3012
|
+
ZoneStoreContext,
|
3013
|
+
(s) => !!s.draggedItem
|
3014
|
+
);
|
2847
3015
|
const canCollide = canDrag || userIsDragging;
|
2848
3016
|
const disabled = !isEnabled || !canCollide;
|
2849
3017
|
const [dragAxis, setDragAxis] = useState13(userDragAxis || autoDragAxis);
|
@@ -2872,8 +3040,8 @@ var DraggableComponent = ({
|
|
2872
3040
|
}
|
2873
3041
|
});
|
2874
3042
|
const thisIsDragging = status === "dragging";
|
2875
|
-
const ref =
|
2876
|
-
const refSetter =
|
3043
|
+
const ref = useRef2(null);
|
3044
|
+
const refSetter = useCallback7(
|
2877
3045
|
(el) => {
|
2878
3046
|
sortableRef(el);
|
2879
3047
|
if (el) {
|
@@ -2883,13 +3051,13 @@ var DraggableComponent = ({
|
|
2883
3051
|
[sortableRef]
|
2884
3052
|
);
|
2885
3053
|
const [portalEl, setPortalEl] = useState13();
|
2886
|
-
|
3054
|
+
useEffect10(() => {
|
2887
3055
|
var _a, _b, _c;
|
2888
3056
|
setPortalEl(
|
2889
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
|
2890
3058
|
);
|
2891
3059
|
}, [iframe.enabled, ref.current]);
|
2892
|
-
const getStyle =
|
3060
|
+
const getStyle = useCallback7(() => {
|
2893
3061
|
var _a, _b, _c;
|
2894
3062
|
if (!ref.current) return;
|
2895
3063
|
const rect = ref.current.getBoundingClientRect();
|
@@ -2910,10 +3078,10 @@ var DraggableComponent = ({
|
|
2910
3078
|
return style2;
|
2911
3079
|
}, [ref.current]);
|
2912
3080
|
const [style, setStyle] = useState13();
|
2913
|
-
const sync =
|
3081
|
+
const sync = useCallback7(() => {
|
2914
3082
|
setStyle(getStyle());
|
2915
3083
|
}, [ref.current, iframe]);
|
2916
|
-
|
3084
|
+
useEffect10(() => {
|
2917
3085
|
if (ref.current) {
|
2918
3086
|
const observer = new ResizeObserver(sync);
|
2919
3087
|
observer.observe(ref.current);
|
@@ -2922,20 +3090,22 @@ var DraggableComponent = ({
|
|
2922
3090
|
};
|
2923
3091
|
}
|
2924
3092
|
}, [ref.current]);
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
3093
|
+
useEffect10(() => {
|
3094
|
+
if (isSelected) {
|
3095
|
+
ctx == null ? void 0 : ctx.registerPath({
|
3096
|
+
index,
|
3097
|
+
zone: zoneCompound
|
3098
|
+
});
|
3099
|
+
}
|
2930
3100
|
}, [isSelected]);
|
2931
|
-
const CustomActionBar =
|
3101
|
+
const CustomActionBar = useMemo7(
|
2932
3102
|
() => overrides.actionBar || DefaultActionBar,
|
2933
3103
|
[overrides.actionBar]
|
2934
3104
|
);
|
2935
3105
|
const permissions = getPermissions({
|
2936
3106
|
item: selectedItem
|
2937
3107
|
});
|
2938
|
-
const onClick =
|
3108
|
+
const onClick = useCallback7(
|
2939
3109
|
(e) => {
|
2940
3110
|
e.stopPropagation();
|
2941
3111
|
dispatch({
|
@@ -2947,7 +3117,7 @@ var DraggableComponent = ({
|
|
2947
3117
|
},
|
2948
3118
|
[index, zoneCompound, id]
|
2949
3119
|
);
|
2950
|
-
const onSelectParent =
|
3120
|
+
const onSelectParent = useCallback7(() => {
|
2951
3121
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
2952
3122
|
return;
|
2953
3123
|
}
|
@@ -2965,14 +3135,14 @@ var DraggableComponent = ({
|
|
2965
3135
|
}
|
2966
3136
|
});
|
2967
3137
|
}, [ctx, path]);
|
2968
|
-
const onDuplicate =
|
3138
|
+
const onDuplicate = useCallback7(() => {
|
2969
3139
|
dispatch({
|
2970
3140
|
type: "duplicate",
|
2971
3141
|
sourceIndex: index,
|
2972
3142
|
sourceZone: zoneCompound
|
2973
3143
|
});
|
2974
3144
|
}, [index, zoneCompound]);
|
2975
|
-
const onDelete =
|
3145
|
+
const onDelete = useCallback7(() => {
|
2976
3146
|
dispatch({
|
2977
3147
|
type: "remove",
|
2978
3148
|
index,
|
@@ -2981,7 +3151,7 @@ var DraggableComponent = ({
|
|
2981
3151
|
}, [index, zoneCompound]);
|
2982
3152
|
const [hover, setHover] = useState13(false);
|
2983
3153
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
2984
|
-
|
3154
|
+
useEffect10(() => {
|
2985
3155
|
if (!ref.current) {
|
2986
3156
|
return;
|
2987
3157
|
}
|
@@ -3031,7 +3201,7 @@ var DraggableComponent = ({
|
|
3031
3201
|
thisIsDragging,
|
3032
3202
|
inDroppableZone
|
3033
3203
|
]);
|
3034
|
-
|
3204
|
+
useEffect10(() => {
|
3035
3205
|
if (ref.current && disabled) {
|
3036
3206
|
ref.current.setAttribute("data-puck-disabled", "");
|
3037
3207
|
return () => {
|
@@ -3041,7 +3211,7 @@ var DraggableComponent = ({
|
|
3041
3211
|
}
|
3042
3212
|
}, [disabled, ref]);
|
3043
3213
|
const [isVisible, setIsVisible] = useState13(false);
|
3044
|
-
|
3214
|
+
useEffect10(() => {
|
3045
3215
|
sync();
|
3046
3216
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3047
3217
|
setIsVisible(true);
|
@@ -3049,7 +3219,7 @@ var DraggableComponent = ({
|
|
3049
3219
|
setIsVisible(false);
|
3050
3220
|
}
|
3051
3221
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3052
|
-
const syncActionsPosition =
|
3222
|
+
const syncActionsPosition = useCallback7(
|
3053
3223
|
(el) => {
|
3054
3224
|
if (el) {
|
3055
3225
|
const view = el.ownerDocument.defaultView;
|
@@ -3066,7 +3236,7 @@ var DraggableComponent = ({
|
|
3066
3236
|
},
|
3067
3237
|
[zoomConfig]
|
3068
3238
|
);
|
3069
|
-
|
3239
|
+
useEffect10(() => {
|
3070
3240
|
if (userDragAxis) {
|
3071
3241
|
setDragAxis(userDragAxis);
|
3072
3242
|
return;
|
@@ -3080,7 +3250,7 @@ var DraggableComponent = ({
|
|
3080
3250
|
}
|
3081
3251
|
setDragAxis(autoDragAxis);
|
3082
3252
|
}, [ref, userDragAxis, autoDragAxis]);
|
3083
|
-
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 }) });
|
3084
3254
|
return /* @__PURE__ */ jsxs9(
|
3085
3255
|
DropZoneProvider,
|
3086
3256
|
{
|
@@ -3101,22 +3271,21 @@ var DraggableComponent = ({
|
|
3101
3271
|
className: getClassName16({
|
3102
3272
|
isSelected,
|
3103
3273
|
isDragging: thisIsDragging,
|
3104
|
-
isModifierHeld,
|
3105
3274
|
hover: hover || indicativeHover
|
3106
3275
|
}),
|
3107
3276
|
style: __spreadValues({}, style),
|
3108
3277
|
"data-puck-overlay": true,
|
3109
3278
|
children: [
|
3110
3279
|
debug,
|
3111
|
-
isLoading && /* @__PURE__ */
|
3112
|
-
/* @__PURE__ */
|
3280
|
+
isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
|
3281
|
+
/* @__PURE__ */ jsx21(
|
3113
3282
|
"div",
|
3114
3283
|
{
|
3115
3284
|
className: getClassName16("actionsOverlay"),
|
3116
3285
|
style: {
|
3117
3286
|
top: actionsOverlayTop / zoomConfig.zoom
|
3118
3287
|
},
|
3119
|
-
children: /* @__PURE__ */
|
3288
|
+
children: /* @__PURE__ */ jsx21(
|
3120
3289
|
"div",
|
3121
3290
|
{
|
3122
3291
|
className: getClassName16("actions"),
|
@@ -3134,8 +3303,8 @@ var DraggableComponent = ({
|
|
3134
3303
|
parentAction,
|
3135
3304
|
label: DEBUG2 ? id : label,
|
3136
3305
|
children: [
|
3137
|
-
permissions.duplicate && /* @__PURE__ */
|
3138
|
-
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 }) })
|
3139
3308
|
]
|
3140
3309
|
}
|
3141
3310
|
)
|
@@ -3143,7 +3312,7 @@ var DraggableComponent = ({
|
|
3143
3312
|
)
|
3144
3313
|
}
|
3145
3314
|
),
|
3146
|
-
/* @__PURE__ */
|
3315
|
+
/* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
|
3147
3316
|
]
|
3148
3317
|
}
|
3149
3318
|
),
|
@@ -3159,98 +3328,26 @@ var DraggableComponent = ({
|
|
3159
3328
|
init_react_import();
|
3160
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" };
|
3161
3330
|
|
3162
|
-
// components/DropZone/
|
3163
|
-
init_react_import();
|
3164
|
-
import {
|
3165
|
-
createContext as createContext2,
|
3166
|
-
useCallback as useCallback7,
|
3167
|
-
useMemo as useMemo6,
|
3168
|
-
useState as useState14
|
3169
|
-
} from "react";
|
3170
|
-
import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
|
3171
|
-
var dropZoneContext = createContext2(null);
|
3172
|
-
var DropZoneProvider = ({
|
3173
|
-
children,
|
3174
|
-
value
|
3175
|
-
}) => {
|
3176
|
-
const [hoveringComponent, setHoveringComponent] = useState14();
|
3177
|
-
const [areasWithZones, setAreasWithZones] = useState14(
|
3178
|
-
{}
|
3179
|
-
);
|
3180
|
-
const [activeZones, setActiveZones] = useState14({});
|
3181
|
-
const { dispatch = null } = value ? value : {};
|
3182
|
-
const registerZoneArea = useCallback7(
|
3183
|
-
(area) => {
|
3184
|
-
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3185
|
-
},
|
3186
|
-
[setAreasWithZones]
|
3187
|
-
);
|
3188
|
-
const registerZone = useCallback7(
|
3189
|
-
(zoneCompound) => {
|
3190
|
-
if (!dispatch) {
|
3191
|
-
return;
|
3192
|
-
}
|
3193
|
-
dispatch({
|
3194
|
-
type: "registerZone",
|
3195
|
-
zone: zoneCompound
|
3196
|
-
});
|
3197
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
3198
|
-
},
|
3199
|
-
[setActiveZones, dispatch]
|
3200
|
-
);
|
3201
|
-
const unregisterZone = useCallback7(
|
3202
|
-
(zoneCompound) => {
|
3203
|
-
if (!dispatch) {
|
3204
|
-
return;
|
3205
|
-
}
|
3206
|
-
dispatch({
|
3207
|
-
type: "unregisterZone",
|
3208
|
-
zone: zoneCompound
|
3209
|
-
});
|
3210
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
3211
|
-
[zoneCompound]: false
|
3212
|
-
}));
|
3213
|
-
},
|
3214
|
-
[setActiveZones, dispatch]
|
3215
|
-
);
|
3216
|
-
const memoValue = useMemo6(
|
3217
|
-
() => __spreadValues({
|
3218
|
-
hoveringComponent,
|
3219
|
-
setHoveringComponent,
|
3220
|
-
registerZoneArea,
|
3221
|
-
areasWithZones,
|
3222
|
-
registerZone,
|
3223
|
-
unregisterZone,
|
3224
|
-
activeZones
|
3225
|
-
}, value),
|
3226
|
-
[value, hoveringComponent, areasWithZones, activeZones]
|
3227
|
-
);
|
3228
|
-
return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
|
3229
|
-
};
|
3230
|
-
|
3231
|
-
// lib/insert.ts
|
3232
|
-
init_react_import();
|
3233
|
-
var insert = (list, index, item) => {
|
3234
|
-
const result = Array.from(list);
|
3235
|
-
result.splice(index, 0, item);
|
3236
|
-
return result;
|
3237
|
-
};
|
3238
|
-
|
3239
|
-
// components/DropZone/use-min-empty-height.ts
|
3331
|
+
// components/DropZone/lib/use-min-empty-height.ts
|
3240
3332
|
init_react_import();
|
3241
|
-
import { useEffect as
|
3333
|
+
import { useEffect as useEffect11, useState as useState14 } from "react";
|
3242
3334
|
var useMinEmptyHeight = ({
|
3243
|
-
draggedItem,
|
3244
3335
|
zoneCompound,
|
3245
3336
|
userMinEmptyHeight,
|
3246
3337
|
ref
|
3247
3338
|
}) => {
|
3248
|
-
const [prevHeight, setPrevHeight] =
|
3249
|
-
const [isAnimating, setIsAnimating] =
|
3250
|
-
|
3339
|
+
const [prevHeight, setPrevHeight] = useState14(0);
|
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
|
+
});
|
3348
|
+
useEffect11(() => {
|
3251
3349
|
if (draggedItem && ref.current) {
|
3252
|
-
|
3253
|
-
if (componentData.zone === zoneCompound) {
|
3350
|
+
if (isZone) {
|
3254
3351
|
const rect = ref.current.getBoundingClientRect();
|
3255
3352
|
setPrevHeight(rect.height);
|
3256
3353
|
setIsAnimating(true);
|
@@ -3280,13 +3377,128 @@ function assignRefs(refs, node) {
|
|
3280
3377
|
});
|
3281
3378
|
}
|
3282
3379
|
|
3283
|
-
// components/DropZone/
|
3284
|
-
|
3285
|
-
|
3286
|
-
|
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";
|
3287
3464
|
var GRID_DRAG_AXIS = "dynamic";
|
3288
3465
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3289
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;
|
3290
3502
|
var DropZoneEdit = forwardRef3(
|
3291
3503
|
function DropZoneEdit2({
|
3292
3504
|
zone,
|
@@ -3298,31 +3510,50 @@ var DropZoneEdit = forwardRef3(
|
|
3298
3510
|
collisionAxis
|
3299
3511
|
}, userRef) {
|
3300
3512
|
const appContext2 = useAppContext();
|
3301
|
-
const ctx =
|
3513
|
+
const ctx = useContext6(dropZoneContext);
|
3302
3514
|
const {
|
3303
3515
|
// These all need setting via context
|
3304
3516
|
data,
|
3305
3517
|
config,
|
3306
3518
|
areaId,
|
3307
|
-
draggedItem,
|
3308
3519
|
registerZoneArea,
|
3309
3520
|
depth,
|
3310
3521
|
registerLocalZone,
|
3311
3522
|
unregisterLocalZone,
|
3312
|
-
deepestZone = rootDroppableId,
|
3313
|
-
deepestArea,
|
3314
|
-
nextDeepestArea,
|
3315
3523
|
path = [],
|
3316
3524
|
activeZones
|
3317
3525
|
} = ctx;
|
3318
|
-
const { itemSelector } = appContext2.state.ui;
|
3319
3526
|
let zoneCompound = rootDroppableId;
|
3320
|
-
|
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(() => {
|
3321
3552
|
if (areaId && registerZoneArea) {
|
3322
3553
|
registerZoneArea(areaId);
|
3323
3554
|
}
|
3324
3555
|
}, [areaId]);
|
3325
|
-
|
3556
|
+
useEffect14(() => {
|
3326
3557
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3327
3558
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3328
3559
|
}
|
@@ -3332,25 +3563,18 @@ var DropZoneEdit = forwardRef3(
|
|
3332
3563
|
}
|
3333
3564
|
};
|
3334
3565
|
}, []);
|
3335
|
-
|
3336
|
-
if (zone !== rootDroppableId) {
|
3337
|
-
zoneCompound = `${areaId}:${zone}`;
|
3338
|
-
}
|
3339
|
-
}
|
3340
|
-
const content = useMemo7(() => {
|
3566
|
+
const content = useMemo8(() => {
|
3341
3567
|
if (areaId && zone !== rootDroppableId) {
|
3342
3568
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3343
3569
|
}
|
3344
3570
|
return data.content || [];
|
3345
3571
|
}, [data, zoneCompound]);
|
3346
|
-
const ref =
|
3347
|
-
const acceptsTarget =
|
3348
|
-
(
|
3349
|
-
if (!
|
3572
|
+
const ref = useRef3(null);
|
3573
|
+
const acceptsTarget = useCallback10(
|
3574
|
+
(componentType) => {
|
3575
|
+
if (!componentType) {
|
3350
3576
|
return true;
|
3351
3577
|
}
|
3352
|
-
const data2 = target.data;
|
3353
|
-
const { componentType } = data2;
|
3354
3578
|
if (disallow) {
|
3355
3579
|
const defaultedAllow = allow || [];
|
3356
3580
|
const filteredDisallow = (disallow || []).filter(
|
@@ -3368,49 +3592,26 @@ var DropZoneEdit = forwardRef3(
|
|
3368
3592
|
},
|
3369
3593
|
[allow, disallow]
|
3370
3594
|
);
|
3371
|
-
|
3595
|
+
useEffect14(() => {
|
3372
3596
|
if (registerLocalZone) {
|
3373
|
-
registerLocalZone(zoneCompound, acceptsTarget(
|
3597
|
+
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3374
3598
|
}
|
3375
3599
|
return () => {
|
3376
3600
|
if (unregisterLocalZone) {
|
3377
3601
|
unregisterLocalZone(zoneCompound);
|
3378
3602
|
}
|
3379
3603
|
};
|
3380
|
-
}, [
|
3381
|
-
const
|
3382
|
-
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3383
|
-
const userIsDragging = !!draggedItem;
|
3604
|
+
}, [draggedComponentType, zoneCompound]);
|
3605
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
3384
3606
|
let isEnabled = true;
|
3385
|
-
if (
|
3386
|
-
isEnabled =
|
3607
|
+
if (userIsDragging) {
|
3608
|
+
isEnabled = isDeepestZone;
|
3387
3609
|
}
|
3388
3610
|
if (isEnabled) {
|
3389
|
-
isEnabled = acceptsTarget(
|
3390
|
-
}
|
3391
|
-
const
|
3392
|
-
const
|
3393
|
-
const contentWithPreview = useMemo7(() => {
|
3394
|
-
let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
|
3395
|
-
if (previewInZone) {
|
3396
|
-
contentWithPreview2 = content.filter(
|
3397
|
-
(item) => item.props.id !== preview.props.id
|
3398
|
-
);
|
3399
|
-
if (preview.type === "insert") {
|
3400
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3401
|
-
type: "preview",
|
3402
|
-
props: { id: preview.props.id }
|
3403
|
-
});
|
3404
|
-
} else {
|
3405
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3406
|
-
type: preview.componentType,
|
3407
|
-
props: preview.props
|
3408
|
-
});
|
3409
|
-
}
|
3410
|
-
}
|
3411
|
-
return contentWithPreview2;
|
3412
|
-
}, [preview, content]);
|
3413
|
-
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);
|
3414
3615
|
const droppableConfig = {
|
3415
3616
|
id: zoneCompound,
|
3416
3617
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -3420,45 +3621,20 @@ var DropZoneEdit = forwardRef3(
|
|
3420
3621
|
data: {
|
3421
3622
|
areaId,
|
3422
3623
|
depth,
|
3423
|
-
isDroppableTarget: acceptsTarget(
|
3624
|
+
isDroppableTarget: acceptsTarget(draggedComponentType),
|
3424
3625
|
path
|
3425
3626
|
}
|
3426
3627
|
};
|
3427
3628
|
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
3428
3629
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3429
3630
|
const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
|
3430
|
-
const [dragAxis
|
3431
|
-
collisionAxis || DEFAULT_DRAG_AXIS
|
3432
|
-
);
|
3433
|
-
const calculateDragAxis = useCallback8(() => {
|
3434
|
-
if (ref.current) {
|
3435
|
-
const computedStyle = window.getComputedStyle(ref.current);
|
3436
|
-
if (computedStyle.display === "grid") {
|
3437
|
-
setDragAxis(GRID_DRAG_AXIS);
|
3438
|
-
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3439
|
-
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3440
|
-
} else {
|
3441
|
-
setDragAxis(DEFAULT_DRAG_AXIS);
|
3442
|
-
}
|
3443
|
-
}
|
3444
|
-
}, [ref.current]);
|
3445
|
-
useEffect13(calculateDragAxis, [appContext2.status, collisionAxis]);
|
3446
|
-
useEffect13(() => {
|
3447
|
-
const onViewportChange = () => {
|
3448
|
-
calculateDragAxis();
|
3449
|
-
};
|
3450
|
-
window.addEventListener("viewportchange", onViewportChange);
|
3451
|
-
return () => {
|
3452
|
-
window.removeEventListener("viewportchange", onViewportChange);
|
3453
|
-
};
|
3454
|
-
}, []);
|
3631
|
+
const [dragAxis] = useDragAxis(ref, collisionAxis);
|
3455
3632
|
const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
|
3456
|
-
draggedItem,
|
3457
3633
|
zoneCompound,
|
3458
3634
|
userMinEmptyHeight,
|
3459
3635
|
ref
|
3460
3636
|
});
|
3461
|
-
return /* @__PURE__ */
|
3637
|
+
return /* @__PURE__ */ jsx22(
|
3462
3638
|
"div",
|
3463
3639
|
{
|
3464
3640
|
className: `${getClassName17({
|
@@ -3478,87 +3654,92 @@ var DropZoneEdit = forwardRef3(
|
|
3478
3654
|
"data-puck-dropzone": zoneCompound,
|
3479
3655
|
"data-puck-dnd": zoneCompound,
|
3480
3656
|
style: __spreadProps(__spreadValues({}, style), {
|
3481
|
-
"--min-empty-height": `${minEmptyHeight}px
|
3657
|
+
"--min-empty-height": `${minEmptyHeight}px`,
|
3658
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3482
3659
|
}),
|
3483
|
-
children:
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
|
3488
|
-
|
3489
|
-
|
3490
|
-
|
3491
|
-
|
3492
|
-
|
3493
|
-
|
3494
|
-
|
3495
|
-
|
3496
|
-
|
3497
|
-
|
3498
|
-
|
3499
|
-
|
3500
|
-
|
3501
|
-
|
3502
|
-
|
3503
|
-
|
3504
|
-
|
3505
|
-
|
3506
|
-
|
3507
|
-
|
3508
|
-
|
3509
|
-
|
3510
|
-
|
3511
|
-
|
3512
|
-
|
3513
|
-
|
3514
|
-
|
3515
|
-
|
3516
|
-
|
3517
|
-
|
3518
|
-
|
3519
|
-
|
3520
|
-
|
3521
|
-
|
3522
|
-
|
3523
|
-
|
3524
|
-
|
3525
|
-
|
3526
|
-
|
3527
|
-
|
3528
|
-
|
3529
|
-
|
3530
|
-
|
3531
|
-
|
3532
|
-
|
3533
|
-
|
3534
|
-
|
3535
|
-
|
3536
|
-
|
3537
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx21(
|
3538
|
-
Render2,
|
3539
|
-
__spreadProps(__spreadValues({}, defaultedProps), {
|
3540
|
-
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3541
|
-
dragRef
|
3542
|
-
})
|
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 });
|
3684
|
+
};
|
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
|
3543
3714
|
})
|
3544
|
-
|
3545
|
-
}
|
3546
|
-
|
3547
|
-
|
3548
|
-
|
3549
|
-
|
3550
|
-
|
3551
|
-
|
3715
|
+
})
|
3716
|
+
) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
|
3717
|
+
}
|
3718
|
+
)
|
3719
|
+
},
|
3720
|
+
componentId
|
3721
|
+
);
|
3722
|
+
})
|
3552
3723
|
}
|
3553
3724
|
);
|
3554
3725
|
}
|
3555
3726
|
);
|
3556
3727
|
var DropZoneRender = forwardRef3(
|
3557
3728
|
function DropZoneRender2({ className, style, zone }, ref) {
|
3558
|
-
const ctx =
|
3729
|
+
const ctx = useContext6(dropZoneContext);
|
3559
3730
|
const { data, areaId = "root", config } = ctx || {};
|
3560
3731
|
let zoneCompound = rootDroppableId;
|
3561
3732
|
let content = (data == null ? void 0 : data.content) || [];
|
3733
|
+
useEffect14(() => {
|
3734
|
+
if (ctx == null ? void 0 : ctx.registerZone) {
|
3735
|
+
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3736
|
+
}
|
3737
|
+
return () => {
|
3738
|
+
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
3739
|
+
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
3740
|
+
}
|
3741
|
+
};
|
3742
|
+
}, []);
|
3562
3743
|
if (!data || !config) {
|
3563
3744
|
return null;
|
3564
3745
|
}
|
@@ -3566,10 +3747,10 @@ var DropZoneRender = forwardRef3(
|
|
3566
3747
|
zoneCompound = `${areaId}:${zone}`;
|
3567
3748
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3568
3749
|
}
|
3569
|
-
return /* @__PURE__ */
|
3750
|
+
return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
|
3570
3751
|
const Component = config.components[item.type];
|
3571
3752
|
if (Component) {
|
3572
|
-
return /* @__PURE__ */
|
3753
|
+
return /* @__PURE__ */ jsx22(
|
3573
3754
|
DropZoneProvider,
|
3574
3755
|
{
|
3575
3756
|
value: {
|
@@ -3579,7 +3760,7 @@ var DropZoneRender = forwardRef3(
|
|
3579
3760
|
depth: 1,
|
3580
3761
|
path: []
|
3581
3762
|
},
|
3582
|
-
children: /* @__PURE__ */
|
3763
|
+
children: /* @__PURE__ */ jsx22(
|
3583
3764
|
Component.render,
|
3584
3765
|
__spreadProps(__spreadValues({}, item.props), {
|
3585
3766
|
puck: { renderDropZone: DropZoneRender2 }
|
@@ -3595,11 +3776,11 @@ var DropZoneRender = forwardRef3(
|
|
3595
3776
|
);
|
3596
3777
|
var DropZone = forwardRef3(
|
3597
3778
|
function DropZone2(props, ref) {
|
3598
|
-
const ctx =
|
3779
|
+
const ctx = useContext6(dropZoneContext);
|
3599
3780
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3600
|
-
return /* @__PURE__ */
|
3781
|
+
return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3601
3782
|
}
|
3602
|
-
return /* @__PURE__ */
|
3783
|
+
return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3603
3784
|
}
|
3604
3785
|
);
|
3605
3786
|
|
@@ -3615,7 +3796,7 @@ var getZoneId = (zoneCompound) => {
|
|
3615
3796
|
return [rootDroppableId, zoneCompound];
|
3616
3797
|
};
|
3617
3798
|
|
3618
|
-
//
|
3799
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3619
3800
|
init_react_import();
|
3620
3801
|
import { Plugin } from "@dnd-kit/abstract";
|
3621
3802
|
import { effects } from "@dnd-kit/state";
|
@@ -3657,7 +3838,7 @@ var getFrame = () => {
|
|
3657
3838
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3658
3839
|
};
|
3659
3840
|
|
3660
|
-
//
|
3841
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3661
3842
|
var depthSort = (candidates) => {
|
3662
3843
|
return candidates.sort((a, b) => {
|
3663
3844
|
const aData = a.data;
|
@@ -3772,9 +3953,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
|
|
3772
3953
|
area: null
|
3773
3954
|
};
|
3774
3955
|
};
|
3775
|
-
var createNestedDroppablePlugin = ({
|
3776
|
-
onChange
|
3777
|
-
}) => class NestedDroppablePlugin extends Plugin {
|
3956
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
|
3778
3957
|
constructor(manager, options) {
|
3779
3958
|
super(manager);
|
3780
3959
|
if (typeof window === "undefined") {
|
@@ -3788,10 +3967,17 @@ var createNestedDroppablePlugin = ({
|
|
3788
3967
|
};
|
3789
3968
|
const target = event.originalTarget || event.target;
|
3790
3969
|
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
3791
|
-
|
3792
|
-
|
3793
|
-
|
3970
|
+
const elements = document.elementsFromPoint(
|
3971
|
+
event.clientX,
|
3972
|
+
event.clientY
|
3794
3973
|
);
|
3974
|
+
const overEl = elements.some((el) => el.id === id);
|
3975
|
+
if (overEl) {
|
3976
|
+
onChange(
|
3977
|
+
findDeepestCandidate(position, manager, ownerDocument),
|
3978
|
+
manager
|
3979
|
+
);
|
3980
|
+
}
|
3795
3981
|
};
|
3796
3982
|
const handleMoveThrottled = throttle(handleMove, 50);
|
3797
3983
|
const handlePointerMove = (event) => {
|
@@ -4208,7 +4394,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4208
4394
|
import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
|
4209
4395
|
import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
|
4210
4396
|
|
4211
|
-
//
|
4397
|
+
// lib/dnd/PointerSensor.ts
|
4212
4398
|
init_react_import();
|
4213
4399
|
import { batch, effect } from "@dnd-kit/state";
|
4214
4400
|
import { Sensor, configurator } from "@dnd-kit/abstract";
|
@@ -4479,13 +4665,15 @@ function patchWindow(window2) {
|
|
4479
4665
|
}
|
4480
4666
|
|
4481
4667
|
// components/DragDropContext/index.tsx
|
4482
|
-
import {
|
4483
|
-
|
4668
|
+
import { createStore as createStore3 } from "zustand";
|
4669
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
4670
|
+
var DEBUG3 = false;
|
4671
|
+
var dragListenerContext = createContext4({
|
4484
4672
|
dragListeners: {}
|
4485
4673
|
});
|
4486
4674
|
function useDragListener(type, fn, deps = []) {
|
4487
|
-
const { setDragListeners } =
|
4488
|
-
|
4675
|
+
const { setDragListeners } = useContext7(dragListenerContext);
|
4676
|
+
useEffect15(() => {
|
4489
4677
|
if (setDragListeners) {
|
4490
4678
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4491
4679
|
[type]: [...old[type] || [], fn]
|
@@ -4493,78 +4681,145 @@ function useDragListener(type, fn, deps = []) {
|
|
4493
4681
|
}
|
4494
4682
|
}, deps);
|
4495
4683
|
}
|
4496
|
-
var previewContext = createContext3(null);
|
4497
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
|
+
};
|
4498
4699
|
var DragDropContextClient = ({
|
4499
4700
|
children,
|
4500
4701
|
disableAutoScroll
|
4501
4702
|
}) => {
|
4502
4703
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4503
|
-
const
|
4504
|
-
const previewRef = useRef5(null);
|
4704
|
+
const id = useId();
|
4505
4705
|
const { data } = state;
|
4506
|
-
const
|
4507
|
-
const
|
4508
|
-
const
|
4509
|
-
|
4510
|
-
|
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(
|
4511
4740
|
(params, manager) => {
|
4512
|
-
|
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);
|
4513
4748
|
setTimeout(() => {
|
4514
4749
|
manager.collisionObserver.forceUpdate(true);
|
4515
4750
|
}, 50);
|
4516
4751
|
debouncedParamsRef.current = null;
|
4517
4752
|
},
|
4518
|
-
[]
|
4753
|
+
[zoneStore]
|
4519
4754
|
);
|
4520
4755
|
const setDeepestDb = useDebouncedCallback2(
|
4521
4756
|
setDeepestAndCollide,
|
4522
4757
|
AREA_CHANGE_DEBOUNCE_MS
|
4523
4758
|
);
|
4524
|
-
useEffect14(() => {
|
4525
|
-
deepestRef.current = deepest;
|
4526
|
-
}, [deepest]);
|
4527
4759
|
const cancelDb = () => {
|
4528
4760
|
setDeepestDb.cancel();
|
4529
4761
|
debouncedParamsRef.current = null;
|
4530
4762
|
};
|
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
|
+
);
|
4773
|
+
}
|
4774
|
+
);
|
4775
|
+
}
|
4776
|
+
}, []);
|
4531
4777
|
const [plugins] = useState17(() => [
|
4532
4778
|
...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
|
4533
|
-
createNestedDroppablePlugin(
|
4534
|
-
|
4535
|
-
|
4536
|
-
|
4537
|
-
|
4538
|
-
|
4539
|
-
|
4540
|
-
|
4541
|
-
|
4542
|
-
|
4543
|
-
|
4544
|
-
|
4545
|
-
|
4546
|
-
|
4547
|
-
|
4548
|
-
|
4549
|
-
|
4550
|
-
|
4551
|
-
|
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 {
|
4552
4810
|
cancelDb();
|
4553
|
-
|
4554
|
-
debouncedParamsRef.current = params;
|
4811
|
+
setDeepestAndCollide(params, manager);
|
4555
4812
|
}
|
4556
|
-
|
4557
|
-
|
4813
|
+
return;
|
4814
|
+
}
|
4815
|
+
if (zoneChanged) {
|
4558
4816
|
setDeepestAndCollide(params, manager);
|
4559
4817
|
}
|
4560
|
-
|
4818
|
+
cancelDb();
|
4561
4819
|
}
|
4562
|
-
|
4563
|
-
|
4564
|
-
|
4565
|
-
cancelDb();
|
4566
|
-
}
|
4567
|
-
})
|
4820
|
+
},
|
4821
|
+
id
|
4822
|
+
)
|
4568
4823
|
]);
|
4569
4824
|
const [sensors] = useState17(() => [
|
4570
4825
|
PointerSensor.configure({
|
@@ -4585,11 +4840,10 @@ var DragDropContextClient = ({
|
|
4585
4840
|
}
|
4586
4841
|
})
|
4587
4842
|
]);
|
4588
|
-
const [draggedItem, setDraggedItem] = useState17();
|
4589
4843
|
const [dragListeners, setDragListeners] = useState17({});
|
4590
4844
|
const [pathData, setPathData] = useState17();
|
4591
|
-
const dragMode =
|
4592
|
-
const registerPath =
|
4845
|
+
const dragMode = useRef4(null);
|
4846
|
+
const registerPath = useCallback11(
|
4593
4847
|
(selector) => {
|
4594
4848
|
const item = getItem(selector, data);
|
4595
4849
|
if (!item) {
|
@@ -4611,41 +4865,41 @@ var DragDropContextClient = ({
|
|
4611
4865
|
},
|
4612
4866
|
[data, setPathData]
|
4613
4867
|
);
|
4614
|
-
const initialSelector =
|
4615
|
-
return /* @__PURE__ */
|
4868
|
+
const initialSelector = useRef4(void 0);
|
4869
|
+
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
4616
4870
|
dragListenerContext.Provider,
|
4617
4871
|
{
|
4618
4872
|
value: {
|
4619
4873
|
dragListeners,
|
4620
4874
|
setDragListeners
|
4621
4875
|
},
|
4622
|
-
children: /* @__PURE__ */
|
4876
|
+
children: /* @__PURE__ */ jsx23(
|
4623
4877
|
DragDropProvider2,
|
4624
4878
|
{
|
4625
4879
|
plugins,
|
4626
4880
|
sensors,
|
4627
4881
|
onDragEnd: (event, manager) => {
|
4882
|
+
var _a;
|
4628
4883
|
const { source, target } = event.operation;
|
4629
|
-
deepestRef.current = null;
|
4630
4884
|
if (!source) {
|
4631
|
-
|
4885
|
+
zoneStore.setState({ draggedItem: null });
|
4632
4886
|
return;
|
4633
4887
|
}
|
4634
4888
|
const { zone, index } = source.data;
|
4635
|
-
const
|
4636
|
-
|
4889
|
+
const { previewIndex = {} } = zoneStore.getState() || {};
|
4890
|
+
const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
|
4637
4891
|
setTimeout(() => {
|
4638
|
-
var
|
4639
|
-
|
4892
|
+
var _a2, _b;
|
4893
|
+
zoneStore.setState({ draggedItem: null });
|
4640
4894
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4641
|
-
|
4642
|
-
(
|
4895
|
+
zoneStore.setState({ previewIndex: {} });
|
4896
|
+
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
4643
4897
|
fn(event, manager);
|
4644
4898
|
});
|
4645
4899
|
return;
|
4646
4900
|
}
|
4647
4901
|
if (thisPreview) {
|
4648
|
-
|
4902
|
+
zoneStore.setState({ previewIndex: {} });
|
4649
4903
|
if (thisPreview.type === "insert") {
|
4650
4904
|
insertComponent(
|
4651
4905
|
thisPreview.componentType,
|
@@ -4680,8 +4934,9 @@ var DragDropContextClient = ({
|
|
4680
4934
|
}, 250);
|
4681
4935
|
},
|
4682
4936
|
onDragOver: (event, manager) => {
|
4683
|
-
var _a, _b, _c, _d;
|
4937
|
+
var _a, _b, _c, _d, _e;
|
4684
4938
|
event.preventDefault();
|
4939
|
+
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
4685
4940
|
if (!draggedItem) return;
|
4686
4941
|
cancelDb();
|
4687
4942
|
const { source, target } = event.operation;
|
@@ -4697,7 +4952,7 @@ var DragDropContextClient = ({
|
|
4697
4952
|
const targetData = target.data;
|
4698
4953
|
targetZone = targetData.zone;
|
4699
4954
|
targetIndex = targetData.index;
|
4700
|
-
const collisionData = (
|
4955
|
+
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
4701
4956
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4702
4957
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4703
4958
|
targetIndex = targetIndex - 1;
|
@@ -4709,23 +4964,26 @@ var DragDropContextClient = ({
|
|
4709
4964
|
targetZone = target.id.toString();
|
4710
4965
|
targetIndex = 0;
|
4711
4966
|
}
|
4712
|
-
if (targetId === sourceId || ((
|
4967
|
+
if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
|
4713
4968
|
const [pathId] = path.split(":");
|
4714
4969
|
return pathId === sourceId;
|
4715
4970
|
}))) {
|
4716
4971
|
return;
|
4717
4972
|
}
|
4718
4973
|
if (dragMode.current === "new") {
|
4719
|
-
|
4720
|
-
|
4721
|
-
|
4722
|
-
|
4723
|
-
|
4724
|
-
|
4725
|
-
|
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
|
+
}
|
4726
4985
|
}
|
4727
|
-
};
|
4728
|
-
setPreview(previewRef.current);
|
4986
|
+
});
|
4729
4987
|
} else {
|
4730
4988
|
if (!initialSelector.current) {
|
4731
4989
|
initialSelector.current = {
|
@@ -4735,17 +4993,20 @@ var DragDropContextClient = ({
|
|
4735
4993
|
}
|
4736
4994
|
const item = getItem(initialSelector.current, data);
|
4737
4995
|
if (item) {
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4744
|
-
|
4745
|
-
|
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
|
+
});
|
4746
5007
|
}
|
4747
5008
|
}
|
4748
|
-
(
|
5009
|
+
(_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
|
4749
5010
|
fn(event, manager);
|
4750
5011
|
});
|
4751
5012
|
},
|
@@ -4755,46 +5016,61 @@ var DragDropContextClient = ({
|
|
4755
5016
|
type: "setUi",
|
4756
5017
|
ui: { itemSelector: null, isDragging: true }
|
4757
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
|
+
}
|
4758
5043
|
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4759
5044
|
fn(event, manager);
|
4760
5045
|
});
|
4761
5046
|
},
|
4762
5047
|
onBeforeDragStart: (event) => {
|
4763
5048
|
var _a;
|
4764
|
-
if (draggedItem) {
|
4765
|
-
console.warn("New drag started before previous drag cleaned up");
|
4766
|
-
}
|
4767
5049
|
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4768
5050
|
dragMode.current = isNewComponent ? "new" : "existing";
|
4769
5051
|
initialSelector.current = void 0;
|
4770
|
-
|
5052
|
+
zoneStore.setState({ draggedItem: event.operation.source });
|
4771
5053
|
},
|
4772
|
-
children: /* @__PURE__ */
|
5054
|
+
children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
|
4773
5055
|
DropZoneProvider,
|
4774
5056
|
{
|
4775
5057
|
value: {
|
4776
5058
|
data,
|
4777
5059
|
config,
|
4778
|
-
dispatch,
|
4779
|
-
draggedItem,
|
4780
5060
|
mode: "edit",
|
4781
5061
|
areaId: "root",
|
4782
5062
|
depth: 0,
|
4783
5063
|
registerPath,
|
4784
5064
|
pathData,
|
4785
|
-
deepestZone: deepest == null ? void 0 : deepest.zone,
|
4786
|
-
deepestArea: deepest == null ? void 0 : deepest.area,
|
4787
|
-
nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
|
4788
|
-
nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
|
4789
5065
|
path: []
|
4790
5066
|
},
|
4791
5067
|
children
|
4792
5068
|
}
|
4793
|
-
)
|
5069
|
+
) })
|
4794
5070
|
}
|
4795
|
-
)
|
5071
|
+
)
|
4796
5072
|
}
|
4797
|
-
);
|
5073
|
+
) });
|
4798
5074
|
};
|
4799
5075
|
var DragDropContext = ({
|
4800
5076
|
children,
|
@@ -4804,11 +5080,11 @@ var DragDropContext = ({
|
|
4804
5080
|
if (status === "LOADING") {
|
4805
5081
|
return children;
|
4806
5082
|
}
|
4807
|
-
return /* @__PURE__ */
|
5083
|
+
return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
|
4808
5084
|
};
|
4809
5085
|
|
4810
5086
|
// components/Drawer/index.tsx
|
4811
|
-
import { jsx as
|
5087
|
+
import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
|
4812
5088
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
4813
5089
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
4814
5090
|
var DrawerItemInner = ({
|
@@ -4818,11 +5094,11 @@ var DrawerItemInner = ({
|
|
4818
5094
|
dragRef,
|
4819
5095
|
isDragDisabled
|
4820
5096
|
}) => {
|
4821
|
-
const CustomInner =
|
4822
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */
|
5097
|
+
const CustomInner = useMemo9(
|
5098
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
|
4823
5099
|
[children]
|
4824
5100
|
);
|
4825
|
-
return /* @__PURE__ */
|
5101
|
+
return /* @__PURE__ */ jsx24(
|
4826
5102
|
"div",
|
4827
5103
|
{
|
4828
5104
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -4830,9 +5106,9 @@ var DrawerItemInner = ({
|
|
4830
5106
|
onMouseDown: (e) => e.preventDefault(),
|
4831
5107
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
4832
5108
|
"data-puck-drawer-item": true,
|
4833
|
-
children: /* @__PURE__ */
|
4834
|
-
/* @__PURE__ */
|
4835
|
-
/* @__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, {}) })
|
4836
5112
|
] }) }) })
|
4837
5113
|
}
|
4838
5114
|
);
|
@@ -4850,8 +5126,8 @@ var DrawerItemDraggable = ({
|
|
4850
5126
|
disabled: isDragDisabled
|
4851
5127
|
});
|
4852
5128
|
return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
|
4853
|
-
/* @__PURE__ */
|
4854
|
-
/* @__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(
|
4855
5131
|
DrawerItemInner,
|
4856
5132
|
{
|
4857
5133
|
name,
|
@@ -4885,7 +5161,7 @@ var DrawerItem = ({
|
|
4885
5161
|
},
|
4886
5162
|
[resolvedId]
|
4887
5163
|
);
|
4888
|
-
return /* @__PURE__ */
|
5164
|
+
return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
|
4889
5165
|
DrawerItemDraggable,
|
4890
5166
|
{
|
4891
5167
|
name,
|
@@ -4918,7 +5194,7 @@ var Drawer = ({
|
|
4918
5194
|
collisionPriority: 0
|
4919
5195
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
4920
5196
|
});
|
4921
|
-
return /* @__PURE__ */
|
5197
|
+
return /* @__PURE__ */ jsx24(
|
4922
5198
|
"div",
|
4923
5199
|
{
|
4924
5200
|
className: getClassName18(),
|
@@ -4934,9 +5210,9 @@ Drawer.Item = DrawerItem;
|
|
4934
5210
|
// components/Puck/index.tsx
|
4935
5211
|
init_react_import();
|
4936
5212
|
import {
|
4937
|
-
useCallback as
|
4938
|
-
useEffect as
|
4939
|
-
useMemo as
|
5213
|
+
useCallback as useCallback17,
|
5214
|
+
useEffect as useEffect23,
|
5215
|
+
useMemo as useMemo18,
|
4940
5216
|
useReducer,
|
4941
5217
|
useState as useState26
|
4942
5218
|
} from "react";
|
@@ -4950,7 +5226,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
4950
5226
|
|
4951
5227
|
// lib/use-breadcrumbs.ts
|
4952
5228
|
init_react_import();
|
4953
|
-
import { useContext as
|
5229
|
+
import { useContext as useContext8, useMemo as useMemo10 } from "react";
|
4954
5230
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
4955
5231
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
4956
5232
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5000,8 +5276,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5000
5276
|
state: { data },
|
5001
5277
|
selectedItem
|
5002
5278
|
} = useAppContext();
|
5003
|
-
const dzContext =
|
5004
|
-
return
|
5279
|
+
const dzContext = useContext8(dropZoneContext);
|
5280
|
+
return useMemo10(() => {
|
5005
5281
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5006
5282
|
selectedItem,
|
5007
5283
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5015,7 +5291,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
5015
5291
|
};
|
5016
5292
|
|
5017
5293
|
// components/SidebarSection/index.tsx
|
5018
|
-
import { jsx as
|
5294
|
+
import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
5019
5295
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5020
5296
|
var SidebarSection = ({
|
5021
5297
|
children,
|
@@ -5034,9 +5310,9 @@ var SidebarSection = ({
|
|
5034
5310
|
className: getClassName19({ noBorderTop, noPadding }),
|
5035
5311
|
style: { background },
|
5036
5312
|
children: [
|
5037
|
-
/* @__PURE__ */
|
5313
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
|
5038
5314
|
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
|
5039
|
-
/* @__PURE__ */
|
5315
|
+
/* @__PURE__ */ jsx25(
|
5040
5316
|
"button",
|
5041
5317
|
{
|
5042
5318
|
type: "button",
|
@@ -5045,12 +5321,12 @@ var SidebarSection = ({
|
|
5045
5321
|
children: breadcrumb.label
|
5046
5322
|
}
|
5047
5323
|
),
|
5048
|
-
/* @__PURE__ */
|
5324
|
+
/* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
|
5049
5325
|
] }, i)) : null,
|
5050
|
-
/* @__PURE__ */
|
5326
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
|
5051
5327
|
] }) }),
|
5052
|
-
/* @__PURE__ */
|
5053
|
-
isLoading && /* @__PURE__ */
|
5328
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
|
5329
|
+
isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
|
5054
5330
|
]
|
5055
5331
|
}
|
5056
5332
|
);
|
@@ -5081,7 +5357,7 @@ init_react_import();
|
|
5081
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" };
|
5082
5358
|
|
5083
5359
|
// components/MenuBar/index.tsx
|
5084
|
-
import { Fragment as Fragment7, jsx as
|
5360
|
+
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
|
5085
5361
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5086
5362
|
function MenuBar({
|
5087
5363
|
appState,
|
@@ -5095,7 +5371,7 @@ function MenuBar({
|
|
5095
5371
|
history: { back, forward, historyStore }
|
5096
5372
|
} = useAppContext();
|
5097
5373
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5098
|
-
return /* @__PURE__ */
|
5374
|
+
return /* @__PURE__ */ jsx26(
|
5099
5375
|
"div",
|
5100
5376
|
{
|
5101
5377
|
className: getClassName20({ menuOpen }),
|
@@ -5111,10 +5387,10 @@ function MenuBar({
|
|
5111
5387
|
},
|
5112
5388
|
children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
|
5113
5389
|
/* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
|
5114
|
-
/* @__PURE__ */
|
5115
|
-
/* @__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 }) })
|
5116
5392
|
] }),
|
5117
|
-
/* @__PURE__ */
|
5393
|
+
/* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
|
5118
5394
|
state: appState,
|
5119
5395
|
dispatch
|
5120
5396
|
}) })
|
@@ -5125,7 +5401,7 @@ function MenuBar({
|
|
5125
5401
|
|
5126
5402
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5127
5403
|
init_react_import();
|
5128
|
-
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" };
|
5129
5405
|
|
5130
5406
|
// components/Puck/components/Fields/index.tsx
|
5131
5407
|
init_react_import();
|
@@ -5135,15 +5411,15 @@ init_react_import();
|
|
5135
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" };
|
5136
5412
|
|
5137
5413
|
// components/Puck/components/Fields/index.tsx
|
5138
|
-
import { useCallback as
|
5414
|
+
import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo11, useState as useState19 } from "react";
|
5139
5415
|
|
5140
5416
|
// lib/use-parent.ts
|
5141
5417
|
init_react_import();
|
5142
|
-
import { useContext as
|
5418
|
+
import { useContext as useContext9 } from "react";
|
5143
5419
|
var useParent = (itemSelector) => {
|
5144
5420
|
var _a;
|
5145
5421
|
const { selectedItem, state } = useAppContext();
|
5146
|
-
const { pathData } =
|
5422
|
+
const { pathData } = useContext9(dropZoneContext) || {};
|
5147
5423
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
5148
5424
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5149
5425
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -5152,7 +5428,7 @@ var useParent = (itemSelector) => {
|
|
5152
5428
|
};
|
5153
5429
|
|
5154
5430
|
// components/Puck/components/Fields/index.tsx
|
5155
|
-
import { Fragment as Fragment8, jsx as
|
5431
|
+
import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
5156
5432
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5157
5433
|
var defaultPageFields = {
|
5158
5434
|
title: { type: "text" }
|
@@ -5160,7 +5436,7 @@ var defaultPageFields = {
|
|
5160
5436
|
var DefaultFields = ({
|
5161
5437
|
children
|
5162
5438
|
}) => {
|
5163
|
-
return /* @__PURE__ */
|
5439
|
+
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5164
5440
|
};
|
5165
5441
|
var useResolvedFields = () => {
|
5166
5442
|
var _a, _b;
|
@@ -5169,7 +5445,7 @@ var useResolvedFields = () => {
|
|
5169
5445
|
const { data } = state;
|
5170
5446
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5171
5447
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5172
|
-
const defaultFields =
|
5448
|
+
const defaultFields = useMemo11(
|
5173
5449
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5174
5450
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5175
5451
|
);
|
@@ -5182,7 +5458,7 @@ var useResolvedFields = () => {
|
|
5182
5458
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5183
5459
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5184
5460
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5185
|
-
const resolveFields =
|
5461
|
+
const resolveFields = useCallback12(
|
5186
5462
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5187
5463
|
var _a2;
|
5188
5464
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5220,7 +5496,7 @@ var useResolvedFields = () => {
|
|
5220
5496
|
}),
|
5221
5497
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
5222
5498
|
);
|
5223
|
-
|
5499
|
+
useEffect16(() => {
|
5224
5500
|
if (hasResolver) {
|
5225
5501
|
setFieldsLoading(true);
|
5226
5502
|
resolveFields(defaultFields).then((fields) => {
|
@@ -5251,7 +5527,7 @@ var Fields = () => {
|
|
5251
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;
|
5252
5528
|
const isLoading = fieldsResolving || componentResolving;
|
5253
5529
|
const rootProps = data.root.props || data.root;
|
5254
|
-
const Wrapper =
|
5530
|
+
const Wrapper = useMemo11(() => overrides.fields || DefaultFields, [overrides]);
|
5255
5531
|
return /* @__PURE__ */ jsxs14(
|
5256
5532
|
"form",
|
5257
5533
|
{
|
@@ -5260,7 +5536,7 @@ var Fields = () => {
|
|
5260
5536
|
e.preventDefault();
|
5261
5537
|
},
|
5262
5538
|
children: [
|
5263
|
-
/* @__PURE__ */
|
5539
|
+
/* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5264
5540
|
const field = fields[fieldName];
|
5265
5541
|
if (!(field == null ? void 0 : field.type)) return null;
|
5266
5542
|
const onChange = (value, updatedUi) => {
|
@@ -5331,7 +5607,7 @@ var Fields = () => {
|
|
5331
5607
|
item: selectedItem
|
5332
5608
|
});
|
5333
5609
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5334
|
-
return /* @__PURE__ */
|
5610
|
+
return /* @__PURE__ */ jsx27(
|
5335
5611
|
AutoFieldPrivate,
|
5336
5612
|
{
|
5337
5613
|
field,
|
@@ -5349,7 +5625,7 @@ var Fields = () => {
|
|
5349
5625
|
root: true
|
5350
5626
|
});
|
5351
5627
|
const id = `root_${field.type}_${fieldName}`;
|
5352
|
-
return /* @__PURE__ */
|
5628
|
+
return /* @__PURE__ */ jsx27(
|
5353
5629
|
AutoFieldPrivate,
|
5354
5630
|
{
|
5355
5631
|
field,
|
@@ -5363,7 +5639,7 @@ var Fields = () => {
|
|
5363
5639
|
);
|
5364
5640
|
}
|
5365
5641
|
}) }),
|
5366
|
-
isLoading && /* @__PURE__ */
|
5642
|
+
isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
|
5367
5643
|
]
|
5368
5644
|
}
|
5369
5645
|
);
|
@@ -5374,7 +5650,7 @@ init_react_import();
|
|
5374
5650
|
|
5375
5651
|
// lib/use-component-list.tsx
|
5376
5652
|
init_react_import();
|
5377
|
-
import { useEffect as
|
5653
|
+
import { useEffect as useEffect17, useState as useState20 } from "react";
|
5378
5654
|
|
5379
5655
|
// components/ComponentList/index.tsx
|
5380
5656
|
init_react_import();
|
@@ -5384,7 +5660,7 @@ init_react_import();
|
|
5384
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" };
|
5385
5661
|
|
5386
5662
|
// components/ComponentList/index.tsx
|
5387
|
-
import { jsx as
|
5663
|
+
import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
|
5388
5664
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5389
5665
|
var ComponentListItem = ({
|
5390
5666
|
name,
|
@@ -5394,7 +5670,7 @@ var ComponentListItem = ({
|
|
5394
5670
|
const canInsert = getPermissions({
|
5395
5671
|
type: name
|
5396
5672
|
}).insert;
|
5397
|
-
return /* @__PURE__ */
|
5673
|
+
return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5398
5674
|
};
|
5399
5675
|
var ComponentList = ({
|
5400
5676
|
children,
|
@@ -5418,14 +5694,14 @@ var ComponentList = ({
|
|
5418
5694
|
}),
|
5419
5695
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5420
5696
|
children: [
|
5421
|
-
/* @__PURE__ */
|
5422
|
-
/* @__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 }) })
|
5423
5699
|
]
|
5424
5700
|
}
|
5425
5701
|
),
|
5426
|
-
/* @__PURE__ */
|
5702
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
5427
5703
|
var _a;
|
5428
|
-
return /* @__PURE__ */
|
5704
|
+
return /* @__PURE__ */ jsx28(
|
5429
5705
|
ComponentListItem,
|
5430
5706
|
{
|
5431
5707
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5439,10 +5715,10 @@ var ComponentList = ({
|
|
5439
5715
|
ComponentList.Item = ComponentListItem;
|
5440
5716
|
|
5441
5717
|
// lib/use-component-list.tsx
|
5442
|
-
import { jsx as
|
5718
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
5443
5719
|
var useComponentList = (config, ui) => {
|
5444
5720
|
const [componentList, setComponentList] = useState20();
|
5445
|
-
|
5721
|
+
useEffect17(() => {
|
5446
5722
|
var _a, _b, _c;
|
5447
5723
|
if (Object.keys(ui.componentList).length > 0) {
|
5448
5724
|
const matchedComponents = [];
|
@@ -5452,7 +5728,7 @@ var useComponentList = (config, ui) => {
|
|
5452
5728
|
if (category.visible === false || !category.components) {
|
5453
5729
|
return null;
|
5454
5730
|
}
|
5455
|
-
return /* @__PURE__ */
|
5731
|
+
return /* @__PURE__ */ jsx29(
|
5456
5732
|
ComponentList,
|
5457
5733
|
{
|
5458
5734
|
id: categoryKey,
|
@@ -5461,7 +5737,7 @@ var useComponentList = (config, ui) => {
|
|
5461
5737
|
var _a2;
|
5462
5738
|
matchedComponents.push(componentName);
|
5463
5739
|
const componentConf = config.components[componentName] || {};
|
5464
|
-
return /* @__PURE__ */
|
5740
|
+
return /* @__PURE__ */ jsx29(
|
5465
5741
|
ComponentList.Item,
|
5466
5742
|
{
|
5467
5743
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5481,7 +5757,7 @@ var useComponentList = (config, ui) => {
|
|
5481
5757
|
);
|
5482
5758
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5483
5759
|
_componentList.push(
|
5484
|
-
/* @__PURE__ */
|
5760
|
+
/* @__PURE__ */ jsx29(
|
5485
5761
|
ComponentList,
|
5486
5762
|
{
|
5487
5763
|
id: "other",
|
@@ -5489,7 +5765,7 @@ var useComponentList = (config, ui) => {
|
|
5489
5765
|
children: remainingComponents.map((componentName, i) => {
|
5490
5766
|
var _a2;
|
5491
5767
|
const componentConf = config.components[componentName] || {};
|
5492
|
-
return /* @__PURE__ */
|
5768
|
+
return /* @__PURE__ */ jsx29(
|
5493
5769
|
ComponentList.Item,
|
5494
5770
|
{
|
5495
5771
|
name: componentName,
|
@@ -5511,30 +5787,30 @@ var useComponentList = (config, ui) => {
|
|
5511
5787
|
};
|
5512
5788
|
|
5513
5789
|
// components/Puck/components/Components/index.tsx
|
5514
|
-
import { useMemo as
|
5515
|
-
import { jsx as
|
5790
|
+
import { useMemo as useMemo12 } from "react";
|
5791
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
5516
5792
|
var Components = () => {
|
5517
5793
|
const { config, state, overrides } = useAppContext();
|
5518
5794
|
const componentList = useComponentList(config, state.ui);
|
5519
|
-
const Wrapper =
|
5520
|
-
return /* @__PURE__ */
|
5795
|
+
const Wrapper = useMemo12(() => overrides.components || "div", [overrides]);
|
5796
|
+
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
5521
5797
|
};
|
5522
5798
|
|
5523
5799
|
// components/Puck/components/Preview/index.tsx
|
5524
5800
|
init_react_import();
|
5525
|
-
import { useCallback as
|
5801
|
+
import { useCallback as useCallback13, useEffect as useEffect19, useRef as useRef6, useMemo as useMemo13 } from "react";
|
5526
5802
|
|
5527
5803
|
// components/AutoFrame/index.tsx
|
5528
5804
|
init_react_import();
|
5529
5805
|
import {
|
5530
|
-
createContext as
|
5531
|
-
useContext as
|
5532
|
-
useEffect as
|
5806
|
+
createContext as createContext5,
|
5807
|
+
useContext as useContext10,
|
5808
|
+
useEffect as useEffect18,
|
5533
5809
|
useState as useState21
|
5534
5810
|
} from "react";
|
5535
5811
|
import hash from "object-hash";
|
5536
5812
|
import { createPortal as createPortal3 } from "react-dom";
|
5537
|
-
import { Fragment as Fragment9, jsx as
|
5813
|
+
import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
|
5538
5814
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5539
5815
|
var collectStyles = (doc) => {
|
5540
5816
|
const collected = [];
|
@@ -5577,7 +5853,7 @@ var CopyHostStyles = ({
|
|
5577
5853
|
onStylesLoaded = () => null
|
5578
5854
|
}) => {
|
5579
5855
|
const { document: doc, window: win } = useFrame();
|
5580
|
-
|
5856
|
+
useEffect18(() => {
|
5581
5857
|
if (!win || !doc) {
|
5582
5858
|
return () => {
|
5583
5859
|
};
|
@@ -5734,10 +6010,10 @@ var CopyHostStyles = ({
|
|
5734
6010
|
observer.disconnect();
|
5735
6011
|
};
|
5736
6012
|
}, []);
|
5737
|
-
return /* @__PURE__ */
|
6013
|
+
return /* @__PURE__ */ jsx31(Fragment9, { children });
|
5738
6014
|
};
|
5739
|
-
var autoFrameContext =
|
5740
|
-
var useFrame = () =>
|
6015
|
+
var autoFrameContext = createContext5({});
|
6016
|
+
var useFrame = () => useContext10(autoFrameContext);
|
5741
6017
|
function AutoFrame(_a) {
|
5742
6018
|
var _b = _a, {
|
5743
6019
|
children,
|
@@ -5757,7 +6033,7 @@ function AutoFrame(_a) {
|
|
5757
6033
|
const [loaded, setLoaded] = useState21(false);
|
5758
6034
|
const [ctx, setCtx] = useState21({});
|
5759
6035
|
const [mountTarget, setMountTarget] = useState21();
|
5760
|
-
|
6036
|
+
useEffect18(() => {
|
5761
6037
|
var _a2;
|
5762
6038
|
if (frameRef.current) {
|
5763
6039
|
setCtx({
|
@@ -5769,7 +6045,7 @@ function AutoFrame(_a) {
|
|
5769
6045
|
);
|
5770
6046
|
}
|
5771
6047
|
}, [frameRef, loaded]);
|
5772
|
-
return /* @__PURE__ */
|
6048
|
+
return /* @__PURE__ */ jsx31(
|
5773
6049
|
"iframe",
|
5774
6050
|
__spreadProps(__spreadValues({}, props), {
|
5775
6051
|
className,
|
@@ -5779,7 +6055,7 @@ function AutoFrame(_a) {
|
|
5779
6055
|
onLoad: () => {
|
5780
6056
|
setLoaded(true);
|
5781
6057
|
},
|
5782
|
-
children: /* @__PURE__ */
|
6058
|
+
children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
|
5783
6059
|
})
|
5784
6060
|
);
|
5785
6061
|
}
|
@@ -5790,12 +6066,68 @@ var AutoFrame_default = AutoFrame;
|
|
5790
6066
|
init_react_import();
|
5791
6067
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
5792
6068
|
|
6069
|
+
// components/Render/index.tsx
|
6070
|
+
init_react_import();
|
6071
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
6072
|
+
function Render({
|
6073
|
+
config,
|
6074
|
+
data
|
6075
|
+
}) {
|
6076
|
+
var _a;
|
6077
|
+
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
6078
|
+
root: data.root || {},
|
6079
|
+
content: data.content || []
|
6080
|
+
});
|
6081
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
6082
|
+
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
6083
|
+
if ((_a = config.root) == null ? void 0 : _a.render) {
|
6084
|
+
return /* @__PURE__ */ jsx32(
|
6085
|
+
DropZoneProvider,
|
6086
|
+
{
|
6087
|
+
value: {
|
6088
|
+
data: defaultedData,
|
6089
|
+
config,
|
6090
|
+
mode: "render",
|
6091
|
+
depth: 0,
|
6092
|
+
path: []
|
6093
|
+
},
|
6094
|
+
children: /* @__PURE__ */ jsx32(
|
6095
|
+
config.root.render,
|
6096
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
6097
|
+
puck: {
|
6098
|
+
renderDropZone: DropZone,
|
6099
|
+
isEditing: false
|
6100
|
+
},
|
6101
|
+
title,
|
6102
|
+
editMode: false,
|
6103
|
+
id: "puck-root",
|
6104
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
6105
|
+
})
|
6106
|
+
)
|
6107
|
+
}
|
6108
|
+
);
|
6109
|
+
}
|
6110
|
+
return /* @__PURE__ */ jsx32(
|
6111
|
+
DropZoneProvider,
|
6112
|
+
{
|
6113
|
+
value: {
|
6114
|
+
data: defaultedData,
|
6115
|
+
config,
|
6116
|
+
mode: "render",
|
6117
|
+
depth: 0,
|
6118
|
+
path: []
|
6119
|
+
},
|
6120
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
6121
|
+
}
|
6122
|
+
);
|
6123
|
+
}
|
6124
|
+
|
5793
6125
|
// components/Puck/components/Preview/index.tsx
|
5794
|
-
import { Fragment as Fragment10, jsx as
|
6126
|
+
import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
|
5795
6127
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5796
6128
|
var useBubbleIframeEvents = (ref) => {
|
5797
6129
|
const { status } = useAppContext();
|
5798
|
-
|
6130
|
+
useEffect19(() => {
|
5799
6131
|
var _a;
|
5800
6132
|
if (ref.current && status === "READY") {
|
5801
6133
|
const iframe = ref.current;
|
@@ -5832,22 +6164,34 @@ var useBubbleIframeEvents = (ref) => {
|
|
5832
6164
|
}
|
5833
6165
|
}, [status]);
|
5834
6166
|
};
|
5835
|
-
var
|
6167
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
5836
6168
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
5837
|
-
const Page =
|
6169
|
+
const Page = useCallback13(
|
5838
6170
|
(pageProps) => {
|
5839
6171
|
var _a, _b;
|
5840
6172
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
5841
6173
|
id: "puck-root"
|
5842
|
-
}, pageProps)) : /* @__PURE__ */
|
6174
|
+
}, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
|
5843
6175
|
},
|
5844
6176
|
[config.root]
|
5845
6177
|
);
|
5846
|
-
const Frame =
|
6178
|
+
const Frame = useMemo13(() => overrides.iframe, [overrides]);
|
5847
6179
|
const rootProps = state.data.root.props || state.data.root;
|
5848
|
-
const ref =
|
6180
|
+
const ref = useRef6(null);
|
5849
6181
|
useBubbleIframeEvents(ref);
|
5850
|
-
|
6182
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
|
6183
|
+
Page,
|
6184
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
6185
|
+
puck: {
|
6186
|
+
renderDropZone: DropZone,
|
6187
|
+
isEditing: true,
|
6188
|
+
dragRef: null
|
6189
|
+
},
|
6190
|
+
editMode: true,
|
6191
|
+
children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
|
6192
|
+
})
|
6193
|
+
) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
|
6194
|
+
return /* @__PURE__ */ jsx33(
|
5851
6195
|
"div",
|
5852
6196
|
{
|
5853
6197
|
className: getClassName23(),
|
@@ -5856,7 +6200,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5856
6200
|
onClick: () => {
|
5857
6201
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
5858
6202
|
},
|
5859
|
-
children: iframe.enabled ? /* @__PURE__ */
|
6203
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx33(
|
5860
6204
|
AutoFrame_default,
|
5861
6205
|
{
|
5862
6206
|
id: "preview-frame",
|
@@ -5866,40 +6210,21 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
5866
6210
|
setStatus("READY");
|
5867
6211
|
},
|
5868
6212
|
frameRef: ref,
|
5869
|
-
children: /* @__PURE__ */
|
5870
|
-
const inner = /* @__PURE__ */ jsx31(
|
5871
|
-
Page,
|
5872
|
-
__spreadProps(__spreadValues({}, rootProps), {
|
5873
|
-
puck: {
|
5874
|
-
renderDropZone: DropZone,
|
5875
|
-
isEditing: true,
|
5876
|
-
dragRef: null
|
5877
|
-
},
|
5878
|
-
editMode: true,
|
5879
|
-
children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
|
5880
|
-
})
|
5881
|
-
);
|
6213
|
+
children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
5882
6214
|
if (Frame) {
|
5883
|
-
return /* @__PURE__ */
|
6215
|
+
return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
|
5884
6216
|
}
|
5885
6217
|
return inner;
|
5886
6218
|
} })
|
5887
6219
|
}
|
5888
|
-
) : /* @__PURE__ */
|
6220
|
+
) : /* @__PURE__ */ jsx33(
|
5889
6221
|
"div",
|
5890
6222
|
{
|
5891
6223
|
id: "preview-frame",
|
5892
6224
|
className: getClassName23("frame"),
|
5893
6225
|
ref,
|
5894
6226
|
"data-puck-entry": true,
|
5895
|
-
children:
|
5896
|
-
Page,
|
5897
|
-
__spreadProps(__spreadValues({}, rootProps), {
|
5898
|
-
puck: { renderDropZone: DropZone, isEditing: true, dragRef: null },
|
5899
|
-
editMode: true,
|
5900
|
-
children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
|
5901
|
-
})
|
5902
|
-
)
|
6227
|
+
children: inner
|
5903
6228
|
}
|
5904
6229
|
)
|
5905
6230
|
}
|
@@ -5949,7 +6274,7 @@ var scrollIntoView = (el) => {
|
|
5949
6274
|
};
|
5950
6275
|
|
5951
6276
|
// components/LayerTree/index.tsx
|
5952
|
-
import { useContext as
|
6277
|
+
import { useContext as useContext11 } from "react";
|
5953
6278
|
|
5954
6279
|
// lib/is-child-of-zone.ts
|
5955
6280
|
init_react_import();
|
@@ -5982,7 +6307,7 @@ var onScrollEnd = (frame, cb) => {
|
|
5982
6307
|
};
|
5983
6308
|
|
5984
6309
|
// components/LayerTree/index.tsx
|
5985
|
-
import { Fragment as Fragment11, jsx as
|
6310
|
+
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
|
5986
6311
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
5987
6312
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
5988
6313
|
var LayerTree = ({
|
@@ -5995,15 +6320,15 @@ var LayerTree = ({
|
|
5995
6320
|
label
|
5996
6321
|
}) => {
|
5997
6322
|
const zones = data.zones || {};
|
5998
|
-
const ctx =
|
6323
|
+
const ctx = useContext11(dropZoneContext);
|
5999
6324
|
return /* @__PURE__ */ jsxs16(Fragment11, { children: [
|
6000
6325
|
label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
|
6001
|
-
/* @__PURE__ */
|
6326
|
+
/* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
|
6002
6327
|
" ",
|
6003
6328
|
label
|
6004
6329
|
] }),
|
6005
6330
|
/* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
|
6006
|
-
zoneContent.length === 0 && /* @__PURE__ */
|
6331
|
+
zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
|
6007
6332
|
zoneContent.map((item, i) => {
|
6008
6333
|
var _a;
|
6009
6334
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6026,7 +6351,7 @@ var LayerTree = ({
|
|
6026
6351
|
childIsSelected
|
6027
6352
|
}),
|
6028
6353
|
children: [
|
6029
|
-
/* @__PURE__ */
|
6354
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
|
6030
6355
|
"button",
|
6031
6356
|
{
|
6032
6357
|
type: "button",
|
@@ -6065,22 +6390,22 @@ var LayerTree = ({
|
|
6065
6390
|
setHoveringComponent(null);
|
6066
6391
|
},
|
6067
6392
|
children: [
|
6068
|
-
containsZone && /* @__PURE__ */
|
6393
|
+
containsZone && /* @__PURE__ */ jsx34(
|
6069
6394
|
"div",
|
6070
6395
|
{
|
6071
6396
|
className: getClassNameLayer("chevron"),
|
6072
6397
|
title: isSelected ? "Collapse" : "Expand",
|
6073
|
-
children: /* @__PURE__ */
|
6398
|
+
children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
|
6074
6399
|
}
|
6075
6400
|
),
|
6076
6401
|
/* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
|
6077
|
-
/* @__PURE__ */
|
6078
|
-
/* @__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 })
|
6079
6404
|
] })
|
6080
6405
|
]
|
6081
6406
|
}
|
6082
6407
|
) }),
|
6083
|
-
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(
|
6084
6409
|
LayerTree,
|
6085
6410
|
{
|
6086
6411
|
config,
|
@@ -6102,13 +6427,13 @@ var LayerTree = ({
|
|
6102
6427
|
};
|
6103
6428
|
|
6104
6429
|
// components/Puck/components/Outline/index.tsx
|
6105
|
-
import { useCallback as
|
6106
|
-
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";
|
6107
6432
|
var Outline = () => {
|
6108
6433
|
const { dispatch, state, overrides, config } = useAppContext();
|
6109
6434
|
const { data, ui } = state;
|
6110
6435
|
const { itemSelector } = ui;
|
6111
|
-
const setItemSelector =
|
6436
|
+
const setItemSelector = useCallback14(
|
6112
6437
|
(newItemSelector) => {
|
6113
6438
|
dispatch({
|
6114
6439
|
type: "setUi",
|
@@ -6117,9 +6442,9 @@ var Outline = () => {
|
|
6117
6442
|
},
|
6118
6443
|
[]
|
6119
6444
|
);
|
6120
|
-
const Wrapper =
|
6121
|
-
return /* @__PURE__ */
|
6122
|
-
(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(
|
6123
6448
|
LayerTree,
|
6124
6449
|
{
|
6125
6450
|
config,
|
@@ -6132,7 +6457,7 @@ var Outline = () => {
|
|
6132
6457
|
),
|
6133
6458
|
Object.entries(findZonesForArea(data, "root")).map(
|
6134
6459
|
([zoneKey, zone]) => {
|
6135
|
-
return /* @__PURE__ */
|
6460
|
+
return /* @__PURE__ */ jsx35(
|
6136
6461
|
LayerTree,
|
6137
6462
|
{
|
6138
6463
|
config,
|
@@ -6404,27 +6729,27 @@ var getBox = function getBox2(el) {
|
|
6404
6729
|
|
6405
6730
|
// components/Puck/components/Canvas/index.tsx
|
6406
6731
|
import {
|
6407
|
-
useCallback as
|
6408
|
-
useEffect as
|
6409
|
-
useMemo as
|
6410
|
-
useRef as
|
6732
|
+
useCallback as useCallback15,
|
6733
|
+
useEffect as useEffect21,
|
6734
|
+
useMemo as useMemo16,
|
6735
|
+
useRef as useRef7,
|
6411
6736
|
useState as useState24
|
6412
6737
|
} from "react";
|
6413
6738
|
|
6414
6739
|
// components/ViewportControls/index.tsx
|
6415
6740
|
init_react_import();
|
6416
|
-
import { useEffect as
|
6741
|
+
import { useEffect as useEffect20, useMemo as useMemo15, useState as useState23 } from "react";
|
6417
6742
|
|
6418
6743
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6419
6744
|
init_react_import();
|
6420
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" };
|
6421
6746
|
|
6422
6747
|
// components/ViewportControls/index.tsx
|
6423
|
-
import { jsx as
|
6748
|
+
import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
|
6424
6749
|
var icons = {
|
6425
|
-
Smartphone: /* @__PURE__ */
|
6426
|
-
Tablet: /* @__PURE__ */
|
6427
|
-
Monitor: /* @__PURE__ */
|
6750
|
+
Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
|
6751
|
+
Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
|
6752
|
+
Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
|
6428
6753
|
};
|
6429
6754
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6430
6755
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6437,10 +6762,10 @@ var ViewportButton = ({
|
|
6437
6762
|
}) => {
|
6438
6763
|
const { state } = useAppContext();
|
6439
6764
|
const [isActive, setIsActive] = useState23(false);
|
6440
|
-
|
6765
|
+
useEffect20(() => {
|
6441
6766
|
setIsActive(width === state.ui.viewports.current.width);
|
6442
6767
|
}, [width, state.ui.viewports.current.width]);
|
6443
|
-
return /* @__PURE__ */
|
6768
|
+
return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
|
6444
6769
|
IconButton,
|
6445
6770
|
{
|
6446
6771
|
title,
|
@@ -6449,7 +6774,7 @@ var ViewportButton = ({
|
|
6449
6774
|
e.stopPropagation();
|
6450
6775
|
onClick({ width, height });
|
6451
6776
|
},
|
6452
|
-
children: /* @__PURE__ */
|
6777
|
+
children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
|
6453
6778
|
}
|
6454
6779
|
) });
|
6455
6780
|
};
|
@@ -6473,7 +6798,7 @@ var ViewportControls = ({
|
|
6473
6798
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6474
6799
|
(option) => option.value === autoZoom
|
6475
6800
|
);
|
6476
|
-
const zoomOptions =
|
6801
|
+
const zoomOptions = useMemo15(
|
6477
6802
|
() => [
|
6478
6803
|
...defaultZoomOptions,
|
6479
6804
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6486,7 +6811,7 @@ var ViewportControls = ({
|
|
6486
6811
|
[autoZoom]
|
6487
6812
|
);
|
6488
6813
|
return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
|
6489
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
6814
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
|
6490
6815
|
ViewportButton,
|
6491
6816
|
{
|
6492
6817
|
height: viewport.height,
|
@@ -6497,8 +6822,8 @@ var ViewportControls = ({
|
|
6497
6822
|
},
|
6498
6823
|
i
|
6499
6824
|
)),
|
6500
|
-
/* @__PURE__ */
|
6501
|
-
/* @__PURE__ */
|
6825
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6826
|
+
/* @__PURE__ */ jsx36(
|
6502
6827
|
IconButton,
|
6503
6828
|
{
|
6504
6829
|
title: "Zoom viewport out",
|
@@ -6512,10 +6837,10 @@ var ViewportControls = ({
|
|
6512
6837
|
)].value
|
6513
6838
|
);
|
6514
6839
|
},
|
6515
|
-
children: /* @__PURE__ */
|
6840
|
+
children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
|
6516
6841
|
}
|
6517
6842
|
),
|
6518
|
-
/* @__PURE__ */
|
6843
|
+
/* @__PURE__ */ jsx36(
|
6519
6844
|
IconButton,
|
6520
6845
|
{
|
6521
6846
|
title: "Zoom viewport in",
|
@@ -6529,11 +6854,11 @@ var ViewportControls = ({
|
|
6529
6854
|
)].value
|
6530
6855
|
);
|
6531
6856
|
},
|
6532
|
-
children: /* @__PURE__ */
|
6857
|
+
children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
|
6533
6858
|
}
|
6534
6859
|
),
|
6535
|
-
/* @__PURE__ */
|
6536
|
-
/* @__PURE__ */
|
6860
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6861
|
+
/* @__PURE__ */ jsx36(
|
6537
6862
|
"select",
|
6538
6863
|
{
|
6539
6864
|
className: getClassName25("zoomSelect"),
|
@@ -6541,7 +6866,7 @@ var ViewportControls = ({
|
|
6541
6866
|
onChange: (e) => {
|
6542
6867
|
onZoom(parseFloat(e.currentTarget.value));
|
6543
6868
|
},
|
6544
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
6869
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
|
6545
6870
|
"option",
|
6546
6871
|
{
|
6547
6872
|
value: option.value,
|
@@ -6589,24 +6914,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6589
6914
|
};
|
6590
6915
|
|
6591
6916
|
// components/Puck/components/Canvas/index.tsx
|
6592
|
-
import { Fragment as Fragment13, jsx as
|
6917
|
+
import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
|
6593
6918
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6594
6919
|
var ZOOM_ON_CHANGE = true;
|
6595
6920
|
var Canvas = () => {
|
6596
6921
|
const { status, iframe } = useAppContext();
|
6597
6922
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6598
6923
|
const { ui } = state;
|
6599
|
-
const frameRef =
|
6924
|
+
const frameRef = useRef7(null);
|
6600
6925
|
const [showTransition, setShowTransition] = useState24(false);
|
6601
|
-
const defaultRender =
|
6602
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
6926
|
+
const defaultRender = useMemo16(() => {
|
6927
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
|
6603
6928
|
return PuckDefault;
|
6604
6929
|
}, []);
|
6605
|
-
const CustomPreview =
|
6930
|
+
const CustomPreview = useMemo16(
|
6606
6931
|
() => overrides.preview || defaultRender,
|
6607
6932
|
[overrides]
|
6608
6933
|
);
|
6609
|
-
const getFrameDimensions =
|
6934
|
+
const getFrameDimensions = useCallback15(() => {
|
6610
6935
|
if (frameRef.current) {
|
6611
6936
|
const frame = frameRef.current;
|
6612
6937
|
const box = getBox(frame);
|
@@ -6614,7 +6939,7 @@ var Canvas = () => {
|
|
6614
6939
|
}
|
6615
6940
|
return { width: 0, height: 0 };
|
6616
6941
|
}, [frameRef]);
|
6617
|
-
const resetAutoZoom =
|
6942
|
+
const resetAutoZoom = useCallback15(
|
6618
6943
|
(ui2 = state.ui) => {
|
6619
6944
|
if (frameRef.current) {
|
6620
6945
|
setZoomConfig(
|
@@ -6624,11 +6949,11 @@ var Canvas = () => {
|
|
6624
6949
|
},
|
6625
6950
|
[frameRef, zoomConfig, state.ui]
|
6626
6951
|
);
|
6627
|
-
|
6952
|
+
useEffect21(() => {
|
6628
6953
|
setShowTransition(false);
|
6629
6954
|
resetAutoZoom();
|
6630
6955
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6631
|
-
|
6956
|
+
useEffect21(() => {
|
6632
6957
|
const { height: frameHeight } = getFrameDimensions();
|
6633
6958
|
if (ui.viewports.current.height === "auto") {
|
6634
6959
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6636,13 +6961,13 @@ var Canvas = () => {
|
|
6636
6961
|
}));
|
6637
6962
|
}
|
6638
6963
|
}, [zoomConfig.zoom]);
|
6639
|
-
|
6964
|
+
useEffect21(() => {
|
6640
6965
|
if (ZOOM_ON_CHANGE) {
|
6641
6966
|
setShowTransition(true);
|
6642
6967
|
resetAutoZoom(ui);
|
6643
6968
|
}
|
6644
6969
|
}, [ui.viewports.current.width]);
|
6645
|
-
|
6970
|
+
useEffect21(() => {
|
6646
6971
|
const cb = () => {
|
6647
6972
|
setShowTransition(false);
|
6648
6973
|
resetAutoZoom();
|
@@ -6653,7 +6978,7 @@ var Canvas = () => {
|
|
6653
6978
|
};
|
6654
6979
|
}, []);
|
6655
6980
|
const [showLoader, setShowLoader] = useState24(false);
|
6656
|
-
|
6981
|
+
useEffect21(() => {
|
6657
6982
|
setTimeout(() => {
|
6658
6983
|
setShowLoader(true);
|
6659
6984
|
}, 500);
|
@@ -6671,7 +6996,7 @@ var Canvas = () => {
|
|
6671
6996
|
recordHistory: true
|
6672
6997
|
}),
|
6673
6998
|
children: [
|
6674
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
6999
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
|
6675
7000
|
ViewportControls,
|
6676
7001
|
{
|
6677
7002
|
autoZoom: zoomConfig.autoZoom,
|
@@ -6698,7 +7023,7 @@ var Canvas = () => {
|
|
6698
7023
|
}
|
6699
7024
|
) }),
|
6700
7025
|
/* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
6701
|
-
/* @__PURE__ */
|
7026
|
+
/* @__PURE__ */ jsx37(
|
6702
7027
|
"div",
|
6703
7028
|
{
|
6704
7029
|
className: getClassName26("root"),
|
@@ -6719,10 +7044,10 @@ var Canvas = () => {
|
|
6719
7044
|
})
|
6720
7045
|
);
|
6721
7046
|
},
|
6722
|
-
children: /* @__PURE__ */
|
7047
|
+
children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
|
6723
7048
|
}
|
6724
7049
|
),
|
6725
|
-
/* @__PURE__ */
|
7050
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
|
6726
7051
|
] })
|
6727
7052
|
]
|
6728
7053
|
}
|
@@ -6731,7 +7056,7 @@ var Canvas = () => {
|
|
6731
7056
|
|
6732
7057
|
// lib/use-loaded-overrides.ts
|
6733
7058
|
init_react_import();
|
6734
|
-
import { useMemo as
|
7059
|
+
import { useMemo as useMemo17 } from "react";
|
6735
7060
|
|
6736
7061
|
// lib/load-overrides.ts
|
6737
7062
|
init_react_import();
|
@@ -6770,29 +7095,26 @@ var useLoadedOverrides = ({
|
|
6770
7095
|
overrides,
|
6771
7096
|
plugins
|
6772
7097
|
}) => {
|
6773
|
-
return
|
7098
|
+
return useMemo17(() => {
|
6774
7099
|
return loadOverrides({ overrides, plugins });
|
6775
7100
|
}, [plugins, overrides]);
|
6776
7101
|
};
|
6777
7102
|
|
6778
7103
|
// components/DefaultOverride/index.tsx
|
6779
7104
|
init_react_import();
|
6780
|
-
import { Fragment as Fragment14, jsx as
|
6781
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */
|
6782
|
-
|
6783
|
-
// components/Puck/index.tsx
|
6784
|
-
import { DragDropManager as DragDropManager2, Feedback } from "@dnd-kit/dom";
|
7105
|
+
import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
|
7106
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
|
6785
7107
|
|
6786
7108
|
// lib/use-inject-css.ts
|
6787
7109
|
init_react_import();
|
6788
|
-
import { useEffect as
|
7110
|
+
import { useEffect as useEffect22, useState as useState25 } from "react";
|
6789
7111
|
var styles = ``;
|
6790
7112
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6791
7113
|
const [el, setEl] = useState25();
|
6792
|
-
|
7114
|
+
useEffect22(() => {
|
6793
7115
|
setEl(document.createElement("style"));
|
6794
7116
|
}, []);
|
6795
|
-
|
7117
|
+
useEffect22(() => {
|
6796
7118
|
var _a;
|
6797
7119
|
if (!el || typeof window === "undefined") {
|
6798
7120
|
return;
|
@@ -6810,8 +7132,35 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
6810
7132
|
return useInjectStyleSheet(styles, iframeEnabled);
|
6811
7133
|
};
|
6812
7134
|
|
7135
|
+
// lib/use-preview-mode-hotkeys.ts
|
7136
|
+
init_react_import();
|
7137
|
+
import { useCallback as useCallback16 } from "react";
|
7138
|
+
import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
|
7139
|
+
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7140
|
+
const toggleInteractive = useCallback16(() => {
|
7141
|
+
dispatch({
|
7142
|
+
type: "setUi",
|
7143
|
+
ui: (ui) => ({
|
7144
|
+
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
7145
|
+
})
|
7146
|
+
});
|
7147
|
+
}, [dispatch]);
|
7148
|
+
const toggleInteractiveIframe = () => {
|
7149
|
+
if (iframeEnabled) {
|
7150
|
+
toggleInteractive();
|
7151
|
+
}
|
7152
|
+
};
|
7153
|
+
const frame = getFrame();
|
7154
|
+
const resolvedFrame = typeof window !== "undefined" && frame !== document ? frame : void 0;
|
7155
|
+
useHotkeys2("meta+i", toggleInteractive, { preventDefault: true });
|
7156
|
+
useHotkeys2("meta+i", toggleInteractiveIframe, {
|
7157
|
+
preventDefault: true,
|
7158
|
+
document: resolvedFrame
|
7159
|
+
});
|
7160
|
+
};
|
7161
|
+
|
6813
7162
|
// components/Puck/index.tsx
|
6814
|
-
import { Fragment as Fragment15, jsx as
|
7163
|
+
import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
|
6815
7164
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
6816
7165
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
6817
7166
|
function Puck({
|
@@ -6933,11 +7282,11 @@ function Puck({
|
|
6933
7282
|
const [menuOpen, setMenuOpen] = useState26(false);
|
6934
7283
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
6935
7284
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
6936
|
-
|
7285
|
+
useEffect23(() => {
|
6937
7286
|
if (onChange) onChange(data);
|
6938
7287
|
}, [data]);
|
6939
7288
|
const rootProps = data.root.props || data.root;
|
6940
|
-
const toggleSidebars =
|
7289
|
+
const toggleSidebars = useCallback17(
|
6941
7290
|
(sidebar) => {
|
6942
7291
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
6943
7292
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -6951,7 +7300,7 @@ function Puck({
|
|
6951
7300
|
},
|
6952
7301
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
6953
7302
|
);
|
6954
|
-
|
7303
|
+
useEffect23(() => {
|
6955
7304
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
6956
7305
|
dispatch({
|
6957
7306
|
type: "setUi",
|
@@ -6974,7 +7323,7 @@ function Puck({
|
|
6974
7323
|
window.removeEventListener("resize", handleResize);
|
6975
7324
|
};
|
6976
7325
|
}, []);
|
6977
|
-
const defaultHeaderRender =
|
7326
|
+
const defaultHeaderRender = useMemo18(() => {
|
6978
7327
|
if (renderHeader) {
|
6979
7328
|
console.warn(
|
6980
7329
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -6982,20 +7331,20 @@ function Puck({
|
|
6982
7331
|
const RenderHeader = (_a2) => {
|
6983
7332
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
6984
7333
|
const Comp = renderHeader;
|
6985
|
-
return /* @__PURE__ */
|
7334
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
6986
7335
|
};
|
6987
7336
|
return RenderHeader;
|
6988
7337
|
}
|
6989
7338
|
return DefaultOverride;
|
6990
7339
|
}, [renderHeader]);
|
6991
|
-
const defaultHeaderActionsRender =
|
7340
|
+
const defaultHeaderActionsRender = useMemo18(() => {
|
6992
7341
|
if (renderHeaderActions) {
|
6993
7342
|
console.warn(
|
6994
7343
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
6995
7344
|
);
|
6996
7345
|
const RenderHeader = (props) => {
|
6997
7346
|
const Comp = renderHeaderActions;
|
6998
|
-
return /* @__PURE__ */
|
7347
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
6999
7348
|
};
|
7000
7349
|
return RenderHeader;
|
7001
7350
|
}
|
@@ -7005,27 +7354,27 @@ function Puck({
|
|
7005
7354
|
overrides,
|
7006
7355
|
plugins
|
7007
7356
|
});
|
7008
|
-
const CustomPuck =
|
7357
|
+
const CustomPuck = useMemo18(
|
7009
7358
|
() => loadedOverrides.puck || DefaultOverride,
|
7010
7359
|
[loadedOverrides]
|
7011
7360
|
);
|
7012
|
-
const CustomHeader =
|
7361
|
+
const CustomHeader = useMemo18(
|
7013
7362
|
() => loadedOverrides.header || defaultHeaderRender,
|
7014
7363
|
[loadedOverrides]
|
7015
7364
|
);
|
7016
|
-
const CustomHeaderActions =
|
7365
|
+
const CustomHeaderActions = useMemo18(
|
7017
7366
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7018
7367
|
[loadedOverrides]
|
7019
7368
|
);
|
7020
7369
|
const [mounted, setMounted] = useState26(false);
|
7021
|
-
|
7370
|
+
useEffect23(() => {
|
7022
7371
|
setMounted(true);
|
7023
7372
|
}, []);
|
7024
7373
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7025
7374
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7026
|
-
|
7375
|
+
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7027
7376
|
return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
|
7028
|
-
/* @__PURE__ */
|
7377
|
+
/* @__PURE__ */ jsx39(
|
7029
7378
|
AppProvider,
|
7030
7379
|
{
|
7031
7380
|
value: {
|
@@ -7047,7 +7396,7 @@ function Puck({
|
|
7047
7396
|
getPermissions: () => ({}),
|
7048
7397
|
refreshPermissions: () => null
|
7049
7398
|
},
|
7050
|
-
children: /* @__PURE__ */
|
7399
|
+
children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
|
7051
7400
|
"div",
|
7052
7401
|
{
|
7053
7402
|
className: getLayoutClassName({
|
@@ -7057,59 +7406,59 @@ function Puck({
|
|
7057
7406
|
rightSideBarVisible
|
7058
7407
|
}),
|
7059
7408
|
children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
|
7060
|
-
/* @__PURE__ */
|
7409
|
+
/* @__PURE__ */ jsx39(
|
7061
7410
|
CustomHeader,
|
7062
7411
|
{
|
7063
|
-
actions: /* @__PURE__ */
|
7412
|
+
actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7064
7413
|
Button,
|
7065
7414
|
{
|
7066
7415
|
onClick: () => {
|
7067
7416
|
onPublish && onPublish(data);
|
7068
7417
|
},
|
7069
|
-
icon: /* @__PURE__ */
|
7418
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7070
7419
|
children: "Publish"
|
7071
7420
|
}
|
7072
7421
|
) }) }),
|
7073
|
-
children: /* @__PURE__ */
|
7422
|
+
children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
|
7074
7423
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
|
7075
|
-
/* @__PURE__ */
|
7424
|
+
/* @__PURE__ */ jsx39(
|
7076
7425
|
"div",
|
7077
7426
|
{
|
7078
7427
|
className: getLayoutClassName("leftSideBarToggle"),
|
7079
|
-
children: /* @__PURE__ */
|
7428
|
+
children: /* @__PURE__ */ jsx39(
|
7080
7429
|
IconButton,
|
7081
7430
|
{
|
7082
7431
|
onClick: () => {
|
7083
7432
|
toggleSidebars("left");
|
7084
7433
|
},
|
7085
7434
|
title: "Toggle left sidebar",
|
7086
|
-
children: /* @__PURE__ */
|
7435
|
+
children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
|
7087
7436
|
}
|
7088
7437
|
)
|
7089
7438
|
}
|
7090
7439
|
),
|
7091
|
-
/* @__PURE__ */
|
7440
|
+
/* @__PURE__ */ jsx39(
|
7092
7441
|
"div",
|
7093
7442
|
{
|
7094
7443
|
className: getLayoutClassName("rightSideBarToggle"),
|
7095
|
-
children: /* @__PURE__ */
|
7444
|
+
children: /* @__PURE__ */ jsx39(
|
7096
7445
|
IconButton,
|
7097
7446
|
{
|
7098
7447
|
onClick: () => {
|
7099
7448
|
toggleSidebars("right");
|
7100
7449
|
},
|
7101
7450
|
title: "Toggle right sidebar",
|
7102
|
-
children: /* @__PURE__ */
|
7451
|
+
children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
|
7103
7452
|
}
|
7104
7453
|
)
|
7105
7454
|
}
|
7106
7455
|
)
|
7107
7456
|
] }),
|
7108
|
-
/* @__PURE__ */
|
7457
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
|
7109
7458
|
headerTitle || rootProps.title || "Page",
|
7110
7459
|
headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
|
7111
7460
|
" ",
|
7112
|
-
/* @__PURE__ */
|
7461
|
+
/* @__PURE__ */ jsx39(
|
7113
7462
|
"code",
|
7114
7463
|
{
|
7115
7464
|
className: getLayoutClassName("headerPath"),
|
@@ -7119,30 +7468,30 @@ function Puck({
|
|
7119
7468
|
] })
|
7120
7469
|
] }) }),
|
7121
7470
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
|
7122
|
-
/* @__PURE__ */
|
7471
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
|
7123
7472
|
IconButton,
|
7124
7473
|
{
|
7125
7474
|
onClick: () => {
|
7126
7475
|
return setMenuOpen(!menuOpen);
|
7127
7476
|
},
|
7128
7477
|
title: "Toggle menu bar",
|
7129
|
-
children: menuOpen ? /* @__PURE__ */
|
7478
|
+
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
7130
7479
|
}
|
7131
7480
|
) }),
|
7132
|
-
/* @__PURE__ */
|
7481
|
+
/* @__PURE__ */ jsx39(
|
7133
7482
|
MenuBar,
|
7134
7483
|
{
|
7135
7484
|
appState,
|
7136
7485
|
dispatch,
|
7137
7486
|
onPublish,
|
7138
7487
|
menuOpen,
|
7139
|
-
renderHeaderActions: () => /* @__PURE__ */
|
7488
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7140
7489
|
Button,
|
7141
7490
|
{
|
7142
7491
|
onClick: () => {
|
7143
7492
|
onPublish && onPublish(data);
|
7144
7493
|
},
|
7145
|
-
icon: /* @__PURE__ */
|
7494
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7146
7495
|
children: "Publish"
|
7147
7496
|
}
|
7148
7497
|
) }),
|
@@ -7154,18 +7503,18 @@ function Puck({
|
|
7154
7503
|
}
|
7155
7504
|
),
|
7156
7505
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7157
|
-
/* @__PURE__ */
|
7158
|
-
/* @__PURE__ */
|
7506
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
|
7507
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
|
7159
7508
|
] }),
|
7160
|
-
/* @__PURE__ */
|
7161
|
-
/* @__PURE__ */
|
7509
|
+
/* @__PURE__ */ jsx39(Canvas, {}),
|
7510
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
|
7162
7511
|
SidebarSection,
|
7163
7512
|
{
|
7164
7513
|
noPadding: true,
|
7165
7514
|
noBorderTop: true,
|
7166
7515
|
showBreadcrumbs: true,
|
7167
7516
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7168
|
-
children: /* @__PURE__ */
|
7517
|
+
children: /* @__PURE__ */ jsx39(Fields, {})
|
7169
7518
|
}
|
7170
7519
|
) })
|
7171
7520
|
] })
|
@@ -7173,69 +7522,13 @@ function Puck({
|
|
7173
7522
|
) }) })
|
7174
7523
|
}
|
7175
7524
|
),
|
7176
|
-
/* @__PURE__ */
|
7525
|
+
/* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7177
7526
|
] });
|
7178
7527
|
}
|
7179
7528
|
Puck.Components = Components;
|
7180
7529
|
Puck.Fields = Fields;
|
7181
7530
|
Puck.Outline = Outline;
|
7182
|
-
Puck.Preview =
|
7183
|
-
|
7184
|
-
// components/Render/index.tsx
|
7185
|
-
init_react_import();
|
7186
|
-
import { jsx as jsx38 } from "react/jsx-runtime";
|
7187
|
-
function Render({
|
7188
|
-
config,
|
7189
|
-
data
|
7190
|
-
}) {
|
7191
|
-
var _a;
|
7192
|
-
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
7193
|
-
root: data.root || {},
|
7194
|
-
content: data.content || []
|
7195
|
-
});
|
7196
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
7197
|
-
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
7198
|
-
if ((_a = config.root) == null ? void 0 : _a.render) {
|
7199
|
-
return /* @__PURE__ */ jsx38(
|
7200
|
-
DropZoneProvider,
|
7201
|
-
{
|
7202
|
-
value: {
|
7203
|
-
data: defaultedData,
|
7204
|
-
config,
|
7205
|
-
mode: "render",
|
7206
|
-
depth: 0,
|
7207
|
-
path: []
|
7208
|
-
},
|
7209
|
-
children: /* @__PURE__ */ jsx38(
|
7210
|
-
config.root.render,
|
7211
|
-
__spreadProps(__spreadValues({}, rootProps), {
|
7212
|
-
puck: {
|
7213
|
-
renderDropZone: DropZone,
|
7214
|
-
isEditing: false
|
7215
|
-
},
|
7216
|
-
title,
|
7217
|
-
editMode: false,
|
7218
|
-
id: "puck-root",
|
7219
|
-
children: /* @__PURE__ */ jsx38(DropZone, { zone: rootDroppableId })
|
7220
|
-
})
|
7221
|
-
)
|
7222
|
-
}
|
7223
|
-
);
|
7224
|
-
}
|
7225
|
-
return /* @__PURE__ */ jsx38(
|
7226
|
-
DropZoneProvider,
|
7227
|
-
{
|
7228
|
-
value: {
|
7229
|
-
data: defaultedData,
|
7230
|
-
config,
|
7231
|
-
mode: "render",
|
7232
|
-
depth: 0,
|
7233
|
-
path: []
|
7234
|
-
},
|
7235
|
-
children: /* @__PURE__ */ jsx38(DropZone, { zone: rootDroppableId })
|
7236
|
-
}
|
7237
|
-
);
|
7238
|
-
}
|
7531
|
+
Puck.Preview = Preview2;
|
7239
7532
|
|
7240
7533
|
// lib/migrate.ts
|
7241
7534
|
init_react_import();
|