@measured/puck 0.18.0-canary.874ba1b → 0.18.0-canary.88863c3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  resolveRootData,
17
17
  rootDroppableId,
18
18
  setupZone
19
- } from "./chunk-EXKSBUY5.mjs";
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": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
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 useMemo4,
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 jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
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__ */ jsx7("div", __spreadValues({}, props))
1226
+ Label: Label2 = (props) => /* @__PURE__ */ jsx8("div", __spreadValues({}, props))
1181
1227
  }) => {
1182
1228
  const { state, setUi, selectedItem, getPermissions } = useAppContext();
1183
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
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__ */ jsx7(
1289
+ return /* @__PURE__ */ jsx8(
1244
1290
  Label2,
1245
1291
  {
1246
1292
  label: label || name,
1247
- icon: /* @__PURE__ */ jsx7(List, { size: 16 }),
1293
+ icon: /* @__PURE__ */ jsx8(List, { size: 16 }),
1248
1294
  el: "div",
1249
1295
  readOnly,
1250
- children: /* @__PURE__ */ jsx7(
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__ */ jsx7(
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__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
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__ */ jsx7(Copy, { size: 16 })
1390
+ children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
1345
1391
  }
1346
1392
  ) }),
1347
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
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__ */ jsx7(Trash, { size: 16 })
1414
+ children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
1369
1415
  }
1370
1416
  ) })
1371
1417
  ] }),
1372
- /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(DragIcon, {}) })
1418
+ /* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(DragIcon, {}) })
1373
1419
  ] })
1374
1420
  ]
1375
1421
  }
1376
1422
  ),
1377
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((fieldName) => {
1378
- const subField = field.arrayFields[fieldName];
1379
- const subFieldName = `${name}[${i}].${fieldName}`;
1380
- const wildcardFieldName = `${name}[*].${fieldName}`;
1381
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
1382
- const label2 = subField.label || fieldName;
1383
- return /* @__PURE__ */ jsx7(
1384
- AutoFieldPrivate,
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: subFieldName,
1387
- label: label2,
1388
- id: `${_arrayId}_${fieldName}`,
1389
- readOnly: subReadOnly,
1390
- field: __spreadProps(__spreadValues({}, subField), {
1391
- label: label2
1392
- // May be used by custom fields
1393
- }),
1394
- value: data[fieldName],
1395
- onChange: (val, ui) => {
1396
- onChange(
1397
- replace(value, i, __spreadProps(__spreadValues({}, data), {
1398
- [fieldName]: val
1399
- })),
1400
- ui
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
- subFieldName
1463
+ subPath
1405
1464
  );
1406
1465
  }) }) })
1407
1466
  ]
@@ -1411,7 +1470,7 @@ var ArrayField = ({
1411
1470
  _arrayId
1412
1471
  );
1413
1472
  }),
1414
- !addDisabled && /* @__PURE__ */ jsx7(
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__ */ jsx7(Plus, { size: 21 })
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 jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
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
- return /* @__PURE__ */ jsx8(
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__ */ jsx8(Type, { size: 16 }),
1460
- field.type === "number" && /* @__PURE__ */ jsx8(Hash, { size: 16 })
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__ */ jsx8(
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: typeof value === "undefined" ? "" : value.toString(),
1531
+ value: (value == null ? void 0 : value.toString) ? value.toString() : "",
1472
1532
  onChange: (e) => {
1473
1533
  if (field.type === "number") {
1474
- onChange(Number(e.currentTarget.value));
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 jsx9 } from "react/jsx-runtime";
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__ */ jsx9("div", {});
1597
+ return /* @__PURE__ */ jsx10("div", {});
1531
1598
  }
1532
1599
  return createPortal(
1533
- /* @__PURE__ */ jsx9("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx9(
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 jsx10 } from "react/jsx-runtime";
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__ */ jsx10(
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 jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
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__ */ jsx11("div", { className: getClassName9("icon"), children: icon }),
1719
+ icon && /* @__PURE__ */ jsx12("div", { className: getClassName9("icon"), children: icon }),
1653
1720
  children,
1654
- loading && /* @__PURE__ */ jsx11("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx11(Loader, { size: 14 }) })
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 jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
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 = useMemo(() => {
1752
+ const mappedData = useMemo2(() => {
1686
1753
  return data.map(mapRow);
1687
1754
  }, [data]);
1688
- const keys = useMemo(() => {
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__ */ jsx12(
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__ */ jsx12(Link, { size: "16" }),
1744
- /* @__PURE__ */ jsx12("span", { children: field.placeholder })
1810
+ /* @__PURE__ */ jsx13(Link, { size: "16" }),
1811
+ /* @__PURE__ */ jsx13("span", { children: field.placeholder })
1745
1812
  ] })
1746
1813
  }
1747
1814
  ),
1748
- value && /* @__PURE__ */ jsx12(
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__ */ jsx12(LockOpen, { size: 16 })
1824
+ children: /* @__PURE__ */ jsx13(LockOpen, { size: 16 })
1758
1825
  }
1759
1826
  )
1760
1827
  ] }),
1761
- /* @__PURE__ */ jsx12(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
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__ */ jsx12("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
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__ */ jsx12("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
1778
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx12(Search, { size: "18" }) }),
1779
- /* @__PURE__ */ jsx12(
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__ */ jsx12(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
1796
- hasFilterFields && /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx12(
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__ */ jsx12(SlidersHorizontal, { size: 20 })
1872
+ children: /* @__PURE__ */ jsx13(SlidersHorizontal, { size: 20 })
1806
1873
  }
1807
1874
  ) })
1808
1875
  ] })
1809
- ] }) : /* @__PURE__ */ jsx12(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
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__ */ jsx12("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1878
+ hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1812
1879
  const filterField = filterFields[fieldName];
1813
- return /* @__PURE__ */ jsx12(
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__ */ jsx12("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx12("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx12(
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__ */ jsx12("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
1842
- return /* @__PURE__ */ jsx12(
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__ */ jsx12("td", { className: getClassNameModal("td"), children: item[key] }, key))
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__ */ jsx12("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx12(Loader, { size: 24 }) })
1924
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx13(Loader, { size: 24 }) })
1858
1925
  ] })
1859
1926
  ] }),
