@measured/puck 0.18.0-canary.874ba1b → 0.18.0-canary.97d25d4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/{chunk-EXKSBUY5.mjs → chunk-CHWFBYEM.mjs} +2 -4
- package/dist/index.css +44 -47
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +816 -637
- package/dist/index.mjs +658 -476
- package/dist/rsc.js +2 -4
- package/dist/rsc.mjs +1 -1
- package/package.json +1 -1
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({
|
@@ -205,13 +205,14 @@ init_react_import();
|
|
205
205
|
|
206
206
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
207
207
|
init_react_import();
|
208
|
-
var styles_module_default2 = { "InputWrapper": "
|
208
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
|
209
209
|
|
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
|
|
@@ -1165,8 +1166,53 @@ var Sortable = ({
|
|
1165
1166
|
return children({ status, ref: sortableRef });
|
1166
1167
|
};
|
1167
1168
|
|
1169
|
+
// components/AutoField/context.tsx
|
1170
|
+
init_react_import();
|
1171
|
+
import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
|
1172
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
1173
|
+
var NestedFieldContext = createContext2({});
|
1174
|
+
var useNestedFieldContext = () => {
|
1175
|
+
const context = useContext2(NestedFieldContext);
|
1176
|
+
return __spreadProps(__spreadValues({}, context), {
|
1177
|
+
readOnlyFields: context.readOnlyFields || {}
|
1178
|
+
});
|
1179
|
+
};
|
1180
|
+
var NestedFieldProvider = ({
|
1181
|
+
children,
|
1182
|
+
name,
|
1183
|
+
subName,
|
1184
|
+
wildcardName = name,
|
1185
|
+
readOnlyFields
|
1186
|
+
}) => {
|
1187
|
+
const subPath = `${name}.${subName}`;
|
1188
|
+
const wildcardSubPath = `${wildcardName}.${subName}`;
|
1189
|
+
const subReadOnlyFields = useMemo(
|
1190
|
+
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
1191
|
+
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
1192
|
+
if (isLocal) {
|
1193
|
+
const subPathPattern = new RegExp(
|
1194
|
+
`^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
|
1195
|
+
);
|
1196
|
+
const localName = readOnlyKey.replace(subPathPattern, "");
|
1197
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1198
|
+
[localName]: readOnlyFields[readOnlyKey]
|
1199
|
+
});
|
1200
|
+
}
|
1201
|
+
return acc;
|
1202
|
+
}, {}),
|
1203
|
+
[name, subName, wildcardName, readOnlyFields]
|
1204
|
+
);
|
1205
|
+
return /* @__PURE__ */ jsx7(
|
1206
|
+
NestedFieldContext.Provider,
|
1207
|
+
{
|
1208
|
+
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
1209
|
+
children
|
1210
|
+
}
|
1211
|
+
);
|
1212
|
+
};
|
1213
|
+
|
1168
1214
|
// components/AutoField/fields/ArrayField/index.tsx
|
1169
|
-
import { jsx as
|
1215
|
+
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
1170
1216
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
1171
1217
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
1172
1218
|
var ArrayField = ({
|
@@ -1177,10 +1223,10 @@ var ArrayField = ({
|
|
1177
1223
|
label,
|
1178
1224
|
readOnly,
|
1179
1225
|
id,
|
1180
|
-
Label: Label2 = (props) => /* @__PURE__ */
|
1226
|
+
Label: Label2 = (props) => /* @__PURE__ */ jsx8("div", __spreadValues({}, props))
|
1181
1227
|
}) => {
|
1182
1228
|
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
1183
|
-
const readOnlyFields =
|
1229
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
1184
1230
|
const value = _value;
|
1185
1231
|
const arrayState = state.ui.arrayState[id] || {
|
1186
1232
|
items: Array.from(value || []).map((item, idx) => {
|
@@ -1240,14 +1286,14 @@ var ArrayField = ({
|
|
1240
1286
|
return null;
|
1241
1287
|
}
|
1242
1288
|
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
1243
|
-
return /* @__PURE__ */
|
1289
|
+
return /* @__PURE__ */ jsx8(
|
1244
1290
|
Label2,
|
1245
1291
|
{
|
1246
1292
|
label: label || name,
|
1247
|
-
icon: /* @__PURE__ */
|
1293
|
+
icon: /* @__PURE__ */ jsx8(List, { size: 16 }),
|
1248
1294
|
el: "div",
|
1249
1295
|
readOnly,
|
1250
|
-
children: /* @__PURE__ */
|
1296
|
+
children: /* @__PURE__ */ jsx8(
|
1251
1297
|
SortableProvider,
|
1252
1298
|
{
|
1253
1299
|
onMove: (move) => {
|
@@ -1283,7 +1329,7 @@ var ArrayField = ({
|
|
1283
1329
|
localState.arrayState.items.map((item, i) => {
|
1284
1330
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
1285
1331
|
const data = Array.from(localState.value || [])[i] || {};
|
1286
|
-
return /* @__PURE__ */
|
1332
|
+
return /* @__PURE__ */ jsx8(
|
1287
1333
|
Sortable,
|
1288
1334
|
{
|
1289
1335
|
id: _arrayId,
|
@@ -1324,7 +1370,7 @@ var ArrayField = ({
|
|
1324
1370
|
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
1325
1371
|
/* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
|
1326
1372
|
!readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
|
1327
|
-
/* @__PURE__ */
|
1373
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
1328
1374
|
IconButton,
|
1329
1375
|
{
|
1330
1376
|
type: "button",
|
@@ -1341,10 +1387,10 @@ var ArrayField = ({
|
|
1341
1387
|
);
|
1342
1388
|
},
|
1343
1389
|
title: "Duplicate",
|
1344
|
-
children: /* @__PURE__ */
|
1390
|
+
children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
|
1345
1391
|
}
|
1346
1392
|
) }),
|
1347
|
-
/* @__PURE__ */
|
1393
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
1348
1394
|
IconButton,
|
1349
1395
|
{
|
1350
1396
|
type: "button",
|
@@ -1365,43 +1411,56 @@ var ArrayField = ({
|
|
1365
1411
|
);
|
1366
1412
|
},
|
1367
1413
|
title: "Delete",
|
1368
|
-
children: /* @__PURE__ */
|
1414
|
+
children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
|
1369
1415
|
}
|
1370
1416
|
) })
|
1371
1417
|
] }),
|
1372
|
-
/* @__PURE__ */
|
1418
|
+
/* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(DragIcon, {}) })
|
1373
1419
|
] })
|
1374
1420
|
]
|
1375
1421
|
}
|
1376
1422
|
),
|
1377
|
-
/* @__PURE__ */
|
1378
|
-
const subField = field.arrayFields[
|
1379
|
-
const
|
1380
|
-
const
|
1381
|
-
const
|
1382
|
-
const
|
1383
|
-
|
1384
|
-
|
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,
|
1385
1435
|
{
|
1386
|
-
name:
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
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
|
+
)
|
1403
1462
|
},
|
1404
|
-
|
1463
|
+
subPath
|
1405
1464
|
);
|
1406
1465
|
}) }) })
|
1407
1466
|
]
|
@@ -1411,7 +1470,7 @@ var ArrayField = ({
|
|
1411
1470
|
_arrayId
|
1412
1471
|
);
|
1413
1472
|
}),
|
1414
|
-
!addDisabled && /* @__PURE__ */
|
1473
|
+
!addDisabled && /* @__PURE__ */ jsx8(
|
1415
1474
|
"button",
|
1416
1475
|
{
|
1417
1476
|
type: "button",
|
@@ -1425,7 +1484,7 @@ var ArrayField = ({
|
|
1425
1484
|
const newArrayState = regenerateArrayState(newValue);
|
1426
1485
|
onChange(newValue, mapArrayStateToUi(newArrayState));
|
1427
1486
|
},
|
1428
|
-
children: /* @__PURE__ */
|
1487
|
+
children: /* @__PURE__ */ jsx8(Plus, { size: 21 })
|
1429
1488
|
}
|
1430
1489
|
)
|
1431
1490
|
]
|
@@ -1439,28 +1498,29 @@ var ArrayField = ({
|
|
1439
1498
|
|
1440
1499
|
// components/AutoField/fields/DefaultField/index.tsx
|
1441
1500
|
init_react_import();
|
1442
|
-
import { Fragment as Fragment2, jsx as
|
1501
|
+
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
1443
1502
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
1444
1503
|
var DefaultField = ({
|
1445
1504
|
field,
|
1446
1505
|
onChange,
|
1447
1506
|
readOnly,
|
1448
|
-
value,
|
1507
|
+
value: _value,
|
1449
1508
|
name,
|
1450
1509
|
label,
|
1451
1510
|
Label: Label2,
|
1452
1511
|
id
|
1453
1512
|
}) => {
|
1454
|
-
|
1513
|
+
const value = _value;
|
1514
|
+
return /* @__PURE__ */ jsx9(
|
1455
1515
|
Label2,
|
1456
1516
|
{
|
1457
1517
|
label: label || name,
|
1458
1518
|
icon: /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
1459
|
-
field.type === "text" && /* @__PURE__ */
|
1460
|
-
field.type === "number" && /* @__PURE__ */
|
1519
|
+
field.type === "text" && /* @__PURE__ */ jsx9(Type, { size: 16 }),
|
1520
|
+
field.type === "number" && /* @__PURE__ */ jsx9(Hash, { size: 16 })
|
1461
1521
|
] }),
|
1462
1522
|
readOnly,
|
1463
|
-
children: /* @__PURE__ */
|
1523
|
+
children: /* @__PURE__ */ jsx9(
|
1464
1524
|
"input",
|
1465
1525
|
{
|
1466
1526
|
className: getClassName6("input"),
|
@@ -1468,10 +1528,17 @@ var DefaultField = ({
|
|
1468
1528
|
type: field.type,
|
1469
1529
|
title: label || name,
|
1470
1530
|
name,
|
1471
|
-
value:
|
1531
|
+
value: (value == null ? void 0 : value.toString) ? value.toString() : "",
|
1472
1532
|
onChange: (e) => {
|
1473
1533
|
if (field.type === "number") {
|
1474
|
-
|
1534
|
+
const numberValue = Number(e.currentTarget.value);
|
1535
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
1536
|
+
return;
|
1537
|
+
}
|
1538
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
1539
|
+
return;
|
1540
|
+
}
|
1541
|
+
onChange(numberValue);
|
1475
1542
|
} else {
|
1476
1543
|
onChange(e.currentTarget.value);
|
1477
1544
|
}
|
@@ -1494,7 +1561,7 @@ import { useEffect as useEffect8 } from "react";
|
|
1494
1561
|
// components/ExternalInput/index.tsx
|
1495
1562
|
init_react_import();
|
1496
1563
|
import {
|
1497
|
-
useMemo,
|
1564
|
+
useMemo as useMemo2,
|
1498
1565
|
useEffect as useEffect7,
|
1499
1566
|
useState as useState9,
|
1500
1567
|
useCallback as useCallback4,
|
@@ -1515,7 +1582,7 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
1515
1582
|
|
1516
1583
|
// components/Modal/index.tsx
|
1517
1584
|
import { createPortal } from "react-dom";
|
1518
|
-
import { jsx as
|
1585
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
1519
1586
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
1520
1587
|
var Modal = ({
|
1521
1588
|
children,
|
@@ -1527,10 +1594,10 @@ var Modal = ({
|
|
1527
1594
|
setRootEl(document.getElementById("puck-portal-root"));
|
1528
1595
|
}, []);
|
1529
1596
|
if (!rootEl) {
|
1530
|
-
return /* @__PURE__ */
|
1597
|
+
return /* @__PURE__ */ jsx10("div", {});
|
1531
1598
|
}
|
1532
1599
|
return createPortal(
|
1533
|
-
/* @__PURE__ */
|
1600
|
+
/* @__PURE__ */ jsx10("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx10(
|
1534
1601
|
"div",
|
1535
1602
|
{
|
1536
1603
|
className: getClassName7("inner"),
|
@@ -1550,11 +1617,11 @@ init_react_import();
|
|
1550
1617
|
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" };
|
1551
1618
|
|
1552
1619
|
// components/Heading/index.tsx
|
1553
|
-
import { jsx as
|
1620
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
1554
1621
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
1555
1622
|
var Heading = ({ children, rank, size = "m" }) => {
|
1556
1623
|
const Tag = rank ? `h${rank}` : "span";
|
1557
|
-
return /* @__PURE__ */
|
1624
|
+
return /* @__PURE__ */ jsx11(
|
1558
1625
|
Tag,
|
1559
1626
|
{
|
1560
1627
|
className: getClassName8({
|
@@ -1590,7 +1657,7 @@ var filterDataAttrs = (props) => {
|
|
1590
1657
|
};
|
1591
1658
|
|
1592
1659
|
// components/Button/Button.tsx
|
1593
|
-
import { jsx as
|
1660
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
1594
1661
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
1595
1662
|
var Button = (_a) => {
|
1596
1663
|
var _b = _a, {
|
@@ -1649,9 +1716,9 @@ var Button = (_a) => {
|
|
1649
1716
|
href
|
1650
1717
|
}, dataAttrs), {
|
1651
1718
|
children: [
|
1652
|
-
icon && /* @__PURE__ */
|
1719
|
+
icon && /* @__PURE__ */ jsx12("div", { className: getClassName9("icon"), children: icon }),
|
1653
1720
|
children,
|
1654
|
-
loading && /* @__PURE__ */
|
1721
|
+
loading && /* @__PURE__ */ jsx12("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx12(Loader, { size: 14 }) })
|
1655
1722
|
]
|
1656
1723
|
})
|
1657
1724
|
);
|
@@ -1659,7 +1726,7 @@ var Button = (_a) => {
|
|
1659
1726
|
};
|
1660
1727
|
|
1661
1728
|
// components/ExternalInput/index.tsx
|
1662
|
-
import { Fragment as Fragment3, jsx as
|
1729
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
1663
1730
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
1664
1731
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
1665
1732
|
var dataCache = {};
|
@@ -1682,10 +1749,10 @@ var ExternalInput = ({
|
|
1682
1749
|
const hasFilterFields = !!filterFields;
|
1683
1750
|
const [filters, setFilters] = useState9(field.initialFilters || {});
|
1684
1751
|
const [filtersToggled, setFiltersToggled] = useState9(hasFilterFields);
|
1685
|
-
const mappedData =
|
1752
|
+
const mappedData = useMemo2(() => {
|
1686
1753
|
return data.map(mapRow);
|
1687
1754
|
}, [data]);
|
1688
|
-
const keys =
|
1755
|
+
const keys = useMemo2(() => {
|
1689
1756
|
const validKeys = /* @__PURE__ */ new Set();
|
1690
1757
|
for (const item of mappedData) {
|
1691
1758
|
for (const key of Object.keys(item)) {
|
@@ -1732,7 +1799,7 @@ var ExternalInput = ({
|
|
1732
1799
|
id,
|
1733
1800
|
children: [
|
1734
1801
|
/* @__PURE__ */ jsxs6("div", { className: getClassName10("actions"), children: [
|
1735
|
-
/* @__PURE__ */
|
1802
|
+
/* @__PURE__ */ jsx13(
|
1736
1803
|
"button",
|
1737
1804
|
{
|
1738
1805
|
type: "button",
|
@@ -1740,12 +1807,12 @@ var ExternalInput = ({
|
|
1740
1807
|
className: getClassName10("button"),
|
1741
1808
|
disabled: readOnly,
|
1742
1809
|
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
1743
|
-
/* @__PURE__ */
|
1744
|
-
/* @__PURE__ */
|
1810
|
+
/* @__PURE__ */ jsx13(Link, { size: "16" }),
|
1811
|
+
/* @__PURE__ */ jsx13("span", { children: field.placeholder })
|
1745
1812
|
] })
|
1746
1813
|
}
|
1747
1814
|
),
|
1748
|
-
value && /* @__PURE__ */
|
1815
|
+
value && /* @__PURE__ */ jsx13(
|
1749
1816
|
"button",
|
1750
1817
|
{
|
1751
1818
|
type: "button",
|
@@ -1754,11 +1821,11 @@ var ExternalInput = ({
|
|
1754
1821
|
onChange(null);
|
1755
1822
|
},
|
1756
1823
|
disabled: readOnly,
|
1757
|
-
children: /* @__PURE__ */
|
1824
|
+
children: /* @__PURE__ */ jsx13(LockOpen, { size: 16 })
|
1758
1825
|
}
|
1759
1826
|
)
|
1760
1827
|
] }),
|
1761
|
-
/* @__PURE__ */
|
1828
|
+
/* @__PURE__ */ jsx13(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
|
1762
1829
|
"form",
|
1763
1830
|
{
|
1764
1831
|
className: getClassNameModal({
|
@@ -1772,11 +1839,11 @@ var ExternalInput = ({
|
|
1772
1839
|
search(searchQuery, filters);
|
1773
1840
|
},
|
1774
1841
|
children: [
|
1775
|
-
/* @__PURE__ */
|
1842
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
|
1776
1843
|
/* @__PURE__ */ jsxs6("label", { className: getClassNameModal("search"), children: [
|
1777
|
-
/* @__PURE__ */
|
1778
|
-
/* @__PURE__ */
|
1779
|
-
/* @__PURE__ */
|
1844
|
+
/* @__PURE__ */ jsx13("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
1845
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx13(Search, { size: "18" }) }),
|
1846
|
+
/* @__PURE__ */ jsx13(
|
1780
1847
|
"input",
|
1781
1848
|
{
|
1782
1849
|
className: getClassNameModal("searchInput"),
|
@@ -1792,8 +1859,8 @@ var ExternalInput = ({
|
|
1792
1859
|
)
|
1793
1860
|
] }),
|
1794
1861
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchActions"), children: [
|
1795
|
-
/* @__PURE__ */
|
1796
|
-
hasFilterFields && /* @__PURE__ */
|
1862
|
+
/* @__PURE__ */ jsx13(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
1863
|
+
hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx13(
|
1797
1864
|
IconButton,
|
1798
1865
|
{
|
1799
1866
|
title: "Toggle filters",
|
@@ -1802,15 +1869,15 @@ var ExternalInput = ({
|
|
1802
1869
|
e.stopPropagation();
|
1803
1870
|
setFiltersToggled(!filtersToggled);
|
1804
1871
|
},
|
1805
|
-
children: /* @__PURE__ */
|
1872
|
+
children: /* @__PURE__ */ jsx13(SlidersHorizontal, { size: 20 })
|
1806
1873
|
}
|
1807
1874
|
) })
|
1808
1875
|
] })
|
1809
|
-
] }) : /* @__PURE__ */
|
1876
|
+
] }) : /* @__PURE__ */ jsx13(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
1810
1877
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("grid"), children: [
|
1811
|
-
hasFilterFields && /* @__PURE__ */
|
1878
|
+
hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
1812
1879
|
const filterField = filterFields[fieldName];
|
1813
|
-
return /* @__PURE__ */
|
1880
|
+
return /* @__PURE__ */ jsx13(
|
1814
1881
|
AutoFieldPrivate,
|
1815
1882
|
{
|
1816
1883
|
field: filterField,
|
@@ -1829,7 +1896,7 @@ var ExternalInput = ({
|
|
1829
1896
|
}) }),
|
1830
1897
|
/* @__PURE__ */ jsxs6("div", { className: getClassNameModal("tableWrapper"), children: [
|
1831
1898
|
/* @__PURE__ */ jsxs6("table", { className: getClassNameModal("table"), children: [
|
1832
|
-
/* @__PURE__ */
|
1899
|
+
/* @__PURE__ */ jsx13("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx13("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx13(
|
1833
1900
|
"th",
|
1834
1901
|
{
|
1835
1902
|
className: getClassNameModal("th"),
|
@@ -1838,8 +1905,8 @@ var ExternalInput = ({
|
|
1838
1905
|
},
|
1839
1906
|
key
|
1840
1907
|
)) }) }),
|
1841
|
-
/* @__PURE__ */
|
1842
|
-
return /* @__PURE__ */
|
1908
|
+
/* @__PURE__ */ jsx13("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
1909
|
+
return /* @__PURE__ */ jsx13(
|
1843
1910
|
"tr",
|
1844
1911
|
{
|
1845
1912
|
style: { whiteSpace: "nowrap" },
|
@@ -1848,16 +1915,16 @@ var ExternalInput = ({
|
|
1848
1915
|
onChange(mapProp(data[i]));
|
1849
1916
|
setOpen(false);
|
1850
1917
|
},
|
1851
|
-
children: keys.map((key) => /* @__PURE__ */
|
1918
|
+
children: keys.map((key) => /* @__PURE__ */ jsx13("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
1852
1919
|
},
|
1853
1920
|
i
|
1854
1921
|
);
|
1855
1922
|
}) })
|
1856
1923
|
] }),
|
1857
|
-
/* @__PURE__ */
|
1924
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx13(Loader, { size: 24 }) })
|
1858
1925
|
] })
|
1859
1926
|
] }),
|
1860
|
-
/* @__PURE__ */
|
1927
|
+
/* @__PURE__ */ jsx13("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx13(Footer, { items: mappedData }) })
|
1861
1928
|
]
|
1862
1929
|
}
|
1863
1930
|
) })
|
@@ -1867,7 +1934,7 @@ var ExternalInput = ({
|
|
1867
1934
|
};
|
1868
1935
|
|
1869
1936
|
// components/AutoField/fields/ExternalField/index.tsx
|
1870
|
-
import { jsx as
|
1937
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
1871
1938
|
var ExternalField = ({
|
1872
1939
|
field,
|
1873
1940
|
onChange,
|
@@ -1891,7 +1958,7 @@ var ExternalField = ({
|
|
1891
1958
|
if (field.type !== "external") {
|
1892
1959
|
return null;
|
1893
1960
|
}
|
1894
|
-
return /* @__PURE__ */
|
1961
|
+
return /* @__PURE__ */ jsx14(Label2, { label: label || name, icon: /* @__PURE__ */ jsx14(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx14(
|
1895
1962
|
ExternalInput,
|
1896
1963
|
{
|
1897
1964
|
name,
|
@@ -1916,7 +1983,7 @@ var ExternalField = ({
|
|
1916
1983
|
|
1917
1984
|
// components/AutoField/fields/RadioField/index.tsx
|
1918
1985
|
init_react_import();
|
1919
|
-
import { useMemo as
|
1986
|
+
import { useMemo as useMemo3 } from "react";
|
1920
1987
|
|
1921
1988
|
// lib/safe-json-parse.ts
|
1922
1989
|
init_react_import();
|
@@ -1930,7 +1997,7 @@ var safeJsonParse = (str) => {
|
|
1930
1997
|
};
|
1931
1998
|
|
1932
1999
|
// components/AutoField/fields/RadioField/index.tsx
|
1933
|
-
import { jsx as
|
2000
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
1934
2001
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
1935
2002
|
var RadioField = ({
|
1936
2003
|
field,
|
@@ -1942,26 +2009,26 @@ var RadioField = ({
|
|
1942
2009
|
label,
|
1943
2010
|
Label: Label2
|
1944
2011
|
}) => {
|
1945
|
-
const flatOptions =
|
2012
|
+
const flatOptions = useMemo3(
|
1946
2013
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
1947
2014
|
[field]
|
1948
2015
|
);
|
1949
2016
|
if (field.type !== "radio" || !field.options) {
|
1950
2017
|
return null;
|
1951
2018
|
}
|
1952
|
-
return /* @__PURE__ */
|
2019
|
+
return /* @__PURE__ */ jsx15(
|
1953
2020
|
Label2,
|
1954
2021
|
{
|
1955
|
-
icon: /* @__PURE__ */
|
2022
|
+
icon: /* @__PURE__ */ jsx15(CircleCheckBig, { size: 16 }),
|
1956
2023
|
label: label || name,
|
1957
2024
|
readOnly,
|
1958
2025
|
el: "div",
|
1959
|
-
children: /* @__PURE__ */
|
2026
|
+
children: /* @__PURE__ */ jsx15("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs7(
|
1960
2027
|
"label",
|
1961
2028
|
{
|
1962
2029
|
className: getClassName11("radio"),
|
1963
2030
|
children: [
|
1964
|
-
/* @__PURE__ */
|
2031
|
+
/* @__PURE__ */ jsx15(
|
1965
2032
|
"input",
|
1966
2033
|
{
|
1967
2034
|
type: "radio",
|
@@ -1981,7 +2048,7 @@ var RadioField = ({
|
|
1981
2048
|
checked: value === option.value
|
1982
2049
|
}
|
1983
2050
|
),
|
1984
|
-
/* @__PURE__ */
|
2051
|
+
/* @__PURE__ */ jsx15("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
1985
2052
|
]
|
1986
2053
|
},
|
1987
2054
|
option.label + option.value
|
@@ -1992,8 +2059,8 @@ var RadioField = ({
|
|
1992
2059
|
|
1993
2060
|
// components/AutoField/fields/SelectField/index.tsx
|
1994
2061
|
init_react_import();
|
1995
|
-
import { useMemo as
|
1996
|
-
import { jsx as
|
2062
|
+
import { useMemo as useMemo4 } from "react";
|
2063
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
1997
2064
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
1998
2065
|
var SelectField = ({
|
1999
2066
|
field,
|
@@ -2005,20 +2072,20 @@ var SelectField = ({
|
|
2005
2072
|
readOnly,
|
2006
2073
|
id
|
2007
2074
|
}) => {
|
2008
|
-
const flatOptions =
|
2075
|
+
const flatOptions = useMemo4(
|
2009
2076
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2010
2077
|
[field]
|
2011
2078
|
);
|
2012
2079
|
if (field.type !== "select" || !field.options) {
|
2013
2080
|
return null;
|
2014
2081
|
}
|
2015
|
-
return /* @__PURE__ */
|
2082
|
+
return /* @__PURE__ */ jsx16(
|
2016
2083
|
Label2,
|
2017
2084
|
{
|
2018
2085
|
label: label || name,
|
2019
|
-
icon: /* @__PURE__ */
|
2086
|
+
icon: /* @__PURE__ */ jsx16(ChevronDown, { size: 16 }),
|
2020
2087
|
readOnly,
|
2021
|
-
children: /* @__PURE__ */
|
2088
|
+
children: /* @__PURE__ */ jsx16(
|
2022
2089
|
"select",
|
2023
2090
|
{
|
2024
2091
|
id,
|
@@ -2035,7 +2102,7 @@ var SelectField = ({
|
|
2035
2102
|
}
|
2036
2103
|
},
|
2037
2104
|
value,
|
2038
|
-
children: field.options.map((option) => /* @__PURE__ */
|
2105
|
+
children: field.options.map((option) => /* @__PURE__ */ jsx16(
|
2039
2106
|
"option",
|
2040
2107
|
{
|
2041
2108
|
label: option.label,
|
@@ -2051,7 +2118,7 @@ var SelectField = ({
|
|
2051
2118
|
|
2052
2119
|
// components/AutoField/fields/TextareaField/index.tsx
|
2053
2120
|
init_react_import();
|
2054
|
-
import { jsx as
|
2121
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
2055
2122
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2056
2123
|
var TextareaField = ({
|
2057
2124
|
onChange,
|
@@ -2062,7 +2129,7 @@ var TextareaField = ({
|
|
2062
2129
|
Label: Label2,
|
2063
2130
|
id
|
2064
2131
|
}) => {
|
2065
|
-
return /* @__PURE__ */
|
2132
|
+
return /* @__PURE__ */ jsx17(Label2, { label: label || name, icon: /* @__PURE__ */ jsx17(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx17(
|
2066
2133
|
"textarea",
|
2067
2134
|
{
|
2068
2135
|
id,
|
@@ -2089,7 +2156,7 @@ init_react_import();
|
|
2089
2156
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
2090
2157
|
|
2091
2158
|
// components/AutoField/fields/ObjectField/index.tsx
|
2092
|
-
import { jsx as
|
2159
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
2093
2160
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
2094
2161
|
var ObjectField = ({
|
2095
2162
|
field,
|
@@ -2101,47 +2168,54 @@ var ObjectField = ({
|
|
2101
2168
|
readOnly,
|
2102
2169
|
id
|
2103
2170
|
}) => {
|
2104
|
-
const {
|
2171
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
2105
2172
|
if (field.type !== "object" || !field.objectFields) {
|
2106
2173
|
return null;
|
2107
2174
|
}
|
2108
|
-
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
2109
2175
|
const data = value || {};
|
2110
|
-
return /* @__PURE__ */
|
2176
|
+
return /* @__PURE__ */ jsx18(
|
2111
2177
|
Label2,
|
2112
2178
|
{
|
2113
2179
|
label: label || name,
|
2114
|
-
icon: /* @__PURE__ */
|
2180
|
+
icon: /* @__PURE__ */ jsx18(EllipsisVertical, { size: 16 }),
|
2115
2181
|
el: "div",
|
2116
2182
|
readOnly,
|
2117
|
-
children: /* @__PURE__ */
|
2118
|
-
const subField = field.objectFields[
|
2119
|
-
const
|
2120
|
-
const
|
2121
|
-
const subReadOnly = readOnly ? readOnly :
|
2122
|
-
const label2 = subField.label ||
|
2123
|
-
return /* @__PURE__ */
|
2124
|
-
|
2183
|
+
children: /* @__PURE__ */ jsx18("div", { className: getClassName14(), children: /* @__PURE__ */ jsx18("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
2184
|
+
const subField = field.objectFields[subName];
|
2185
|
+
const subPath = `${name}.${subName}`;
|
2186
|
+
const localSubPath = `${localName || name}.${subName}`;
|
2187
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
2188
|
+
const label2 = subField.label || subName;
|
2189
|
+
return /* @__PURE__ */ jsx18(
|
2190
|
+
NestedFieldProvider,
|
2125
2191
|
{
|
2126
|
-
name:
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2192
|
+
name: localName || id,
|
2193
|
+
subName,
|
2194
|
+
readOnlyFields,
|
2195
|
+
children: /* @__PURE__ */ jsx18(
|
2196
|
+
AutoFieldPrivate,
|
2197
|
+
{
|
2198
|
+
name: subPath,
|
2199
|
+
label: subPath,
|
2200
|
+
id: `${id}_${subName}`,
|
2201
|
+
readOnly: subReadOnly,
|
2202
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2203
|
+
label: label2
|
2204
|
+
// May be used by custom fields
|
2139
2205
|
}),
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2206
|
+
value: data[subName],
|
2207
|
+
onChange: (val, ui) => {
|
2208
|
+
onChange(
|
2209
|
+
__spreadProps(__spreadValues({}, data), {
|
2210
|
+
[subName]: val
|
2211
|
+
}),
|
2212
|
+
ui
|
2213
|
+
);
|
2214
|
+
}
|
2215
|
+
}
|
2216
|
+
)
|
2143
2217
|
},
|
2144
|
-
|
2218
|
+
subPath
|
2145
2219
|
);
|
2146
2220
|
}) }) })
|
2147
2221
|
}
|
@@ -2167,7 +2241,7 @@ var useSafeId = () => {
|
|
2167
2241
|
};
|
2168
2242
|
|
2169
2243
|
// components/AutoField/index.tsx
|
2170
|
-
import { Fragment as Fragment4, jsx as
|
2244
|
+
import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
2171
2245
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
2172
2246
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
2173
2247
|
var FieldLabel = ({
|
@@ -2181,14 +2255,14 @@ var FieldLabel = ({
|
|
2181
2255
|
const El = el;
|
2182
2256
|
return /* @__PURE__ */ jsxs8(El, { className, children: [
|
2183
2257
|
/* @__PURE__ */ jsxs8("div", { className: getClassName15("label"), children: [
|
2184
|
-
icon ? /* @__PURE__ */
|
2258
|
+
icon ? /* @__PURE__ */ jsx19("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx19(Fragment4, {}),
|
2185
2259
|
label,
|
2186
|
-
readOnly && /* @__PURE__ */
|
2260
|
+
readOnly && /* @__PURE__ */ jsx19("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx19(Lock, { size: "12" }) })
|
2187
2261
|
] }),
|
2188
2262
|
children
|
2189
2263
|
] });
|
2190
2264
|
};
|
2191
|
-
var
|
2265
|
+
var FieldLabelInternal = ({
|
2192
2266
|
children,
|
2193
2267
|
icon,
|
2194
2268
|
label,
|
@@ -2196,14 +2270,14 @@ var FieldLabelInternal2 = ({
|
|
2196
2270
|
readOnly
|
2197
2271
|
}) => {
|
2198
2272
|
const { overrides } = useAppContext();
|
2199
|
-
const Wrapper =
|
2273
|
+
const Wrapper = useMemo5(
|
2200
2274
|
() => overrides.fieldLabel || FieldLabel,
|
2201
2275
|
[overrides]
|
2202
2276
|
);
|
2203
2277
|
if (!label) {
|
2204
|
-
return /* @__PURE__ */
|
2278
|
+
return /* @__PURE__ */ jsx19(Fragment4, { children });
|
2205
2279
|
}
|
2206
|
-
return /* @__PURE__ */
|
2280
|
+
return /* @__PURE__ */ jsx19(
|
2207
2281
|
Wrapper,
|
2208
2282
|
{
|
2209
2283
|
label,
|
@@ -2217,8 +2291,9 @@ var FieldLabelInternal2 = ({
|
|
2217
2291
|
};
|
2218
2292
|
function AutoFieldInternal(props) {
|
2219
2293
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2220
|
-
const { dispatch, overrides } = useAppContext();
|
2221
|
-
const
|
2294
|
+
const { dispatch, overrides, selectedItem } = useAppContext();
|
2295
|
+
const nestedFieldContext = useContext3(NestedFieldContext);
|
2296
|
+
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2222
2297
|
const field = props.field;
|
2223
2298
|
const label = field.label;
|
2224
2299
|
const defaultId = useSafeId();
|
@@ -2278,20 +2353,29 @@ function AutoFieldInternal(props) {
|
|
2278
2353
|
return null;
|
2279
2354
|
}
|
2280
2355
|
const CustomField = field.render;
|
2281
|
-
return /* @__PURE__ */
|
2356
|
+
return /* @__PURE__ */ jsx19("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx19("div", { className: getClassName15(), children: /* @__PURE__ */ jsx19(CustomField, __spreadValues({}, mergedProps)) }) });
|
2282
2357
|
}
|
2283
2358
|
const children = defaultFields[field.type](mergedProps);
|
2284
2359
|
const Render2 = render[field.type];
|
2285
|
-
return /* @__PURE__ */
|
2286
|
-
|
2360
|
+
return /* @__PURE__ */ jsx19(
|
2361
|
+
NestedFieldContext.Provider,
|
2287
2362
|
{
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
onClick: (e) => {
|
2292
|
-
e.stopPropagation();
|
2363
|
+
value: {
|
2364
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
|
2365
|
+
localName: nestedFieldContext.localName
|
2293
2366
|
},
|
2294
|
-
children: /* @__PURE__ */
|
2367
|
+
children: /* @__PURE__ */ jsx19(
|
2368
|
+
"div",
|
2369
|
+
{
|
2370
|
+
className: getClassNameWrapper(),
|
2371
|
+
onFocus,
|
2372
|
+
onBlur,
|
2373
|
+
onClick: (e) => {
|
2374
|
+
e.stopPropagation();
|
2375
|
+
},
|
2376
|
+
children: /* @__PURE__ */ jsx19(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
2377
|
+
}
|
2378
|
+
)
|
2295
2379
|
}
|
2296
2380
|
);
|
2297
2381
|
}
|
@@ -2319,11 +2403,11 @@ function AutoFieldPrivate(props) {
|
|
2319
2403
|
value: localValue,
|
2320
2404
|
onChange: onChangeLocal
|
2321
2405
|
};
|
2322
|
-
return /* @__PURE__ */
|
2406
|
+
return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2323
2407
|
}
|
2324
2408
|
function AutoField(props) {
|
2325
|
-
const DefaultLabel =
|
2326
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */
|
2409
|
+
const DefaultLabel = useMemo5(() => {
|
2410
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx19(
|
2327
2411
|
"div",
|
2328
2412
|
__spreadProps(__spreadValues({}, labelProps), {
|
2329
2413
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -2331,7 +2415,7 @@ function AutoField(props) {
|
|
2331
2415
|
);
|
2332
2416
|
return DefaultLabel2;
|
2333
2417
|
}, [props.readOnly]);
|
2334
|
-
return /* @__PURE__ */
|
2418
|
+
return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2335
2419
|
}
|
2336
2420
|
|
2337
2421
|
// components/Drawer/index.tsx
|
@@ -2342,18 +2426,18 @@ init_react_import();
|
|
2342
2426
|
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" };
|
2343
2427
|
|
2344
2428
|
// components/Drawer/index.tsx
|
2345
|
-
import { useMemo as
|
2429
|
+
import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
|
2346
2430
|
|
2347
2431
|
// components/DragDropContext/index.tsx
|
2348
2432
|
init_react_import();
|
2349
2433
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
2350
2434
|
import {
|
2351
|
-
createContext as
|
2435
|
+
createContext as createContext4,
|
2352
2436
|
useCallback as useCallback11,
|
2353
|
-
useContext as
|
2437
|
+
useContext as useContext7,
|
2354
2438
|
useEffect as useEffect15,
|
2355
2439
|
useId,
|
2356
|
-
useRef as
|
2440
|
+
useRef as useRef3,
|
2357
2441
|
useState as useState17
|
2358
2442
|
} from "react";
|
2359
2443
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
@@ -2363,20 +2447,20 @@ init_react_import();
|
|
2363
2447
|
import {
|
2364
2448
|
forwardRef as forwardRef3,
|
2365
2449
|
useCallback as useCallback10,
|
2366
|
-
useContext as
|
2450
|
+
useContext as useContext6,
|
2367
2451
|
useEffect as useEffect14,
|
2368
|
-
useMemo as
|
2369
|
-
useRef as
|
2452
|
+
useMemo as useMemo8,
|
2453
|
+
useRef as useRef2
|
2370
2454
|
} from "react";
|
2371
2455
|
|
2372
2456
|
// components/DraggableComponent/index.tsx
|
2373
2457
|
init_react_import();
|
2374
2458
|
import {
|
2375
2459
|
useCallback as useCallback7,
|
2376
|
-
useContext as
|
2460
|
+
useContext as useContext5,
|
2377
2461
|
useEffect as useEffect10,
|
2378
|
-
useMemo as
|
2379
|
-
useRef
|
2462
|
+
useMemo as useMemo7,
|
2463
|
+
useRef,
|
2380
2464
|
useState as useState13
|
2381
2465
|
} from "react";
|
2382
2466
|
|
@@ -2747,15 +2831,15 @@ function getDeepScrollPosition(element) {
|
|
2747
2831
|
// components/DropZone/context.tsx
|
2748
2832
|
init_react_import();
|
2749
2833
|
import {
|
2750
|
-
createContext as
|
2834
|
+
createContext as createContext3,
|
2751
2835
|
useCallback as useCallback6,
|
2752
|
-
useMemo as
|
2836
|
+
useMemo as useMemo6,
|
2753
2837
|
useState as useState12
|
2754
2838
|
} from "react";
|
2755
2839
|
import { createStore as createStore2 } from "zustand";
|
2756
|
-
import { Fragment as Fragment5, jsx as
|
2757
|
-
var dropZoneContext =
|
2758
|
-
var ZoneStoreContext =
|
2840
|
+
import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
|
2841
|
+
var dropZoneContext = createContext3(null);
|
2842
|
+
var ZoneStoreContext = createContext3(
|
2759
2843
|
createStore2(() => ({
|
2760
2844
|
zoneDepthIndex: {},
|
2761
2845
|
nextZoneDepthIndex: {},
|
@@ -2769,7 +2853,7 @@ var ZoneStoreProvider = ({
|
|
2769
2853
|
children,
|
2770
2854
|
store
|
2771
2855
|
}) => {
|
2772
|
-
return /* @__PURE__ */
|
2856
|
+
return /* @__PURE__ */ jsx20(ZoneStoreContext.Provider, { value: store, children });
|
2773
2857
|
};
|
2774
2858
|
var DropZoneProvider = ({
|
2775
2859
|
children,
|
@@ -2815,7 +2899,7 @@ var DropZoneProvider = ({
|
|
2815
2899
|
},
|
2816
2900
|
[setActiveZones, dispatch]
|
2817
2901
|
);
|
2818
|
-
const memoValue =
|
2902
|
+
const memoValue = useMemo6(
|
2819
2903
|
() => __spreadValues({
|
2820
2904
|
hoveringComponent,
|
2821
2905
|
setHoveringComponent,
|
@@ -2827,16 +2911,16 @@ var DropZoneProvider = ({
|
|
2827
2911
|
}, value),
|
2828
2912
|
[value, hoveringComponent, areasWithZones, activeZones]
|
2829
2913
|
);
|
2830
|
-
return /* @__PURE__ */
|
2914
|
+
return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
|
2831
2915
|
};
|
2832
2916
|
|
2833
2917
|
// lib/use-context-store.ts
|
2834
2918
|
init_react_import();
|
2835
|
-
import { useContext as
|
2919
|
+
import { useContext as useContext4 } from "react";
|
2836
2920
|
import { useStore } from "zustand";
|
2837
2921
|
import { useShallow } from "zustand/react/shallow";
|
2838
2922
|
function useContextStore(context, selector) {
|
2839
|
-
const store =
|
2923
|
+
const store = useContext4(context);
|
2840
2924
|
if (!store) {
|
2841
2925
|
throw new Error("useContextStore must be used inside context");
|
2842
2926
|
}
|
@@ -2844,7 +2928,7 @@ function useContextStore(context, selector) {
|
|
2844
2928
|
}
|
2845
2929
|
|
2846
2930
|
// components/DraggableComponent/index.tsx
|
2847
|
-
import { jsx as
|
2931
|
+
import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
|
2848
2932
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2849
2933
|
var DEBUG2 = false;
|
2850
2934
|
var space = 8;
|
@@ -2858,9 +2942,9 @@ var DefaultActionBar = ({
|
|
2858
2942
|
}) => /* @__PURE__ */ jsxs9(ActionBar, { children: [
|
2859
2943
|
/* @__PURE__ */ jsxs9(ActionBar.Group, { children: [
|
2860
2944
|
parentAction,
|
2861
|
-
label && /* @__PURE__ */
|
2945
|
+
label && /* @__PURE__ */ jsx21(ActionBar.Label, { label })
|
2862
2946
|
] }),
|
2863
|
-
/* @__PURE__ */
|
2947
|
+
/* @__PURE__ */ jsx21(ActionBar.Group, { children })
|
2864
2948
|
] });
|
2865
2949
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
2866
2950
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -2895,7 +2979,7 @@ var DraggableComponent = ({
|
|
2895
2979
|
iframe,
|
2896
2980
|
state
|
2897
2981
|
} = useAppContext();
|
2898
|
-
const ctx =
|
2982
|
+
const ctx = useContext5(dropZoneContext);
|
2899
2983
|
const [localZones, setLocalZones] = useState13({});
|
2900
2984
|
const registerLocalZone = useCallback7(
|
2901
2985
|
(zoneCompound2, active) => {
|
@@ -2964,7 +3048,7 @@ var DraggableComponent = ({
|
|
2964
3048
|
}
|
2965
3049
|
});
|
2966
3050
|
const thisIsDragging = status === "dragging";
|
2967
|
-
const ref =
|
3051
|
+
const ref = useRef(null);
|
2968
3052
|
const refSetter = useCallback7(
|
2969
3053
|
(el) => {
|
2970
3054
|
sortableRef(el);
|
@@ -3022,7 +3106,7 @@ var DraggableComponent = ({
|
|
3022
3106
|
});
|
3023
3107
|
}
|
3024
3108
|
}, [isSelected]);
|
3025
|
-
const CustomActionBar =
|
3109
|
+
const CustomActionBar = useMemo7(
|
3026
3110
|
() => overrides.actionBar || DefaultActionBar,
|
3027
3111
|
[overrides.actionBar]
|
3028
3112
|
);
|
@@ -3174,7 +3258,7 @@ var DraggableComponent = ({
|
|
3174
3258
|
}
|
3175
3259
|
setDragAxis(autoDragAxis);
|
3176
3260
|
}, [ref, userDragAxis, autoDragAxis]);
|
3177
|
-
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */
|
3261
|
+
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 }) });
|
3178
3262
|
return /* @__PURE__ */ jsxs9(
|
3179
3263
|
DropZoneProvider,
|
3180
3264
|
{
|
@@ -3201,15 +3285,15 @@ var DraggableComponent = ({
|
|
3201
3285
|
"data-puck-overlay": true,
|
3202
3286
|
children: [
|
3203
3287
|
debug,
|
3204
|
-
isLoading && /* @__PURE__ */
|
3205
|
-
/* @__PURE__ */
|
3288
|
+
isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
|
3289
|
+
/* @__PURE__ */ jsx21(
|
3206
3290
|
"div",
|
3207
3291
|
{
|
3208
3292
|
className: getClassName16("actionsOverlay"),
|
3209
3293
|
style: {
|
3210
3294
|
top: actionsOverlayTop / zoomConfig.zoom
|
3211
3295
|
},
|
3212
|
-
children: /* @__PURE__ */
|
3296
|
+
children: /* @__PURE__ */ jsx21(
|
3213
3297
|
"div",
|
3214
3298
|
{
|
3215
3299
|
className: getClassName16("actions"),
|
@@ -3227,8 +3311,8 @@ var DraggableComponent = ({
|
|
3227
3311
|
parentAction,
|
3228
3312
|
label: DEBUG2 ? id : label,
|
3229
3313
|
children: [
|
3230
|
-
permissions.duplicate && /* @__PURE__ */
|
3231
|
-
permissions.delete && /* @__PURE__ */
|
3314
|
+
permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
|
3315
|
+
permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
|
3232
3316
|
]
|
3233
3317
|
}
|
3234
3318
|
)
|
@@ -3236,7 +3320,7 @@ var DraggableComponent = ({
|
|
3236
3320
|
)
|
3237
3321
|
}
|
3238
3322
|
),
|
3239
|
-
/* @__PURE__ */
|
3323
|
+
/* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
|
3240
3324
|
]
|
3241
3325
|
}
|
3242
3326
|
),
|
@@ -3419,12 +3503,13 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
3419
3503
|
};
|
3420
3504
|
|
3421
3505
|
// components/DropZone/index.tsx
|
3422
|
-
import { Fragment as Fragment6, jsx as
|
3506
|
+
import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
|
3423
3507
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3424
3508
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3425
3509
|
var RENDER_DEBUG = false;
|
3510
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
|
3426
3511
|
var DropZoneEdit = forwardRef3(
|
3427
|
-
function
|
3512
|
+
function DropZoneEditInternal({
|
3428
3513
|
zone,
|
3429
3514
|
allow,
|
3430
3515
|
disallow,
|
@@ -3434,7 +3519,7 @@ var DropZoneEdit = forwardRef3(
|
|
3434
3519
|
collisionAxis
|
3435
3520
|
}, userRef) {
|
3436
3521
|
const appContext2 = useAppContext();
|
3437
|
-
const ctx =
|
3522
|
+
const ctx = useContext6(dropZoneContext);
|
3438
3523
|
const {
|
3439
3524
|
// These all need setting via context
|
3440
3525
|
data,
|
@@ -3487,13 +3572,13 @@ var DropZoneEdit = forwardRef3(
|
|
3487
3572
|
}
|
3488
3573
|
};
|
3489
3574
|
}, []);
|
3490
|
-
const content =
|
3575
|
+
const content = useMemo8(() => {
|
3491
3576
|
if (areaId && zone !== rootDroppableId) {
|
3492
3577
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3493
3578
|
}
|
3494
3579
|
return data.content || [];
|
3495
3580
|
}, [data, zoneCompound]);
|
3496
|
-
const ref =
|
3581
|
+
const ref = useRef2(null);
|
3497
3582
|
const acceptsTarget = useCallback10(
|
3498
3583
|
(componentType) => {
|
3499
3584
|
if (!componentType) {
|
@@ -3558,7 +3643,7 @@ var DropZoneEdit = forwardRef3(
|
|
3558
3643
|
userMinEmptyHeight,
|
3559
3644
|
ref
|
3560
3645
|
});
|
3561
|
-
return /* @__PURE__ */
|
3646
|
+
return /* @__PURE__ */ jsx22(
|
3562
3647
|
"div",
|
3563
3648
|
{
|
3564
3649
|
className: `${getClassName17({
|
@@ -3582,10 +3667,10 @@ var DropZoneEdit = forwardRef3(
|
|
3582
3667
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3583
3668
|
}),
|
3584
3669
|
children: contentWithPreview.map((item, i) => {
|
3585
|
-
var _a, _b, _c, _d, _e;
|
3670
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3586
3671
|
const componentId = item.props.id;
|
3587
3672
|
const puckProps = {
|
3588
|
-
renderDropZone:
|
3673
|
+
renderDropZone: DropZoneEditPure,
|
3589
3674
|
isEditing: true,
|
3590
3675
|
dragRef: null
|
3591
3676
|
};
|
@@ -3602,20 +3687,20 @@ var DropZoneEdit = forwardRef3(
|
|
3602
3687
|
const componentConfig = config.components[item.type];
|
3603
3688
|
let componentType = item.type;
|
3604
3689
|
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3605
|
-
if (item.type === "preview"
|
3690
|
+
if (item.type === "preview") {
|
3606
3691
|
let Preview4 = function() {
|
3607
|
-
return /* @__PURE__ */
|
3692
|
+
return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3608
3693
|
};
|
3609
3694
|
var Preview3 = Preview4;
|
3610
|
-
componentType = preview.componentType;
|
3611
|
-
label = (
|
3695
|
+
componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
|
3696
|
+
label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
|
3612
3697
|
Render2 = Preview4;
|
3613
3698
|
}
|
3614
|
-
return /* @__PURE__ */
|
3699
|
+
return /* @__PURE__ */ jsx22(
|
3615
3700
|
DropZoneProvider,
|
3616
3701
|
{
|
3617
3702
|
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3618
|
-
children: /* @__PURE__ */
|
3703
|
+
children: /* @__PURE__ */ jsx22(
|
3619
3704
|
DraggableComponent,
|
3620
3705
|
{
|
3621
3706
|
id: componentId,
|
@@ -3623,21 +3708,21 @@ var DropZoneEdit = forwardRef3(
|
|
3623
3708
|
zoneCompound,
|
3624
3709
|
depth: depth + 1,
|
3625
3710
|
index: i,
|
3626
|
-
isLoading: ((
|
3711
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3627
3712
|
isSelected,
|
3628
3713
|
label,
|
3629
3714
|
isEnabled,
|
3630
3715
|
autoDragAxis: dragAxis,
|
3631
3716
|
userDragAxis: collisionAxis,
|
3632
3717
|
inDroppableZone: acceptsTarget(draggedComponentType),
|
3633
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */
|
3718
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx22(
|
3634
3719
|
Render2,
|
3635
3720
|
__spreadProps(__spreadValues({}, defaultedProps), {
|
3636
3721
|
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3637
3722
|
dragRef
|
3638
3723
|
})
|
3639
3724
|
})
|
3640
|
-
) : /* @__PURE__ */
|
3725
|
+
) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
|
3641
3726
|
}
|
3642
3727
|
)
|
3643
3728
|
},
|
@@ -3648,9 +3733,10 @@ var DropZoneEdit = forwardRef3(
|
|
3648
3733
|
);
|
3649
3734
|
}
|
3650
3735
|
);
|
3736
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
|
3651
3737
|
var DropZoneRender = forwardRef3(
|
3652
|
-
function
|
3653
|
-
const ctx =
|
3738
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3739
|
+
const ctx = useContext6(dropZoneContext);
|
3654
3740
|
const { data, areaId = "root", config } = ctx || {};
|
3655
3741
|
let zoneCompound = rootDroppableId;
|
3656
3742
|
let content = (data == null ? void 0 : data.content) || [];
|
@@ -3671,10 +3757,10 @@ var DropZoneRender = forwardRef3(
|
|
3671
3757
|
zoneCompound = `${areaId}:${zone}`;
|
3672
3758
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3673
3759
|
}
|
3674
|
-
return /* @__PURE__ */
|
3760
|
+
return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
|
3675
3761
|
const Component = config.components[item.type];
|
3676
3762
|
if (Component) {
|
3677
|
-
return /* @__PURE__ */
|
3763
|
+
return /* @__PURE__ */ jsx22(
|
3678
3764
|
DropZoneProvider,
|
3679
3765
|
{
|
3680
3766
|
value: {
|
@@ -3684,10 +3770,12 @@ var DropZoneRender = forwardRef3(
|
|
3684
3770
|
depth: 1,
|
3685
3771
|
path: []
|
3686
3772
|
},
|
3687
|
-
children: /* @__PURE__ */
|
3773
|
+
children: /* @__PURE__ */ jsx22(
|
3688
3774
|
Component.render,
|
3689
3775
|
__spreadProps(__spreadValues({}, item.props), {
|
3690
|
-
puck: {
|
3776
|
+
puck: {
|
3777
|
+
renderDropZone: DropZoneRenderPure
|
3778
|
+
}
|
3691
3779
|
})
|
3692
3780
|
)
|
3693
3781
|
},
|
@@ -3700,11 +3788,11 @@ var DropZoneRender = forwardRef3(
|
|
3700
3788
|
);
|
3701
3789
|
var DropZone = forwardRef3(
|
3702
3790
|
function DropZone2(props, ref) {
|
3703
|
-
const ctx =
|
3791
|
+
const ctx = useContext6(dropZoneContext);
|
3704
3792
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3705
|
-
return /* @__PURE__ */
|
3793
|
+
return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3706
3794
|
}
|
3707
|
-
return /* @__PURE__ */
|
3795
|
+
return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
3708
3796
|
}
|
3709
3797
|
);
|
3710
3798
|
|
@@ -3762,6 +3850,48 @@ var getFrame = () => {
|
|
3762
3850
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3763
3851
|
};
|
3764
3852
|
|
3853
|
+
// lib/global-position.ts
|
3854
|
+
init_react_import();
|
3855
|
+
var GlobalPosition = class {
|
3856
|
+
constructor(target, original) {
|
3857
|
+
this.scaleFactor = 1;
|
3858
|
+
this.frameEl = null;
|
3859
|
+
this.frameRect = null;
|
3860
|
+
var _a;
|
3861
|
+
this.target = target;
|
3862
|
+
this.original = original;
|
3863
|
+
this.frameEl = document.querySelector("iframe");
|
3864
|
+
if (this.frameEl) {
|
3865
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
3866
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
3867
|
+
}
|
3868
|
+
}
|
3869
|
+
get x() {
|
3870
|
+
return this.original.x;
|
3871
|
+
}
|
3872
|
+
get y() {
|
3873
|
+
return this.original.y;
|
3874
|
+
}
|
3875
|
+
get global() {
|
3876
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
3877
|
+
return {
|
3878
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
3879
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
3880
|
+
};
|
3881
|
+
}
|
3882
|
+
return this.original;
|
3883
|
+
}
|
3884
|
+
get frame() {
|
3885
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
3886
|
+
return {
|
3887
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
3888
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
3889
|
+
};
|
3890
|
+
}
|
3891
|
+
return this.original;
|
3892
|
+
}
|
3893
|
+
};
|
3894
|
+
|
3765
3895
|
// lib/dnd/NestedDroppablePlugin.ts
|
3766
3896
|
var depthSort = (candidates) => {
|
3767
3897
|
return candidates.sort((a, b) => {
|
@@ -3791,10 +3921,12 @@ var getZoneId2 = (candidate) => {
|
|
3791
3921
|
}
|
3792
3922
|
return id;
|
3793
3923
|
};
|
3794
|
-
var getPointerCollisions = (position, manager
|
3795
|
-
var _a;
|
3924
|
+
var getPointerCollisions = (position, manager) => {
|
3796
3925
|
const candidates = [];
|
3797
|
-
let elements = ownerDocument.elementsFromPoint(
|
3926
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
3927
|
+
position.x,
|
3928
|
+
position.y
|
3929
|
+
);
|
3798
3930
|
const previewFrame = elements.find(
|
3799
3931
|
(el) => el.getAttribute("data-puck-preview")
|
3800
3932
|
);
|
@@ -3803,17 +3935,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3803
3935
|
elements = [drawer];
|
3804
3936
|
}
|
3805
3937
|
if (previewFrame) {
|
3806
|
-
const
|
3807
|
-
if (
|
3808
|
-
|
3809
|
-
const frame = getFrame();
|
3810
|
-
if (frame) {
|
3811
|
-
const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
3812
|
-
elements = frame.elementsFromPoint(
|
3813
|
-
(position.x - rect.left) / scaleFactor,
|
3814
|
-
(position.y - rect.top) / scaleFactor
|
3815
|
-
);
|
3816
|
-
}
|
3938
|
+
const frame = getFrame();
|
3939
|
+
if (frame) {
|
3940
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
3817
3941
|
}
|
3818
3942
|
}
|
3819
3943
|
if (elements) {
|
@@ -3830,9 +3954,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3830
3954
|
}
|
3831
3955
|
return candidates;
|
3832
3956
|
};
|
3833
|
-
var findDeepestCandidate = (position, manager
|
3957
|
+
var findDeepestCandidate = (position, manager) => {
|
3834
3958
|
var _a;
|
3835
|
-
const candidates = getPointerCollisions(position, manager
|
3959
|
+
const candidates = getPointerCollisions(position, manager);
|
3836
3960
|
if (candidates.length > 0) {
|
3837
3961
|
const sortedCandidates = depthSort(candidates);
|
3838
3962
|
const draggable = manager.dragOperation.source;
|
@@ -3885,22 +4009,18 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
3885
4009
|
}
|
3886
4010
|
const cleanupEffect = effects(() => {
|
3887
4011
|
const handleMove = (event) => {
|
3888
|
-
const
|
4012
|
+
const target = event.originalTarget || event.target;
|
4013
|
+
const position = new GlobalPosition(target, {
|
3889
4014
|
x: event.clientX,
|
3890
4015
|
y: event.clientY
|
3891
|
-
};
|
3892
|
-
const target = event.originalTarget || event.target;
|
3893
|
-
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
4016
|
+
});
|
3894
4017
|
const elements = document.elementsFromPoint(
|
3895
|
-
|
3896
|
-
|
4018
|
+
position.global.x,
|
4019
|
+
position.global.y
|
3897
4020
|
);
|
3898
4021
|
const overEl = elements.some((el) => el.id === id);
|
3899
4022
|
if (overEl) {
|
3900
|
-
onChange(
|
3901
|
-
findDeepestCandidate(position, manager, ownerDocument),
|
3902
|
-
manager
|
3903
|
-
);
|
4023
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
3904
4024
|
}
|
3905
4025
|
};
|
3906
4026
|
const handleMoveThrottled = throttle(handleMove, 50);
|
@@ -4231,6 +4351,11 @@ var reduceUi = (ui, action) => {
|
|
4231
4351
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4232
4352
|
});
|
4233
4353
|
}
|
4354
|
+
if (action.type === "remove") {
|
4355
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4356
|
+
itemSelector: null
|
4357
|
+
});
|
4358
|
+
}
|
4234
4359
|
return ui;
|
4235
4360
|
};
|
4236
4361
|
|
@@ -4490,6 +4615,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
4490
4615
|
}
|
4491
4616
|
}
|
4492
4617
|
handlePointerUp(event) {
|
4618
|
+
if (!this.source) {
|
4619
|
+
return;
|
4620
|
+
}
|
4493
4621
|
event.preventDefault();
|
4494
4622
|
event.stopPropagation();
|
4495
4623
|
const { status } = this.manager.dragOperation;
|
@@ -4590,13 +4718,13 @@ function patchWindow(window2) {
|
|
4590
4718
|
|
4591
4719
|
// components/DragDropContext/index.tsx
|
4592
4720
|
import { createStore as createStore3 } from "zustand";
|
4593
|
-
import { jsx as
|
4721
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
4594
4722
|
var DEBUG3 = false;
|
4595
|
-
var dragListenerContext =
|
4723
|
+
var dragListenerContext = createContext4({
|
4596
4724
|
dragListeners: {}
|
4597
4725
|
});
|
4598
4726
|
function useDragListener(type, fn, deps = []) {
|
4599
|
-
const { setDragListeners } =
|
4727
|
+
const { setDragListeners } = useContext7(dragListenerContext);
|
4600
4728
|
useEffect15(() => {
|
4601
4729
|
if (setDragListeners) {
|
4602
4730
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
@@ -4607,7 +4735,7 @@ function useDragListener(type, fn, deps = []) {
|
|
4607
4735
|
}
|
4608
4736
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4609
4737
|
var useTempDisableFallback = (timeout3) => {
|
4610
|
-
const lastFallbackDisable =
|
4738
|
+
const lastFallbackDisable = useRef3(null);
|
4611
4739
|
return useCallback11((manager) => {
|
4612
4740
|
collisionStore.setState({ fallbackEnabled: false });
|
4613
4741
|
const fallbackId = generateId();
|
@@ -4627,7 +4755,7 @@ var DragDropContextClient = ({
|
|
4627
4755
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4628
4756
|
const id = useId();
|
4629
4757
|
const { data } = state;
|
4630
|
-
const debouncedParamsRef =
|
4758
|
+
const debouncedParamsRef = useRef3(null);
|
4631
4759
|
const tempDisableFallback = useTempDisableFallback(100);
|
4632
4760
|
const [zoneStore] = useState17(
|
4633
4761
|
() => createStore3(() => ({
|
@@ -4766,7 +4894,7 @@ var DragDropContextClient = ({
|
|
4766
4894
|
]);
|
4767
4895
|
const [dragListeners, setDragListeners] = useState17({});
|
4768
4896
|
const [pathData, setPathData] = useState17();
|
4769
|
-
const dragMode =
|
4897
|
+
const dragMode = useRef3(null);
|
4770
4898
|
const registerPath = useCallback11(
|
4771
4899
|
(selector) => {
|
4772
4900
|
const item = getItem(selector, data);
|
@@ -4789,15 +4917,15 @@ var DragDropContextClient = ({
|
|
4789
4917
|
},
|
4790
4918
|
[data, setPathData]
|
4791
4919
|
);
|
4792
|
-
const initialSelector =
|
4793
|
-
return /* @__PURE__ */
|
4920
|
+
const initialSelector = useRef3(void 0);
|
4921
|
+
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
4794
4922
|
dragListenerContext.Provider,
|
4795
4923
|
{
|
4796
4924
|
value: {
|
4797
4925
|
dragListeners,
|
4798
4926
|
setDragListeners
|
4799
4927
|
},
|
4800
|
-
children: /* @__PURE__ */
|
4928
|
+
children: /* @__PURE__ */ jsx23(
|
4801
4929
|
DragDropProvider2,
|
4802
4930
|
{
|
4803
4931
|
plugins,
|
@@ -4975,7 +5103,7 @@ var DragDropContextClient = ({
|
|
4975
5103
|
initialSelector.current = void 0;
|
4976
5104
|
zoneStore.setState({ draggedItem: event.operation.source });
|
4977
5105
|
},
|
4978
|
-
children: /* @__PURE__ */
|
5106
|
+
children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
|
4979
5107
|
DropZoneProvider,
|
4980
5108
|
{
|
4981
5109
|
value: {
|
@@ -5004,11 +5132,11 @@ var DragDropContext = ({
|
|
5004
5132
|
if (status === "LOADING") {
|
5005
5133
|
return children;
|
5006
5134
|
}
|
5007
|
-
return /* @__PURE__ */
|
5135
|
+
return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
|
5008
5136
|
};
|
5009
5137
|
|
5010
5138
|
// components/Drawer/index.tsx
|
5011
|
-
import { jsx as
|
5139
|
+
import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
|
5012
5140
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
5013
5141
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
5014
5142
|
var DrawerItemInner = ({
|
@@ -5018,11 +5146,11 @@ var DrawerItemInner = ({
|
|
5018
5146
|
dragRef,
|
5019
5147
|
isDragDisabled
|
5020
5148
|
}) => {
|
5021
|
-
const CustomInner =
|
5022
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */
|
5149
|
+
const CustomInner = useMemo9(
|
5150
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
|
5023
5151
|
[children]
|
5024
5152
|
);
|
5025
|
-
return /* @__PURE__ */
|
5153
|
+
return /* @__PURE__ */ jsx24(
|
5026
5154
|
"div",
|
5027
5155
|
{
|
5028
5156
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -5030,9 +5158,9 @@ var DrawerItemInner = ({
|
|
5030
5158
|
onMouseDown: (e) => e.preventDefault(),
|
5031
5159
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
5032
5160
|
"data-puck-drawer-item": true,
|
5033
|
-
children: /* @__PURE__ */
|
5034
|
-
/* @__PURE__ */
|
5035
|
-
/* @__PURE__ */
|
5161
|
+
children: /* @__PURE__ */ jsx24(CustomInner, { name, children: /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
|
5162
|
+
/* @__PURE__ */ jsx24("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
5163
|
+
/* @__PURE__ */ jsx24("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx24(DragIcon, {}) })
|
5036
5164
|
] }) }) })
|
5037
5165
|
}
|
5038
5166
|
);
|
@@ -5050,8 +5178,8 @@ var DrawerItemDraggable = ({
|
|
5050
5178
|
disabled: isDragDisabled
|
5051
5179
|
});
|
5052
5180
|
return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
|
5053
|
-
/* @__PURE__ */
|
5054
|
-
/* @__PURE__ */
|
5181
|
+
/* @__PURE__ */ jsx24("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx24(DrawerItemInner, { name, label, children }) }),
|
5182
|
+
/* @__PURE__ */ jsx24("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx24(
|
5055
5183
|
DrawerItemInner,
|
5056
5184
|
{
|
5057
5185
|
name,
|
@@ -5085,7 +5213,7 @@ var DrawerItem = ({
|
|
5085
5213
|
},
|
5086
5214
|
[resolvedId]
|
5087
5215
|
);
|
5088
|
-
return /* @__PURE__ */
|
5216
|
+
return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
|
5089
5217
|
DrawerItemDraggable,
|
5090
5218
|
{
|
5091
5219
|
name,
|
@@ -5111,14 +5239,14 @@ var Drawer = ({
|
|
5111
5239
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5112
5240
|
);
|
5113
5241
|
}
|
5114
|
-
const
|
5242
|
+
const id = useId2();
|
5115
5243
|
const { ref } = useDroppableSafe({
|
5116
5244
|
id,
|
5117
5245
|
type: "void",
|
5118
5246
|
collisionPriority: 0
|
5119
5247
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
5120
5248
|
});
|
5121
|
-
return /* @__PURE__ */
|
5249
|
+
return /* @__PURE__ */ jsx24(
|
5122
5250
|
"div",
|
5123
5251
|
{
|
5124
5252
|
className: getClassName18(),
|
@@ -5134,9 +5262,9 @@ Drawer.Item = DrawerItem;
|
|
5134
5262
|
// components/Puck/index.tsx
|
5135
5263
|
init_react_import();
|
5136
5264
|
import {
|
5137
|
-
useCallback as
|
5138
|
-
useEffect as
|
5139
|
-
useMemo as
|
5265
|
+
useCallback as useCallback18,
|
5266
|
+
useEffect as useEffect24,
|
5267
|
+
useMemo as useMemo19,
|
5140
5268
|
useReducer,
|
5141
5269
|
useState as useState26
|
5142
5270
|
} from "react";
|
@@ -5150,7 +5278,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
5150
5278
|
|
5151
5279
|
// lib/use-breadcrumbs.ts
|
5152
5280
|
init_react_import();
|
5153
|
-
import { useContext as
|
5281
|
+
import { useContext as useContext8, useMemo as useMemo10 } from "react";
|
5154
5282
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5155
5283
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5156
5284
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5200,8 +5328,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5200
5328
|
state: { data },
|
5201
5329
|
selectedItem
|
5202
5330
|
} = useAppContext();
|
5203
|
-
const dzContext =
|
5204
|
-
return
|
5331
|
+
const dzContext = useContext8(dropZoneContext);
|
5332
|
+
return useMemo10(() => {
|
5205
5333
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5206
5334
|
selectedItem,
|
5207
5335
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5215,7 +5343,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
5215
5343
|
};
|
5216
5344
|
|
5217
5345
|
// components/SidebarSection/index.tsx
|
5218
|
-
import { jsx as
|
5346
|
+
import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
5219
5347
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5220
5348
|
var SidebarSection = ({
|
5221
5349
|
children,
|
@@ -5234,9 +5362,9 @@ var SidebarSection = ({
|
|
5234
5362
|
className: getClassName19({ noBorderTop, noPadding }),
|
5235
5363
|
style: { background },
|
5236
5364
|
children: [
|
5237
|
-
/* @__PURE__ */
|
5365
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
|
5238
5366
|
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
|
5239
|
-
/* @__PURE__ */
|
5367
|
+
/* @__PURE__ */ jsx25(
|
5240
5368
|
"button",
|
5241
5369
|
{
|
5242
5370
|
type: "button",
|
@@ -5245,12 +5373,12 @@ var SidebarSection = ({
|
|
5245
5373
|
children: breadcrumb.label
|
5246
5374
|
}
|
5247
5375
|
),
|
5248
|
-
/* @__PURE__ */
|
5376
|
+
/* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
|
5249
5377
|
] }, i)) : null,
|
5250
|
-
/* @__PURE__ */
|
5378
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
|
5251
5379
|
] }) }),
|
5252
|
-
/* @__PURE__ */
|
5253
|
-
isLoading && /* @__PURE__ */
|
5380
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
|
5381
|
+
isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
|
5254
5382
|
]
|
5255
5383
|
}
|
5256
5384
|
);
|
@@ -5281,7 +5409,7 @@ init_react_import();
|
|
5281
5409
|
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" };
|
5282
5410
|
|
5283
5411
|
// components/MenuBar/index.tsx
|
5284
|
-
import { Fragment as Fragment7, jsx as
|
5412
|
+
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
|
5285
5413
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
5286
5414
|
function MenuBar({
|
5287
5415
|
appState,
|
@@ -5295,7 +5423,7 @@ function MenuBar({
|
|
5295
5423
|
history: { back, forward, historyStore }
|
5296
5424
|
} = useAppContext();
|
5297
5425
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
5298
|
-
return /* @__PURE__ */
|
5426
|
+
return /* @__PURE__ */ jsx26(
|
5299
5427
|
"div",
|
5300
5428
|
{
|
5301
5429
|
className: getClassName20({ menuOpen }),
|
@@ -5311,10 +5439,10 @@ function MenuBar({
|
|
5311
5439
|
},
|
5312
5440
|
children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
|
5313
5441
|
/* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
|
5314
|
-
/* @__PURE__ */
|
5315
|
-
/* @__PURE__ */
|
5442
|
+
/* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
|
5443
|
+
/* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
|
5316
5444
|
] }),
|
5317
|
-
/* @__PURE__ */
|
5445
|
+
/* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
|
5318
5446
|
state: appState,
|
5319
5447
|
dispatch
|
5320
5448
|
}) })
|
@@ -5332,36 +5460,61 @@ init_react_import();
|
|
5332
5460
|
|
5333
5461
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5334
5462
|
init_react_import();
|
5335
|
-
var styles_module_default16 = { "PuckFields": "
|
5463
|
+
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
5336
5464
|
|
5337
5465
|
// components/Puck/components/Fields/index.tsx
|
5338
|
-
import {
|
5466
|
+
import { useMemo as useMemo12 } from "react";
|
5467
|
+
|
5468
|
+
// lib/use-resolved-fields.ts
|
5469
|
+
init_react_import();
|
5470
|
+
import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
|
5339
5471
|
|
5340
5472
|
// lib/use-parent.ts
|
5341
5473
|
init_react_import();
|
5342
|
-
import { useContext as
|
5343
|
-
var
|
5474
|
+
import { useCallback as useCallback12, useContext as useContext9 } from "react";
|
5475
|
+
var getParent = (itemSelector, pathData, data) => {
|
5344
5476
|
var _a;
|
5345
|
-
|
5346
|
-
const
|
5347
|
-
const
|
5348
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5477
|
+
if (!itemSelector) return null;
|
5478
|
+
const item = getItem(itemSelector, data);
|
5479
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5349
5480
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5350
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5481
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5351
5482
|
return parent || null;
|
5352
5483
|
};
|
5484
|
+
var useGetParent = () => {
|
5485
|
+
const { state } = useAppContext();
|
5486
|
+
const { pathData } = useContext9(dropZoneContext) || {};
|
5487
|
+
return useCallback12(
|
5488
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5489
|
+
[state.ui.itemSelector, pathData, state.data]
|
5490
|
+
);
|
5491
|
+
};
|
5492
|
+
var useParent = () => {
|
5493
|
+
return useGetParent()();
|
5494
|
+
};
|
5353
5495
|
|
5354
|
-
//
|
5355
|
-
|
5356
|
-
|
5496
|
+
// lib/use-on-value-change.ts
|
5497
|
+
init_react_import();
|
5498
|
+
import { useRef as useRef4, useEffect as useEffect16 } from "react";
|
5499
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5500
|
+
const tracked = useRef4(value);
|
5501
|
+
useEffect16(() => {
|
5502
|
+
const oldValue = tracked.current;
|
5503
|
+
if (!compare(value, oldValue)) {
|
5504
|
+
tracked.current = value;
|
5505
|
+
onChange(value, oldValue);
|
5506
|
+
}
|
5507
|
+
}, [onChange, compare, value, ...deps]);
|
5508
|
+
}
|
5509
|
+
|
5510
|
+
// lib/selector-is.ts
|
5511
|
+
init_react_import();
|
5512
|
+
var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
|
5513
|
+
|
5514
|
+
// lib/use-resolved-fields.ts
|
5357
5515
|
var defaultPageFields = {
|
5358
5516
|
title: { type: "text" }
|
5359
5517
|
};
|
5360
|
-
var DefaultFields = ({
|
5361
|
-
children
|
5362
|
-
}) => {
|
5363
|
-
return /* @__PURE__ */ jsx26(Fragment8, { children });
|
5364
|
-
};
|
5365
5518
|
var useResolvedFields = () => {
|
5366
5519
|
var _a, _b;
|
5367
5520
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5369,7 +5522,7 @@ var useResolvedFields = () => {
|
|
5369
5522
|
const { data } = state;
|
5370
5523
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5371
5524
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5372
|
-
const defaultFields =
|
5525
|
+
const defaultFields = useMemo11(
|
5373
5526
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5374
5527
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5375
5528
|
);
|
@@ -5377,12 +5530,13 @@ var useResolvedFields = () => {
|
|
5377
5530
|
const [lastSelectedData, setLastSelectedData] = useState19({});
|
5378
5531
|
const [resolvedFields, setResolvedFields] = useState19(defaultFields);
|
5379
5532
|
const [fieldsLoading, setFieldsLoading] = useState19(false);
|
5533
|
+
const lastFields = useRef5(defaultFields);
|
5380
5534
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5381
5535
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5382
5536
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5383
5537
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5384
5538
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5385
|
-
const resolveFields =
|
5539
|
+
const resolveFields = useCallback13(
|
5386
5540
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5387
5541
|
var _a2;
|
5388
5542
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5394,7 +5548,7 @@ var useResolvedFields = () => {
|
|
5394
5548
|
{
|
5395
5549
|
changed,
|
5396
5550
|
fields,
|
5397
|
-
lastFields:
|
5551
|
+
lastFields: lastFields.current,
|
5398
5552
|
lastData,
|
5399
5553
|
appState: state,
|
5400
5554
|
parent
|
@@ -5405,7 +5559,7 @@ var useResolvedFields = () => {
|
|
5405
5559
|
return yield config.root.resolveFields(componentData, {
|
5406
5560
|
changed,
|
5407
5561
|
fields,
|
5408
|
-
lastFields:
|
5562
|
+
lastFields: lastFields.current,
|
5409
5563
|
lastData,
|
5410
5564
|
appState: state,
|
5411
5565
|
parent
|
@@ -5414,26 +5568,56 @@ var useResolvedFields = () => {
|
|
5414
5568
|
return defaultResolveFields(componentData, {
|
5415
5569
|
changed,
|
5416
5570
|
fields,
|
5417
|
-
lastFields:
|
5571
|
+
lastFields: lastFields.current,
|
5418
5572
|
lastData
|
5419
5573
|
});
|
5420
5574
|
}),
|
5421
|
-
[data, config, componentData, selectedItem,
|
5575
|
+
[data, config, componentData, selectedItem, state, parent]
|
5422
5576
|
);
|
5423
|
-
|
5424
|
-
|
5425
|
-
|
5426
|
-
|
5427
|
-
|
5428
|
-
|
5429
|
-
|
5430
|
-
|
5431
|
-
|
5577
|
+
const triggerResolver = useCallback13(() => {
|
5578
|
+
var _a2, _b2;
|
5579
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5580
|
+
if (hasResolver) {
|
5581
|
+
setFieldsLoading(true);
|
5582
|
+
resolveFields(defaultFields).then((fields) => {
|
5583
|
+
setResolvedFields(fields || {});
|
5584
|
+
lastFields.current = fields;
|
5585
|
+
setFieldsLoading(false);
|
5586
|
+
});
|
5587
|
+
return;
|
5588
|
+
}
|
5432
5589
|
}
|
5433
|
-
|
5590
|
+
setResolvedFields(defaultFields);
|
5591
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5592
|
+
useOnValueChange(
|
5593
|
+
state.ui.itemSelector,
|
5594
|
+
() => {
|
5595
|
+
lastFields.current = defaultFields;
|
5596
|
+
},
|
5597
|
+
selectorIs
|
5598
|
+
);
|
5599
|
+
useOnValueChange(
|
5600
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5601
|
+
() => {
|
5602
|
+
triggerResolver();
|
5603
|
+
},
|
5604
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5605
|
+
);
|
5606
|
+
useEffect17(() => {
|
5607
|
+
triggerResolver();
|
5608
|
+
}, []);
|
5434
5609
|
return [resolvedFields, fieldsLoading];
|
5435
5610
|
};
|
5436
|
-
|
5611
|
+
|
5612
|
+
// components/Puck/components/Fields/index.tsx
|
5613
|
+
import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
5614
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5615
|
+
var DefaultFields = ({
|
5616
|
+
children
|
5617
|
+
}) => {
|
5618
|
+
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5619
|
+
};
|
5620
|
+
var Fields = ({ wrapFields = true }) => {
|
5437
5621
|
var _a, _b;
|
5438
5622
|
const {
|
5439
5623
|
selectedItem,
|
@@ -5451,16 +5635,16 @@ var Fields = () => {
|
|
5451
5635
|
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;
|
5452
5636
|
const isLoading = fieldsResolving || componentResolving;
|
5453
5637
|
const rootProps = data.root.props || data.root;
|
5454
|
-
const Wrapper =
|
5638
|
+
const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
|
5455
5639
|
return /* @__PURE__ */ jsxs14(
|
5456
5640
|
"form",
|
5457
5641
|
{
|
5458
|
-
className: getClassName21(),
|
5642
|
+
className: getClassName21({ wrapFields }),
|
5459
5643
|
onSubmit: (e) => {
|
5460
5644
|
e.preventDefault();
|
5461
5645
|
},
|
5462
5646
|
children: [
|
5463
|
-
/* @__PURE__ */
|
5647
|
+
/* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
5464
5648
|
const field = fields[fieldName];
|
5465
5649
|
if (!(field == null ? void 0 : field.type)) return null;
|
5466
5650
|
const onChange = (value, updatedUi) => {
|
@@ -5531,7 +5715,7 @@ var Fields = () => {
|
|
5531
5715
|
item: selectedItem
|
5532
5716
|
});
|
5533
5717
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5534
|
-
return /* @__PURE__ */
|
5718
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
|
5535
5719
|
AutoFieldPrivate,
|
5536
5720
|
{
|
5537
5721
|
field,
|
@@ -5540,16 +5724,15 @@ var Fields = () => {
|
|
5540
5724
|
readOnly: !edit || readOnly[fieldName],
|
5541
5725
|
value: selectedItem.props[fieldName],
|
5542
5726
|
onChange
|
5543
|
-
}
|
5544
|
-
|
5545
|
-
);
|
5727
|
+
}
|
5728
|
+
) }, id);
|
5546
5729
|
} else {
|
5547
5730
|
const readOnly = data.root.readOnly || {};
|
5548
5731
|
const { edit } = getPermissions({
|
5549
5732
|
root: true
|
5550
5733
|
});
|
5551
5734
|
const id = `root_${field.type}_${fieldName}`;
|
5552
|
-
return /* @__PURE__ */
|
5735
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
|
5553
5736
|
AutoFieldPrivate,
|
5554
5737
|
{
|
5555
5738
|
field,
|
@@ -5558,12 +5741,11 @@ var Fields = () => {
|
|
5558
5741
|
readOnly: !edit || readOnly[fieldName],
|
5559
5742
|
value: rootProps[fieldName],
|
5560
5743
|
onChange
|
5561
|
-
}
|
5562
|
-
|
5563
|
-
);
|
5744
|
+
}
|
5745
|
+
) }, id);
|
5564
5746
|
}
|
5565
5747
|
}) }),
|
5566
|
-
isLoading && /* @__PURE__ */
|
5748
|
+
isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
|
5567
5749
|
]
|
5568
5750
|
}
|
5569
5751
|
);
|
@@ -5574,7 +5756,7 @@ init_react_import();
|
|
5574
5756
|
|
5575
5757
|
// lib/use-component-list.tsx
|
5576
5758
|
init_react_import();
|
5577
|
-
import { useEffect as
|
5759
|
+
import { useEffect as useEffect18, useState as useState20 } from "react";
|
5578
5760
|
|
5579
5761
|
// components/ComponentList/index.tsx
|
5580
5762
|
init_react_import();
|
@@ -5584,7 +5766,7 @@ init_react_import();
|
|
5584
5766
|
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" };
|
5585
5767
|
|
5586
5768
|
// components/ComponentList/index.tsx
|
5587
|
-
import { jsx as
|
5769
|
+
import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
|
5588
5770
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
5589
5771
|
var ComponentListItem = ({
|
5590
5772
|
name,
|
@@ -5594,7 +5776,7 @@ var ComponentListItem = ({
|
|
5594
5776
|
const canInsert = getPermissions({
|
5595
5777
|
type: name
|
5596
5778
|
}).insert;
|
5597
|
-
return /* @__PURE__ */
|
5779
|
+
return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
5598
5780
|
};
|
5599
5781
|
var ComponentList = ({
|
5600
5782
|
children,
|
@@ -5618,14 +5800,14 @@ var ComponentList = ({
|
|
5618
5800
|
}),
|
5619
5801
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
5620
5802
|
children: [
|
5621
|
-
/* @__PURE__ */
|
5622
|
-
/* @__PURE__ */
|
5803
|
+
/* @__PURE__ */ jsx28("div", { children: title }),
|
5804
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
|
5623
5805
|
]
|
5624
5806
|
}
|
5625
5807
|
),
|
5626
|
-
/* @__PURE__ */
|
5808
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
5627
5809
|
var _a;
|
5628
|
-
return /* @__PURE__ */
|
5810
|
+
return /* @__PURE__ */ jsx28(
|
5629
5811
|
ComponentListItem,
|
5630
5812
|
{
|
5631
5813
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -5639,10 +5821,10 @@ var ComponentList = ({
|
|
5639
5821
|
ComponentList.Item = ComponentListItem;
|
5640
5822
|
|
5641
5823
|
// lib/use-component-list.tsx
|
5642
|
-
import { jsx as
|
5824
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
5643
5825
|
var useComponentList = (config, ui) => {
|
5644
5826
|
const [componentList, setComponentList] = useState20();
|
5645
|
-
|
5827
|
+
useEffect18(() => {
|
5646
5828
|
var _a, _b, _c;
|
5647
5829
|
if (Object.keys(ui.componentList).length > 0) {
|
5648
5830
|
const matchedComponents = [];
|
@@ -5652,7 +5834,7 @@ var useComponentList = (config, ui) => {
|
|
5652
5834
|
if (category.visible === false || !category.components) {
|
5653
5835
|
return null;
|
5654
5836
|
}
|
5655
|
-
return /* @__PURE__ */
|
5837
|
+
return /* @__PURE__ */ jsx29(
|
5656
5838
|
ComponentList,
|
5657
5839
|
{
|
5658
5840
|
id: categoryKey,
|
@@ -5661,7 +5843,7 @@ var useComponentList = (config, ui) => {
|
|
5661
5843
|
var _a2;
|
5662
5844
|
matchedComponents.push(componentName);
|
5663
5845
|
const componentConf = config.components[componentName] || {};
|
5664
|
-
return /* @__PURE__ */
|
5846
|
+
return /* @__PURE__ */ jsx29(
|
5665
5847
|
ComponentList.Item,
|
5666
5848
|
{
|
5667
5849
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -5681,7 +5863,7 @@ var useComponentList = (config, ui) => {
|
|
5681
5863
|
);
|
5682
5864
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
5683
5865
|
_componentList.push(
|
5684
|
-
/* @__PURE__ */
|
5866
|
+
/* @__PURE__ */ jsx29(
|
5685
5867
|
ComponentList,
|
5686
5868
|
{
|
5687
5869
|
id: "other",
|
@@ -5689,7 +5871,7 @@ var useComponentList = (config, ui) => {
|
|
5689
5871
|
children: remainingComponents.map((componentName, i) => {
|
5690
5872
|
var _a2;
|
5691
5873
|
const componentConf = config.components[componentName] || {};
|
5692
|
-
return /* @__PURE__ */
|
5874
|
+
return /* @__PURE__ */ jsx29(
|
5693
5875
|
ComponentList.Item,
|
5694
5876
|
{
|
5695
5877
|
name: componentName,
|
@@ -5711,30 +5893,30 @@ var useComponentList = (config, ui) => {
|
|
5711
5893
|
};
|
5712
5894
|
|
5713
5895
|
// components/Puck/components/Components/index.tsx
|
5714
|
-
import { useMemo as
|
5715
|
-
import { jsx as
|
5896
|
+
import { useMemo as useMemo13 } from "react";
|
5897
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
5716
5898
|
var Components = () => {
|
5717
5899
|
const { config, state, overrides } = useAppContext();
|
5718
5900
|
const componentList = useComponentList(config, state.ui);
|
5719
|
-
const Wrapper =
|
5720
|
-
return /* @__PURE__ */
|
5901
|
+
const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
|
5902
|
+
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
5721
5903
|
};
|
5722
5904
|
|
5723
5905
|
// components/Puck/components/Preview/index.tsx
|
5724
5906
|
init_react_import();
|
5725
|
-
import { useCallback as
|
5907
|
+
import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
|
5726
5908
|
|
5727
5909
|
// components/AutoFrame/index.tsx
|
5728
5910
|
init_react_import();
|
5729
5911
|
import {
|
5730
|
-
createContext as
|
5731
|
-
useContext as
|
5732
|
-
useEffect as
|
5912
|
+
createContext as createContext5,
|
5913
|
+
useContext as useContext10,
|
5914
|
+
useEffect as useEffect19,
|
5733
5915
|
useState as useState21
|
5734
5916
|
} from "react";
|
5735
5917
|
import hash from "object-hash";
|
5736
5918
|
import { createPortal as createPortal3 } from "react-dom";
|
5737
|
-
import { Fragment as Fragment9, jsx as
|
5919
|
+
import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
|
5738
5920
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
5739
5921
|
var collectStyles = (doc) => {
|
5740
5922
|
const collected = [];
|
@@ -5777,7 +5959,7 @@ var CopyHostStyles = ({
|
|
5777
5959
|
onStylesLoaded = () => null
|
5778
5960
|
}) => {
|
5779
5961
|
const { document: doc, window: win } = useFrame();
|
5780
|
-
|
5962
|
+
useEffect19(() => {
|
5781
5963
|
if (!win || !doc) {
|
5782
5964
|
return () => {
|
5783
5965
|
};
|
@@ -5934,10 +6116,10 @@ var CopyHostStyles = ({
|
|
5934
6116
|
observer.disconnect();
|
5935
6117
|
};
|
5936
6118
|
}, []);
|
5937
|
-
return /* @__PURE__ */
|
6119
|
+
return /* @__PURE__ */ jsx31(Fragment9, { children });
|
5938
6120
|
};
|
5939
|
-
var autoFrameContext =
|
5940
|
-
var useFrame = () =>
|
6121
|
+
var autoFrameContext = createContext5({});
|
6122
|
+
var useFrame = () => useContext10(autoFrameContext);
|
5941
6123
|
function AutoFrame(_a) {
|
5942
6124
|
var _b = _a, {
|
5943
6125
|
children,
|
@@ -5957,7 +6139,7 @@ function AutoFrame(_a) {
|
|
5957
6139
|
const [loaded, setLoaded] = useState21(false);
|
5958
6140
|
const [ctx, setCtx] = useState21({});
|
5959
6141
|
const [mountTarget, setMountTarget] = useState21();
|
5960
|
-
|
6142
|
+
useEffect19(() => {
|
5961
6143
|
var _a2;
|
5962
6144
|
if (frameRef.current) {
|
5963
6145
|
setCtx({
|
@@ -5969,7 +6151,7 @@ function AutoFrame(_a) {
|
|
5969
6151
|
);
|
5970
6152
|
}
|
5971
6153
|
}, [frameRef, loaded]);
|
5972
|
-
return /* @__PURE__ */
|
6154
|
+
return /* @__PURE__ */ jsx31(
|
5973
6155
|
"iframe",
|
5974
6156
|
__spreadProps(__spreadValues({}, props), {
|
5975
6157
|
className,
|
@@ -5979,7 +6161,7 @@ function AutoFrame(_a) {
|
|
5979
6161
|
onLoad: () => {
|
5980
6162
|
setLoaded(true);
|
5981
6163
|
},
|
5982
|
-
children: /* @__PURE__ */
|
6164
|
+
children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
|
5983
6165
|
})
|
5984
6166
|
);
|
5985
6167
|
}
|
@@ -5992,7 +6174,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
|
|
5992
6174
|
|
5993
6175
|
// components/Render/index.tsx
|
5994
6176
|
init_react_import();
|
5995
|
-
import { jsx as
|
6177
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
5996
6178
|
function Render({
|
5997
6179
|
config,
|
5998
6180
|
data
|
@@ -6005,7 +6187,7 @@ function Render({
|
|
6005
6187
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
6006
6188
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
6007
6189
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
6008
|
-
return /* @__PURE__ */
|
6190
|
+
return /* @__PURE__ */ jsx32(
|
6009
6191
|
DropZoneProvider,
|
6010
6192
|
{
|
6011
6193
|
value: {
|
@@ -6015,7 +6197,7 @@ function Render({
|
|
6015
6197
|
depth: 0,
|
6016
6198
|
path: []
|
6017
6199
|
},
|
6018
|
-
children: /* @__PURE__ */
|
6200
|
+
children: /* @__PURE__ */ jsx32(
|
6019
6201
|
config.root.render,
|
6020
6202
|
__spreadProps(__spreadValues({}, rootProps), {
|
6021
6203
|
puck: {
|
@@ -6025,13 +6207,13 @@ function Render({
|
|
6025
6207
|
title,
|
6026
6208
|
editMode: false,
|
6027
6209
|
id: "puck-root",
|
6028
|
-
children: /* @__PURE__ */
|
6210
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
6029
6211
|
})
|
6030
6212
|
)
|
6031
6213
|
}
|
6032
6214
|
);
|
6033
6215
|
}
|
6034
|
-
return /* @__PURE__ */
|
6216
|
+
return /* @__PURE__ */ jsx32(
|
6035
6217
|
DropZoneProvider,
|
6036
6218
|
{
|
6037
6219
|
value: {
|
@@ -6041,17 +6223,17 @@ function Render({
|
|
6041
6223
|
depth: 0,
|
6042
6224
|
path: []
|
6043
6225
|
},
|
6044
|
-
children: /* @__PURE__ */
|
6226
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
6045
6227
|
}
|
6046
6228
|
);
|
6047
6229
|
}
|
6048
6230
|
|
6049
6231
|
// components/Puck/components/Preview/index.tsx
|
6050
|
-
import { Fragment as Fragment10, jsx as
|
6232
|
+
import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
|
6051
6233
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6052
6234
|
var useBubbleIframeEvents = (ref) => {
|
6053
6235
|
const { status } = useAppContext();
|
6054
|
-
|
6236
|
+
useEffect20(() => {
|
6055
6237
|
var _a;
|
6056
6238
|
if (ref.current && status === "READY") {
|
6057
6239
|
const iframe = ref.current;
|
@@ -6090,20 +6272,20 @@ var useBubbleIframeEvents = (ref) => {
|
|
6090
6272
|
};
|
6091
6273
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6092
6274
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6093
|
-
const Page =
|
6275
|
+
const Page = useCallback14(
|
6094
6276
|
(pageProps) => {
|
6095
6277
|
var _a, _b;
|
6096
6278
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
6097
6279
|
id: "puck-root"
|
6098
|
-
}, pageProps)) : /* @__PURE__ */
|
6280
|
+
}, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
|
6099
6281
|
},
|
6100
6282
|
[config.root]
|
6101
6283
|
);
|
6102
|
-
const Frame =
|
6284
|
+
const Frame = useMemo14(() => overrides.iframe, [overrides]);
|
6103
6285
|
const rootProps = state.data.root.props || state.data.root;
|
6104
6286
|
const ref = useRef7(null);
|
6105
6287
|
useBubbleIframeEvents(ref);
|
6106
|
-
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */
|
6288
|
+
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
|
6107
6289
|
Page,
|
6108
6290
|
__spreadProps(__spreadValues({}, rootProps), {
|
6109
6291
|
puck: {
|
@@ -6112,10 +6294,10 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6112
6294
|
dragRef: null
|
6113
6295
|
},
|
6114
6296
|
editMode: true,
|
6115
|
-
children: /* @__PURE__ */
|
6297
|
+
children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
|
6116
6298
|
})
|
6117
|
-
) : /* @__PURE__ */
|
6118
|
-
return /* @__PURE__ */
|
6299
|
+
) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
|
6300
|
+
return /* @__PURE__ */ jsx33(
|
6119
6301
|
"div",
|
6120
6302
|
{
|
6121
6303
|
className: getClassName23(),
|
@@ -6124,7 +6306,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6124
6306
|
onClick: () => {
|
6125
6307
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
6126
6308
|
},
|
6127
|
-
children: iframe.enabled ? /* @__PURE__ */
|
6309
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx33(
|
6128
6310
|
AutoFrame_default,
|
6129
6311
|
{
|
6130
6312
|
id: "preview-frame",
|
@@ -6134,14 +6316,14 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6134
6316
|
setStatus("READY");
|
6135
6317
|
},
|
6136
6318
|
frameRef: ref,
|
6137
|
-
children: /* @__PURE__ */
|
6319
|
+
children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
6138
6320
|
if (Frame) {
|
6139
|
-
return /* @__PURE__ */
|
6321
|
+
return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
|
6140
6322
|
}
|
6141
6323
|
return inner;
|
6142
6324
|
} })
|
6143
6325
|
}
|
6144
|
-
) : /* @__PURE__ */
|
6326
|
+
) : /* @__PURE__ */ jsx33(
|
6145
6327
|
"div",
|
6146
6328
|
{
|
6147
6329
|
id: "preview-frame",
|
@@ -6198,7 +6380,7 @@ var scrollIntoView = (el) => {
|
|
6198
6380
|
};
|
6199
6381
|
|
6200
6382
|
// components/LayerTree/index.tsx
|
6201
|
-
import { useContext as
|
6383
|
+
import { useContext as useContext11 } from "react";
|
6202
6384
|
|
6203
6385
|
// lib/is-child-of-zone.ts
|
6204
6386
|
init_react_import();
|
@@ -6231,7 +6413,7 @@ var onScrollEnd = (frame, cb) => {
|
|
6231
6413
|
};
|
6232
6414
|
|
6233
6415
|
// components/LayerTree/index.tsx
|
6234
|
-
import { Fragment as Fragment11, jsx as
|
6416
|
+
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
|
6235
6417
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6236
6418
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6237
6419
|
var LayerTree = ({
|
@@ -6244,15 +6426,15 @@ var LayerTree = ({
|
|
6244
6426
|
label
|
6245
6427
|
}) => {
|
6246
6428
|
const zones = data.zones || {};
|
6247
|
-
const ctx =
|
6429
|
+
const ctx = useContext11(dropZoneContext);
|
6248
6430
|
return /* @__PURE__ */ jsxs16(Fragment11, { children: [
|
6249
6431
|
label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
|
6250
|
-
/* @__PURE__ */
|
6432
|
+
/* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
|
6251
6433
|
" ",
|
6252
6434
|
label
|
6253
6435
|
] }),
|
6254
6436
|
/* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
|
6255
|
-
zoneContent.length === 0 && /* @__PURE__ */
|
6437
|
+
zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
|
6256
6438
|
zoneContent.map((item, i) => {
|
6257
6439
|
var _a;
|
6258
6440
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -6275,7 +6457,7 @@ var LayerTree = ({
|
|
6275
6457
|
childIsSelected
|
6276
6458
|
}),
|
6277
6459
|
children: [
|
6278
|
-
/* @__PURE__ */
|
6460
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
|
6279
6461
|
"button",
|
6280
6462
|
{
|
6281
6463
|
type: "button",
|
@@ -6314,22 +6496,22 @@ var LayerTree = ({
|
|
6314
6496
|
setHoveringComponent(null);
|
6315
6497
|
},
|
6316
6498
|
children: [
|
6317
|
-
containsZone && /* @__PURE__ */
|
6499
|
+
containsZone && /* @__PURE__ */ jsx34(
|
6318
6500
|
"div",
|
6319
6501
|
{
|
6320
6502
|
className: getClassNameLayer("chevron"),
|
6321
6503
|
title: isSelected ? "Collapse" : "Expand",
|
6322
|
-
children: /* @__PURE__ */
|
6504
|
+
children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
|
6323
6505
|
}
|
6324
6506
|
),
|
6325
6507
|
/* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
|
6326
|
-
/* @__PURE__ */
|
6327
|
-
/* @__PURE__ */
|
6508
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
|
6509
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
|
6328
6510
|
] })
|
6329
6511
|
]
|
6330
6512
|
}
|
6331
6513
|
) }),
|
6332
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */
|
6514
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
|
6333
6515
|
LayerTree,
|
6334
6516
|
{
|
6335
6517
|
config,
|
@@ -6351,13 +6533,13 @@ var LayerTree = ({
|
|
6351
6533
|
};
|
6352
6534
|
|
6353
6535
|
// components/Puck/components/Outline/index.tsx
|
6354
|
-
import { useCallback as
|
6355
|
-
import { Fragment as Fragment12, jsx as
|
6536
|
+
import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
|
6537
|
+
import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
|
6356
6538
|
var Outline = () => {
|
6357
6539
|
const { dispatch, state, overrides, config } = useAppContext();
|
6358
6540
|
const { data, ui } = state;
|
6359
6541
|
const { itemSelector } = ui;
|
6360
|
-
const setItemSelector =
|
6542
|
+
const setItemSelector = useCallback15(
|
6361
6543
|
(newItemSelector) => {
|
6362
6544
|
dispatch({
|
6363
6545
|
type: "setUi",
|
@@ -6366,9 +6548,9 @@ var Outline = () => {
|
|
6366
6548
|
},
|
6367
6549
|
[]
|
6368
6550
|
);
|
6369
|
-
const Wrapper =
|
6370
|
-
return /* @__PURE__ */
|
6371
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */
|
6551
|
+
const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
|
6552
|
+
return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
|
6553
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
|
6372
6554
|
LayerTree,
|
6373
6555
|
{
|
6374
6556
|
config,
|
@@ -6381,7 +6563,7 @@ var Outline = () => {
|
|
6381
6563
|
),
|
6382
6564
|
Object.entries(findZonesForArea(data, "root")).map(
|
6383
6565
|
([zoneKey, zone]) => {
|
6384
|
-
return /* @__PURE__ */
|
6566
|
+
return /* @__PURE__ */ jsx35(
|
6385
6567
|
LayerTree,
|
6386
6568
|
{
|
6387
6569
|
config,
|
@@ -6653,27 +6835,27 @@ var getBox = function getBox2(el) {
|
|
6653
6835
|
|
6654
6836
|
// components/Puck/components/Canvas/index.tsx
|
6655
6837
|
import {
|
6656
|
-
useCallback as
|
6657
|
-
useEffect as
|
6658
|
-
useMemo as
|
6838
|
+
useCallback as useCallback16,
|
6839
|
+
useEffect as useEffect22,
|
6840
|
+
useMemo as useMemo17,
|
6659
6841
|
useRef as useRef8,
|
6660
6842
|
useState as useState24
|
6661
6843
|
} from "react";
|
6662
6844
|
|
6663
6845
|
// components/ViewportControls/index.tsx
|
6664
6846
|
init_react_import();
|
6665
|
-
import { useEffect as
|
6847
|
+
import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
|
6666
6848
|
|
6667
6849
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6668
6850
|
init_react_import();
|
6669
6851
|
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" };
|
6670
6852
|
|
6671
6853
|
// components/ViewportControls/index.tsx
|
6672
|
-
import { jsx as
|
6854
|
+
import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
|
6673
6855
|
var icons = {
|
6674
|
-
Smartphone: /* @__PURE__ */
|
6675
|
-
Tablet: /* @__PURE__ */
|
6676
|
-
Monitor: /* @__PURE__ */
|
6856
|
+
Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
|
6857
|
+
Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
|
6858
|
+
Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
|
6677
6859
|
};
|
6678
6860
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
6679
6861
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -6686,10 +6868,10 @@ var ViewportButton = ({
|
|
6686
6868
|
}) => {
|
6687
6869
|
const { state } = useAppContext();
|
6688
6870
|
const [isActive, setIsActive] = useState23(false);
|
6689
|
-
|
6871
|
+
useEffect21(() => {
|
6690
6872
|
setIsActive(width === state.ui.viewports.current.width);
|
6691
6873
|
}, [width, state.ui.viewports.current.width]);
|
6692
|
-
return /* @__PURE__ */
|
6874
|
+
return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
|
6693
6875
|
IconButton,
|
6694
6876
|
{
|
6695
6877
|
title,
|
@@ -6698,7 +6880,7 @@ var ViewportButton = ({
|
|
6698
6880
|
e.stopPropagation();
|
6699
6881
|
onClick({ width, height });
|
6700
6882
|
},
|
6701
|
-
children: /* @__PURE__ */
|
6883
|
+
children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
|
6702
6884
|
}
|
6703
6885
|
) });
|
6704
6886
|
};
|
@@ -6722,7 +6904,7 @@ var ViewportControls = ({
|
|
6722
6904
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6723
6905
|
(option) => option.value === autoZoom
|
6724
6906
|
);
|
6725
|
-
const zoomOptions =
|
6907
|
+
const zoomOptions = useMemo16(
|
6726
6908
|
() => [
|
6727
6909
|
...defaultZoomOptions,
|
6728
6910
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6735,7 +6917,7 @@ var ViewportControls = ({
|
|
6735
6917
|
[autoZoom]
|
6736
6918
|
);
|
6737
6919
|
return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
|
6738
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
6920
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
|
6739
6921
|
ViewportButton,
|
6740
6922
|
{
|
6741
6923
|
height: viewport.height,
|
@@ -6746,8 +6928,8 @@ var ViewportControls = ({
|
|
6746
6928
|
},
|
6747
6929
|
i
|
6748
6930
|
)),
|
6749
|
-
/* @__PURE__ */
|
6750
|
-
/* @__PURE__ */
|
6931
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6932
|
+
/* @__PURE__ */ jsx36(
|
6751
6933
|
IconButton,
|
6752
6934
|
{
|
6753
6935
|
title: "Zoom viewport out",
|
@@ -6761,10 +6943,10 @@ var ViewportControls = ({
|
|
6761
6943
|
)].value
|
6762
6944
|
);
|
6763
6945
|
},
|
6764
|
-
children: /* @__PURE__ */
|
6946
|
+
children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
|
6765
6947
|
}
|
6766
6948
|
),
|
6767
|
-
/* @__PURE__ */
|
6949
|
+
/* @__PURE__ */ jsx36(
|
6768
6950
|
IconButton,
|
6769
6951
|
{
|
6770
6952
|
title: "Zoom viewport in",
|
@@ -6778,11 +6960,11 @@ var ViewportControls = ({
|
|
6778
6960
|
)].value
|
6779
6961
|
);
|
6780
6962
|
},
|
6781
|
-
children: /* @__PURE__ */
|
6963
|
+
children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
|
6782
6964
|
}
|
6783
6965
|
),
|
6784
|
-
/* @__PURE__ */
|
6785
|
-
/* @__PURE__ */
|
6966
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6967
|
+
/* @__PURE__ */ jsx36(
|
6786
6968
|
"select",
|
6787
6969
|
{
|
6788
6970
|
className: getClassName25("zoomSelect"),
|
@@ -6790,7 +6972,7 @@ var ViewportControls = ({
|
|
6790
6972
|
onChange: (e) => {
|
6791
6973
|
onZoom(parseFloat(e.currentTarget.value));
|
6792
6974
|
},
|
6793
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
6975
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
|
6794
6976
|
"option",
|
6795
6977
|
{
|
6796
6978
|
value: option.value,
|
@@ -6838,7 +7020,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
6838
7020
|
};
|
6839
7021
|
|
6840
7022
|
// components/Puck/components/Canvas/index.tsx
|
6841
|
-
import { Fragment as Fragment13, jsx as
|
7023
|
+
import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
|
6842
7024
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
6843
7025
|
var ZOOM_ON_CHANGE = true;
|
6844
7026
|
var Canvas = () => {
|
@@ -6847,15 +7029,15 @@ var Canvas = () => {
|
|
6847
7029
|
const { ui } = state;
|
6848
7030
|
const frameRef = useRef8(null);
|
6849
7031
|
const [showTransition, setShowTransition] = useState24(false);
|
6850
|
-
const defaultRender =
|
6851
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
7032
|
+
const defaultRender = useMemo17(() => {
|
7033
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
|
6852
7034
|
return PuckDefault;
|
6853
7035
|
}, []);
|
6854
|
-
const CustomPreview =
|
7036
|
+
const CustomPreview = useMemo17(
|
6855
7037
|
() => overrides.preview || defaultRender,
|
6856
7038
|
[overrides]
|
6857
7039
|
);
|
6858
|
-
const getFrameDimensions =
|
7040
|
+
const getFrameDimensions = useCallback16(() => {
|
6859
7041
|
if (frameRef.current) {
|
6860
7042
|
const frame = frameRef.current;
|
6861
7043
|
const box = getBox(frame);
|
@@ -6863,7 +7045,7 @@ var Canvas = () => {
|
|
6863
7045
|
}
|
6864
7046
|
return { width: 0, height: 0 };
|
6865
7047
|
}, [frameRef]);
|
6866
|
-
const resetAutoZoom =
|
7048
|
+
const resetAutoZoom = useCallback16(
|
6867
7049
|
(ui2 = state.ui) => {
|
6868
7050
|
if (frameRef.current) {
|
6869
7051
|
setZoomConfig(
|
@@ -6873,11 +7055,11 @@ var Canvas = () => {
|
|
6873
7055
|
},
|
6874
7056
|
[frameRef, zoomConfig, state.ui]
|
6875
7057
|
);
|
6876
|
-
|
7058
|
+
useEffect22(() => {
|
6877
7059
|
setShowTransition(false);
|
6878
7060
|
resetAutoZoom();
|
6879
7061
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6880
|
-
|
7062
|
+
useEffect22(() => {
|
6881
7063
|
const { height: frameHeight } = getFrameDimensions();
|
6882
7064
|
if (ui.viewports.current.height === "auto") {
|
6883
7065
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6885,13 +7067,13 @@ var Canvas = () => {
|
|
6885
7067
|
}));
|
6886
7068
|
}
|
6887
7069
|
}, [zoomConfig.zoom]);
|
6888
|
-
|
7070
|
+
useEffect22(() => {
|
6889
7071
|
if (ZOOM_ON_CHANGE) {
|
6890
7072
|
setShowTransition(true);
|
6891
7073
|
resetAutoZoom(ui);
|
6892
7074
|
}
|
6893
7075
|
}, [ui.viewports.current.width]);
|
6894
|
-
|
7076
|
+
useEffect22(() => {
|
6895
7077
|
const cb = () => {
|
6896
7078
|
setShowTransition(false);
|
6897
7079
|
resetAutoZoom();
|
@@ -6902,7 +7084,7 @@ var Canvas = () => {
|
|
6902
7084
|
};
|
6903
7085
|
}, []);
|
6904
7086
|
const [showLoader, setShowLoader] = useState24(false);
|
6905
|
-
|
7087
|
+
useEffect22(() => {
|
6906
7088
|
setTimeout(() => {
|
6907
7089
|
setShowLoader(true);
|
6908
7090
|
}, 500);
|
@@ -6920,7 +7102,7 @@ var Canvas = () => {
|
|
6920
7102
|
recordHistory: true
|
6921
7103
|
}),
|
6922
7104
|
children: [
|
6923
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
7105
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
|
6924
7106
|
ViewportControls,
|
6925
7107
|
{
|
6926
7108
|
autoZoom: zoomConfig.autoZoom,
|
@@ -6947,7 +7129,7 @@ var Canvas = () => {
|
|
6947
7129
|
}
|
6948
7130
|
) }),
|
6949
7131
|
/* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
6950
|
-
/* @__PURE__ */
|
7132
|
+
/* @__PURE__ */ jsx37(
|
6951
7133
|
"div",
|
6952
7134
|
{
|
6953
7135
|
className: getClassName26("root"),
|
@@ -6968,10 +7150,10 @@ var Canvas = () => {
|
|
6968
7150
|
})
|
6969
7151
|
);
|
6970
7152
|
},
|
6971
|
-
children: /* @__PURE__ */
|
7153
|
+
children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
|
6972
7154
|
}
|
6973
7155
|
),
|
6974
|
-
/* @__PURE__ */
|
7156
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
|
6975
7157
|
] })
|
6976
7158
|
]
|
6977
7159
|
}
|
@@ -6980,7 +7162,7 @@ var Canvas = () => {
|
|
6980
7162
|
|
6981
7163
|
// lib/use-loaded-overrides.ts
|
6982
7164
|
init_react_import();
|
6983
|
-
import { useMemo as
|
7165
|
+
import { useMemo as useMemo18 } from "react";
|
6984
7166
|
|
6985
7167
|
// lib/load-overrides.ts
|
6986
7168
|
init_react_import();
|
@@ -7019,26 +7201,26 @@ var useLoadedOverrides = ({
|
|
7019
7201
|
overrides,
|
7020
7202
|
plugins
|
7021
7203
|
}) => {
|
7022
|
-
return
|
7204
|
+
return useMemo18(() => {
|
7023
7205
|
return loadOverrides({ overrides, plugins });
|
7024
7206
|
}, [plugins, overrides]);
|
7025
7207
|
};
|
7026
7208
|
|
7027
7209
|
// components/DefaultOverride/index.tsx
|
7028
7210
|
init_react_import();
|
7029
|
-
import { Fragment as Fragment14, jsx as
|
7030
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */
|
7211
|
+
import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
|
7212
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
|
7031
7213
|
|
7032
7214
|
// lib/use-inject-css.ts
|
7033
7215
|
init_react_import();
|
7034
|
-
import { useEffect as
|
7216
|
+
import { useEffect as useEffect23, useState as useState25 } from "react";
|
7035
7217
|
var styles = ``;
|
7036
7218
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7037
7219
|
const [el, setEl] = useState25();
|
7038
|
-
|
7220
|
+
useEffect23(() => {
|
7039
7221
|
setEl(document.createElement("style"));
|
7040
7222
|
}, []);
|
7041
|
-
|
7223
|
+
useEffect23(() => {
|
7042
7224
|
var _a;
|
7043
7225
|
if (!el || typeof window === "undefined") {
|
7044
7226
|
return;
|
@@ -7058,10 +7240,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7058
7240
|
|
7059
7241
|
// lib/use-preview-mode-hotkeys.ts
|
7060
7242
|
init_react_import();
|
7061
|
-
import { useCallback as
|
7243
|
+
import { useCallback as useCallback17 } from "react";
|
7062
7244
|
import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
|
7063
7245
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7064
|
-
const toggleInteractive =
|
7246
|
+
const toggleInteractive = useCallback17(() => {
|
7065
7247
|
dispatch({
|
7066
7248
|
type: "setUi",
|
7067
7249
|
ui: (ui) => ({
|
@@ -7084,7 +7266,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
|
7084
7266
|
};
|
7085
7267
|
|
7086
7268
|
// components/Puck/index.tsx
|
7087
|
-
import { Fragment as Fragment15, jsx as
|
7269
|
+
import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
|
7088
7270
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
7089
7271
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
7090
7272
|
function Puck({
|
@@ -7206,11 +7388,11 @@ function Puck({
|
|
7206
7388
|
const [menuOpen, setMenuOpen] = useState26(false);
|
7207
7389
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7208
7390
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7209
|
-
|
7391
|
+
useEffect24(() => {
|
7210
7392
|
if (onChange) onChange(data);
|
7211
7393
|
}, [data]);
|
7212
7394
|
const rootProps = data.root.props || data.root;
|
7213
|
-
const toggleSidebars =
|
7395
|
+
const toggleSidebars = useCallback18(
|
7214
7396
|
(sidebar) => {
|
7215
7397
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7216
7398
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7224,7 +7406,7 @@ function Puck({
|
|
7224
7406
|
},
|
7225
7407
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7226
7408
|
);
|
7227
|
-
|
7409
|
+
useEffect24(() => {
|
7228
7410
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7229
7411
|
dispatch({
|
7230
7412
|
type: "setUi",
|
@@ -7247,7 +7429,7 @@ function Puck({
|
|
7247
7429
|
window.removeEventListener("resize", handleResize);
|
7248
7430
|
};
|
7249
7431
|
}, []);
|
7250
|
-
const defaultHeaderRender =
|
7432
|
+
const defaultHeaderRender = useMemo19(() => {
|
7251
7433
|
if (renderHeader) {
|
7252
7434
|
console.warn(
|
7253
7435
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7255,20 +7437,20 @@ function Puck({
|
|
7255
7437
|
const RenderHeader = (_a2) => {
|
7256
7438
|
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
7257
7439
|
const Comp = renderHeader;
|
7258
|
-
return /* @__PURE__ */
|
7440
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7259
7441
|
};
|
7260
7442
|
return RenderHeader;
|
7261
7443
|
}
|
7262
7444
|
return DefaultOverride;
|
7263
7445
|
}, [renderHeader]);
|
7264
|
-
const defaultHeaderActionsRender =
|
7446
|
+
const defaultHeaderActionsRender = useMemo19(() => {
|
7265
7447
|
if (renderHeaderActions) {
|
7266
7448
|
console.warn(
|
7267
7449
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7268
7450
|
);
|
7269
7451
|
const RenderHeader = (props) => {
|
7270
7452
|
const Comp = renderHeaderActions;
|
7271
|
-
return /* @__PURE__ */
|
7453
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7272
7454
|
};
|
7273
7455
|
return RenderHeader;
|
7274
7456
|
}
|
@@ -7278,27 +7460,27 @@ function Puck({
|
|
7278
7460
|
overrides,
|
7279
7461
|
plugins
|
7280
7462
|
});
|
7281
|
-
const CustomPuck =
|
7463
|
+
const CustomPuck = useMemo19(
|
7282
7464
|
() => loadedOverrides.puck || DefaultOverride,
|
7283
7465
|
[loadedOverrides]
|
7284
7466
|
);
|
7285
|
-
const CustomHeader =
|
7467
|
+
const CustomHeader = useMemo19(
|
7286
7468
|
() => loadedOverrides.header || defaultHeaderRender,
|
7287
7469
|
[loadedOverrides]
|
7288
7470
|
);
|
7289
|
-
const CustomHeaderActions =
|
7471
|
+
const CustomHeaderActions = useMemo19(
|
7290
7472
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7291
7473
|
[loadedOverrides]
|
7292
7474
|
);
|
7293
7475
|
const [mounted, setMounted] = useState26(false);
|
7294
|
-
|
7476
|
+
useEffect24(() => {
|
7295
7477
|
setMounted(true);
|
7296
7478
|
}, []);
|
7297
7479
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
7298
7480
|
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
7299
7481
|
usePreviewModeHotkeys(dispatch, iframe.enabled);
|
7300
7482
|
return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
|
7301
|
-
/* @__PURE__ */
|
7483
|
+
/* @__PURE__ */ jsx39(
|
7302
7484
|
AppProvider,
|
7303
7485
|
{
|
7304
7486
|
value: {
|
@@ -7320,7 +7502,7 @@ function Puck({
|
|
7320
7502
|
getPermissions: () => ({}),
|
7321
7503
|
refreshPermissions: () => null
|
7322
7504
|
},
|
7323
|
-
children: /* @__PURE__ */
|
7505
|
+
children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
|
7324
7506
|
"div",
|
7325
7507
|
{
|
7326
7508
|
className: getLayoutClassName({
|
@@ -7330,59 +7512,59 @@ function Puck({
|
|
7330
7512
|
rightSideBarVisible
|
7331
7513
|
}),
|
7332
7514
|
children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
|
7333
|
-
/* @__PURE__ */
|
7515
|
+
/* @__PURE__ */ jsx39(
|
7334
7516
|
CustomHeader,
|
7335
7517
|
{
|
7336
|
-
actions: /* @__PURE__ */
|
7518
|
+
actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7337
7519
|
Button,
|
7338
7520
|
{
|
7339
7521
|
onClick: () => {
|
7340
7522
|
onPublish && onPublish(data);
|
7341
7523
|
},
|
7342
|
-
icon: /* @__PURE__ */
|
7524
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7343
7525
|
children: "Publish"
|
7344
7526
|
}
|
7345
7527
|
) }) }),
|
7346
|
-
children: /* @__PURE__ */
|
7528
|
+
children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
|
7347
7529
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
|
7348
|
-
/* @__PURE__ */
|
7530
|
+
/* @__PURE__ */ jsx39(
|
7349
7531
|
"div",
|
7350
7532
|
{
|
7351
7533
|
className: getLayoutClassName("leftSideBarToggle"),
|
7352
|
-
children: /* @__PURE__ */
|
7534
|
+
children: /* @__PURE__ */ jsx39(
|
7353
7535
|
IconButton,
|
7354
7536
|
{
|
7355
7537
|
onClick: () => {
|
7356
7538
|
toggleSidebars("left");
|
7357
7539
|
},
|
7358
7540
|
title: "Toggle left sidebar",
|
7359
|
-
children: /* @__PURE__ */
|
7541
|
+
children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
|
7360
7542
|
}
|
7361
7543
|
)
|
7362
7544
|
}
|
7363
7545
|
),
|
7364
|
-
/* @__PURE__ */
|
7546
|
+
/* @__PURE__ */ jsx39(
|
7365
7547
|
"div",
|
7366
7548
|
{
|
7367
7549
|
className: getLayoutClassName("rightSideBarToggle"),
|
7368
|
-
children: /* @__PURE__ */
|
7550
|
+
children: /* @__PURE__ */ jsx39(
|
7369
7551
|
IconButton,
|
7370
7552
|
{
|
7371
7553
|
onClick: () => {
|
7372
7554
|
toggleSidebars("right");
|
7373
7555
|
},
|
7374
7556
|
title: "Toggle right sidebar",
|
7375
|
-
children: /* @__PURE__ */
|
7557
|
+
children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
|
7376
7558
|
}
|
7377
7559
|
)
|
7378
7560
|
}
|
7379
7561
|
)
|
7380
7562
|
] }),
|
7381
|
-
/* @__PURE__ */
|
7563
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
|
7382
7564
|
headerTitle || rootProps.title || "Page",
|
7383
7565
|
headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
|
7384
7566
|
" ",
|
7385
|
-
/* @__PURE__ */
|
7567
|
+
/* @__PURE__ */ jsx39(
|
7386
7568
|
"code",
|
7387
7569
|
{
|
7388
7570
|
className: getLayoutClassName("headerPath"),
|
@@ -7392,30 +7574,30 @@ function Puck({
|
|
7392
7574
|
] })
|
7393
7575
|
] }) }),
|
7394
7576
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
|
7395
|
-
/* @__PURE__ */
|
7577
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
|
7396
7578
|
IconButton,
|
7397
7579
|
{
|
7398
7580
|
onClick: () => {
|
7399
7581
|
return setMenuOpen(!menuOpen);
|
7400
7582
|
},
|
7401
7583
|
title: "Toggle menu bar",
|
7402
|
-
children: menuOpen ? /* @__PURE__ */
|
7584
|
+
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
7403
7585
|
}
|
7404
7586
|
) }),
|
7405
|
-
/* @__PURE__ */
|
7587
|
+
/* @__PURE__ */ jsx39(
|
7406
7588
|
MenuBar,
|
7407
7589
|
{
|
7408
7590
|
appState,
|
7409
7591
|
dispatch,
|
7410
7592
|
onPublish,
|
7411
7593
|
menuOpen,
|
7412
|
-
renderHeaderActions: () => /* @__PURE__ */
|
7594
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7413
7595
|
Button,
|
7414
7596
|
{
|
7415
7597
|
onClick: () => {
|
7416
7598
|
onPublish && onPublish(data);
|
7417
7599
|
},
|
7418
|
-
icon: /* @__PURE__ */
|
7600
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7419
7601
|
children: "Publish"
|
7420
7602
|
}
|
7421
7603
|
) }),
|
@@ -7427,18 +7609,18 @@ function Puck({
|
|
7427
7609
|
}
|
7428
7610
|
),
|
7429
7611
|
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
|
7430
|
-
/* @__PURE__ */
|
7431
|
-
/* @__PURE__ */
|
7612
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
|
7613
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
|
7432
7614
|
] }),
|
7433
|
-
/* @__PURE__ */
|
7434
|
-
/* @__PURE__ */
|
7615
|
+
/* @__PURE__ */ jsx39(Canvas, {}),
|
7616
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
|
7435
7617
|
SidebarSection,
|
7436
7618
|
{
|
7437
7619
|
noPadding: true,
|
7438
7620
|
noBorderTop: true,
|
7439
7621
|
showBreadcrumbs: true,
|
7440
7622
|
title: selectedItem ? selectedComponentLabel : "Page",
|
7441
|
-
children: /* @__PURE__ */
|
7623
|
+
children: /* @__PURE__ */ jsx39(Fields, {})
|
7442
7624
|
}
|
7443
7625
|
) })
|
7444
7626
|
] })
|
@@ -7446,7 +7628,7 @@ function Puck({
|
|
7446
7628
|
) }) })
|
7447
7629
|
}
|
7448
7630
|
),
|
7449
|
-
/* @__PURE__ */
|
7631
|
+
/* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
7450
7632
|
] });
|
7451
7633
|
}
|
7452
7634
|
Puck.Components = Components;
|