1860
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx12(Footer, { items: mappedData }) })
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 jsx13 } from "react/jsx-runtime";
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__ */ jsx13(Label2, { label: label || name, icon: /* @__PURE__ */ jsx13(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx13(
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 useMemo2 } from "react";
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 jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
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 = useMemo2(
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__ */ jsx14(
2019
+ return /* @__PURE__ */ jsx15(
1953
2020
  Label2,
1954
2021
  {
1955
- icon: /* @__PURE__ */ jsx14(CircleCheckBig, { size: 16 }),
2022
+ icon: /* @__PURE__ */ jsx15(CircleCheckBig, { size: 16 }),
1956
2023
  label: label || name,
1957
2024
  readOnly,
1958
2025
  el: "div",
1959
- children: /* @__PURE__ */ jsx14("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs7(
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__ */ jsx14(
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__ */ jsx14("div", { className: getClassName11("radioInner"), children: option.label || option.value })
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 useMemo3 } from "react";
1996
- import { jsx as jsx15 } from "react/jsx-runtime";
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 = useMemo3(
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__ */ jsx15(
2082
+ return /* @__PURE__ */ jsx16(
2016
2083
  Label2,
2017
2084
  {
2018
2085
  label: label || name,
2019
- icon: /* @__PURE__ */ jsx15(ChevronDown, { size: 16 }),
2086
+ icon: /* @__PURE__ */ jsx16(ChevronDown, { size: 16 }),
2020
2087
  readOnly,
2021
- children: /* @__PURE__ */ jsx15(
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__ */ jsx15(
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 jsx16 } from "react/jsx-runtime";
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__ */ jsx16(Label2, { label: label || name, icon: /* @__PURE__ */ jsx16(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx16(
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 jsx17 } from "react/jsx-runtime";
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 { selectedItem } = useAppContext();
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__ */ jsx17(
2176
+ return /* @__PURE__ */ jsx18(
2111
2177
  Label2,
2112
2178
  {
2113
2179
  label: label || name,
2114
- icon: /* @__PURE__ */ jsx17(EllipsisVertical, { size: 16 }),
2180
+ icon: /* @__PURE__ */ jsx18(EllipsisVertical, { size: 16 }),
2115
2181
  el: "div",
2116
2182
  readOnly,
2117
- children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((fieldName) => {
2118
- const subField = field.objectFields[fieldName];
2119
- const subFieldName = `${name}.${fieldName}`;
2120
- const wildcardFieldName = `${name}.${fieldName}`;
2121
- const subReadOnly = readOnly ? readOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
2122
- const label2 = subField.label || fieldName;
2123
- return /* @__PURE__ */ jsx17(
2124
- AutoFieldPrivate,
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: subFieldName,
2127
- label: label2,
2128
- id: `${id}_${fieldName}`,
2129
- readOnly: subReadOnly,
2130
- field: __spreadProps(__spreadValues({}, subField), {
2131
- label: label2
2132
- // May be used by custom fields
2133
- }),
2134
- value: data[fieldName],
2135
- onChange: (val, ui) => {
2136
- onChange(
2137
- __spreadProps(__spreadValues({}, data), {
2138
- [fieldName]: val
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
- ui
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
- subFieldName
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 jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
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__ */ jsx18("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx18(Fragment4, {}),
2258
+ icon ? /* @__PURE__ */ jsx19("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx19(Fragment4, {}),
2185
2259
  label,
2186
- readOnly && /* @__PURE__ */ jsx18("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx18(Lock, { size: "12" }) })
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 FieldLabelInternal2 = ({
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 = useMemo4(
2273
+ const Wrapper = useMemo5(
2200
2274
  () => overrides.fieldLabel || FieldLabel,
2201
2275
  [overrides]
2202
2276
  );
2203
2277
  if (!label) {
2204
- return /* @__PURE__ */ jsx18(Fragment4, { children });
2278
+ return /* @__PURE__ */ jsx19(Fragment4, { children });
2205
2279
  }
2206
- return /* @__PURE__ */ jsx18(
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 { id, Label: Label2 = FieldLabelInternal2 } = props;
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__ */ jsx18("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx18("div", { className: getClassName15(), children: /* @__PURE__ */ jsx18(CustomField, __spreadValues({}, mergedProps)) }) });
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__ */ jsx18(
2286
- "div",
2360
+ return /* @__PURE__ */ jsx19(
2361
+ NestedFieldContext.Provider,
2287
2362
  {
2288
- className: getClassNameWrapper(),
2289
- onFocus,
2290
- onBlur,
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__ */ jsx18(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
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__ */ jsx18(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2406
+ return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2323
2407
  }
2324
2408
  function AutoField(props) {
2325
- const DefaultLabel = useMemo4(() => {
2326
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx18(
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__ */ jsx18(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
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 useMemo8, useState as useState18 } from "react";
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 createContext3,
2435
+ createContext as createContext4,
2352
2436
  useCallback as useCallback11,
2353
- useContext as useContext5,
2437
+ useContext as useContext7,
2354
2438
  useEffect as useEffect15,
2355
2439
  useId,
2356
- useRef as useRef5,
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 useContext4,
2450
+ useContext as useContext6,
2367
2451
  useEffect as useEffect14,
2368
- useMemo as useMemo7,
2369
- useRef as useRef4
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 useContext3,
2460
+ useContext as useContext5,
2377
2461
  useEffect as useEffect10,
2378
- useMemo as useMemo6,
2379
- useRef as useRef3,
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 createContext2,
2834
+ createContext as createContext3,
2751
2835
  useCallback as useCallback6,
2752
- useMemo as useMemo5,
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 jsx19 } from "react/jsx-runtime";
2757
- var dropZoneContext = createContext2(null);
2758
- var ZoneStoreContext = createContext2(
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__ */ jsx19(ZoneStoreContext.Provider, { value: store, children });
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 = useMemo5(
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__ */ jsx19(Fragment5, { children: memoValue && /* @__PURE__ */ jsx19(dropZoneContext.Provider, { value: memoValue, children }) });
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 useContext2 } from "react";
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 = useContext2(context);
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 jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
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__ */ jsx20(ActionBar.Label, { label })
2945
+ label && /* @__PURE__ */ jsx21(ActionBar.Label, { label })
2862
2946
  ] }),
2863
- /* @__PURE__ */ jsx20(ActionBar.Group, { children })
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 = useContext3(dropZoneContext);
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 = useRef3(null);
3051
+ const ref = useRef(null);
2968
3052
  const refSetter = useCallback7(
2969
3053
  (el) => {
2970
3054
  sortableRef(el);
@@ -3015,14 +3099,20 @@ var DraggableComponent = ({
3015
3099
  }
3016
3100
  }, [ref.current]);
3017
3101
  useEffect10(() => {
3018
- if (isSelected) {
3019
- ctx == null ? void 0 : ctx.registerPath({
3102
+ ctx == null ? void 0 : ctx.registerPath(
3103
+ id,
3104
+ {
3020
3105
  index,
3021
3106
  zone: zoneCompound
3022
- });
3023
- }
3024
- }, [isSelected]);
3025
- const CustomActionBar = useMemo6(
3107
+ },
3108
+ componentType
3109
+ );
3110
+ return () => {
3111
+ var _a;
3112
+ (_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
3113
+ };
3114
+ }, [id, zoneCompound, index, componentType]);
3115
+ const CustomActionBar = useMemo7(
3026
3116
  () => overrides.actionBar || DefaultActionBar,
3027
3117
  [overrides.actionBar]
3028
3118
  );
@@ -3174,7 +3264,7 @@ var DraggableComponent = ({
3174
3264
  }
3175
3265
  setDragAxis(autoDragAxis);
3176
3266
  }, [ref, userDragAxis, autoDragAxis]);
3177
- const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx20(CornerLeftUp, { size: 16 }) });
3267
+ 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
3268
  return /* @__PURE__ */ jsxs9(
3179
3269
  DropZoneProvider,
3180
3270
  {
@@ -3201,15 +3291,15 @@ var DraggableComponent = ({
3201
3291
  "data-puck-overlay": true,
3202
3292
  children: [
3203
3293
  debug,
3204
- isLoading && /* @__PURE__ */ jsx20("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx20(Loader, {}) }),
3205
- /* @__PURE__ */ jsx20(
3294
+ isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
3295
+ /* @__PURE__ */ jsx21(
3206
3296
  "div",
3207
3297
  {
3208
3298
  className: getClassName16("actionsOverlay"),
3209
3299
  style: {
3210
3300
  top: actionsOverlayTop / zoomConfig.zoom
3211
3301
  },
3212
- children: /* @__PURE__ */ jsx20(
3302
+ children: /* @__PURE__ */ jsx21(
3213
3303
  "div",
3214
3304
  {
3215
3305
  className: getClassName16("actions"),
@@ -3227,8 +3317,8 @@ var DraggableComponent = ({
3227
3317
  parentAction,
3228
3318
  label: DEBUG2 ? id : label,
3229
3319
  children: [
3230
- permissions.duplicate && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx20(Copy, { size: 16 }) }),
3231
- permissions.delete && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx20(Trash, { size: 16 }) })
3320
+ permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
3321
+ permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
3232
3322
  ]
3233
3323
  }
3234
3324
  )
@@ -3236,7 +3326,7 @@ var DraggableComponent = ({
3236
3326
  )
3237
3327
  }
3238
3328
  ),
3239
- /* @__PURE__ */ jsx20("div", { className: getClassName16("overlay") })
3329
+ /* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
3240
3330
  ]
3241
3331
  }
3242
3332
  ),
@@ -3419,12 +3509,13 @@ var useDragAxis = (ref, collisionAxis) => {
3419
3509
  };
3420
3510
 
3421
3511
  // components/DropZone/index.tsx
3422
- import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
3512
+ import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
3423
3513
  var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3424
3514
  var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3425
3515
  var RENDER_DEBUG = false;
3516
+ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
3426
3517
  var DropZoneEdit = forwardRef3(
3427
- function DropZoneEdit2({
3518
+ function DropZoneEditInternal({
3428
3519
  zone,
3429
3520
  allow,
3430
3521
  disallow,
@@ -3434,7 +3525,7 @@ var DropZoneEdit = forwardRef3(
3434
3525
  collisionAxis
3435
3526
  }, userRef) {
3436
3527
  const appContext2 = useAppContext();
3437
- const ctx = useContext4(dropZoneContext);
3528
+ const ctx = useContext6(dropZoneContext);
3438
3529
  const {
3439
3530
  // These all need setting via context
3440
3531
  data,
@@ -3487,13 +3578,13 @@ var DropZoneEdit = forwardRef3(
3487
3578
  }
3488
3579
  };
3489
3580
  }, []);
3490
- const content = useMemo7(() => {
3581
+ const content = useMemo8(() => {
3491
3582
  if (areaId && zone !== rootDroppableId) {
3492
3583
  return setupZone(data, zoneCompound).zones[zoneCompound];
3493
3584
  }
3494
3585
  return data.content || [];
3495
3586
  }, [data, zoneCompound]);
3496
- const ref = useRef4(null);
3587
+ const ref = useRef2(null);
3497
3588
  const acceptsTarget = useCallback10(
3498
3589
  (componentType) => {
3499
3590
  if (!componentType) {
@@ -3558,7 +3649,7 @@ var DropZoneEdit = forwardRef3(
3558
3649
  userMinEmptyHeight,
3559
3650
  ref
3560
3651
  });
3561
- return /* @__PURE__ */ jsx21(
3652
+ return /* @__PURE__ */ jsx22(
3562
3653
  "div",
3563
3654
  {
3564
3655
  className: `${getClassName17({
@@ -3582,10 +3673,10 @@ var DropZoneEdit = forwardRef3(
3582
3673
  backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3583
3674
  }),
3584
3675
  children: contentWithPreview.map((item, i) => {
3585
- var _a, _b, _c, _d, _e;
3676
+ var _a, _b, _c, _d, _e, _f, _g;
3586
3677
  const componentId = item.props.id;
3587
3678
  const puckProps = {
3588
- renderDropZone: DropZone,
3679
+ renderDropZone: DropZoneEditPure,
3589
3680
  isEditing: true,
3590
3681
  dragRef: null
3591
3682
  };
@@ -3602,20 +3693,20 @@ var DropZoneEdit = forwardRef3(
3602
3693
  const componentConfig = config.components[item.type];
3603
3694
  let componentType = item.type;
3604
3695
  let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3605
- if (item.type === "preview" && preview) {
3696
+ if (item.type === "preview") {
3606
3697
  let Preview4 = function() {
3607
- return /* @__PURE__ */ jsx21(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3698
+ return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3608
3699
  };
3609
3700
  var Preview3 = Preview4;
3610
- componentType = preview.componentType;
3611
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3701
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3702
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3612
3703
  Render2 = Preview4;
3613
3704
  }
3614
- return /* @__PURE__ */ jsx21(
3705
+ return /* @__PURE__ */ jsx22(
3615
3706
  DropZoneProvider,
3616
3707
  {
3617
3708
  value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3618
- children: /* @__PURE__ */ jsx21(
3709
+ children: /* @__PURE__ */ jsx22(
3619
3710
  DraggableComponent,
3620
3711
  {
3621
3712
  id: componentId,
@@ -3623,21 +3714,21 @@ var DropZoneEdit = forwardRef3(
3623
3714
  zoneCompound,
3624
3715
  depth: depth + 1,
3625
3716
  index: i,
3626
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3717
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3627
3718
  isSelected,
3628
3719
  label,
3629
3720
  isEnabled,
3630
3721
  autoDragAxis: dragAxis,
3631
3722
  userDragAxis: collisionAxis,
3632
3723
  inDroppableZone: acceptsTarget(draggedComponentType),
3633
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx21(
3724
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx22(
3634
3725
  Render2,
3635
3726
  __spreadProps(__spreadValues({}, defaultedProps), {
3636
3727
  puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3637
3728
  dragRef
3638
3729
  })
3639
3730
  })
3640
- ) : /* @__PURE__ */ jsx21("div", { ref: dragRef, children: /* @__PURE__ */ jsx21(Render2, __spreadValues({}, defaultedProps)) })
3731
+ ) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
3641
3732
  }
3642
3733
  )
3643
3734
  },
@@ -3648,9 +3739,10 @@ var DropZoneEdit = forwardRef3(
3648
3739
  );
3649
3740
  }
3650
3741
  );
3742
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
3651
3743
  var DropZoneRender = forwardRef3(
3652
- function DropZoneRender2({ className, style, zone }, ref) {
3653
- const ctx = useContext4(dropZoneContext);
3744
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3745
+ const ctx = useContext6(dropZoneContext);
3654
3746
  const { data, areaId = "root", config } = ctx || {};
3655
3747
  let zoneCompound = rootDroppableId;
3656
3748
  let content = (data == null ? void 0 : data.content) || [];
@@ -3671,10 +3763,10 @@ var DropZoneRender = forwardRef3(
3671
3763
  zoneCompound = `${areaId}:${zone}`;
3672
3764
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3673
3765
  }
3674
- return /* @__PURE__ */ jsx21("div", { className, style, ref, children: content.map((item) => {
3766
+ return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
3675
3767
  const Component = config.components[item.type];
3676
3768
  if (Component) {
3677
- return /* @__PURE__ */ jsx21(
3769
+ return /* @__PURE__ */ jsx22(
3678
3770
  DropZoneProvider,
3679
3771
  {
3680
3772
  value: {
@@ -3684,10 +3776,12 @@ var DropZoneRender = forwardRef3(
3684
3776
  depth: 1,
3685
3777
  path: []
3686
3778
  },
3687
- children: /* @__PURE__ */ jsx21(
3779
+ children: /* @__PURE__ */ jsx22(
3688
3780
  Component.render,
3689
3781
  __spreadProps(__spreadValues({}, item.props), {
3690
- puck: { renderDropZone: DropZoneRender2 }
3782
+ puck: {
3783
+ renderDropZone: DropZoneRenderPure
3784
+ }
3691
3785
  })
3692
3786
  )
3693
3787
  },
@@ -3700,11 +3794,11 @@ var DropZoneRender = forwardRef3(
3700
3794
  );
3701
3795
  var DropZone = forwardRef3(
3702
3796
  function DropZone2(props, ref) {
3703
- const ctx = useContext4(dropZoneContext);
3797
+ const ctx = useContext6(dropZoneContext);
3704
3798
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3705
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3799
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3706
3800
  }
3707
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3801
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3708
3802
  }
3709
3803
  );
3710
3804
 
@@ -3762,6 +3856,48 @@ var getFrame = () => {
3762
3856
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3763
3857
  };
3764
3858
 
3859
+ // lib/global-position.ts
3860
+ init_react_import();
3861
+ var GlobalPosition = class {
3862
+ constructor(target, original) {
3863
+ this.scaleFactor = 1;
3864
+ this.frameEl = null;
3865
+ this.frameRect = null;
3866
+ var _a;
3867
+ this.target = target;
3868
+ this.original = original;
3869
+ this.frameEl = document.querySelector("iframe");
3870
+ if (this.frameEl) {
3871
+ this.frameRect = this.frameEl.getBoundingClientRect();
3872
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3873
+ }
3874
+ }
3875
+ get x() {
3876
+ return this.original.x;
3877
+ }
3878
+ get y() {
3879
+ return this.original.y;
3880
+ }
3881
+ get global() {
3882
+ if (document !== this.target.ownerDocument && this.frameRect) {
3883
+ return {
3884
+ x: this.x * this.scaleFactor + this.frameRect.left,
3885
+ y: this.y * this.scaleFactor + this.frameRect.top
3886
+ };
3887
+ }
3888
+ return this.original;
3889
+ }
3890
+ get frame() {
3891
+ if (document === this.target.ownerDocument && this.frameRect) {
3892
+ return {
3893
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
3894
+ y: (this.y - this.frameRect.top) / this.scaleFactor
3895
+ };
3896
+ }
3897
+ return this.original;
3898
+ }
3899
+ };
3900
+
3765
3901
  // lib/dnd/NestedDroppablePlugin.ts
3766
3902
  var depthSort = (candidates) => {
3767
3903
  return candidates.sort((a, b) => {
@@ -3791,10 +3927,12 @@ var getZoneId2 = (candidate) => {
3791
3927
  }
3792
3928
  return id;
3793
3929
  };
3794
- var getPointerCollisions = (position, manager, ownerDocument) => {
3795
- var _a;
3930
+ var getPointerCollisions = (position, manager) => {
3796
3931
  const candidates = [];
3797
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
3932
+ let elements = position.target.ownerDocument.elementsFromPoint(
3933
+ position.x,
3934
+ position.y
3935
+ );
3798
3936
  const previewFrame = elements.find(
3799
3937
  (el) => el.getAttribute("data-puck-preview")
3800
3938
  );
@@ -3803,17 +3941,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3803
3941
  elements = [drawer];
3804
3942
  }
3805
3943
  if (previewFrame) {
3806
- const iframe = previewFrame.querySelector("iframe");
3807
- if (iframe) {
3808
- const rect = iframe.getBoundingClientRect();
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
- }
3944
+ const frame = getFrame();
3945
+ if (frame) {
3946
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3817
3947
  }
3818
3948
  }
3819
3949
  if (elements) {
@@ -3830,9 +3960,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3830
3960
  }
3831
3961
  return candidates;
3832
3962
  };
3833
- var findDeepestCandidate = (position, manager, ownerDocument) => {
3963
+ var findDeepestCandidate = (position, manager) => {
3834
3964
  var _a;
3835
- const candidates = getPointerCollisions(position, manager, ownerDocument);
3965
+ const candidates = getPointerCollisions(position, manager);
3836
3966
  if (candidates.length > 0) {
3837
3967
  const sortedCandidates = depthSort(candidates);
3838
3968
  const draggable = manager.dragOperation.source;
@@ -3885,22 +4015,18 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
3885
4015
  }
3886
4016
  const cleanupEffect = effects(() => {
3887
4017
  const handleMove = (event) => {
3888
- const position = {
4018
+ const target = event.originalTarget || event.target;
4019
+ const position = new GlobalPosition(target, {
3889
4020
  x: event.clientX,
3890
4021
  y: event.clientY
3891
- };
3892
- const target = event.originalTarget || event.target;
3893
- const ownerDocument = target == null ? void 0 : target.ownerDocument;
4022
+ });
3894
4023
  const elements = document.elementsFromPoint(
3895
- event.clientX,
3896
- event.clientY
4024
+ position.global.x,
4025
+ position.global.y
3897
4026
  );
3898
4027
  const overEl = elements.some((el) => el.id === id);
3899
4028
  if (overEl) {
3900
- onChange(
3901
- findDeepestCandidate(position, manager, ownerDocument),
3902
- manager
3903
- );
4029
+ onChange(findDeepestCandidate(position, manager), manager);
3904
4030
  }
3905
4031
  };
3906
4032
  const handleMoveThrottled = throttle(handleMove, 50);
@@ -4231,6 +4357,11 @@ var reduceUi = (ui, action) => {
4231
4357
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4232
4358
  });
4233
4359
  }
4360
+ if (action.type === "remove") {
4361
+ return __spreadProps(__spreadValues({}, ui), {
4362
+ itemSelector: null
4363
+ });
4364
+ }
4234
4365
  return ui;
4235
4366
  };
4236
4367
 
@@ -4490,6 +4621,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
4490
4621
  }
4491
4622
  }
4492
4623
  handlePointerUp(event) {
4624
+ if (!this.source) {
4625
+ return;
4626
+ }
4493
4627
  event.preventDefault();
4494
4628
  event.stopPropagation();
4495
4629
  const { status } = this.manager.dragOperation;
@@ -4590,13 +4724,13 @@ function patchWindow(window2) {
4590
4724
 
4591
4725
  // components/DragDropContext/index.tsx
4592
4726
  import { createStore as createStore3 } from "zustand";
4593
- import { jsx as jsx22 } from "react/jsx-runtime";
4727
+ import { jsx as jsx23 } from "react/jsx-runtime";
4594
4728
  var DEBUG3 = false;
4595
- var dragListenerContext = createContext3({
4729
+ var dragListenerContext = createContext4({
4596
4730
  dragListeners: {}
4597
4731
  });
4598
4732
  function useDragListener(type, fn, deps = []) {
4599
- const { setDragListeners } = useContext5(dragListenerContext);
4733
+ const { setDragListeners } = useContext7(dragListenerContext);
4600
4734
  useEffect15(() => {
4601
4735
  if (setDragListeners) {
4602
4736
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
@@ -4607,7 +4741,7 @@ function useDragListener(type, fn, deps = []) {
4607
4741
  }
4608
4742
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4609
4743
  var useTempDisableFallback = (timeout3) => {
4610
- const lastFallbackDisable = useRef5(null);
4744
+ const lastFallbackDisable = useRef3(null);
4611
4745
  return useCallback11((manager) => {
4612
4746
  collisionStore.setState({ fallbackEnabled: false });
4613
4747
  const fallbackId = generateId();
@@ -4627,7 +4761,7 @@ var DragDropContextClient = ({
4627
4761
  const { state, config, dispatch, resolveData } = useAppContext();
4628
4762
  const id = useId();
4629
4763
  const { data } = state;
4630
- const debouncedParamsRef = useRef5(null);
4764
+ const debouncedParamsRef = useRef3(null);
4631
4765
  const tempDisableFallback = useTempDisableFallback(100);
4632
4766
  const [zoneStore] = useState17(
4633
4767
  () => createStore3(() => ({
@@ -4766,38 +4900,44 @@ var DragDropContextClient = ({
4766
4900
  ]);
4767
4901
  const [dragListeners, setDragListeners] = useState17({});
4768
4902
  const [pathData, setPathData] = useState17();
4769
- const dragMode = useRef5(null);
4903
+ const dragMode = useRef3(null);
4770
4904
  const registerPath = useCallback11(
4771
- (selector) => {
4772
- const item = getItem(selector, data);
4773
- if (!item) {
4774
- return;
4775
- }
4905
+ (id2, selector, label) => {
4776
4906
  const [area] = getZoneId(selector.zone);
4777
4907
  setPathData((latestPathData = {}) => {
4778
4908
  const parentPathData = latestPathData[area] || { path: [] };
4779
4909
  return __spreadProps(__spreadValues({}, latestPathData), {
4780
- [item.props.id]: {
4910
+ [id2]: {
4781
4911
  path: [
4782
4912
  ...parentPathData.path,
4783
4913
  ...selector.zone ? [selector.zone] : []
4784
4914
  ],
4785
- label: item.type
4915
+ label
4786
4916
  }
4787
4917
  });
4788
4918
  });
4789
4919
  },
4790
4920
  [data, setPathData]
4791
4921
  );
4792
- const initialSelector = useRef5(void 0);
4793
- return /* @__PURE__ */ jsx22("div", { id, children: /* @__PURE__ */ jsx22(
4922
+ const unregisterPath = useCallback11(
4923
+ (id2) => {
4924
+ setPathData((latestPathData = {}) => {
4925
+ const newPathData = __spreadValues({}, latestPathData);
4926
+ delete newPathData[id2];
4927
+ return newPathData;
4928
+ });
4929
+ },
4930
+ [data, setPathData]
4931
+ );
4932
+ const initialSelector = useRef3(void 0);
4933
+ return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
4794
4934
  dragListenerContext.Provider,
4795
4935
  {
4796
4936
  value: {
4797
4937
  dragListeners,
4798
4938
  setDragListeners
4799
4939
  },
4800
- children: /* @__PURE__ */ jsx22(
4940
+ children: /* @__PURE__ */ jsx23(
4801
4941
  DragDropProvider2,
4802
4942
  {
4803
4943
  plugins,
@@ -4975,7 +5115,7 @@ var DragDropContextClient = ({
4975
5115
  initialSelector.current = void 0;
4976
5116
  zoneStore.setState({ draggedItem: event.operation.source });
4977
5117
  },
4978
- children: /* @__PURE__ */ jsx22(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx22(
5118
+ children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
4979
5119
  DropZoneProvider,
4980
5120
  {
4981
5121
  value: {
@@ -4985,6 +5125,7 @@ var DragDropContextClient = ({
4985
5125
  areaId: "root",
4986
5126
  depth: 0,
4987
5127
  registerPath,
5128
+ unregisterPath,
4988
5129
  pathData,
4989
5130
  path: []
4990
5131
  },
@@ -5004,11 +5145,11 @@ var DragDropContext = ({
5004
5145
  if (status === "LOADING") {
5005
5146
  return children;
5006
5147
  }
5007
- return /* @__PURE__ */ jsx22(DragDropContextClient, { disableAutoScroll, children });
5148
+ return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
5008
5149
  };
5009
5150
 
5010
5151
  // components/Drawer/index.tsx
5011
- import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
5152
+ import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
5012
5153
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
5013
5154
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
5014
5155
  var DrawerItemInner = ({
@@ -5018,11 +5159,11 @@ var DrawerItemInner = ({
5018
5159
  dragRef,
5019
5160
  isDragDisabled
5020
5161
  }) => {
5021
- const CustomInner = useMemo8(
5022
- () => children || (({ children: children2 }) => /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("default"), children: children2 })),
5162
+ const CustomInner = useMemo9(
5163
+ () => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
5023
5164
  [children]
5024
5165
  );
5025
- return /* @__PURE__ */ jsx23(
5166
+ return /* @__PURE__ */ jsx24(
5026
5167
  "div",
5027
5168
  {
5028
5169
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -5030,9 +5171,9 @@ var DrawerItemInner = ({
5030
5171
  onMouseDown: (e) => e.preventDefault(),
5031
5172
  "data-testid": dragRef ? `drawer-item:${name}` : "",
5032
5173
  "data-puck-drawer-item": true,
5033
- children: /* @__PURE__ */ jsx23(CustomInner, { name, children: /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
5034
- /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5035
- /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx23(DragIcon, {}) })
5174
+ children: /* @__PURE__ */ jsx24(CustomInner, { name, children: /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
5175
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5176
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx24(DragIcon, {}) })
5036
5177
  ] }) }) })
5037
5178
  }
5038
5179
  );
@@ -5050,8 +5191,8 @@ var DrawerItemDraggable = ({
5050
5191
  disabled: isDragDisabled
5051
5192
  });
5052
5193
  return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
5053
- /* @__PURE__ */ jsx23("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx23(DrawerItemInner, { name, label, children }) }),
5054
- /* @__PURE__ */ jsx23("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx23(
5194
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx24(DrawerItemInner, { name, label, children }) }),
5195
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx24(
5055
5196
  DrawerItemInner,
5056
5197
  {
5057
5198
  name,
@@ -5085,7 +5226,7 @@ var DrawerItem = ({
5085
5226
  },
5086
5227
  [resolvedId]
5087
5228
  );
5088
- return /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
5229
+ return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
5089
5230
  DrawerItemDraggable,
5090
5231
  {
5091
5232
  name,
@@ -5111,14 +5252,14 @@ var Drawer = ({
5111
5252
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5112
5253
  );
5113
5254
  }
5114
- const [id] = useState18(generateId());
5255
+ const id = useId2();
5115
5256
  const { ref } = useDroppableSafe({
5116
5257
  id,
5117
5258
  type: "void",
5118
5259
  collisionPriority: 0
5119
5260
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
5120
5261
  });
5121
- return /* @__PURE__ */ jsx23(
5262
+ return /* @__PURE__ */ jsx24(
5122
5263
  "div",
5123
5264
  {
5124
5265
  className: getClassName18(),
@@ -5134,9 +5275,9 @@ Drawer.Item = DrawerItem;
5134
5275
  // components/Puck/index.tsx
5135
5276
  init_react_import();
5136
5277
  import {
5137
- useCallback as useCallback17,
5138
- useEffect as useEffect23,
5139
- useMemo as useMemo17,
5278
+ useCallback as useCallback18,
5279
+ useEffect as useEffect24,
5280
+ useMemo as useMemo19,
5140
5281
  useReducer,
5141
5282
  useState as useState26
5142
5283
  } from "react";
@@ -5150,7 +5291,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
5150
5291
 
5151
5292
  // lib/use-breadcrumbs.ts
5152
5293
  init_react_import();
5153
- import { useContext as useContext6, useMemo as useMemo9 } from "react";
5294
+ import { useContext as useContext8, useMemo as useMemo10 } from "react";
5154
5295
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
5155
5296
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
5156
5297
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -5200,8 +5341,8 @@ var useBreadcrumbs = (renderCount) => {
5200
5341
  state: { data },
5201
5342
  selectedItem
5202
5343
  } = useAppContext();
5203
- const dzContext = useContext6(dropZoneContext);
5204
- return useMemo9(() => {
5344
+ const dzContext = useContext8(dropZoneContext);
5345
+ return useMemo10(() => {
5205
5346
  const breadcrumbs = convertPathDataToBreadcrumbs(
5206
5347
  selectedItem,
5207
5348
  dzContext == null ? void 0 : dzContext.pathData,
@@ -5215,7 +5356,7 @@ var useBreadcrumbs = (renderCount) => {
5215
5356
  };
5216
5357
 
5217
5358
  // components/SidebarSection/index.tsx
5218
- import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
5359
+ import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
5219
5360
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5220
5361
  var SidebarSection = ({
5221
5362
  children,
@@ -5234,9 +5375,9 @@ var SidebarSection = ({
5234
5375
  className: getClassName19({ noBorderTop, noPadding }),
5235
5376
  style: { background },
5236
5377
  children: [
5237
- /* @__PURE__ */ jsx24("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5378
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5238
5379
  showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
5239
- /* @__PURE__ */ jsx24(
5380
+ /* @__PURE__ */ jsx25(
5240
5381
  "button",
5241
5382
  {
5242
5383
  type: "button",
@@ -5245,12 +5386,12 @@ var SidebarSection = ({
5245
5386
  children: breadcrumb.label
5246
5387
  }
5247
5388
  ),
5248
- /* @__PURE__ */ jsx24(ChevronRight, { size: 16 })
5389
+ /* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
5249
5390
  ] }, i)) : null,
5250
- /* @__PURE__ */ jsx24("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx24(Heading, { rank: "2", size: "xs", children: title }) })
5391
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
5251
5392
  ] }) }),
5252
- /* @__PURE__ */ jsx24("div", { className: getClassName19("content"), children }),
5253
- isLoading && /* @__PURE__ */ jsx24("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx24(Loader, { size: 32 }) })
5393
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
5394
+ isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
5254
5395
  ]
5255
5396
  }
5256
5397
  );
@@ -5281,7 +5422,7 @@ init_react_import();
5281
5422
  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
5423
 
5283
5424
  // components/MenuBar/index.tsx
5284
- import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
5425
+ import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
5285
5426
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5286
5427
  function MenuBar({
5287
5428
  appState,
@@ -5295,7 +5436,7 @@ function MenuBar({
5295
5436
  history: { back, forward, historyStore }
5296
5437
  } = useAppContext();
5297
5438
  const { hasFuture = false, hasPast = false } = historyStore || {};
5298
- return /* @__PURE__ */ jsx25(
5439
+ return /* @__PURE__ */ jsx26(
5299
5440
  "div",
5300
5441
  {
5301
5442
  className: getClassName20({ menuOpen }),
@@ -5311,10 +5452,10 @@ function MenuBar({
5311
5452
  },
5312
5453
  children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
5313
5454
  /* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
5314
- /* @__PURE__ */ jsx25(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx25(Undo2, { size: 21 }) }),
5315
- /* @__PURE__ */ jsx25(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx25(Redo2, { size: 21 }) })
5455
+ /* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
5456
+ /* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
5316
5457
  ] }),
5317
- /* @__PURE__ */ jsx25(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5458
+ /* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5318
5459
  state: appState,
5319
5460
  dispatch
5320
5461
  }) })
@@ -5332,36 +5473,61 @@ init_react_import();
5332
5473
 
5333
5474
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5334
5475
  init_react_import();
5335
- var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
5476
+ 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
5477
 
5337
5478
  // components/Puck/components/Fields/index.tsx
5338
- import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo10, useState as useState19 } from "react";
5479
+ import { useMemo as useMemo12 } from "react";
5480
+
5481
+ // lib/use-resolved-fields.ts
5482
+ init_react_import();
5483
+ import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
5339
5484
 
5340
5485
  // lib/use-parent.ts
5341
5486
  init_react_import();
5342
- import { useContext as useContext7 } from "react";
5343
- var useParent = (itemSelector) => {
5487
+ import { useCallback as useCallback12, useContext as useContext9 } from "react";
5488
+ var getParent = (itemSelector, pathData, data) => {
5344
5489
  var _a;
5345
- const { selectedItem, state } = useAppContext();
5346
- const { pathData } = useContext7(dropZoneContext) || {};
5347
- const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5348
- const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5490
+ if (!itemSelector) return null;
5491
+ const item = getItem(itemSelector, data);
5492
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
5349
5493
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
5350
- const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
5494
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
5351
5495
  return parent || null;
5352
5496
  };
5497
+ var useGetParent = () => {
5498
+ const { state } = useAppContext();
5499
+ const { pathData } = useContext9(dropZoneContext) || {};
5500
+ return useCallback12(
5501
+ () => getParent(state.ui.itemSelector, pathData, state.data),
5502
+ [state.ui.itemSelector, pathData, state.data]
5503
+ );
5504
+ };
5505
+ var useParent = () => {
5506
+ return useGetParent()();
5507
+ };
5353
5508
 
5354
- // components/Puck/components/Fields/index.tsx
5355
- import { Fragment as Fragment8, jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
5356
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5509
+ // lib/use-on-value-change.ts
5510
+ init_react_import();
5511
+ import { useRef as useRef4, useEffect as useEffect16 } from "react";
5512
+ function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5513
+ const tracked = useRef4(value);
5514
+ useEffect16(() => {
5515
+ const oldValue = tracked.current;
5516
+ if (!compare(value, oldValue)) {
5517
+ tracked.current = value;
5518
+ onChange(value, oldValue);
5519
+ }
5520
+ }, [onChange, compare, value, ...deps]);
5521
+ }
5522
+
5523
+ // lib/selector-is.ts
5524
+ init_react_import();
5525
+ 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);
5526
+
5527
+ // lib/use-resolved-fields.ts
5357
5528
  var defaultPageFields = {
5358
5529
  title: { type: "text" }
5359
5530
  };
5360
- var DefaultFields = ({
5361
- children
5362
- }) => {
5363
- return /* @__PURE__ */ jsx26(Fragment8, { children });
5364
- };
5365
5531
  var useResolvedFields = () => {
5366
5532
  var _a, _b;
5367
5533
  const { selectedItem, state, config } = useAppContext();
@@ -5369,7 +5535,7 @@ var useResolvedFields = () => {
5369
5535
  const { data } = state;
5370
5536
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5371
5537
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5372
- const defaultFields = useMemo10(
5538
+ const defaultFields = useMemo11(
5373
5539
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5374
5540
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5375
5541
  );
@@ -5377,12 +5543,13 @@ var useResolvedFields = () => {
5377
5543
  const [lastSelectedData, setLastSelectedData] = useState19({});
5378
5544
  const [resolvedFields, setResolvedFields] = useState19(defaultFields);
5379
5545
  const [fieldsLoading, setFieldsLoading] = useState19(false);
5546
+ const lastFields = useRef5(defaultFields);
5380
5547
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5381
5548
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5382
5549
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5383
5550
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5384
5551
  const hasResolver = hasComponentResolver || hasRootResolver;
5385
- const resolveFields = useCallback12(
5552
+ const resolveFields = useCallback13(
5386
5553
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5387
5554
  var _a2;
5388
5555
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5394,7 +5561,7 @@ var useResolvedFields = () => {
5394
5561
  {
5395
5562
  changed,
5396
5563
  fields,
5397
- lastFields: resolvedFields,
5564
+ lastFields: lastFields.current,
5398
5565
  lastData,
5399
5566
  appState: state,
5400
5567
  parent
@@ -5405,7 +5572,7 @@ var useResolvedFields = () => {
5405
5572
  return yield config.root.resolveFields(componentData, {
5406
5573
  changed,
5407
5574
  fields,
5408
- lastFields: resolvedFields,
5575
+ lastFields: lastFields.current,
5409
5576
  lastData,
5410
5577
  appState: state,
5411
5578
  parent
@@ -5414,26 +5581,56 @@ var useResolvedFields = () => {
5414
5581
  return defaultResolveFields(componentData, {
5415
5582
  changed,
5416
5583
  fields,
5417
- lastFields: resolvedFields,
5584
+ lastFields: lastFields.current,
5418
5585
  lastData
5419
5586
  });
5420
5587
  }),
5421
- [data, config, componentData, selectedItem, resolvedFields, state]
5588
+ [data, config, componentData, selectedItem, state, parent]
5422
5589
  );
5423
- useEffect16(() => {
5424
- if (hasResolver) {
5425
- setFieldsLoading(true);
5426
- resolveFields(defaultFields).then((fields) => {
5427
- setResolvedFields(fields || {});
5428
- setFieldsLoading(false);
5429
- });
5430
- } else {
5431
- setResolvedFields(defaultFields);
5590
+ const triggerResolver = useCallback13(() => {
5591
+ var _a2, _b2;
5592
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5593
+ if (hasResolver) {
5594
+ setFieldsLoading(true);
5595
+ resolveFields(defaultFields).then((fields) => {
5596
+ setResolvedFields(fields || {});
5597
+ lastFields.current = fields;
5598
+ setFieldsLoading(false);
5599
+ });
5600
+ return;
5601
+ }
5432
5602
  }
5433
- }, [data, defaultFields, selectedItem, hasResolver]);
5603
+ setResolvedFields(defaultFields);
5604
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5605
+ useOnValueChange(
5606
+ state.ui.itemSelector,
5607
+ () => {
5608
+ lastFields.current = defaultFields;
5609
+ },
5610
+ selectorIs
5611
+ );
5612
+ useOnValueChange(
5613
+ { data, parent, itemSelector: state.ui.itemSelector },
5614
+ () => {
5615
+ triggerResolver();
5616
+ },
5617
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
5618
+ );
5619
+ useEffect17(() => {
5620
+ triggerResolver();
5621
+ }, []);
5434
5622
  return [resolvedFields, fieldsLoading];
5435
5623
  };
5436
- var Fields = () => {
5624
+
5625
+ // components/Puck/components/Fields/index.tsx
5626
+ import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5627
+ var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5628
+ var DefaultFields = ({
5629
+ children
5630
+ }) => {
5631
+ return /* @__PURE__ */ jsx27(Fragment8, { children });
5632
+ };
5633
+ var Fields = ({ wrapFields = true }) => {
5437
5634
  var _a, _b;
5438
5635
  const {
5439
5636
  selectedItem,
@@ -5451,16 +5648,16 @@ var Fields = () => {
5451
5648
  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
5649
  const isLoading = fieldsResolving || componentResolving;
5453
5650
  const rootProps = data.root.props || data.root;
5454
- const Wrapper = useMemo10(() => overrides.fields || DefaultFields, [overrides]);
5651
+ const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
5455
5652
  return /* @__PURE__ */ jsxs14(
5456
5653
  "form",
5457
5654
  {
5458
- className: getClassName21(),
5655
+ className: getClassName21({ wrapFields }),
5459
5656
  onSubmit: (e) => {
5460
5657
  e.preventDefault();
5461
5658
  },
5462
5659
  children: [
5463
- /* @__PURE__ */ jsx26(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5660
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5464
5661
  const field = fields[fieldName];
5465
5662
  if (!(field == null ? void 0 : field.type)) return null;
5466
5663
  const onChange = (value, updatedUi) => {
@@ -5531,7 +5728,7 @@ var Fields = () => {
5531
5728
  item: selectedItem
5532
5729
  });
5533
5730
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5534
- return /* @__PURE__ */ jsx26(
5731
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5535
5732
  AutoFieldPrivate,
5536
5733
  {
5537
5734
  field,
@@ -5540,16 +5737,15 @@ var Fields = () => {
5540
5737
  readOnly: !edit || readOnly[fieldName],
5541
5738
  value: selectedItem.props[fieldName],
5542
5739
  onChange
5543
- },
5544
- id
5545
- );
5740
+ }
5741
+ ) }, id);
5546
5742
  } else {
5547
5743
  const readOnly = data.root.readOnly || {};
5548
5744
  const { edit } = getPermissions({
5549
5745
  root: true
5550
5746
  });
5551
5747
  const id = `root_${field.type}_${fieldName}`;
5552
- return /* @__PURE__ */ jsx26(
5748
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5553
5749
  AutoFieldPrivate,
5554
5750
  {
5555
5751
  field,
@@ -5558,12 +5754,11 @@ var Fields = () => {
5558
5754
  readOnly: !edit || readOnly[fieldName],
5559
5755
  value: rootProps[fieldName],
5560
5756
  onChange
5561
- },
5562
- id
5563
- );
5757
+ }
5758
+ ) }, id);
5564
5759
  }
5565
5760
  }) }),
5566
- isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx26(Loader, { size: 16 }) }) })
5761
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
5567
5762
  ]
5568
5763
  }
5569
5764
  );
@@ -5574,7 +5769,7 @@ init_react_import();
5574
5769
 
5575
5770
  // lib/use-component-list.tsx
5576
5771
  init_react_import();
5577
- import { useEffect as useEffect17, useState as useState20 } from "react";
5772
+ import { useEffect as useEffect18, useState as useState20 } from "react";
5578
5773
 
5579
5774
  // components/ComponentList/index.tsx
5580
5775
  init_react_import();
@@ -5584,7 +5779,7 @@ init_react_import();
5584
5779
  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
5780
 
5586
5781
  // components/ComponentList/index.tsx
5587
- import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
5782
+ import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
5588
5783
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
5589
5784
  var ComponentListItem = ({
5590
5785
  name,
@@ -5594,7 +5789,7 @@ var ComponentListItem = ({
5594
5789
  const canInsert = getPermissions({
5595
5790
  type: name
5596
5791
  }).insert;
5597
- return /* @__PURE__ */ jsx27(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5792
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5598
5793
  };
5599
5794
  var ComponentList = ({
5600
5795
  children,
@@ -5618,14 +5813,14 @@ var ComponentList = ({
5618
5813
  }),
5619
5814
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
5620
5815
  children: [
5621
- /* @__PURE__ */ jsx27("div", { children: title }),
5622
- /* @__PURE__ */ jsx27("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx27(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx27(ChevronDown, { size: 12 }) })
5816
+ /* @__PURE__ */ jsx28("div", { children: title }),
5817
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
5623
5818
  ]
5624
5819
  }
5625
5820
  ),
5626
- /* @__PURE__ */ jsx27("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx27(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5821
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5627
5822
  var _a;
5628
- return /* @__PURE__ */ jsx27(
5823
+ return /* @__PURE__ */ jsx28(
5629
5824
  ComponentListItem,
5630
5825
  {
5631
5826
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -5639,10 +5834,10 @@ var ComponentList = ({
5639
5834
  ComponentList.Item = ComponentListItem;
5640
5835
 
5641
5836
  // lib/use-component-list.tsx
5642
- import { jsx as jsx28 } from "react/jsx-runtime";
5837
+ import { jsx as jsx29 } from "react/jsx-runtime";
5643
5838
  var useComponentList = (config, ui) => {
5644
5839
  const [componentList, setComponentList] = useState20();
5645
- useEffect17(() => {
5840
+ useEffect18(() => {
5646
5841
  var _a, _b, _c;
5647
5842
  if (Object.keys(ui.componentList).length > 0) {
5648
5843
  const matchedComponents = [];
@@ -5652,7 +5847,7 @@ var useComponentList = (config, ui) => {
5652
5847
  if (category.visible === false || !category.components) {
5653
5848
  return null;
5654
5849
  }
5655
- return /* @__PURE__ */ jsx28(
5850
+ return /* @__PURE__ */ jsx29(
5656
5851
  ComponentList,
5657
5852
  {
5658
5853
  id: categoryKey,
@@ -5661,7 +5856,7 @@ var useComponentList = (config, ui) => {
5661
5856
  var _a2;
5662
5857
  matchedComponents.push(componentName);
5663
5858
  const componentConf = config.components[componentName] || {};
5664
- return /* @__PURE__ */ jsx28(
5859
+ return /* @__PURE__ */ jsx29(
5665
5860
  ComponentList.Item,
5666
5861
  {
5667
5862
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -5681,7 +5876,7 @@ var useComponentList = (config, ui) => {
5681
5876
  );
5682
5877
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
5683
5878
  _componentList.push(
5684
- /* @__PURE__ */ jsx28(
5879
+ /* @__PURE__ */ jsx29(
5685
5880
  ComponentList,
5686
5881
  {
5687
5882
  id: "other",
@@ -5689,7 +5884,7 @@ var useComponentList = (config, ui) => {
5689
5884
  children: remainingComponents.map((componentName, i) => {
5690
5885
  var _a2;
5691
5886
  const componentConf = config.components[componentName] || {};
5692
- return /* @__PURE__ */ jsx28(
5887
+ return /* @__PURE__ */ jsx29(
5693
5888
  ComponentList.Item,
5694
5889
  {
5695
5890
  name: componentName,
@@ -5711,30 +5906,30 @@ var useComponentList = (config, ui) => {
5711
5906
  };
5712
5907
 
5713
5908
  // components/Puck/components/Components/index.tsx
5714
- import { useMemo as useMemo11 } from "react";
5715
- import { jsx as jsx29 } from "react/jsx-runtime";
5909
+ import { useMemo as useMemo13 } from "react";
5910
+ import { jsx as jsx30 } from "react/jsx-runtime";
5716
5911
  var Components = () => {
5717
5912
  const { config, state, overrides } = useAppContext();
5718
5913
  const componentList = useComponentList(config, state.ui);
5719
- const Wrapper = useMemo11(() => overrides.components || "div", [overrides]);
5720
- return /* @__PURE__ */ jsx29(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx29(ComponentList, { id: "all" }) });
5914
+ const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
5915
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
5721
5916
  };
5722
5917
 
5723
5918
  // components/Puck/components/Preview/index.tsx
5724
5919
  init_react_import();
5725
- import { useCallback as useCallback13, useEffect as useEffect19, useRef as useRef7, useMemo as useMemo12 } from "react";
5920
+ import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
5726
5921
 
5727
5922
  // components/AutoFrame/index.tsx
5728
5923
  init_react_import();
5729
5924
  import {
5730
- createContext as createContext4,
5731
- useContext as useContext8,
5732
- useEffect as useEffect18,
5925
+ createContext as createContext5,
5926
+ useContext as useContext10,
5927
+ useEffect as useEffect19,
5733
5928
  useState as useState21
5734
5929
  } from "react";
5735
5930
  import hash from "object-hash";
5736
5931
  import { createPortal as createPortal3 } from "react-dom";
5737
- import { Fragment as Fragment9, jsx as jsx30 } from "react/jsx-runtime";
5932
+ import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
5738
5933
  var styleSelector = 'style, link[rel="stylesheet"]';
5739
5934
  var collectStyles = (doc) => {
5740
5935
  const collected = [];
@@ -5777,7 +5972,7 @@ var CopyHostStyles = ({
5777
5972
  onStylesLoaded = () => null
5778
5973
  }) => {
5779
5974
  const { document: doc, window: win } = useFrame();
5780
- useEffect18(() => {
5975
+ useEffect19(() => {
5781
5976
  if (!win || !doc) {
5782
5977
  return () => {
5783
5978
  };
@@ -5934,10 +6129,10 @@ var CopyHostStyles = ({
5934
6129
  observer.disconnect();
5935
6130
  };
5936
6131
  }, []);
5937
- return /* @__PURE__ */ jsx30(Fragment9, { children });
6132
+ return /* @__PURE__ */ jsx31(Fragment9, { children });
5938
6133
  };
5939
- var autoFrameContext = createContext4({});
5940
- var useFrame = () => useContext8(autoFrameContext);
6134
+ var autoFrameContext = createContext5({});
6135
+ var useFrame = () => useContext10(autoFrameContext);
5941
6136
  function AutoFrame(_a) {
5942
6137
  var _b = _a, {
5943
6138
  children,
@@ -5957,7 +6152,7 @@ function AutoFrame(_a) {
5957
6152
  const [loaded, setLoaded] = useState21(false);
5958
6153
  const [ctx, setCtx] = useState21({});
5959
6154
  const [mountTarget, setMountTarget] = useState21();
5960
- useEffect18(() => {
6155
+ useEffect19(() => {
5961
6156
  var _a2;
5962
6157
  if (frameRef.current) {
5963
6158
  setCtx({
@@ -5969,7 +6164,7 @@ function AutoFrame(_a) {
5969
6164
  );
5970
6165
  }
5971
6166
  }, [frameRef, loaded]);
5972
- return /* @__PURE__ */ jsx30(
6167
+ return /* @__PURE__ */ jsx31(
5973
6168
  "iframe",
5974
6169
  __spreadProps(__spreadValues({}, props), {
5975
6170
  className,
@@ -5979,7 +6174,7 @@ function AutoFrame(_a) {
5979
6174
  onLoad: () => {
5980
6175
  setLoaded(true);
5981
6176
  },
5982
- children: /* @__PURE__ */ jsx30(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx30(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
6177
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
5983
6178
  })
5984
6179
  );
5985
6180
  }
@@ -5992,7 +6187,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
5992
6187
 
5993
6188
  // components/Render/index.tsx
5994
6189
  init_react_import();
5995
- import { jsx as jsx31 } from "react/jsx-runtime";
6190
+ import { jsx as jsx32 } from "react/jsx-runtime";
5996
6191
  function Render({
5997
6192
  config,
5998
6193
  data
@@ -6005,7 +6200,7 @@ function Render({
6005
6200
  const rootProps = defaultedData.root.props || defaultedData.root;
6006
6201
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
6007
6202
  if ((_a = config.root) == null ? void 0 : _a.render) {
6008
- return /* @__PURE__ */ jsx31(
6203
+ return /* @__PURE__ */ jsx32(
6009
6204
  DropZoneProvider,
6010
6205
  {
6011
6206
  value: {
@@ -6015,7 +6210,7 @@ function Render({
6015
6210
  depth: 0,
6016
6211
  path: []
6017
6212
  },
6018
- children: /* @__PURE__ */ jsx31(
6213
+ children: /* @__PURE__ */ jsx32(
6019
6214
  config.root.render,
6020
6215
  __spreadProps(__spreadValues({}, rootProps), {
6021
6216
  puck: {
@@ -6025,13 +6220,13 @@ function Render({
6025
6220
  title,
6026
6221
  editMode: false,
6027
6222
  id: "puck-root",
6028
- children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
6223
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6029
6224
  })
6030
6225
  )
6031
6226
  }
6032
6227
  );
6033
6228
  }
6034
- return /* @__PURE__ */ jsx31(
6229
+ return /* @__PURE__ */ jsx32(
6035
6230
  DropZoneProvider,
6036
6231
  {
6037
6232
  value: {
@@ -6041,17 +6236,17 @@ function Render({
6041
6236
  depth: 0,
6042
6237
  path: []
6043
6238
  },
6044
- children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
6239
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6045
6240
  }
6046
6241
  );
6047
6242
  }
6048
6243
 
6049
6244
  // components/Puck/components/Preview/index.tsx
6050
- import { Fragment as Fragment10, jsx as jsx32 } from "react/jsx-runtime";
6245
+ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
6051
6246
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6052
6247
  var useBubbleIframeEvents = (ref) => {
6053
6248
  const { status } = useAppContext();
6054
- useEffect19(() => {
6249
+ useEffect20(() => {
6055
6250
  var _a;
6056
6251
  if (ref.current && status === "READY") {
6057
6252
  const iframe = ref.current;
@@ -6090,20 +6285,20 @@ var useBubbleIframeEvents = (ref) => {
6090
6285
  };
6091
6286
  var Preview2 = ({ id = "puck-preview" }) => {
6092
6287
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
6093
- const Page = useCallback13(
6288
+ const Page = useCallback14(
6094
6289
  (pageProps) => {
6095
6290
  var _a, _b;
6096
6291
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
6097
6292
  id: "puck-root"
6098
- }, pageProps)) : /* @__PURE__ */ jsx32(Fragment10, { children: pageProps.children });
6293
+ }, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
6099
6294
  },
6100
6295
  [config.root]
6101
6296
  );
6102
- const Frame = useMemo12(() => overrides.iframe, [overrides]);
6297
+ const Frame = useMemo14(() => overrides.iframe, [overrides]);
6103
6298
  const rootProps = state.data.root.props || state.data.root;
6104
6299
  const ref = useRef7(null);
6105
6300
  useBubbleIframeEvents(ref);
6106
- const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx32(
6301
+ const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
6107
6302
  Page,
6108
6303
  __spreadProps(__spreadValues({}, rootProps), {
6109
6304
  puck: {
@@ -6112,10 +6307,10 @@ var Preview2 = ({ id = "puck-preview" }) => {
6112
6307
  dragRef: null
6113
6308
  },
6114
6309
  editMode: true,
6115
- children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6310
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
6116
6311
  })
6117
- ) : /* @__PURE__ */ jsx32(Render, { data: state.data, config });
6118
- return /* @__PURE__ */ jsx32(
6312
+ ) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
6313
+ return /* @__PURE__ */ jsx33(
6119
6314
  "div",
6120
6315
  {
6121
6316
  className: getClassName23(),
@@ -6124,7 +6319,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
6124
6319
  onClick: () => {
6125
6320
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
6126
6321
  },
6127
- children: iframe.enabled ? /* @__PURE__ */ jsx32(
6322
+ children: iframe.enabled ? /* @__PURE__ */ jsx33(
6128
6323
  AutoFrame_default,
6129
6324
  {
6130
6325
  id: "preview-frame",
@@ -6134,14 +6329,14 @@ var Preview2 = ({ id = "puck-preview" }) => {
6134
6329
  setStatus("READY");
6135
6330
  },
6136
6331
  frameRef: ref,
6137
- children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6332
+ children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6138
6333
  if (Frame) {
6139
- return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
6334
+ return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
6140
6335
  }
6141
6336
  return inner;
6142
6337
  } })
6143
6338
  }
6144
- ) : /* @__PURE__ */ jsx32(
6339
+ ) : /* @__PURE__ */ jsx33(
6145
6340
  "div",
6146
6341
  {
6147
6342
  id: "preview-frame",
@@ -6198,7 +6393,7 @@ var scrollIntoView = (el) => {
6198
6393
  };
6199
6394
 
6200
6395
  // components/LayerTree/index.tsx
6201
- import { useContext as useContext9 } from "react";
6396
+ import { useContext as useContext11 } from "react";
6202
6397
 
6203
6398
  // lib/is-child-of-zone.ts
6204
6399
  init_react_import();
@@ -6231,7 +6426,7 @@ var onScrollEnd = (frame, cb) => {
6231
6426
  };
6232
6427
 
6233
6428
  // components/LayerTree/index.tsx
6234
- import { Fragment as Fragment11, jsx as jsx33, jsxs as jsxs16 } from "react/jsx-runtime";
6429
+ import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
6235
6430
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
6236
6431
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
6237
6432
  var LayerTree = ({
@@ -6244,15 +6439,15 @@ var LayerTree = ({
6244
6439
  label
6245
6440
  }) => {
6246
6441
  const zones = data.zones || {};
6247
- const ctx = useContext9(dropZoneContext);
6442
+ const ctx = useContext11(dropZoneContext);
6248
6443
  return /* @__PURE__ */ jsxs16(Fragment11, { children: [
6249
6444
  label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
6250
- /* @__PURE__ */ jsx33("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
6445
+ /* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
6251
6446
  " ",
6252
6447
  label
6253
6448
  ] }),
6254
6449
  /* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
6255
- zoneContent.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName24("helper"), children: "No items" }),
6450
+ zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
6256
6451
  zoneContent.map((item, i) => {
6257
6452
  var _a;
6258
6453
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -6275,7 +6470,7 @@ var LayerTree = ({
6275
6470
  childIsSelected
6276
6471
  }),
6277
6472
  children: [
6278
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6473
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6279
6474
  "button",
6280
6475
  {
6281
6476
  type: "button",
@@ -6314,22 +6509,22 @@ var LayerTree = ({
6314
6509
  setHoveringComponent(null);
6315
6510
  },
6316
6511
  children: [
6317
- containsZone && /* @__PURE__ */ jsx33(
6512
+ containsZone && /* @__PURE__ */ jsx34(
6318
6513
  "div",
6319
6514
  {
6320
6515
  className: getClassNameLayer("chevron"),
6321
6516
  title: isSelected ? "Collapse" : "Expand",
6322
- children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
6517
+ children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
6323
6518
  }
6324
6519
  ),
6325
6520
  /* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
6326
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
6327
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label2 })
6521
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
6522
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
6328
6523
  ] })
6329
6524
  ]
6330
6525
  }
6331
6526
  ) }),
6332
- containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(
6527
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
6333
6528
  LayerTree,
6334
6529
  {
6335
6530
  config,
@@ -6351,13 +6546,13 @@ var LayerTree = ({
6351
6546
  };
6352
6547
 
6353
6548
  // components/Puck/components/Outline/index.tsx
6354
- import { useCallback as useCallback14, useMemo as useMemo13 } from "react";
6355
- import { Fragment as Fragment12, jsx as jsx34, jsxs as jsxs17 } from "react/jsx-runtime";
6549
+ import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
6550
+ import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
6356
6551
  var Outline = () => {
6357
6552
  const { dispatch, state, overrides, config } = useAppContext();
6358
6553
  const { data, ui } = state;
6359
6554
  const { itemSelector } = ui;
6360
- const setItemSelector = useCallback14(
6555
+ const setItemSelector = useCallback15(
6361
6556
  (newItemSelector) => {
6362
6557
  dispatch({
6363
6558
  type: "setUi",
@@ -6366,9 +6561,9 @@ var Outline = () => {
6366
6561
  },
6367
6562
  []
6368
6563
  );
6369
- const Wrapper = useMemo13(() => overrides.outline || "div", [overrides]);
6370
- return /* @__PURE__ */ jsx34(Wrapper, { children: /* @__PURE__ */ jsx34(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6371
- (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx34(
6564
+ const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
6565
+ return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6566
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
6372
6567
  LayerTree,
6373
6568
  {
6374
6569
  config,
@@ -6381,7 +6576,7 @@ var Outline = () => {
6381
6576
  ),
6382
6577
  Object.entries(findZonesForArea(data, "root")).map(
6383
6578
  ([zoneKey, zone]) => {
6384
- return /* @__PURE__ */ jsx34(
6579
+ return /* @__PURE__ */ jsx35(
6385
6580
  LayerTree,
6386
6581
  {
6387
6582
  config,
@@ -6653,27 +6848,27 @@ var getBox = function getBox2(el) {
6653
6848
 
6654
6849
  // components/Puck/components/Canvas/index.tsx
6655
6850
  import {
6656
- useCallback as useCallback15,
6657
- useEffect as useEffect21,
6658
- useMemo as useMemo15,
6851
+ useCallback as useCallback16,
6852
+ useEffect as useEffect22,
6853
+ useMemo as useMemo17,
6659
6854
  useRef as useRef8,
6660
6855
  useState as useState24
6661
6856
  } from "react";
6662
6857
 
6663
6858
  // components/ViewportControls/index.tsx
6664
6859
  init_react_import();
6665
- import { useEffect as useEffect20, useMemo as useMemo14, useState as useState23 } from "react";
6860
+ import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
6666
6861
 
6667
6862
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6668
6863
  init_react_import();
6669
6864
  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
6865
 
6671
6866
  // components/ViewportControls/index.tsx
6672
- import { jsx as jsx35, jsxs as jsxs18 } from "react/jsx-runtime";
6867
+ import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
6673
6868
  var icons = {
6674
- Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
6675
- Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
6676
- Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
6869
+ Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
6870
+ Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
6871
+ Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
6677
6872
  };
6678
6873
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
6679
6874
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -6686,10 +6881,10 @@ var ViewportButton = ({
6686
6881
  }) => {
6687
6882
  const { state } = useAppContext();
6688
6883
  const [isActive, setIsActive] = useState23(false);
6689
- useEffect20(() => {
6884
+ useEffect21(() => {
6690
6885
  setIsActive(width === state.ui.viewports.current.width);
6691
6886
  }, [width, state.ui.viewports.current.width]);
6692
- return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
6887
+ return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
6693
6888
  IconButton,
6694
6889
  {
6695
6890
  title,
@@ -6698,7 +6893,7 @@ var ViewportButton = ({
6698
6893
  e.stopPropagation();
6699
6894
  onClick({ width, height });
6700
6895
  },
6701
- children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
6896
+ children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
6702
6897
  }
6703
6898
  ) });
6704
6899
  };
@@ -6722,7 +6917,7 @@ var ViewportControls = ({
6722
6917
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6723
6918
  (option) => option.value === autoZoom
6724
6919
  );
6725
- const zoomOptions = useMemo14(
6920
+ const zoomOptions = useMemo16(
6726
6921
  () => [
6727
6922
  ...defaultZoomOptions,
6728
6923
  ...defaultsContainAutoZoom ? [] : [
@@ -6735,7 +6930,7 @@ var ViewportControls = ({
6735
6930
  [autoZoom]
6736
6931
  );
6737
6932
  return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
6738
- viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
6933
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
6739
6934
  ViewportButton,
6740
6935
  {
6741
6936
  height: viewport.height,
@@ -6746,8 +6941,8 @@ var ViewportControls = ({
6746
6941
  },
6747
6942
  i
6748
6943
  )),
6749
- /* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
6750
- /* @__PURE__ */ jsx35(
6944
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6945
+ /* @__PURE__ */ jsx36(
6751
6946
  IconButton,
6752
6947
  {
6753
6948
  title: "Zoom viewport out",
@@ -6761,10 +6956,10 @@ var ViewportControls = ({
6761
6956
  )].value
6762
6957
  );
6763
6958
  },
6764
- children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
6959
+ children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
6765
6960
  }
6766
6961
  ),
6767
- /* @__PURE__ */ jsx35(
6962
+ /* @__PURE__ */ jsx36(
6768
6963
  IconButton,
6769
6964
  {
6770
6965
  title: "Zoom viewport in",
@@ -6778,11 +6973,11 @@ var ViewportControls = ({
6778
6973
  )].value
6779
6974
  );
6780
6975
  },
6781
- children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
6976
+ children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
6782
6977
  }
6783
6978
  ),
6784
- /* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
6785
- /* @__PURE__ */ jsx35(
6979
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6980
+ /* @__PURE__ */ jsx36(
6786
6981
  "select",
6787
6982
  {
6788
6983
  className: getClassName25("zoomSelect"),
@@ -6790,7 +6985,7 @@ var ViewportControls = ({
6790
6985
  onChange: (e) => {
6791
6986
  onZoom(parseFloat(e.currentTarget.value));
6792
6987
  },
6793
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
6988
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
6794
6989
  "option",
6795
6990
  {
6796
6991
  value: option.value,
@@ -6838,7 +7033,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
6838
7033
  };
6839
7034
 
6840
7035
  // components/Puck/components/Canvas/index.tsx
6841
- import { Fragment as Fragment13, jsx as jsx36, jsxs as jsxs19 } from "react/jsx-runtime";
7036
+ import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
6842
7037
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
6843
7038
  var ZOOM_ON_CHANGE = true;
6844
7039
  var Canvas = () => {
@@ -6847,15 +7042,15 @@ var Canvas = () => {
6847
7042
  const { ui } = state;
6848
7043
  const frameRef = useRef8(null);
6849
7044
  const [showTransition, setShowTransition] = useState24(false);
6850
- const defaultRender = useMemo15(() => {
6851
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment13, { children });
7045
+ const defaultRender = useMemo17(() => {
7046
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
6852
7047
  return PuckDefault;
6853
7048
  }, []);
6854
- const CustomPreview = useMemo15(
7049
+ const CustomPreview = useMemo17(
6855
7050
  () => overrides.preview || defaultRender,
6856
7051
  [overrides]
6857
7052
  );
6858
- const getFrameDimensions = useCallback15(() => {
7053
+ const getFrameDimensions = useCallback16(() => {
6859
7054
  if (frameRef.current) {
6860
7055
  const frame = frameRef.current;
6861
7056
  const box = getBox(frame);
@@ -6863,7 +7058,7 @@ var Canvas = () => {
6863
7058
  }
6864
7059
  return { width: 0, height: 0 };
6865
7060
  }, [frameRef]);
6866
- const resetAutoZoom = useCallback15(
7061
+ const resetAutoZoom = useCallback16(
6867
7062
  (ui2 = state.ui) => {
6868
7063
  if (frameRef.current) {
6869
7064
  setZoomConfig(
@@ -6873,11 +7068,11 @@ var Canvas = () => {
6873
7068
  },
6874
7069
  [frameRef, zoomConfig, state.ui]
6875
7070
  );
6876
- useEffect21(() => {
7071
+ useEffect22(() => {
6877
7072
  setShowTransition(false);
6878
7073
  resetAutoZoom();
6879
7074
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6880
- useEffect21(() => {
7075
+ useEffect22(() => {
6881
7076
  const { height: frameHeight } = getFrameDimensions();
6882
7077
  if (ui.viewports.current.height === "auto") {
6883
7078
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6885,13 +7080,13 @@ var Canvas = () => {
6885
7080
  }));
6886
7081
  }
6887
7082
  }, [zoomConfig.zoom]);
6888
- useEffect21(() => {
7083
+ useEffect22(() => {
6889
7084
  if (ZOOM_ON_CHANGE) {
6890
7085
  setShowTransition(true);
6891
7086
  resetAutoZoom(ui);
6892
7087
  }
6893
7088
  }, [ui.viewports.current.width]);
6894
- useEffect21(() => {
7089
+ useEffect22(() => {
6895
7090
  const cb = () => {
6896
7091
  setShowTransition(false);
6897
7092
  resetAutoZoom();
@@ -6902,7 +7097,7 @@ var Canvas = () => {
6902
7097
  };
6903
7098
  }, []);
6904
7099
  const [showLoader, setShowLoader] = useState24(false);
6905
- useEffect21(() => {
7100
+ useEffect22(() => {
6906
7101
  setTimeout(() => {
6907
7102
  setShowLoader(true);
6908
7103
  }, 500);
@@ -6920,7 +7115,7 @@ var Canvas = () => {
6920
7115
  recordHistory: true
6921
7116
  }),
6922
7117
  children: [
6923
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx36(
7118
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
6924
7119
  ViewportControls,
6925
7120
  {
6926
7121
  autoZoom: zoomConfig.autoZoom,
@@ -6947,7 +7142,7 @@ var Canvas = () => {
6947
7142
  }
6948
7143
  ) }),
6949
7144
  /* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
6950
- /* @__PURE__ */ jsx36(
7145
+ /* @__PURE__ */ jsx37(
6951
7146
  "div",
6952
7147
  {
6953
7148
  className: getClassName26("root"),
@@ -6968,10 +7163,10 @@ var Canvas = () => {
6968
7163
  })
6969
7164
  );
6970
7165
  },
6971
- children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
7166
+ children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
6972
7167
  }
6973
7168
  ),
6974
- /* @__PURE__ */ jsx36("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
7169
+ /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
6975
7170
  ] })
6976
7171
  ]
6977
7172
  }
@@ -6980,7 +7175,7 @@ var Canvas = () => {
6980
7175
 
6981
7176
  // lib/use-loaded-overrides.ts
6982
7177
  init_react_import();
6983
- import { useMemo as useMemo16 } from "react";
7178
+ import { useMemo as useMemo18 } from "react";
6984
7179
 
6985
7180
  // lib/load-overrides.ts
6986
7181
  init_react_import();
@@ -7019,26 +7214,26 @@ var useLoadedOverrides = ({
7019
7214
  overrides,
7020
7215
  plugins
7021
7216
  }) => {
7022
- return useMemo16(() => {
7217
+ return useMemo18(() => {
7023
7218
  return loadOverrides({ overrides, plugins });
7024
7219
  }, [plugins, overrides]);
7025
7220
  };
7026
7221
 
7027
7222
  // components/DefaultOverride/index.tsx
7028
7223
  init_react_import();
7029
- import { Fragment as Fragment14, jsx as jsx37 } from "react/jsx-runtime";
7030
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment14, { children });
7224
+ import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
7225
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
7031
7226
 
7032
7227
  // lib/use-inject-css.ts
7033
7228
  init_react_import();
7034
- import { useEffect as useEffect22, useState as useState25 } from "react";
7229
+ import { useEffect as useEffect23, useState as useState25 } from "react";
7035
7230
  var styles = ``;
7036
7231
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7037
7232
  const [el, setEl] = useState25();
7038
- useEffect22(() => {
7233
+ useEffect23(() => {
7039
7234
  setEl(document.createElement("style"));
7040
7235
  }, []);
7041
- useEffect22(() => {
7236
+ useEffect23(() => {
7042
7237
  var _a;
7043
7238
  if (!el || typeof window === "undefined") {
7044
7239
  return;
@@ -7058,10 +7253,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
7058
7253
 
7059
7254
  // lib/use-preview-mode-hotkeys.ts
7060
7255
  init_react_import();
7061
- import { useCallback as useCallback16 } from "react";
7256
+ import { useCallback as useCallback17 } from "react";
7062
7257
  import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
7063
7258
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7064
- const toggleInteractive = useCallback16(() => {
7259
+ const toggleInteractive = useCallback17(() => {
7065
7260
  dispatch({
7066
7261
  type: "setUi",
7067
7262
  ui: (ui) => ({
@@ -7084,7 +7279,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7084
7279
  };
7085
7280
 
7086
7281
  // components/Puck/index.tsx
7087
- import { Fragment as Fragment15, jsx as jsx38, jsxs as jsxs20 } from "react/jsx-runtime";
7282
+ import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
7088
7283
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
7089
7284
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
7090
7285
  function Puck({
@@ -7206,11 +7401,11 @@ function Puck({
7206
7401
  const [menuOpen, setMenuOpen] = useState26(false);
7207
7402
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
7208
7403
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
7209
- useEffect23(() => {
7404
+ useEffect24(() => {
7210
7405
  if (onChange) onChange(data);
7211
7406
  }, [data]);
7212
7407
  const rootProps = data.root.props || data.root;
7213
- const toggleSidebars = useCallback17(
7408
+ const toggleSidebars = useCallback18(
7214
7409
  (sidebar) => {
7215
7410
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7216
7411
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7224,7 +7419,7 @@ function Puck({
7224
7419
  },
7225
7420
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7226
7421
  );
7227
- useEffect23(() => {
7422
+ useEffect24(() => {
7228
7423
  if (!window.matchMedia("(min-width: 638px)").matches) {
7229
7424
  dispatch({
7230
7425
  type: "setUi",
@@ -7247,7 +7442,7 @@ function Puck({
7247
7442
  window.removeEventListener("resize", handleResize);
7248
7443
  };
7249
7444
  }, []);
7250
- const defaultHeaderRender = useMemo17(() => {
7445
+ const defaultHeaderRender = useMemo19(() => {
7251
7446
  if (renderHeader) {
7252
7447
  console.warn(
7253
7448
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7255,20 +7450,20 @@ function Puck({
7255
7450
  const RenderHeader = (_a2) => {
7256
7451
  var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
7257
7452
  const Comp = renderHeader;
7258
- return /* @__PURE__ */ jsx38(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7453
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7259
7454
  };
7260
7455
  return RenderHeader;
7261
7456
  }
7262
7457
  return DefaultOverride;
7263
7458
  }, [renderHeader]);
7264
- const defaultHeaderActionsRender = useMemo17(() => {
7459
+ const defaultHeaderActionsRender = useMemo19(() => {
7265
7460
  if (renderHeaderActions) {
7266
7461
  console.warn(
7267
7462
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7268
7463
  );
7269
7464
  const RenderHeader = (props) => {
7270
7465
  const Comp = renderHeaderActions;
7271
- return /* @__PURE__ */ jsx38(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7466
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7272
7467
  };
7273
7468
  return RenderHeader;
7274
7469
  }
@@ -7278,27 +7473,27 @@ function Puck({
7278
7473
  overrides,
7279
7474
  plugins
7280
7475
  });
7281
- const CustomPuck = useMemo17(
7476
+ const CustomPuck = useMemo19(
7282
7477
  () => loadedOverrides.puck || DefaultOverride,
7283
7478
  [loadedOverrides]
7284
7479
  );
7285
- const CustomHeader = useMemo17(
7480
+ const CustomHeader = useMemo19(
7286
7481
  () => loadedOverrides.header || defaultHeaderRender,
7287
7482
  [loadedOverrides]
7288
7483
  );
7289
- const CustomHeaderActions = useMemo17(
7484
+ const CustomHeaderActions = useMemo19(
7290
7485
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7291
7486
  [loadedOverrides]
7292
7487
  );
7293
7488
  const [mounted, setMounted] = useState26(false);
7294
- useEffect23(() => {
7489
+ useEffect24(() => {
7295
7490
  setMounted(true);
7296
7491
  }, []);
7297
7492
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
7298
7493
  const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
7299
7494
  usePreviewModeHotkeys(dispatch, iframe.enabled);
7300
7495
  return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
7301
- /* @__PURE__ */ jsx38(
7496
+ /* @__PURE__ */ jsx39(
7302
7497
  AppProvider,
7303
7498
  {
7304
7499
  value: {
@@ -7320,7 +7515,7 @@ function Puck({
7320
7515
  getPermissions: () => ({}),
7321
7516
  refreshPermissions: () => null
7322
7517
  },
7323
- children: /* @__PURE__ */ jsx38(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx38(CustomPuck, { children: children || /* @__PURE__ */ jsx38(
7518
+ children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
7324
7519
  "div",
7325
7520
  {
7326
7521
  className: getLayoutClassName({
@@ -7330,59 +7525,59 @@ function Puck({
7330
7525
  rightSideBarVisible
7331
7526
  }),
7332
7527
  children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
7333
- /* @__PURE__ */ jsx38(
7528
+ /* @__PURE__ */ jsx39(
7334
7529
  CustomHeader,
7335
7530
  {
7336
- actions: /* @__PURE__ */ jsx38(Fragment15, { children: /* @__PURE__ */ jsx38(CustomHeaderActions, { children: /* @__PURE__ */ jsx38(
7531
+ actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7337
7532
  Button,
7338
7533
  {
7339
7534
  onClick: () => {
7340
7535
  onPublish && onPublish(data);
7341
7536
  },
7342
- icon: /* @__PURE__ */ jsx38(Globe, { size: "14px" }),
7537
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7343
7538
  children: "Publish"
7344
7539
  }
7345
7540
  ) }) }),
7346
- children: /* @__PURE__ */ jsx38("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7541
+ children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7347
7542
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
7348
- /* @__PURE__ */ jsx38(
7543
+ /* @__PURE__ */ jsx39(
7349
7544
  "div",
7350
7545
  {
7351
7546
  className: getLayoutClassName("leftSideBarToggle"),
7352
- children: /* @__PURE__ */ jsx38(
7547
+ children: /* @__PURE__ */ jsx39(
7353
7548
  IconButton,
7354
7549
  {
7355
7550
  onClick: () => {
7356
7551
  toggleSidebars("left");
7357
7552
  },
7358
7553
  title: "Toggle left sidebar",
7359
- children: /* @__PURE__ */ jsx38(PanelLeft, { focusable: "false" })
7554
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7360
7555
  }
7361
7556
  )
7362
7557
  }
7363
7558
  ),
7364
- /* @__PURE__ */ jsx38(
7559
+ /* @__PURE__ */ jsx39(
7365
7560
  "div",
7366
7561
  {
7367
7562
  className: getLayoutClassName("rightSideBarToggle"),
7368
- children: /* @__PURE__ */ jsx38(
7563
+ children: /* @__PURE__ */ jsx39(
7369
7564
  IconButton,
7370
7565
  {
7371
7566
  onClick: () => {
7372
7567
  toggleSidebars("right");
7373
7568
  },
7374
7569
  title: "Toggle right sidebar",
7375
- children: /* @__PURE__ */ jsx38(PanelRight, { focusable: "false" })
7570
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7376
7571
  }
7377
7572
  )
7378
7573
  }
7379
7574
  )
7380
7575
  ] }),
7381
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7576
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7382
7577
  headerTitle || rootProps.title || "Page",
7383
7578
  headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
7384
7579
  " ",
7385
- /* @__PURE__ */ jsx38(
7580
+ /* @__PURE__ */ jsx39(
7386
7581
  "code",
7387
7582
  {
7388
7583
  className: getLayoutClassName("headerPath"),
@@ -7392,30 +7587,30 @@ function Puck({
7392
7587
  ] })
7393
7588
  ] }) }),
7394
7589
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
7395
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx38(
7590
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
7396
7591
  IconButton,
7397
7592
  {
7398
7593
  onClick: () => {
7399
7594
  return setMenuOpen(!menuOpen);
7400
7595
  },
7401
7596
  title: "Toggle menu bar",
7402
- children: menuOpen ? /* @__PURE__ */ jsx38(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx38(ChevronDown, { focusable: "false" })
7597
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7403
7598
  }
7404
7599
  ) }),
7405
- /* @__PURE__ */ jsx38(
7600
+ /* @__PURE__ */ jsx39(
7406
7601
  MenuBar,
7407
7602
  {
7408
7603
  appState,
7409
7604
  dispatch,
7410
7605
  onPublish,
7411
7606
  menuOpen,
7412
- renderHeaderActions: () => /* @__PURE__ */ jsx38(CustomHeaderActions, { children: /* @__PURE__ */ jsx38(
7607
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7413
7608
  Button,
7414
7609
  {
7415
7610
  onClick: () => {
7416
7611
  onPublish && onPublish(data);
7417
7612
  },
7418
- icon: /* @__PURE__ */ jsx38(Globe, { size: "14px" }),
7613
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7419
7614
  children: "Publish"
7420
7615
  }
7421
7616
  ) }),
@@ -7427,18 +7622,18 @@ function Puck({
7427
7622
  }
7428
7623
  ),
7429
7624
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
7430
- /* @__PURE__ */ jsx38(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx38(Components, {}) }),
7431
- /* @__PURE__ */ jsx38(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx38(Outline, {}) })
7625
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
7626
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
7432
7627
  ] }),
7433
- /* @__PURE__ */ jsx38(Canvas, {}),
7434
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx38(
7628
+ /* @__PURE__ */ jsx39(Canvas, {}),
7629
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
7435
7630
  SidebarSection,
7436
7631
  {
7437
7632
  noPadding: true,
7438
7633
  noBorderTop: true,
7439
7634
  showBreadcrumbs: true,
7440
7635
  title: selectedItem ? selectedComponentLabel : "Page",
7441
- children: /* @__PURE__ */ jsx38(Fields, {})
7636
+ children: /* @__PURE__ */ jsx39(Fields, {})
7442
7637
  }
7443
7638
  ) })
7444
7639
  ] })
@@ -7446,7 +7641,7 @@ function Puck({
7446
7641
  ) }) })
7447
7642
  }
7448
7643
  ),
7449
- /* @__PURE__ */ jsx38("div", { id: "puck-portal-root", className: getClassName27("portal") })
7644
+ /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
7450
7645
  ] });
7451
7646
  }
7452
7647
  Puck.Components = Components;