@measured/puck 0.17.2-canary.bbe0a8d → 0.17.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  resolveRootData,
14
14
  rootDroppableId,
15
15
  setupZone
16
- } from "./chunk-7IH6SUIT.mjs";
16
+ } from "./chunk-LNGCTWA7.mjs";
17
17
 
18
18
  // ../../node_modules/classnames/index.js
19
19
  var require_classnames = __commonJS({
@@ -193,8 +193,9 @@ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input":
193
193
  // components/AutoField/index.tsx
194
194
  import {
195
195
  useCallback as useCallback5,
196
+ useContext as useContext3,
196
197
  useEffect as useEffect9,
197
- useMemo as useMemo4,
198
+ useMemo as useMemo5,
198
199
  useState as useState10
199
200
  } from "react";
200
201
 
@@ -1176,21 +1177,66 @@ import { jsx as jsx7 } from "react/jsx-runtime";
1176
1177
  var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default5);
1177
1178
  var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ jsx7("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ jsx7("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ jsx7("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
1178
1179
 
1180
+ // components/AutoField/context.tsx
1181
+ init_react_import();
1182
+ import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
1183
+ import { jsx as jsx8 } from "react/jsx-runtime";
1184
+ var NestedFieldContext = createContext2({});
1185
+ var useNestedFieldContext = () => {
1186
+ const context = useContext2(NestedFieldContext);
1187
+ return __spreadProps(__spreadValues({}, context), {
1188
+ readOnlyFields: context.readOnlyFields || {}
1189
+ });
1190
+ };
1191
+ var NestedFieldProvider = ({
1192
+ children,
1193
+ name,
1194
+ subName,
1195
+ wildcardName = name,
1196
+ readOnlyFields
1197
+ }) => {
1198
+ const subPath = `${name}.${subName}`;
1199
+ const wildcardSubPath = `${wildcardName}.${subName}`;
1200
+ const subReadOnlyFields = useMemo(
1201
+ () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
1202
+ const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
1203
+ if (isLocal) {
1204
+ const subPathPattern = new RegExp(
1205
+ `^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
1206
+ );
1207
+ const localName = readOnlyKey.replace(subPathPattern, "");
1208
+ return __spreadProps(__spreadValues({}, acc), {
1209
+ [localName]: readOnlyFields[readOnlyKey]
1210
+ });
1211
+ }
1212
+ return acc;
1213
+ }, {}),
1214
+ [name, subName, wildcardName, readOnlyFields]
1215
+ );
1216
+ return /* @__PURE__ */ jsx8(
1217
+ NestedFieldContext.Provider,
1218
+ {
1219
+ value: { readOnlyFields: subReadOnlyFields, localName: subName },
1220
+ children
1221
+ }
1222
+ );
1223
+ };
1224
+
1179
1225
  // components/DragDropContext/index.tsx
1180
1226
  init_react_import();
1181
1227
  import {
1182
1228
  DragDropContext as DndDragDropContext
1183
1229
  } from "@measured/dnd";
1184
- import { Fragment as Fragment4, jsx as jsx8 } from "react/jsx-runtime";
1185
- var DefaultDragDropContext = ({ children }) => /* @__PURE__ */ jsx8(Fragment4, { children });
1230
+ import { Fragment as Fragment4, jsx as jsx9 } from "react/jsx-runtime";
1231
+ var DefaultDragDropContext = ({ children }) => /* @__PURE__ */ jsx9(Fragment4, { children });
1186
1232
  var DragDropContext = (props) => {
1187
1233
  const { status } = useAppContext();
1188
1234
  const El = status !== "LOADING" ? DndDragDropContext : DefaultDragDropContext;
1189
- return /* @__PURE__ */ jsx8(El, __spreadValues({}, props));
1235
+ return /* @__PURE__ */ jsx9(El, __spreadValues({}, props));
1190
1236
  };
1191
1237
 
1192
1238
  // components/AutoField/fields/ArrayField/index.tsx
1193
- import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
1239
+ import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
1194
1240
  var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
1195
1241
  var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
1196
1242
  var ArrayField = ({
@@ -1201,10 +1247,10 @@ var ArrayField = ({
1201
1247
  label,
1202
1248
  readOnly,
1203
1249
  id,
1204
- Label = (props) => /* @__PURE__ */ jsx9("div", __spreadValues({}, props))
1250
+ Label = (props) => /* @__PURE__ */ jsx10("div", __spreadValues({}, props))
1205
1251
  }) => {
1206
1252
  const { state, setUi, selectedItem, getPermissions } = useAppContext();
1207
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
1253
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
1208
1254
  const value = _value;
1209
1255
  const arrayState = state.ui.arrayState[id] || {
1210
1256
  items: Array.from(value || []).map((item, idx) => {
@@ -1265,14 +1311,14 @@ var ArrayField = ({
1265
1311
  return null;
1266
1312
  }
1267
1313
  const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
1268
- return /* @__PURE__ */ jsx9(
1314
+ return /* @__PURE__ */ jsx10(
1269
1315
  Label,
1270
1316
  {
1271
1317
  label: label || name,
1272
- icon: /* @__PURE__ */ jsx9(List, { size: 16 }),
1318
+ icon: /* @__PURE__ */ jsx10(List, { size: 16 }),
1273
1319
  el: "div",
1274
1320
  readOnly,
1275
- children: /* @__PURE__ */ jsx9(
1321
+ children: /* @__PURE__ */ jsx10(
1276
1322
  DragDropContext,
1277
1323
  {
1278
1324
  onDragEnd: (event) => {
@@ -1301,7 +1347,7 @@ var ArrayField = ({
1301
1347
  });
1302
1348
  }
1303
1349
  },
1304
- children: /* @__PURE__ */ jsx9(Droppable, { droppableId: "array", isDropDisabled: readOnly, children: (provided, snapshot) => {
1350
+ children: /* @__PURE__ */ jsx10(Droppable, { droppableId: "array", isDropDisabled: readOnly, children: (provided, snapshot) => {
1305
1351
  return /* @__PURE__ */ jsxs4(
1306
1352
  "div",
1307
1353
  __spreadProps(__spreadValues({}, provided.droppableProps), {
@@ -1326,7 +1372,7 @@ var ArrayField = ({
1326
1372
  localState.arrayState.items.map((item, i) => {
1327
1373
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
1328
1374
  const data = Array.from(localState.value || [])[i] || {};
1329
- return /* @__PURE__ */ jsx9(
1375
+ return /* @__PURE__ */ jsx10(
1330
1376
  Draggable,
1331
1377
  {
1332
1378
  id: _arrayId,
@@ -1361,7 +1407,7 @@ var ArrayField = ({
1361
1407
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
1362
1408
  /* @__PURE__ */ jsxs4("div", { className: getClassNameItem("rhs"), children: [
1363
1409
  !readOnly && /* @__PURE__ */ jsxs4("div", { className: getClassNameItem("actions"), children: [
1364
- /* @__PURE__ */ jsx9("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx9(
1410
+ /* @__PURE__ */ jsx10("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx10(
1365
1411
  IconButton,
1366
1412
  {
1367
1413
  type: "button",
@@ -1384,10 +1430,10 @@ var ArrayField = ({
1384
1430
  );
1385
1431
  },
1386
1432
  title: "Duplicate",
1387
- children: /* @__PURE__ */ jsx9(Copy, { size: 16 })
1433
+ children: /* @__PURE__ */ jsx10(Copy, { size: 16 })
1388
1434
  }
1389
1435
  ) }),
1390
- /* @__PURE__ */ jsx9("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx9(
1436
+ /* @__PURE__ */ jsx10("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx10(
1391
1437
  IconButton,
1392
1438
  {
1393
1439
  type: "button",
@@ -1410,40 +1456,57 @@ var ArrayField = ({
1410
1456
  );
1411
1457
  },
1412
1458
  title: "Delete",
1413
- children: /* @__PURE__ */ jsx9(Trash, { size: 16 })
1459
+ children: /* @__PURE__ */ jsx10(Trash, { size: 16 })
1414
1460
  }
1415
1461
  ) })
1416
1462
  ] }),
1417
- /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsx9(DragIcon, {}) })
1463
+ /* @__PURE__ */ jsx10("div", { children: /* @__PURE__ */ jsx10(DragIcon, {}) })
1418
1464
  ] })
1419
1465
  ]
1420
1466
  }
1421
1467
  ),
1422
- /* @__PURE__ */ jsx9("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx9("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
1423
- (fieldName) => {
1424
- const subField = field.arrayFields[fieldName];
1425
- const subFieldName = `${name}[${i}].${fieldName}`;
1426
- const wildcardFieldName = `${name}[*].${fieldName}`;
1427
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
1428
- return /* @__PURE__ */ jsx9(
1429
- AutoFieldPrivate,
1468
+ /* @__PURE__ */ jsx10("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx10("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
1469
+ (subName) => {
1470
+ const subField = field.arrayFields[subName];
1471
+ const indexName = `${name}[${i}]`;
1472
+ const subPath = `${indexName}.${subName}`;
1473
+ const localIndexName = `${localName}[${i}]`;
1474
+ const localWildcardName = `${localName}[*]`;
1475
+ const localSubPath = `${localIndexName}.${subName}`;
1476
+ const localWildcardSubPath = `${localWildcardName}.${subName}`;
1477
+ const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
1478
+ const label2 = subField.label || subName;
1479
+ return /* @__PURE__ */ jsx10(
1480
+ NestedFieldProvider,
1430
1481
  {
1431
- name: subFieldName,
1432
- label: subField.label || fieldName,
1433
- id: `${_arrayId}_${fieldName}`,
1434
- readOnly: subReadOnly,
1435
- field: subField,
1436
- value: data[fieldName],
1437
- onChange: (val, ui) => {
1438
- onChange(
1439
- replace(value, i, __spreadProps(__spreadValues({}, data), {
1440
- [fieldName]: val
1441
- })),
1442
- ui
1443
- );
1444
- }
1482
+ name: localIndexName,
1483
+ wildcardName: localWildcardName,
1484
+ subName,
1485
+ readOnlyFields,
1486
+ children: /* @__PURE__ */ jsx10(
1487
+ AutoFieldPrivate,
1488
+ {
1489
+ name: subPath,
1490
+ label: label2,
1491
+ id: `${_arrayId}_${subName}`,
1492
+ readOnly: subReadOnly,
1493
+ field: __spreadProps(__spreadValues({}, subField), {
1494
+ label: label2
1495
+ // May be used by custom fields
1496
+ }),
1497
+ value: data[subName],
1498
+ onChange: (val, ui) => {
1499
+ onChange(
1500
+ replace(value, i, __spreadProps(__spreadValues({}, data), {
1501
+ [subName]: val
1502
+ })),
1503
+ ui
1504
+ );
1505
+ }
1506
+ }
1507
+ )
1445
1508
  },
1446
- subFieldName
1509
+ subPath
1447
1510
  );
1448
1511
  }
1449
1512
  ) }) })
@@ -1453,7 +1516,7 @@ var ArrayField = ({
1453
1516
  );
1454
1517
  }),
1455
1518
  provided.placeholder,
1456
- !addDisabled && /* @__PURE__ */ jsx9(
1519
+ !addDisabled && /* @__PURE__ */ jsx10(
1457
1520
  "button",
1458
1521
  {
1459
1522
  type: "button",
@@ -1467,7 +1530,7 @@ var ArrayField = ({
1467
1530
  const newArrayState = regenerateArrayState(newValue);
1468
1531
  onChange(newValue, mapArrayStateToUi(newArrayState));
1469
1532
  },
1470
- children: /* @__PURE__ */ jsx9(Plus, { size: 21 })
1533
+ children: /* @__PURE__ */ jsx10(Plus, { size: 21 })
1471
1534
  }
1472
1535
  )
1473
1536
  ]
@@ -1482,7 +1545,7 @@ var ArrayField = ({
1482
1545
 
1483
1546
  // components/AutoField/fields/DefaultField/index.tsx
1484
1547
  init_react_import();
1485
- import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
1548
+ import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
1486
1549
  var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
1487
1550
  var DefaultField = ({
1488
1551
  field,
@@ -1494,16 +1557,16 @@ var DefaultField = ({
1494
1557
  Label,
1495
1558
  id
1496
1559
  }) => {
1497
- return /* @__PURE__ */ jsx10(
1560
+ return /* @__PURE__ */ jsx11(
1498
1561
  Label,
1499
1562
  {
1500
1563
  label: label || name,
1501
1564
  icon: /* @__PURE__ */ jsxs5(Fragment6, { children: [
1502
- field.type === "text" && /* @__PURE__ */ jsx10(Type, { size: 16 }),
1503
- field.type === "number" && /* @__PURE__ */ jsx10(Hash, { size: 16 })
1565
+ field.type === "text" && /* @__PURE__ */ jsx11(Type, { size: 16 }),
1566
+ field.type === "number" && /* @__PURE__ */ jsx11(Hash, { size: 16 })
1504
1567
  ] }),
1505
1568
  readOnly,
1506
- children: /* @__PURE__ */ jsx10(
1569
+ children: /* @__PURE__ */ jsx11(
1507
1570
  "input",
1508
1571
  {
1509
1572
  className: getClassName6("input"),
@@ -1514,7 +1577,14 @@ var DefaultField = ({
1514
1577
  value: typeof value === "undefined" ? "" : value.toString(),
1515
1578
  onChange: (e) => {
1516
1579
  if (field.type === "number") {
1517
- onChange(Number(e.currentTarget.value));
1580
+ const numberValue = Number(e.currentTarget.value);
1581
+ if (typeof field.min !== "undefined" && numberValue < field.min) {
1582
+ return;
1583
+ }
1584
+ if (typeof field.max !== "undefined" && numberValue > field.max) {
1585
+ return;
1586
+ }
1587
+ onChange(numberValue);
1518
1588
  } else {
1519
1589
  onChange(e.currentTarget.value);
1520
1590
  }
@@ -1537,7 +1607,7 @@ import { useEffect as useEffect8 } from "react";
1537
1607
  // components/ExternalInput/index.tsx
1538
1608
  init_react_import();
1539
1609
  import {
1540
- useMemo,
1610
+ useMemo as useMemo2,
1541
1611
  useEffect as useEffect7,
1542
1612
  useState as useState8,
1543
1613
  useCallback as useCallback4,
@@ -1558,7 +1628,7 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
1558
1628
 
1559
1629
  // components/Modal/index.tsx
1560
1630
  import { createPortal } from "react-dom";
1561
- import { jsx as jsx11 } from "react/jsx-runtime";
1631
+ import { jsx as jsx12 } from "react/jsx-runtime";
1562
1632
  var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
1563
1633
  var Modal = ({
1564
1634
  children,
@@ -1570,10 +1640,10 @@ var Modal = ({
1570
1640
  setRootEl(document.getElementById("puck-portal-root"));
1571
1641
  }, []);
1572
1642
  if (!rootEl) {
1573
- return /* @__PURE__ */ jsx11("div", {});
1643
+ return /* @__PURE__ */ jsx12("div", {});
1574
1644
  }
1575
1645
  return createPortal(
1576
- /* @__PURE__ */ jsx11("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx11(
1646
+ /* @__PURE__ */ jsx12("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx12(
1577
1647
  "div",
1578
1648
  {
1579
1649
  className: getClassName7("inner"),
@@ -1593,11 +1663,11 @@ init_react_import();
1593
1663
  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" };
1594
1664
 
1595
1665
  // components/Heading/index.tsx
1596
- import { jsx as jsx12 } from "react/jsx-runtime";
1666
+ import { jsx as jsx13 } from "react/jsx-runtime";
1597
1667
  var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
1598
1668
  var Heading = ({ children, rank, size = "m" }) => {
1599
1669
  const Tag = rank ? `h${rank}` : "span";
1600
- return /* @__PURE__ */ jsx12(
1670
+ return /* @__PURE__ */ jsx13(
1601
1671
  Tag,
1602
1672
  {
1603
1673
  className: getClassName8({
@@ -1619,57 +1689,29 @@ import { useEffect as useEffect6, useState as useState7 } from "react";
1619
1689
  init_react_import();
1620
1690
  var Button_module_default = { "Button": "_Button_1t64k_1", "Button--medium": "_Button--medium_1t64k_29", "Button--large": "_Button--large_1t64k_37", "Button-icon": "_Button-icon_1t64k_44", "Button--primary": "_Button--primary_1t64k_48", "Button--secondary": "_Button--secondary_1t64k_67", "Button--flush": "_Button--flush_1t64k_84", "Button--disabled": "_Button--disabled_1t64k_88", "Button--fullWidth": "_Button--fullWidth_1t64k_95", "Button-spinner": "_Button-spinner_1t64k_100" };
1621
1691
 
1622
- // lib/filter-data-attrs.ts
1623
- init_react_import();
1624
- var dataAttrRe = /^(data-.*)$/;
1625
- var filterDataAttrs = (props) => {
1626
- let filteredProps = {};
1627
- for (const prop in props) {
1628
- if (Object.prototype.hasOwnProperty.call(props, prop) && dataAttrRe.test(prop)) {
1629
- filteredProps[prop] = props[prop];
1630
- }
1631
- }
1632
- return filteredProps;
1633
- };
1634
-
1635
1692
  // components/Button/Button.tsx
1636
- import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
1693
+ import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
1637
1694
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
1638
- var Button = (_a) => {
1639
- var _b = _a, {
1640
- children,
1641
- href,
1642
- onClick,
1643
- variant = "primary",
1644
- type,
1645
- disabled,
1646
- tabIndex,
1647
- newTab,
1648
- fullWidth,
1649
- icon,
1650
- size = "medium",
1651
- loading: loadingProp = false
1652
- } = _b, props = __objRest(_b, [
1653
- "children",
1654
- "href",
1655
- "onClick",
1656
- "variant",
1657
- "type",
1658
- "disabled",
1659
- "tabIndex",
1660
- "newTab",
1661
- "fullWidth",
1662
- "icon",
1663
- "size",
1664
- "loading"
1665
- ]);
1695
+ var Button = ({
1696
+ children,
1697
+ href,
1698
+ onClick,
1699
+ variant = "primary",
1700
+ type,
1701
+ disabled,
1702
+ tabIndex,
1703
+ newTab,
1704
+ fullWidth,
1705
+ icon,
1706
+ size = "medium",
1707
+ loading: loadingProp = false
1708
+ }) => {
1666
1709
  const [loading, setLoading] = useState7(loadingProp);
1667
1710
  useEffect6(() => setLoading(loadingProp), [loadingProp]);
1668
1711
  const ElementType = href ? "a" : type ? "button" : "span";
1669
- const dataAttrs = filterDataAttrs(props);
1670
1712
  const el = /* @__PURE__ */ jsxs6(
1671
1713
  ElementType,
1672
- __spreadProps(__spreadValues({
1714
+ {
1673
1715
  className: getClassName9({
1674
1716
  primary: variant === "primary",
1675
1717
  secondary: variant === "secondary",
@@ -1689,20 +1731,19 @@ var Button = (_a) => {
1689
1731
  tabIndex,
1690
1732
  target: newTab ? "_blank" : void 0,
1691
1733
  rel: newTab ? "noreferrer" : void 0,
1692
- href
1693
- }, dataAttrs), {
1734
+ href,
1694
1735
  children: [
1695
- icon && /* @__PURE__ */ jsx13("div", { className: getClassName9("icon"), children: icon }),
1736
+ icon && /* @__PURE__ */ jsx14("div", { className: getClassName9("icon"), children: icon }),
1696
1737
  children,
1697
- loading && /* @__PURE__ */ jsx13("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx13(Loader, { size: 14 }) })
1738
+ loading && /* @__PURE__ */ jsx14("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx14(Loader, { size: 14 }) })
1698
1739
  ]
1699
- })
1740
+ }
1700
1741
  );
1701
1742
  return el;
1702
1743
  };
1703
1744
 
1704
1745
  // components/ExternalInput/index.tsx
1705
- import { Fragment as Fragment7, jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1746
+ import { Fragment as Fragment7, jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
1706
1747
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
1707
1748
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
1708
1749
  var dataCache = {};
@@ -1725,10 +1766,10 @@ var ExternalInput = ({
1725
1766
  const hasFilterFields = !!filterFields;
1726
1767
  const [filters, setFilters] = useState8(field.initialFilters || {});
1727
1768
  const [filtersToggled, setFiltersToggled] = useState8(hasFilterFields);
1728
- const mappedData = useMemo(() => {
1769
+ const mappedData = useMemo2(() => {
1729
1770
  return data.map(mapRow);
1730
1771
  }, [data]);
1731
- const keys = useMemo(() => {
1772
+ const keys = useMemo2(() => {
1732
1773
  const validKeys = /* @__PURE__ */ new Set();
1733
1774
  for (const item of mappedData) {
1734
1775
  for (const key of Object.keys(item)) {
@@ -1775,7 +1816,7 @@ var ExternalInput = ({
1775
1816
  id,
1776
1817
  children: [
1777
1818
  /* @__PURE__ */ jsxs7("div", { className: getClassName10("actions"), children: [
1778
- /* @__PURE__ */ jsx14(
1819
+ /* @__PURE__ */ jsx15(
1779
1820
  "button",
1780
1821
  {
1781
1822
  type: "button",
@@ -1783,12 +1824,12 @@ var ExternalInput = ({
1783
1824
  className: getClassName10("button"),
1784
1825
  disabled: readOnly,
1785
1826
  children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs7(Fragment7, { children: [
1786
- /* @__PURE__ */ jsx14(Link, { size: "16" }),
1787
- /* @__PURE__ */ jsx14("span", { children: field.placeholder })
1827
+ /* @__PURE__ */ jsx15(Link, { size: "16" }),
1828
+ /* @__PURE__ */ jsx15("span", { children: field.placeholder })
1788
1829
  ] })
1789
1830
  }
1790
1831
  ),
1791
- value && /* @__PURE__ */ jsx14(
1832
+ value && /* @__PURE__ */ jsx15(
1792
1833
  "button",
1793
1834
  {
1794
1835
  type: "button",
@@ -1797,11 +1838,11 @@ var ExternalInput = ({
1797
1838
  onChange(null);
1798
1839
  },
1799
1840
  disabled: readOnly,
1800
- children: /* @__PURE__ */ jsx14(LockOpen, { size: 16 })
1841
+ children: /* @__PURE__ */ jsx15(LockOpen, { size: 16 })
1801
1842
  }
1802
1843
  )
1803
1844
  ] }),
1804
- /* @__PURE__ */ jsx14(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs7(
1845
+ /* @__PURE__ */ jsx15(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs7(
1805
1846
  "form",
1806
1847
  {
1807
1848
  className: getClassNameModal({
@@ -1815,11 +1856,11 @@ var ExternalInput = ({
1815
1856
  search(searchQuery, filters);
1816
1857
  },
1817
1858
  children: [
1818
- /* @__PURE__ */ jsx14("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs7("div", { className: getClassNameModal("searchForm"), children: [
1859
+ /* @__PURE__ */ jsx15("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs7("div", { className: getClassNameModal("searchForm"), children: [
1819
1860
  /* @__PURE__ */ jsxs7("label", { className: getClassNameModal("search"), children: [
1820
- /* @__PURE__ */ jsx14("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
1821
- /* @__PURE__ */ jsx14("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx14(Search, { size: "18" }) }),
1822
- /* @__PURE__ */ jsx14(
1861
+ /* @__PURE__ */ jsx15("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
1862
+ /* @__PURE__ */ jsx15("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx15(Search, { size: "18" }) }),
1863
+ /* @__PURE__ */ jsx15(
1823
1864
  "input",
1824
1865
  {
1825
1866
  className: getClassNameModal("searchInput"),
@@ -1835,8 +1876,8 @@ var ExternalInput = ({
1835
1876
  )
1836
1877
  ] }),
1837
1878
  /* @__PURE__ */ jsxs7("div", { className: getClassNameModal("searchActions"), children: [
1838
- /* @__PURE__ */ jsx14(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
1839
- hasFilterFields && /* @__PURE__ */ jsx14("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx14(
1879
+ /* @__PURE__ */ jsx15(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
1880
+ hasFilterFields && /* @__PURE__ */ jsx15("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx15(
1840
1881
  IconButton,
1841
1882
  {
1842
1883
  title: "Toggle filters",
@@ -1845,15 +1886,15 @@ var ExternalInput = ({
1845
1886
  e.stopPropagation();
1846
1887
  setFiltersToggled(!filtersToggled);
1847
1888
  },
1848
- children: /* @__PURE__ */ jsx14(SlidersHorizontal, { size: 20 })
1889
+ children: /* @__PURE__ */ jsx15(SlidersHorizontal, { size: 20 })
1849
1890
  }
1850
1891
  ) })
1851
1892
  ] })
1852
- ] }) : /* @__PURE__ */ jsx14(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
1893
+ ] }) : /* @__PURE__ */ jsx15(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
1853
1894
  /* @__PURE__ */ jsxs7("div", { className: getClassNameModal("grid"), children: [
1854
- hasFilterFields && /* @__PURE__ */ jsx14("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1895
+ hasFilterFields && /* @__PURE__ */ jsx15("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1855
1896
  const filterField = filterFields[fieldName];
1856
- return /* @__PURE__ */ jsx14(
1897
+ return /* @__PURE__ */ jsx15(
1857
1898
  AutoFieldPrivate,
1858
1899
  {
1859
1900
  field: filterField,
@@ -1872,7 +1913,7 @@ var ExternalInput = ({
1872
1913
  }) }),
1873
1914
  /* @__PURE__ */ jsxs7("div", { className: getClassNameModal("tableWrapper"), children: [
1874
1915
  /* @__PURE__ */ jsxs7("table", { className: getClassNameModal("table"), children: [
1875
- /* @__PURE__ */ jsx14("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx14("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx14(
1916
+ /* @__PURE__ */ jsx15("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx15("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx15(
1876
1917
  "th",
1877
1918
  {
1878
1919
  className: getClassNameModal("th"),
@@ -1881,8 +1922,8 @@ var ExternalInput = ({
1881
1922
  },
1882
1923
  key
1883
1924
  )) }) }),
1884
- /* @__PURE__ */ jsx14("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
1885
- return /* @__PURE__ */ jsx14(
1925
+ /* @__PURE__ */ jsx15("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
1926
+ return /* @__PURE__ */ jsx15(
1886
1927
  "tr",
1887
1928
  {
1888
1929
  style: { whiteSpace: "nowrap" },
@@ -1891,16 +1932,16 @@ var ExternalInput = ({
1891
1932
  onChange(mapProp(data[i]));
1892
1933
  setOpen(false);
1893
1934
  },
1894
- children: keys.map((key) => /* @__PURE__ */ jsx14("td", { className: getClassNameModal("td"), children: item[key] }, key))
1935
+ children: keys.map((key) => /* @__PURE__ */ jsx15("td", { className: getClassNameModal("td"), children: item[key] }, key))
1895
1936
  },
1896
1937
  i
1897
1938
  );
1898
1939
  }) })
1899
1940
  ] }),
1900
- /* @__PURE__ */ jsx14("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx14(Loader, { size: 24 }) })
1941
+ /* @__PURE__ */ jsx15("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx15(Loader, { size: 24 }) })
1901
1942
  ] })
1902
1943
  ] }),
1903
- /* @__PURE__ */ jsx14("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx14(Footer, { items: mappedData }) })
1944
+ /* @__PURE__ */ jsx15("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx15(Footer, { items: mappedData }) })
1904
1945
  ]
1905
1946
  }
1906
1947
  ) })
@@ -1910,7 +1951,7 @@ var ExternalInput = ({
1910
1951
  };
1911
1952
 
1912
1953
  // components/AutoField/fields/ExternalField/index.tsx
1913
- import { jsx as jsx15 } from "react/jsx-runtime";
1954
+ import { jsx as jsx16 } from "react/jsx-runtime";
1914
1955
  var ExternalField = ({
1915
1956
  field,
1916
1957
  onChange,
@@ -1934,7 +1975,7 @@ var ExternalField = ({
1934
1975
  if (field.type !== "external") {
1935
1976
  return null;
1936
1977
  }
1937
- return /* @__PURE__ */ jsx15(Label, { label: label || name, icon: /* @__PURE__ */ jsx15(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx15(
1978
+ return /* @__PURE__ */ jsx16(Label, { label: label || name, icon: /* @__PURE__ */ jsx16(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx16(
1938
1979
  ExternalInput,
1939
1980
  {
1940
1981
  name,
@@ -1959,7 +2000,7 @@ var ExternalField = ({
1959
2000
 
1960
2001
  // components/AutoField/fields/RadioField/index.tsx
1961
2002
  init_react_import();
1962
- import { useMemo as useMemo2 } from "react";
2003
+ import { useMemo as useMemo3 } from "react";
1963
2004
 
1964
2005
  // lib/safe-json-parse.ts
1965
2006
  init_react_import();
@@ -1973,7 +2014,7 @@ var safeJsonParse = (str) => {
1973
2014
  };
1974
2015
 
1975
2016
  // components/AutoField/fields/RadioField/index.tsx
1976
- import { jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
2017
+ import { jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
1977
2018
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
1978
2019
  var RadioField = ({
1979
2020
  field,
@@ -1985,26 +2026,26 @@ var RadioField = ({
1985
2026
  label,
1986
2027
  Label
1987
2028
  }) => {
1988
- const flatOptions = useMemo2(
2029
+ const flatOptions = useMemo3(
1989
2030
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
1990
2031
  [field]
1991
2032
  );
1992
2033
  if (field.type !== "radio" || !field.options) {
1993
2034
  return null;
1994
2035
  }
1995
- return /* @__PURE__ */ jsx16(
2036
+ return /* @__PURE__ */ jsx17(
1996
2037
  Label,
1997
2038
  {
1998
- icon: /* @__PURE__ */ jsx16(CircleCheckBig, { size: 16 }),
2039
+ icon: /* @__PURE__ */ jsx17(CircleCheckBig, { size: 16 }),
1999
2040
  label: label || name,
2000
2041
  readOnly,
2001
2042
  el: "div",
2002
- children: /* @__PURE__ */ jsx16("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs8(
2043
+ children: /* @__PURE__ */ jsx17("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs8(
2003
2044
  "label",
2004
2045
  {
2005
2046
  className: getClassName11("radio"),
2006
2047
  children: [
2007
- /* @__PURE__ */ jsx16(
2048
+ /* @__PURE__ */ jsx17(
2008
2049
  "input",
2009
2050
  {
2010
2051
  type: "radio",
@@ -2024,7 +2065,7 @@ var RadioField = ({
2024
2065
  checked: value === option.value
2025
2066
  }
2026
2067
  ),
2027
- /* @__PURE__ */ jsx16("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2068
+ /* @__PURE__ */ jsx17("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2028
2069
  ]
2029
2070
  },
2030
2071
  option.label + option.value
@@ -2035,8 +2076,8 @@ var RadioField = ({
2035
2076
 
2036
2077
  // components/AutoField/fields/SelectField/index.tsx
2037
2078
  init_react_import();
2038
- import { useMemo as useMemo3 } from "react";
2039
- import { jsx as jsx17 } from "react/jsx-runtime";
2079
+ import { useMemo as useMemo4 } from "react";
2080
+ import { jsx as jsx18 } from "react/jsx-runtime";
2040
2081
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
2041
2082
  var SelectField = ({
2042
2083
  field,
@@ -2048,20 +2089,20 @@ var SelectField = ({
2048
2089
  readOnly,
2049
2090
  id
2050
2091
  }) => {
2051
- const flatOptions = useMemo3(
2092
+ const flatOptions = useMemo4(
2052
2093
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
2053
2094
  [field]
2054
2095
  );
2055
2096
  if (field.type !== "select" || !field.options) {
2056
2097
  return null;
2057
2098
  }
2058
- return /* @__PURE__ */ jsx17(
2099
+ return /* @__PURE__ */ jsx18(
2059
2100
  Label,
2060
2101
  {
2061
2102
  label: label || name,
2062
- icon: /* @__PURE__ */ jsx17(ChevronDown, { size: 16 }),
2103
+ icon: /* @__PURE__ */ jsx18(ChevronDown, { size: 16 }),
2063
2104
  readOnly,
2064
- children: /* @__PURE__ */ jsx17(
2105
+ children: /* @__PURE__ */ jsx18(
2065
2106
  "select",
2066
2107
  {
2067
2108
  id,
@@ -2078,7 +2119,7 @@ var SelectField = ({
2078
2119
  }
2079
2120
  },
2080
2121
  value,
2081
- children: field.options.map((option) => /* @__PURE__ */ jsx17(
2122
+ children: field.options.map((option) => /* @__PURE__ */ jsx18(
2082
2123
  "option",
2083
2124
  {
2084
2125
  label: option.label,
@@ -2094,7 +2135,7 @@ var SelectField = ({
2094
2135
 
2095
2136
  // components/AutoField/fields/TextareaField/index.tsx
2096
2137
  init_react_import();
2097
- import { jsx as jsx18 } from "react/jsx-runtime";
2138
+ import { jsx as jsx19 } from "react/jsx-runtime";
2098
2139
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
2099
2140
  var TextareaField = ({
2100
2141
  onChange,
@@ -2105,7 +2146,7 @@ var TextareaField = ({
2105
2146
  Label,
2106
2147
  id
2107
2148
  }) => {
2108
- return /* @__PURE__ */ jsx18(Label, { label: label || name, icon: /* @__PURE__ */ jsx18(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx18(
2149
+ return /* @__PURE__ */ jsx19(Label, { label: label || name, icon: /* @__PURE__ */ jsx19(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx19(
2109
2150
  "textarea",
2110
2151
  {
2111
2152
  id,
@@ -2132,7 +2173,7 @@ init_react_import();
2132
2173
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
2133
2174
 
2134
2175
  // components/AutoField/fields/ObjectField/index.tsx
2135
- import { jsx as jsx19 } from "react/jsx-runtime";
2176
+ import { jsx as jsx20 } from "react/jsx-runtime";
2136
2177
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
2137
2178
  var ObjectField = ({
2138
2179
  field,
@@ -2144,43 +2185,54 @@ var ObjectField = ({
2144
2185
  readOnly,
2145
2186
  id
2146
2187
  }) => {
2147
- const { selectedItem } = useAppContext();
2188
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
2148
2189
  if (field.type !== "object" || !field.objectFields) {
2149
2190
  return null;
2150
2191
  }
2151
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
2152
2192
  const data = value || {};
2153
- return /* @__PURE__ */ jsx19(
2193
+ return /* @__PURE__ */ jsx20(
2154
2194
  Label,
2155
2195
  {
2156
2196
  label: label || name,
2157
- icon: /* @__PURE__ */ jsx19(EllipsisVertical, { size: 16 }),
2197
+ icon: /* @__PURE__ */ jsx20(EllipsisVertical, { size: 16 }),
2158
2198
  el: "div",
2159
2199
  readOnly,
2160
- children: /* @__PURE__ */ jsx19("div", { className: getClassName14(), children: /* @__PURE__ */ jsx19("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((fieldName) => {
2161
- const subField = field.objectFields[fieldName];
2162
- const subFieldName = `${name}.${fieldName}`;
2163
- const wildcardFieldName = `${name}.${fieldName}`;
2164
- const subReadOnly = readOnly ? readOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
2165
- return /* @__PURE__ */ jsx19(
2166
- AutoFieldPrivate,
2200
+ children: /* @__PURE__ */ jsx20("div", { className: getClassName14(), children: /* @__PURE__ */ jsx20("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
2201
+ const subField = field.objectFields[subName];
2202
+ const subPath = `${name}.${subName}`;
2203
+ const localSubPath = `${localName || name}.${subName}`;
2204
+ const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
2205
+ const label2 = subField.label || subName;
2206
+ return /* @__PURE__ */ jsx20(
2207
+ NestedFieldProvider,
2167
2208
  {
2168
- name: subFieldName,
2169
- label: subField.label || fieldName,
2170
- id: `${id}_${fieldName}`,
2171
- readOnly: subReadOnly,
2172
- field: subField,
2173
- value: data[fieldName],
2174
- onChange: (val, ui) => {
2175
- onChange(
2176
- __spreadProps(__spreadValues({}, data), {
2177
- [fieldName]: val
2209
+ name: localName || id,
2210
+ subName,
2211
+ readOnlyFields,
2212
+ children: /* @__PURE__ */ jsx20(
2213
+ AutoFieldPrivate,
2214
+ {
2215
+ name: subPath,
2216
+ label: subPath,
2217
+ id: `${id}_${subName}`,
2218
+ readOnly: subReadOnly,
2219
+ field: __spreadProps(__spreadValues({}, subField), {
2220
+ label: label2
2221
+ // May be used by custom fields
2178
2222
  }),
2179
- ui
2180
- );
2181
- }
2223
+ value: data[subName],
2224
+ onChange: (val, ui) => {
2225
+ onChange(
2226
+ __spreadProps(__spreadValues({}, data), {
2227
+ [subName]: val
2228
+ }),
2229
+ ui
2230
+ );
2231
+ }
2232
+ }
2233
+ )
2182
2234
  },
2183
- subFieldName
2235
+ subPath
2184
2236
  );
2185
2237
  }) }) })
2186
2238
  }
@@ -2206,7 +2258,7 @@ var useSafeId = () => {
2206
2258
  };
2207
2259
 
2208
2260
  // components/AutoField/index.tsx
2209
- import { Fragment as Fragment8, jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
2261
+ import { Fragment as Fragment8, jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
2210
2262
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2211
2263
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2212
2264
  var FieldLabel = ({
@@ -2220,14 +2272,14 @@ var FieldLabel = ({
2220
2272
  const El = el;
2221
2273
  return /* @__PURE__ */ jsxs9(El, { className, children: [
2222
2274
  /* @__PURE__ */ jsxs9("div", { className: getClassName15("label"), children: [
2223
- icon ? /* @__PURE__ */ jsx20("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx20(Fragment8, {}),
2275
+ icon ? /* @__PURE__ */ jsx21("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx21(Fragment8, {}),
2224
2276
  label,
2225
- readOnly && /* @__PURE__ */ jsx20("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx20(Lock, { size: "12" }) })
2277
+ readOnly && /* @__PURE__ */ jsx21("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx21(Lock, { size: "12" }) })
2226
2278
  ] }),
2227
2279
  children
2228
2280
  ] });
2229
2281
  };
2230
- var FieldLabelInternal2 = ({
2282
+ var FieldLabelInternal = ({
2231
2283
  children,
2232
2284
  icon,
2233
2285
  label,
@@ -2235,14 +2287,14 @@ var FieldLabelInternal2 = ({
2235
2287
  readOnly
2236
2288
  }) => {
2237
2289
  const { overrides } = useAppContext();
2238
- const Wrapper = useMemo4(
2290
+ const Wrapper = useMemo5(
2239
2291
  () => overrides.fieldLabel || FieldLabel,
2240
2292
  [overrides]
2241
2293
  );
2242
2294
  if (!label) {
2243
- return /* @__PURE__ */ jsx20(Fragment8, { children });
2295
+ return /* @__PURE__ */ jsx21(Fragment8, { children });
2244
2296
  }
2245
- return /* @__PURE__ */ jsx20(
2297
+ return /* @__PURE__ */ jsx21(
2246
2298
  Wrapper,
2247
2299
  {
2248
2300
  label,
@@ -2256,8 +2308,9 @@ var FieldLabelInternal2 = ({
2256
2308
  };
2257
2309
  function AutoFieldInternal(props) {
2258
2310
  var _a, _b, _c, _d, _e, _f, _g, _h;
2259
- const { dispatch, overrides } = useAppContext();
2260
- const { id, Label = FieldLabelInternal2 } = props;
2311
+ const { dispatch, overrides, selectedItem } = useAppContext();
2312
+ const nestedFieldContext = useContext3(NestedFieldContext);
2313
+ const { id, Label = FieldLabelInternal } = props;
2261
2314
  const field = props.field;
2262
2315
  const label = field.label;
2263
2316
  const defaultId = useSafeId();
@@ -2317,20 +2370,29 @@ function AutoFieldInternal(props) {
2317
2370
  return null;
2318
2371
  }
2319
2372
  const CustomField = field.render;
2320
- return /* @__PURE__ */ jsx20("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx20("div", { className: getClassName15(), children: /* @__PURE__ */ jsx20(CustomField, __spreadValues({}, mergedProps)) }) });
2373
+ return /* @__PURE__ */ jsx21("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx21("div", { className: getClassName15(), children: /* @__PURE__ */ jsx21(CustomField, __spreadValues({}, mergedProps)) }) });
2321
2374
  }
2322
2375
  const children = defaultFields[field.type](mergedProps);
2323
2376
  const Render2 = render[field.type];
2324
- return /* @__PURE__ */ jsx20(
2325
- "div",
2377
+ return /* @__PURE__ */ jsx21(
2378
+ NestedFieldContext.Provider,
2326
2379
  {
2327
- className: getClassNameWrapper(),
2328
- onFocus,
2329
- onBlur,
2330
- onClick: (e) => {
2331
- e.stopPropagation();
2380
+ value: {
2381
+ readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
2382
+ localName: nestedFieldContext.localName
2332
2383
  },
2333
- children: /* @__PURE__ */ jsx20(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2384
+ children: /* @__PURE__ */ jsx21(
2385
+ "div",
2386
+ {
2387
+ className: getClassNameWrapper(),
2388
+ onFocus,
2389
+ onBlur,
2390
+ onClick: (e) => {
2391
+ e.stopPropagation();
2392
+ },
2393
+ children: /* @__PURE__ */ jsx21(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2394
+ }
2395
+ )
2334
2396
  }
2335
2397
  );
2336
2398
  }
@@ -2358,11 +2420,11 @@ function AutoFieldPrivate(props) {
2358
2420
  value: localValue,
2359
2421
  onChange: onChangeLocal
2360
2422
  };
2361
- return /* @__PURE__ */ jsx20(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2423
+ return /* @__PURE__ */ jsx21(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2362
2424
  }
2363
2425
  function AutoField(props) {
2364
- const DefaultLabel = useMemo4(() => {
2365
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx20(
2426
+ const DefaultLabel = useMemo5(() => {
2427
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx21(
2366
2428
  "div",
2367
2429
  __spreadProps(__spreadValues({}, labelProps), {
2368
2430
  className: getClassName15({ readOnly: props.readOnly })
@@ -2370,7 +2432,7 @@ function AutoField(props) {
2370
2432
  );
2371
2433
  return DefaultLabel2;
2372
2434
  }, [props.readOnly]);
2373
- return /* @__PURE__ */ jsx20(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2435
+ return /* @__PURE__ */ jsx21(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2374
2436
  }
2375
2437
 
2376
2438
  // components/Drawer/index.tsx
@@ -2382,14 +2444,14 @@ var styles_module_default10 = { "Drawer": "_Drawer_1oa7v_1", "DrawerItem--disabl
2382
2444
 
2383
2445
  // components/Drawer/index.tsx
2384
2446
  import {
2385
- createContext as createContext2,
2386
- useContext as useContext2,
2387
- useMemo as useMemo5
2447
+ createContext as createContext3,
2448
+ useContext as useContext4,
2449
+ useMemo as useMemo6
2388
2450
  } from "react";
2389
- import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
2451
+ import { jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
2390
2452
  var getClassName16 = get_class_name_factory_default("Drawer", styles_module_default10);
2391
2453
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
2392
- var drawerContext = createContext2({
2454
+ var drawerContext = createContext3({
2393
2455
  droppableId: ""
2394
2456
  });
2395
2457
  var DrawerDraggable = ({
@@ -2398,7 +2460,7 @@ var DrawerDraggable = ({
2398
2460
  index,
2399
2461
  isDragDisabled
2400
2462
  }) => {
2401
- return /* @__PURE__ */ jsx21(
2463
+ return /* @__PURE__ */ jsx22(
2402
2464
  Draggable,
2403
2465
  {
2404
2466
  id,
@@ -2420,21 +2482,21 @@ var DrawerItem = ({
2420
2482
  index,
2421
2483
  isDragDisabled
2422
2484
  }) => {
2423
- const ctx = useContext2(drawerContext);
2485
+ const ctx = useContext4(drawerContext);
2424
2486
  const resolvedId = `${ctx.droppableId}::${id || name}`;
2425
- const CustomInner = useMemo5(
2426
- () => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ jsx21("div", { className: getClassNameItem2("default"), children: children2 })),
2487
+ const CustomInner = useMemo6(
2488
+ () => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ jsx22("div", { className: getClassNameItem2("default"), children: children2 })),
2427
2489
  [children]
2428
2490
  );
2429
- return /* @__PURE__ */ jsx21(
2491
+ return /* @__PURE__ */ jsx22(
2430
2492
  DrawerDraggable,
2431
2493
  {
2432
2494
  id: resolvedId,
2433
2495
  index,
2434
2496
  isDragDisabled,
2435
- children: /* @__PURE__ */ jsx21(CustomInner, { name, children: /* @__PURE__ */ jsx21("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs10("div", { className: getClassNameItem2("draggable"), children: [
2436
- /* @__PURE__ */ jsx21("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
2437
- /* @__PURE__ */ jsx21("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx21(DragIcon, { isDragDisabled }) })
2497
+ children: /* @__PURE__ */ jsx22(CustomInner, { name, children: /* @__PURE__ */ jsx22("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs10("div", { className: getClassNameItem2("draggable"), children: [
2498
+ /* @__PURE__ */ jsx22("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
2499
+ /* @__PURE__ */ jsx22("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx22(DragIcon, { isDragDisabled }) })
2438
2500
  ] }) }) })
2439
2501
  }
2440
2502
  );
@@ -2445,7 +2507,7 @@ var Drawer = ({
2445
2507
  direction = "vertical"
2446
2508
  }) => {
2447
2509
  const droppableId = `component-list:${_droppableId}`;
2448
- return /* @__PURE__ */ jsx21(drawerContext.Provider, { value: { droppableId }, children: /* @__PURE__ */ jsx21(Droppable, { droppableId, isDropDisabled: true, direction, children: (provided, snapshot) => /* @__PURE__ */ jsxs10(
2510
+ return /* @__PURE__ */ jsx22(drawerContext.Provider, { value: { droppableId }, children: /* @__PURE__ */ jsx22(Droppable, { droppableId, isDropDisabled: true, direction, children: (provided, snapshot) => /* @__PURE__ */ jsxs10(
2449
2511
  "div",
2450
2512
  __spreadProps(__spreadValues({}, provided.droppableProps), {
2451
2513
  ref: provided.innerRef,
@@ -2454,7 +2516,7 @@ var Drawer = ({
2454
2516
  }),
2455
2517
  children: [
2456
2518
  children,
2457
- /* @__PURE__ */ jsx21("span", { style: { display: "none" }, children: provided.placeholder })
2519
+ /* @__PURE__ */ jsx22("span", { style: { display: "none" }, children: provided.placeholder })
2458
2520
  ]
2459
2521
  })
2460
2522
  ) }) });
@@ -2463,13 +2525,13 @@ Drawer.Item = DrawerItem;
2463
2525
 
2464
2526
  // components/DropZone/index.tsx
2465
2527
  init_react_import();
2466
- import { useContext as useContext3, useEffect as useEffect12 } from "react";
2528
+ import { useContext as useContext5, useEffect as useEffect12 } from "react";
2467
2529
 
2468
2530
  // components/DraggableComponent/index.tsx
2469
2531
  init_react_import();
2470
2532
  import {
2471
2533
  useEffect as useEffect11,
2472
- useMemo as useMemo6,
2534
+ useMemo as useMemo7,
2473
2535
  useState as useState12
2474
2536
  } from "react";
2475
2537
  import { Draggable as Draggable2 } from "@measured/dnd";
@@ -2517,7 +2579,7 @@ var isIos = () => [
2517
2579
  navigator.userAgent.includes("Mac") && "ontouchend" in document;
2518
2580
 
2519
2581
  // components/DraggableComponent/index.tsx
2520
- import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
2582
+ import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
2521
2583
  var getClassName17 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
2522
2584
  var space = 8;
2523
2585
  var actionsOverlayTop = space * 6.5;
@@ -2526,7 +2588,7 @@ var actionsRight = space;
2526
2588
  var DefaultActionBar = ({
2527
2589
  label,
2528
2590
  children
2529
- }) => /* @__PURE__ */ jsx22(ActionBar, { label, children: /* @__PURE__ */ jsx22(ActionBar.Group, { children }) });
2591
+ }) => /* @__PURE__ */ jsx23(ActionBar, { label, children: /* @__PURE__ */ jsx23(ActionBar.Group, { children }) });
2530
2592
  var DraggableComponent = ({
2531
2593
  children,
2532
2594
  id,
@@ -2559,14 +2621,14 @@ var DraggableComponent = ({
2559
2621
  setDisableSecondaryAnimation(true);
2560
2622
  }
2561
2623
  }, []);
2562
- const CustomActionBar = useMemo6(
2624
+ const CustomActionBar = useMemo7(
2563
2625
  () => overrides.actionBar || DefaultActionBar,
2564
2626
  [overrides.actionBar]
2565
2627
  );
2566
2628
  const permissions = getPermissions({
2567
2629
  item: selectedItem
2568
2630
  });
2569
- return /* @__PURE__ */ jsx22(
2631
+ return /* @__PURE__ */ jsx23(
2570
2632
  El,
2571
2633
  {
2572
2634
  draggableId: id,
@@ -2596,15 +2658,15 @@ var DraggableComponent = ({
2596
2658
  onClick,
2597
2659
  children: [
2598
2660
  debug,
2599
- isLoading && /* @__PURE__ */ jsx22("div", { className: getClassName17("loadingOverlay"), children: /* @__PURE__ */ jsx22(Loader, {}) }),
2600
- isSelected && /* @__PURE__ */ jsx22(
2661
+ isLoading && /* @__PURE__ */ jsx23("div", { className: getClassName17("loadingOverlay"), children: /* @__PURE__ */ jsx23(Loader, {}) }),
2662
+ isSelected && /* @__PURE__ */ jsx23(
2601
2663
  "div",
2602
2664
  {
2603
2665
  className: getClassName17("actionsOverlay"),
2604
2666
  style: {
2605
2667
  top: actionsOverlayTop / zoomConfig.zoom
2606
2668
  },
2607
- children: /* @__PURE__ */ jsx22(
2669
+ children: /* @__PURE__ */ jsx23(
2608
2670
  "div",
2609
2671
  {
2610
2672
  className: getClassName17("actions"),
@@ -2614,15 +2676,15 @@ var DraggableComponent = ({
2614
2676
  right: actionsRight / zoomConfig.zoom
2615
2677
  },
2616
2678
  children: /* @__PURE__ */ jsxs11(CustomActionBar, { label, children: [
2617
- permissions.duplicate && /* @__PURE__ */ jsx22(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx22(Copy, { size: 16 }) }),
2618
- permissions.delete && /* @__PURE__ */ jsx22(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx22(Trash, { size: 16 }) })
2679
+ permissions.duplicate && /* @__PURE__ */ jsx23(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx23(Copy, { size: 16 }) }),
2680
+ permissions.delete && /* @__PURE__ */ jsx23(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx23(Trash, { size: 16 }) })
2619
2681
  ] })
2620
2682
  }
2621
2683
  )
2622
2684
  }
2623
2685
  ),
2624
- /* @__PURE__ */ jsx22("div", { className: getClassName17("overlay") }),
2625
- /* @__PURE__ */ jsx22("div", { className: getClassName17("contents"), children })
2686
+ /* @__PURE__ */ jsx23("div", { className: getClassName17("overlay") }),
2687
+ /* @__PURE__ */ jsx23("div", { className: getClassName17("contents"), children })
2626
2688
  ]
2627
2689
  })
2628
2690
  )
@@ -2638,7 +2700,7 @@ var styles_module_default12 = { "DropZone": "_DropZone_djoti_1", "DropZone-conte
2638
2700
  // components/DropZone/context.tsx
2639
2701
  init_react_import();
2640
2702
  import {
2641
- createContext as createContext3,
2703
+ createContext as createContext4,
2642
2704
  useCallback as useCallback6,
2643
2705
  useState as useState13
2644
2706
  } from "react";
@@ -2657,8 +2719,8 @@ var getZoneId = (zoneCompound) => {
2657
2719
  };
2658
2720
 
2659
2721
  // components/DropZone/context.tsx
2660
- import { Fragment as Fragment9, jsx as jsx23 } from "react/jsx-runtime";
2661
- var dropZoneContext = createContext3(null);
2722
+ import { Fragment as Fragment9, jsx as jsx24 } from "react/jsx-runtime";
2723
+ var dropZoneContext = createContext4(null);
2662
2724
  var DropZoneProvider = ({
2663
2725
  children,
2664
2726
  value
@@ -2735,7 +2797,7 @@ var DropZoneProvider = ({
2735
2797
  [value, setPathData]
2736
2798
  );
2737
2799
  const [zoneWillDrag, setZoneWillDrag] = useState13("");
2738
- return /* @__PURE__ */ jsx23(Fragment9, { children: value && /* @__PURE__ */ jsx23(
2800
+ return /* @__PURE__ */ jsx24(Fragment9, { children: value && /* @__PURE__ */ jsx24(
2739
2801
  dropZoneContext.Provider,
2740
2802
  {
2741
2803
  value: __spreadValues({
@@ -2761,12 +2823,12 @@ var DropZoneProvider = ({
2761
2823
  };
2762
2824
 
2763
2825
  // components/DropZone/index.tsx
2764
- import { Fragment as Fragment10, jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
2826
+ import { Fragment as Fragment10, jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
2765
2827
  var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
2766
2828
  function DropZoneEdit({ zone, allow, disallow, style }) {
2767
2829
  var _a;
2768
2830
  const appContext2 = useAppContext();
2769
- const ctx = useContext3(dropZoneContext);
2831
+ const ctx = useContext5(dropZoneContext);
2770
2832
  const {
2771
2833
  // These all need setting via context
2772
2834
  data,
@@ -2816,7 +2878,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
2816
2878
  const draggingOverArea = userIsDragging && zoneArea === draggedSourceArea;
2817
2879
  const draggingNewComponent = draggedSourceId == null ? void 0 : draggedSourceId.startsWith("component-list");
2818
2880
  if (!(ctx == null ? void 0 : ctx.config) || !ctx.setHoveringArea || !ctx.setHoveringZone || !ctx.setHoveringComponent || !ctx.setItemSelector || !ctx.registerPath || !ctx.dispatch) {
2819
- return /* @__PURE__ */ jsx24("div", { children: "DropZone requires context to work." });
2881
+ return /* @__PURE__ */ jsx25("div", { children: "DropZone requires context to work." });
2820
2882
  }
2821
2883
  const {
2822
2884
  hoveringArea = "root",
@@ -2857,7 +2919,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
2857
2919
  }
2858
2920
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
2859
2921
  const isAreaSelected = selectedItem && zoneArea === selectedItem.props.id;
2860
- return /* @__PURE__ */ jsx24(
2922
+ return /* @__PURE__ */ jsx25(
2861
2923
  "div",
2862
2924
  {
2863
2925
  className: getClassName18({
@@ -2874,7 +2936,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
2874
2936
  onMouseUp: () => {
2875
2937
  setZoneWillDrag("");
2876
2938
  },
2877
- children: /* @__PURE__ */ jsx24(
2939
+ children: /* @__PURE__ */ jsx25(
2878
2940
  Droppable,
2879
2941
  {
2880
2942
  droppableId: zoneCompound,
@@ -2929,13 +2991,13 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
2929
2991
  className: getClassName18("item"),
2930
2992
  style: { zIndex: isDragging ? 1 : void 0 },
2931
2993
  children: [
2932
- /* @__PURE__ */ jsx24(
2994
+ /* @__PURE__ */ jsx25(
2933
2995
  DropZoneProvider,
2934
2996
  {
2935
2997
  value: __spreadProps(__spreadValues({}, ctx), {
2936
2998
  areaId: componentId
2937
2999
  }),
2938
- children: /* @__PURE__ */ jsx24(
3000
+ children: /* @__PURE__ */ jsx25(
2939
3001
  DraggableComponent,
2940
3002
  {
2941
3003
  label,
@@ -3003,12 +3065,12 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
3003
3065
  style: {
3004
3066
  pointerEvents: userIsDragging && draggingNewComponent ? "all" : void 0
3005
3067
  },
3006
- children: /* @__PURE__ */ jsx24("div", { className: getClassName18("renderWrapper"), children: /* @__PURE__ */ jsx24(Render2, __spreadValues({}, defaultedProps)) })
3068
+ children: /* @__PURE__ */ jsx25("div", { className: getClassName18("renderWrapper"), children: /* @__PURE__ */ jsx25(Render2, __spreadValues({}, defaultedProps)) })
3007
3069
  }
3008
3070
  )
3009
3071
  }
3010
3072
  ),
3011
- userIsDragging && /* @__PURE__ */ jsx24(
3073
+ userIsDragging && /* @__PURE__ */ jsx25(
3012
3074
  "div",
3013
3075
  {
3014
3076
  className: getClassName18("hitbox"),
@@ -3025,7 +3087,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
3025
3087
  );
3026
3088
  }),
3027
3089
  provided == null ? void 0 : provided.placeholder,
3028
- (snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ jsx24(
3090
+ (snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ jsx25(
3029
3091
  "div",
3030
3092
  {
3031
3093
  "data-puck-placeholder": true,
@@ -3046,7 +3108,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
3046
3108
  );
3047
3109
  }
3048
3110
  function DropZoneRender({ zone }) {
3049
- const ctx = useContext3(dropZoneContext);
3111
+ const ctx = useContext5(dropZoneContext);
3050
3112
  const { data, areaId = "root", config } = ctx || {};
3051
3113
  let zoneCompound = rootDroppableId;
3052
3114
  let content = (data == null ? void 0 : data.content) || [];
@@ -3057,14 +3119,14 @@ function DropZoneRender({ zone }) {
3057
3119
  zoneCompound = `${areaId}:${zone}`;
3058
3120
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3059
3121
  }
3060
- return /* @__PURE__ */ jsx24(Fragment10, { children: content.map((item) => {
3122
+ return /* @__PURE__ */ jsx25(Fragment10, { children: content.map((item) => {
3061
3123
  const Component = config.components[item.type];
3062
3124
  if (Component) {
3063
- return /* @__PURE__ */ jsx24(
3125
+ return /* @__PURE__ */ jsx25(
3064
3126
  DropZoneProvider,
3065
3127
  {
3066
3128
  value: { data, config, areaId: item.props.id },
3067
- children: /* @__PURE__ */ jsx24(
3129
+ children: /* @__PURE__ */ jsx25(
3068
3130
  Component.render,
3069
3131
  __spreadProps(__spreadValues({}, item.props), {
3070
3132
  puck: { renderDropZone: DropZone }
@@ -3078,11 +3140,11 @@ function DropZoneRender({ zone }) {
3078
3140
  }) });
3079
3141
  }
3080
3142
  function DropZone(props) {
3081
- const ctx = useContext3(dropZoneContext);
3143
+ const ctx = useContext5(dropZoneContext);
3082
3144
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3083
- return /* @__PURE__ */ jsx24(DropZoneEdit, __spreadValues({}, props));
3145
+ return /* @__PURE__ */ jsx25(DropZoneEdit, __spreadValues({}, props));
3084
3146
  }
3085
- return /* @__PURE__ */ jsx24(DropZoneRender, __spreadValues({}, props));
3147
+ return /* @__PURE__ */ jsx25(DropZoneRender, __spreadValues({}, props));
3086
3148
  }
3087
3149
 
3088
3150
  // components/Puck/index.tsx
@@ -3090,7 +3152,7 @@ init_react_import();
3090
3152
  import {
3091
3153
  useCallback as useCallback11,
3092
3154
  useEffect as useEffect18,
3093
- useMemo as useMemo15,
3155
+ useMemo as useMemo16,
3094
3156
  useReducer,
3095
3157
  useState as useState21
3096
3158
  } from "react";
@@ -3102,11 +3164,12 @@ import { useState as useState14 } from "react";
3102
3164
  // lib/get-frame.ts
3103
3165
  init_react_import();
3104
3166
  var getFrame = () => {
3105
- let frame = document.querySelector("#preview-frame");
3106
- if ((frame == null ? void 0 : frame.tagName) === "IFRAME") {
3107
- frame = frame.contentDocument;
3167
+ if (typeof window === "undefined") return;
3168
+ let frameEl = document.querySelector("#preview-frame");
3169
+ if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
3170
+ return frameEl.contentDocument || document;
3108
3171
  }
3109
- return frame;
3172
+ return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3110
3173
  };
3111
3174
 
3112
3175
  // lib/use-placeholder-style.ts
@@ -3165,7 +3228,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
3165
3228
 
3166
3229
  // lib/use-breadcrumbs.ts
3167
3230
  init_react_import();
3168
- import { useContext as useContext4, useMemo as useMemo7 } from "react";
3231
+ import { useContext as useContext6, useMemo as useMemo8 } from "react";
3169
3232
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
3170
3233
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
3171
3234
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -3215,8 +3278,8 @@ var useBreadcrumbs = (renderCount) => {
3215
3278
  state: { data },
3216
3279
  selectedItem
3217
3280
  } = useAppContext();
3218
- const dzContext = useContext4(dropZoneContext);
3219
- return useMemo7(() => {
3281
+ const dzContext = useContext6(dropZoneContext);
3282
+ return useMemo8(() => {
3220
3283
  const breadcrumbs = convertPathDataToBreadcrumbs(
3221
3284
  selectedItem,
3222
3285
  dzContext == null ? void 0 : dzContext.pathData,
@@ -3230,7 +3293,7 @@ var useBreadcrumbs = (renderCount) => {
3230
3293
  };
3231
3294
 
3232
3295
  // components/SidebarSection/index.tsx
3233
- import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
3296
+ import { jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
3234
3297
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
3235
3298
  var SidebarSection = ({
3236
3299
  children,
@@ -3249,9 +3312,9 @@ var SidebarSection = ({
3249
3312
  className: getClassName19({ noBorderTop, noPadding }),
3250
3313
  style: { background },
3251
3314
  children: [
3252
- /* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs13("div", { className: getClassName19("breadcrumbs"), children: [
3315
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs13("div", { className: getClassName19("breadcrumbs"), children: [
3253
3316
  showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs13("div", { className: getClassName19("breadcrumb"), children: [
3254
- /* @__PURE__ */ jsx25(
3317
+ /* @__PURE__ */ jsx26(
3255
3318
  "button",
3256
3319
  {
3257
3320
  type: "button",
@@ -3260,12 +3323,12 @@ var SidebarSection = ({
3260
3323
  children: breadcrumb.label
3261
3324
  }
3262
3325
  ),
3263
- /* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
3326
+ /* @__PURE__ */ jsx26(ChevronRight, { size: 16 })
3264
3327
  ] }, i)) : null,
3265
- /* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
3328
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx26(Heading, { rank: "2", size: "xs", children: title }) })
3266
3329
  ] }) }),
3267
- /* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
3268
- isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
3330
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("content"), children }),
3331
+ isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26(Loader, { size: 32 }) })
3269
3332
  ]
3270
3333
  }
3271
3334
  );
@@ -3468,6 +3531,9 @@ function reduceData(data, action, config) {
3468
3531
  });
3469
3532
  }
3470
3533
  if (action.type === "move") {
3534
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
3535
+ return data;
3536
+ }
3471
3537
  const newData = setupZone(
3472
3538
  setupZone(data, action.sourceZone),
3473
3539
  action.destinationZone
@@ -3646,7 +3712,7 @@ init_react_import();
3646
3712
  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" };
3647
3713
 
3648
3714
  // components/MenuBar/index.tsx
3649
- import { Fragment as Fragment11, jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
3715
+ import { Fragment as Fragment11, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
3650
3716
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
3651
3717
  function MenuBar({
3652
3718
  appState,
@@ -3660,7 +3726,7 @@ function MenuBar({
3660
3726
  history: { back, forward, historyStore }
3661
3727
  } = useAppContext();
3662
3728
  const { hasFuture = false, hasPast = false } = historyStore || {};
3663
- return /* @__PURE__ */ jsx26(
3729
+ return /* @__PURE__ */ jsx27(
3664
3730
  "div",
3665
3731
  {
3666
3732
  className: getClassName20({ menuOpen }),
@@ -3676,10 +3742,10 @@ function MenuBar({
3676
3742
  },
3677
3743
  children: /* @__PURE__ */ jsxs14("div", { className: getClassName20("inner"), children: [
3678
3744
  /* @__PURE__ */ jsxs14("div", { className: getClassName20("history"), children: [
3679
- /* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
3680
- /* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
3745
+ /* @__PURE__ */ jsx27(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx27(Undo2, { size: 21 }) }),
3746
+ /* @__PURE__ */ jsx27(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx27(Redo2, { size: 21 }) })
3681
3747
  ] }),
3682
- /* @__PURE__ */ jsx26(Fragment11, { children: renderHeaderActions && renderHeaderActions({
3748
+ /* @__PURE__ */ jsx27(Fragment11, { children: renderHeaderActions && renderHeaderActions({
3683
3749
  state: appState,
3684
3750
  dispatch
3685
3751
  }) })
@@ -3700,15 +3766,15 @@ init_react_import();
3700
3766
  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" };
3701
3767
 
3702
3768
  // components/Puck/components/Fields/index.tsx
3703
- import { useCallback as useCallback7, useEffect as useEffect13, useMemo as useMemo8, useState as useState15 } from "react";
3769
+ import { useCallback as useCallback7, useEffect as useEffect13, useMemo as useMemo9, useState as useState15 } from "react";
3704
3770
 
3705
3771
  // lib/use-parent.ts
3706
3772
  init_react_import();
3707
- import { useContext as useContext5 } from "react";
3773
+ import { useContext as useContext7 } from "react";
3708
3774
  var useParent = (itemSelector) => {
3709
3775
  var _a;
3710
3776
  const { selectedItem, state } = useAppContext();
3711
- const { pathData } = useContext5(dropZoneContext) || {};
3777
+ const { pathData } = useContext7(dropZoneContext) || {};
3712
3778
  const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
3713
3779
  const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
3714
3780
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
@@ -3717,7 +3783,7 @@ var useParent = (itemSelector) => {
3717
3783
  };
3718
3784
 
3719
3785
  // components/Puck/components/Fields/index.tsx
3720
- import { Fragment as Fragment12, jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
3786
+ import { Fragment as Fragment12, jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
3721
3787
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
3722
3788
  var defaultPageFields = {
3723
3789
  title: { type: "text" }
@@ -3725,7 +3791,7 @@ var defaultPageFields = {
3725
3791
  var DefaultFields = ({
3726
3792
  children
3727
3793
  }) => {
3728
- return /* @__PURE__ */ jsx27(Fragment12, { children });
3794
+ return /* @__PURE__ */ jsx28(Fragment12, { children });
3729
3795
  };
3730
3796
  var useResolvedFields = () => {
3731
3797
  var _a, _b;
@@ -3734,7 +3800,7 @@ var useResolvedFields = () => {
3734
3800
  const { data } = state;
3735
3801
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
3736
3802
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
3737
- const defaultFields = useMemo8(
3803
+ const defaultFields = useMemo9(
3738
3804
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
3739
3805
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
3740
3806
  );
@@ -3783,19 +3849,33 @@ var useResolvedFields = () => {
3783
3849
  lastData
3784
3850
  });
3785
3851
  }),
3786
- [data, config, componentData, selectedItem, resolvedFields, state]
3852
+ [data, config, componentData, selectedItem, resolvedFields, state, parent]
3787
3853
  );
3854
+ const [hasParent, setHasParent] = useState15(false);
3788
3855
  useEffect13(() => {
3789
- if (hasResolver) {
3790
- setFieldsLoading(true);
3791
- resolveFields(defaultFields).then((fields) => {
3792
- setResolvedFields(fields || {});
3793
- setFieldsLoading(false);
3794
- });
3795
- } else {
3796
- setResolvedFields(defaultFields);
3856
+ setHasParent(!!parent);
3857
+ }, [parent]);
3858
+ useEffect13(() => {
3859
+ var _a2;
3860
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || hasParent) {
3861
+ if (hasResolver) {
3862
+ setFieldsLoading(true);
3863
+ resolveFields(defaultFields).then((fields) => {
3864
+ setResolvedFields(fields || {});
3865
+ setFieldsLoading(false);
3866
+ });
3867
+ } else {
3868
+ setResolvedFields(defaultFields);
3869
+ }
3797
3870
  }
3798
- }, [data, defaultFields, selectedItem, hasResolver]);
3871
+ }, [
3872
+ data,
3873
+ defaultFields,
3874
+ state.ui.itemSelector,
3875
+ selectedItem,
3876
+ hasResolver,
3877
+ hasParent
3878
+ ]);
3799
3879
  return [resolvedFields, fieldsLoading];
3800
3880
  };
3801
3881
  var Fields = () => {
@@ -3816,7 +3896,7 @@ var Fields = () => {
3816
3896
  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;
3817
3897
  const isLoading = fieldsResolving || componentResolving;
3818
3898
  const rootProps = data.root.props || data.root;
3819
- const Wrapper = useMemo8(() => overrides.fields || DefaultFields, [overrides]);
3899
+ const Wrapper = useMemo9(() => overrides.fields || DefaultFields, [overrides]);
3820
3900
  return /* @__PURE__ */ jsxs15(
3821
3901
  "form",
3822
3902
  {
@@ -3825,7 +3905,7 @@ var Fields = () => {
3825
3905
  e.preventDefault();
3826
3906
  },
3827
3907
  children: [
3828
- /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
3908
+ /* @__PURE__ */ jsx28(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
3829
3909
  const field = fields[fieldName];
3830
3910
  if (!(field == null ? void 0 : field.type)) return null;
3831
3911
  const onChange = (value, updatedUi) => {
@@ -3896,7 +3976,7 @@ var Fields = () => {
3896
3976
  item: selectedItem
3897
3977
  });
3898
3978
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
3899
- return /* @__PURE__ */ jsx27(
3979
+ return /* @__PURE__ */ jsx28(
3900
3980
  AutoFieldPrivate,
3901
3981
  {
3902
3982
  field,
@@ -3914,7 +3994,7 @@ var Fields = () => {
3914
3994
  root: true
3915
3995
  });
3916
3996
  const id = `root_${field.type}_${fieldName}`;
3917
- return /* @__PURE__ */ jsx27(
3997
+ return /* @__PURE__ */ jsx28(
3918
3998
  AutoFieldPrivate,
3919
3999
  {
3920
4000
  field,
@@ -3928,7 +4008,7 @@ var Fields = () => {
3928
4008
  );
3929
4009
  }
3930
4010
  }) }),
3931
- isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
4011
+ isLoading && /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx28(Loader, { size: 16 }) }) })
3932
4012
  ]
3933
4013
  }
3934
4014
  );
@@ -3949,7 +4029,7 @@ init_react_import();
3949
4029
  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" };
3950
4030
 
3951
4031
  // components/ComponentList/index.tsx
3952
- import { jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
4032
+ import { jsx as jsx29, jsxs as jsxs16 } from "react/jsx-runtime";
3953
4033
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
3954
4034
  var ComponentListItem = ({
3955
4035
  name,
@@ -3960,7 +4040,7 @@ var ComponentListItem = ({
3960
4040
  const canInsert = getPermissions({
3961
4041
  type: name
3962
4042
  }).insert;
3963
- return /* @__PURE__ */ jsx28(
4043
+ return /* @__PURE__ */ jsx29(
3964
4044
  Drawer.Item,
3965
4045
  {
3966
4046
  label,
@@ -3993,14 +4073,14 @@ var ComponentList = ({
3993
4073
  }),
3994
4074
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
3995
4075
  children: [
3996
- /* @__PURE__ */ jsx28("div", { children: title }),
3997
- /* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
4076
+ /* @__PURE__ */ jsx29("div", { children: title }),
4077
+ /* @__PURE__ */ jsx29("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx29(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx29(ChevronDown, { size: 12 }) })
3998
4078
  ]
3999
4079
  }
4000
4080
  ),
4001
- /* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { droppableId: title, children: children || Object.keys(config.components).map((componentKey, i) => {
4081
+ /* @__PURE__ */ jsx29("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx29(Drawer, { droppableId: title, children: children || Object.keys(config.components).map((componentKey, i) => {
4002
4082
  var _a;
4003
- return /* @__PURE__ */ jsx28(
4083
+ return /* @__PURE__ */ jsx29(
4004
4084
  ComponentListItem,
4005
4085
  {
4006
4086
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -4015,7 +4095,7 @@ var ComponentList = ({
4015
4095
  ComponentList.Item = ComponentListItem;
4016
4096
 
4017
4097
  // lib/use-component-list.tsx
4018
- import { jsx as jsx29 } from "react/jsx-runtime";
4098
+ import { jsx as jsx30 } from "react/jsx-runtime";
4019
4099
  var useComponentList = (config, ui) => {
4020
4100
  const [componentList, setComponentList] = useState16();
4021
4101
  useEffect14(() => {
@@ -4028,7 +4108,7 @@ var useComponentList = (config, ui) => {
4028
4108
  if (category.visible === false || !category.components) {
4029
4109
  return null;
4030
4110
  }
4031
- return /* @__PURE__ */ jsx29(
4111
+ return /* @__PURE__ */ jsx30(
4032
4112
  ComponentList,
4033
4113
  {
4034
4114
  id: categoryKey,
@@ -4037,7 +4117,7 @@ var useComponentList = (config, ui) => {
4037
4117
  var _a2;
4038
4118
  matchedComponents.push(componentName);
4039
4119
  const componentConf = config.components[componentName] || {};
4040
- return /* @__PURE__ */ jsx29(
4120
+ return /* @__PURE__ */ jsx30(
4041
4121
  ComponentList.Item,
4042
4122
  {
4043
4123
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -4057,7 +4137,7 @@ var useComponentList = (config, ui) => {
4057
4137
  );
4058
4138
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
4059
4139
  _componentList.push(
4060
- /* @__PURE__ */ jsx29(
4140
+ /* @__PURE__ */ jsx30(
4061
4141
  ComponentList,
4062
4142
  {
4063
4143
  id: "other",
@@ -4065,7 +4145,7 @@ var useComponentList = (config, ui) => {
4065
4145
  children: remainingComponents.map((componentName, i) => {
4066
4146
  var _a2;
4067
4147
  const componentConf = config.components[componentName] || {};
4068
- return /* @__PURE__ */ jsx29(
4148
+ return /* @__PURE__ */ jsx30(
4069
4149
  ComponentList.Item,
4070
4150
  {
4071
4151
  name: componentName,
@@ -4087,31 +4167,31 @@ var useComponentList = (config, ui) => {
4087
4167
  };
4088
4168
 
4089
4169
  // components/Puck/components/Components/index.tsx
4090
- import { useMemo as useMemo9 } from "react";
4091
- import { jsx as jsx30 } from "react/jsx-runtime";
4170
+ import { useMemo as useMemo10 } from "react";
4171
+ import { jsx as jsx31 } from "react/jsx-runtime";
4092
4172
  var Components = () => {
4093
4173
  const { config, state, overrides } = useAppContext();
4094
4174
  const componentList = useComponentList(config, state.ui);
4095
- const Wrapper = useMemo9(() => overrides.components || "div", [overrides]);
4096
- return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
4175
+ const Wrapper = useMemo10(() => overrides.components || "div", [overrides]);
4176
+ return /* @__PURE__ */ jsx31(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx31(ComponentList, { id: "all" }) });
4097
4177
  };
4098
4178
 
4099
4179
  // components/Puck/components/Preview/index.tsx
4100
4180
  init_react_import();
4101
- import { useCallback as useCallback8, useMemo as useMemo10 } from "react";
4181
+ import { useCallback as useCallback8, useMemo as useMemo11 } from "react";
4102
4182
 
4103
4183
  // components/AutoFrame/index.tsx
4104
4184
  init_react_import();
4105
4185
  import {
4106
- createContext as createContext4,
4107
- useContext as useContext6,
4186
+ createContext as createContext5,
4187
+ useContext as useContext8,
4108
4188
  useEffect as useEffect15,
4109
- useRef as useRef3,
4189
+ useRef as useRef2,
4110
4190
  useState as useState17
4111
4191
  } from "react";
4112
4192
  import hash from "object-hash";
4113
4193
  import { createPortal as createPortal2 } from "react-dom";
4114
- import { Fragment as Fragment13, jsx as jsx31 } from "react/jsx-runtime";
4194
+ import { Fragment as Fragment13, jsx as jsx32 } from "react/jsx-runtime";
4115
4195
  var styleSelector = 'style, link[rel="stylesheet"]';
4116
4196
  var collectStyles = (doc) => {
4117
4197
  const collected = [];
@@ -4311,10 +4391,10 @@ var CopyHostStyles = ({
4311
4391
  observer.disconnect();
4312
4392
  };
4313
4393
  }, []);
4314
- return /* @__PURE__ */ jsx31(Fragment13, { children });
4394
+ return /* @__PURE__ */ jsx32(Fragment13, { children });
4315
4395
  };
4316
- var autoFrameContext = createContext4({});
4317
- var useFrame = () => useContext6(autoFrameContext);
4396
+ var autoFrameContext = createContext5({});
4397
+ var useFrame = () => useContext8(autoFrameContext);
4318
4398
  function AutoFrame(_a) {
4319
4399
  var _b = _a, {
4320
4400
  children,
@@ -4331,7 +4411,7 @@ function AutoFrame(_a) {
4331
4411
  ]);
4332
4412
  const [loaded, setLoaded] = useState17(false);
4333
4413
  const [ctx, setCtx] = useState17({});
4334
- const ref = useRef3(null);
4414
+ const ref = useRef2(null);
4335
4415
  const [mountTarget, setMountTarget] = useState17();
4336
4416
  useEffect15(() => {
4337
4417
  var _a2;
@@ -4343,7 +4423,7 @@ function AutoFrame(_a) {
4343
4423
  setMountTarget((_a2 = ref.current.contentDocument) == null ? void 0 : _a2.getElementById("frame-root"));
4344
4424
  }
4345
4425
  }, [ref, loaded]);
4346
- return /* @__PURE__ */ jsx31(
4426
+ return /* @__PURE__ */ jsx32(
4347
4427
  "iframe",
4348
4428
  __spreadProps(__spreadValues({}, props), {
4349
4429
  className,
@@ -4353,7 +4433,7 @@ function AutoFrame(_a) {
4353
4433
  onLoad: () => {
4354
4434
  setLoaded(true);
4355
4435
  },
4356
- children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal2(children, mountTarget) }) })
4436
+ children: /* @__PURE__ */ jsx32(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx32(CopyHostStyles, { debug, onStylesLoaded, children: createPortal2(children, mountTarget) }) })
4357
4437
  })
4358
4438
  );
4359
4439
  }
@@ -4365,7 +4445,7 @@ init_react_import();
4365
4445
  var styles_module_default18 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
4366
4446
 
4367
4447
  // components/Puck/components/Preview/index.tsx
4368
- import { Fragment as Fragment14, jsx as jsx32 } from "react/jsx-runtime";
4448
+ import { Fragment as Fragment14, jsx as jsx33 } from "react/jsx-runtime";
4369
4449
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
4370
4450
  var Preview = ({ id = "puck-preview" }) => {
4371
4451
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
@@ -4374,13 +4454,13 @@ var Preview = ({ id = "puck-preview" }) => {
4374
4454
  var _a, _b;
4375
4455
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
4376
4456
  id: "puck-root"
4377
- }, pageProps)) : /* @__PURE__ */ jsx32(Fragment14, { children: pageProps.children });
4457
+ }, pageProps)) : /* @__PURE__ */ jsx33(Fragment14, { children: pageProps.children });
4378
4458
  },
4379
4459
  [config.root]
4380
4460
  );
4381
- const Frame = useMemo10(() => overrides.iframe, [overrides]);
4461
+ const Frame = useMemo11(() => overrides.iframe, [overrides]);
4382
4462
  const rootProps = state.data.root.props || state.data.root;
4383
- return /* @__PURE__ */ jsx32(
4463
+ return /* @__PURE__ */ jsx33(
4384
4464
  "div",
4385
4465
  {
4386
4466
  className: getClassName23(),
@@ -4388,7 +4468,7 @@ var Preview = ({ id = "puck-preview" }) => {
4388
4468
  onClick: () => {
4389
4469
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
4390
4470
  },
4391
- children: iframe.enabled ? /* @__PURE__ */ jsx32(
4471
+ children: iframe.enabled ? /* @__PURE__ */ jsx33(
4392
4472
  AutoFrame_default,
4393
4473
  {
4394
4474
  id: "preview-frame",
@@ -4397,27 +4477,27 @@ var Preview = ({ id = "puck-preview" }) => {
4397
4477
  onStylesLoaded: () => {
4398
4478
  setStatus("READY");
4399
4479
  },
4400
- children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
4401
- const inner = /* @__PURE__ */ jsx32(
4480
+ children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
4481
+ const inner = /* @__PURE__ */ jsx33(
4402
4482
  Page,
4403
4483
  __spreadProps(__spreadValues({}, rootProps), {
4404
4484
  puck: { renderDropZone: DropZone, isEditing: true },
4405
4485
  editMode: true,
4406
- children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
4486
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
4407
4487
  })
4408
4488
  );
4409
4489
  if (Frame) {
4410
- return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
4490
+ return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
4411
4491
  }
4412
4492
  return inner;
4413
4493
  } })
4414
4494
  }
4415
- ) : /* @__PURE__ */ jsx32("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ jsx32(
4495
+ ) : /* @__PURE__ */ jsx33("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ jsx33(
4416
4496
  Page,
4417
4497
  __spreadProps(__spreadValues({}, rootProps), {
4418
4498
  puck: { renderDropZone: DropZone, isEditing: true },
4419
4499
  editMode: true,
4420
- children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
4500
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
4421
4501
  })
4422
4502
  ) })
4423
4503
  }
@@ -4467,7 +4547,7 @@ var scrollIntoView = (el) => {
4467
4547
  };
4468
4548
 
4469
4549
  // components/LayerTree/index.tsx
4470
- import { useContext as useContext7 } from "react";
4550
+ import { useContext as useContext9 } from "react";
4471
4551
 
4472
4552
  // lib/is-child-of-zone.ts
4473
4553
  init_react_import();
@@ -4481,7 +4561,7 @@ var isChildOfZone = (item, maybeChild, ctx) => {
4481
4561
  };
4482
4562
 
4483
4563
  // components/LayerTree/index.tsx
4484
- import { Fragment as Fragment15, jsx as jsx33, jsxs as jsxs17 } from "react/jsx-runtime";
4564
+ import { Fragment as Fragment15, jsx as jsx34, jsxs as jsxs17 } from "react/jsx-runtime";
4485
4565
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
4486
4566
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
4487
4567
  var LayerTree = ({
@@ -4494,15 +4574,15 @@ var LayerTree = ({
4494
4574
  label
4495
4575
  }) => {
4496
4576
  const zones = data.zones || {};
4497
- const ctx = useContext7(dropZoneContext);
4577
+ const ctx = useContext9(dropZoneContext);
4498
4578
  return /* @__PURE__ */ jsxs17(Fragment15, { children: [
4499
4579
  label && /* @__PURE__ */ jsxs17("div", { className: getClassName24("zoneTitle"), children: [
4500
- /* @__PURE__ */ jsx33("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
4580
+ /* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
4501
4581
  " ",
4502
4582
  label
4503
4583
  ] }),
4504
4584
  /* @__PURE__ */ jsxs17("ul", { className: getClassName24(), children: [
4505
- zoneContent.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName24("helper"), children: "No items" }),
4585
+ zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
4506
4586
  zoneContent.map((item, i) => {
4507
4587
  var _a;
4508
4588
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -4530,7 +4610,7 @@ var LayerTree = ({
4530
4610
  childIsSelected
4531
4611
  }),
4532
4612
  children: [
4533
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs17(
4613
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs17(
4534
4614
  "button",
4535
4615
  {
4536
4616
  type: "button",
@@ -4563,22 +4643,22 @@ var LayerTree = ({
4563
4643
  setHoveringComponent(null);
4564
4644
  },
4565
4645
  children: [
4566
- containsZone && /* @__PURE__ */ jsx33(
4646
+ containsZone && /* @__PURE__ */ jsx34(
4567
4647
  "div",
4568
4648
  {
4569
4649
  className: getClassNameLayer("chevron"),
4570
4650
  title: isSelected ? "Collapse" : "Expand",
4571
- children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
4651
+ children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
4572
4652
  }
4573
4653
  ),
4574
4654
  /* @__PURE__ */ jsxs17("div", { className: getClassNameLayer("title"), children: [
4575
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
4576
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label2 })
4655
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
4656
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
4577
4657
  ] })
4578
4658
  ]
4579
4659
  }
4580
4660
  ) }),
4581
- containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(
4661
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
4582
4662
  LayerTree,
4583
4663
  {
4584
4664
  config,
@@ -4600,8 +4680,8 @@ var LayerTree = ({
4600
4680
  };
4601
4681
 
4602
4682
  // components/Puck/components/Outline/index.tsx
4603
- import { useCallback as useCallback9, useMemo as useMemo11 } from "react";
4604
- import { Fragment as Fragment16, jsx as jsx34, jsxs as jsxs18 } from "react/jsx-runtime";
4683
+ import { useCallback as useCallback9, useMemo as useMemo12 } from "react";
4684
+ import { Fragment as Fragment16, jsx as jsx35, jsxs as jsxs18 } from "react/jsx-runtime";
4605
4685
  var Outline = () => {
4606
4686
  const { dispatch, state, overrides, config } = useAppContext();
4607
4687
  const { data, ui } = state;
@@ -4615,9 +4695,9 @@ var Outline = () => {
4615
4695
  },
4616
4696
  []
4617
4697
  );
4618
- const Wrapper = useMemo11(() => overrides.outline || "div", [overrides]);
4619
- return /* @__PURE__ */ jsx34(Wrapper, { children: /* @__PURE__ */ jsx34(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs18(Fragment16, { children: [
4620
- (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx34(
4698
+ const Wrapper = useMemo12(() => overrides.outline || "div", [overrides]);
4699
+ return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs18(Fragment16, { children: [
4700
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
4621
4701
  LayerTree,
4622
4702
  {
4623
4703
  config,
@@ -4630,7 +4710,7 @@ var Outline = () => {
4630
4710
  ),
4631
4711
  Object.entries(findZonesForArea(data, "root")).map(
4632
4712
  ([zoneKey, zone]) => {
4633
- return /* @__PURE__ */ jsx34(
4713
+ return /* @__PURE__ */ jsx35(
4634
4714
  LayerTree,
4635
4715
  {
4636
4716
  config,
@@ -4654,7 +4734,8 @@ import { useHotkeys } from "react-hotkeys-hook";
4654
4734
  function usePuckHistory({
4655
4735
  dispatch,
4656
4736
  initialAppState,
4657
- historyStore
4737
+ historyStore,
4738
+ iframeEnabled
4658
4739
  }) {
4659
4740
  const back = () => {
4660
4741
  var _a;
@@ -4672,6 +4753,16 @@ function usePuckHistory({
4672
4753
  historyStore.forward();
4673
4754
  }
4674
4755
  };
4756
+ const backIframe = () => {
4757
+ if (iframeEnabled) {
4758
+ back();
4759
+ }
4760
+ };
4761
+ const forwardIframe = () => {
4762
+ if (iframeEnabled) {
4763
+ forward();
4764
+ }
4765
+ };
4675
4766
  const setHistories = (histories) => {
4676
4767
  var _a;
4677
4768
  dispatch({
@@ -4690,9 +4781,23 @@ function usePuckHistory({
4690
4781
  historyStore.setHistoryIndex(index);
4691
4782
  }
4692
4783
  };
4784
+ const frame = getFrame();
4785
+ const resolvedFrame = typeof window !== "undefined" && frame !== document ? frame : void 0;
4693
4786
  useHotkeys("meta+z", back, { preventDefault: true });
4694
4787
  useHotkeys("meta+shift+z", forward, { preventDefault: true });
4695
4788
  useHotkeys("meta+y", forward, { preventDefault: true });
4789
+ useHotkeys("meta+z", backIframe, {
4790
+ preventDefault: true,
4791
+ document: resolvedFrame
4792
+ });
4793
+ useHotkeys("meta+shift+z", forwardIframe, {
4794
+ preventDefault: true,
4795
+ document: resolvedFrame
4796
+ });
4797
+ useHotkeys("meta+y", forwardIframe, {
4798
+ preventDefault: true,
4799
+ document: resolvedFrame
4800
+ });
4696
4801
  return {
4697
4802
  back,
4698
4803
  forward,
@@ -4879,25 +4984,25 @@ var getBox = function getBox2(el) {
4879
4984
  import {
4880
4985
  useCallback as useCallback10,
4881
4986
  useEffect as useEffect17,
4882
- useMemo as useMemo13,
4883
- useRef as useRef4,
4987
+ useMemo as useMemo14,
4988
+ useRef as useRef3,
4884
4989
  useState as useState20
4885
4990
  } from "react";
4886
4991
 
4887
4992
  // components/ViewportControls/index.tsx
4888
4993
  init_react_import();
4889
- import { useEffect as useEffect16, useMemo as useMemo12, useState as useState19 } from "react";
4994
+ import { useEffect as useEffect16, useMemo as useMemo13, useState as useState19 } from "react";
4890
4995
 
4891
4996
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
4892
4997
  init_react_import();
4893
4998
  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" };
4894
4999
 
4895
5000
  // components/ViewportControls/index.tsx
4896
- import { jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
5001
+ import { jsx as jsx36, jsxs as jsxs19 } from "react/jsx-runtime";
4897
5002
  var icons = {
4898
- Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
4899
- Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
4900
- Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
5003
+ Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
5004
+ Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
5005
+ Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
4901
5006
  };
4902
5007
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
4903
5008
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -4913,7 +5018,7 @@ var ViewportButton = ({
4913
5018
  useEffect16(() => {
4914
5019
  setIsActive(width === state.ui.viewports.current.width);
4915
5020
  }, [width, state.ui.viewports.current.width]);
4916
- return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
5021
+ return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
4917
5022
  IconButton,
4918
5023
  {
4919
5024
  title,
@@ -4922,7 +5027,7 @@ var ViewportButton = ({
4922
5027
  e.stopPropagation();
4923
5028
  onClick({ width, height });
4924
5029
  },
4925
- children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
5030
+ children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
4926
5031
  }
4927
5032
  ) });
4928
5033
  };
@@ -4946,7 +5051,7 @@ var ViewportControls = ({
4946
5051
  const defaultsContainAutoZoom = defaultZoomOptions.find(
4947
5052
  (option) => option.value === autoZoom
4948
5053
  );
4949
- const zoomOptions = useMemo12(
5054
+ const zoomOptions = useMemo13(
4950
5055
  () => [
4951
5056
  ...defaultZoomOptions,
4952
5057
  ...defaultsContainAutoZoom ? [] : [
@@ -4959,7 +5064,7 @@ var ViewportControls = ({
4959
5064
  [autoZoom]
4960
5065
  );
4961
5066
  return /* @__PURE__ */ jsxs19("div", { className: getClassName25(), children: [
4962
- viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
5067
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
4963
5068
  ViewportButton,
4964
5069
  {
4965
5070
  height: viewport.height,
@@ -4970,8 +5075,8 @@ var ViewportControls = ({
4970
5075
  },
4971
5076
  i
4972
5077
  )),
4973
- /* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
4974
- /* @__PURE__ */ jsx35(
5078
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
5079
+ /* @__PURE__ */ jsx36(
4975
5080
  IconButton,
4976
5081
  {
4977
5082
  title: "Zoom viewport out",
@@ -4985,10 +5090,10 @@ var ViewportControls = ({
4985
5090
  )].value
4986
5091
  );
4987
5092
  },
4988
- children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
5093
+ children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
4989
5094
  }
4990
5095
  ),
4991
- /* @__PURE__ */ jsx35(
5096
+ /* @__PURE__ */ jsx36(
4992
5097
  IconButton,
4993
5098
  {
4994
5099
  title: "Zoom viewport in",
@@ -5002,11 +5107,11 @@ var ViewportControls = ({
5002
5107
  )].value
5003
5108
  );
5004
5109
  },
5005
- children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
5110
+ children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
5006
5111
  }
5007
5112
  ),
5008
- /* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
5009
- /* @__PURE__ */ jsx35(
5113
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
5114
+ /* @__PURE__ */ jsx36(
5010
5115
  "select",
5011
5116
  {
5012
5117
  className: getClassName25("zoomSelect"),
@@ -5014,7 +5119,7 @@ var ViewportControls = ({
5014
5119
  onChange: (e) => {
5015
5120
  onZoom(parseFloat(e.currentTarget.value));
5016
5121
  },
5017
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
5122
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
5018
5123
  "option",
5019
5124
  {
5020
5125
  value: option.value,
@@ -5029,7 +5134,7 @@ var ViewportControls = ({
5029
5134
 
5030
5135
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
5031
5136
  init_react_import();
5032
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_avf1c_1", "PuckCanvas-controls": "_PuckCanvas-controls_avf1c_16", "PuckCanvas-inner": "_PuckCanvas-inner_avf1c_21", "PuckCanvas-root": "_PuckCanvas-root_avf1c_32", "PuckCanvas--ready": "_PuckCanvas--ready_avf1c_57", "PuckCanvas-loader": "_PuckCanvas-loader_avf1c_62", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_avf1c_72" };
5137
+ var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
5033
5138
 
5034
5139
  // lib/get-zoom-config.ts
5035
5140
  init_react_import();
@@ -5062,20 +5167,20 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
5062
5167
  };
5063
5168
 
5064
5169
  // components/Puck/components/Canvas/index.tsx
5065
- import { Fragment as Fragment17, jsx as jsx36, jsxs as jsxs20 } from "react/jsx-runtime";
5170
+ import { Fragment as Fragment17, jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
5066
5171
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
5067
5172
  var ZOOM_ON_CHANGE = true;
5068
5173
  var Canvas = () => {
5069
5174
  const { status, iframe } = useAppContext();
5070
5175
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
5071
5176
  const { ui } = state;
5072
- const frameRef = useRef4(null);
5177
+ const frameRef = useRef3(null);
5073
5178
  const [showTransition, setShowTransition] = useState20(false);
5074
- const defaultRender = useMemo13(() => {
5075
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment17, { children });
5179
+ const defaultRender = useMemo14(() => {
5180
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment17, { children });
5076
5181
  return PuckDefault;
5077
5182
  }, []);
5078
- const CustomPreview = useMemo13(
5183
+ const CustomPreview = useMemo14(
5079
5184
  () => overrides.preview || defaultRender,
5080
5185
  [overrides]
5081
5186
  );
@@ -5146,7 +5251,7 @@ var Canvas = () => {
5146
5251
  recordHistory: true
5147
5252
  }),
5148
5253
  children: [
5149
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx36(
5254
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
5150
5255
  ViewportControls,
5151
5256
  {
5152
5257
  autoZoom: zoomConfig.autoZoom,
@@ -5172,7 +5277,7 @@ var Canvas = () => {
5172
5277
  }
5173
5278
  ) }),
5174
5279
  /* @__PURE__ */ jsxs20("div", { className: getClassName26("inner"), ref: frameRef, children: [
5175
- /* @__PURE__ */ jsx36(
5280
+ /* @__PURE__ */ jsx37(
5176
5281
  "div",
5177
5282
  {
5178
5283
  className: getClassName26("root"),
@@ -5184,10 +5289,10 @@ var Canvas = () => {
5184
5289
  overflow: iframe.enabled ? void 0 : "auto"
5185
5290
  },
5186
5291
  suppressHydrationWarning: true,
5187
- children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview, {}) })
5292
+ children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview, {}) })
5188
5293
  }
5189
5294
  ),
5190
- /* @__PURE__ */ jsx36("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
5295
+ /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
5191
5296
  ] })
5192
5297
  ]
5193
5298
  }
@@ -5231,7 +5336,7 @@ var insertComponent = (componentType, zone, index, {
5231
5336
 
5232
5337
  // lib/use-loaded-overrides.ts
5233
5338
  init_react_import();
5234
- import { useMemo as useMemo14 } from "react";
5339
+ import { useMemo as useMemo15 } from "react";
5235
5340
 
5236
5341
  // lib/load-overrides.ts
5237
5342
  init_react_import();
@@ -5270,18 +5375,18 @@ var useLoadedOverrides = ({
5270
5375
  overrides,
5271
5376
  plugins
5272
5377
  }) => {
5273
- return useMemo14(() => {
5378
+ return useMemo15(() => {
5274
5379
  return loadOverrides({ overrides, plugins });
5275
5380
  }, [plugins, overrides]);
5276
5381
  };
5277
5382
 
5278
5383
  // components/DefaultOverride/index.tsx
5279
5384
  init_react_import();
5280
- import { Fragment as Fragment18, jsx as jsx37 } from "react/jsx-runtime";
5281
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment18, { children });
5385
+ import { Fragment as Fragment18, jsx as jsx38 } from "react/jsx-runtime";
5386
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment18, { children });
5282
5387
 
5283
5388
  // components/Puck/index.tsx
5284
- import { Fragment as Fragment19, jsx as jsx38, jsxs as jsxs21 } from "react/jsx-runtime";
5389
+ import { Fragment as Fragment19, jsx as jsx39, jsxs as jsxs21 } from "react/jsx-runtime";
5285
5390
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
5286
5391
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
5287
5392
  function Puck({
@@ -5304,13 +5409,13 @@ function Puck({
5304
5409
  dnd,
5305
5410
  initialHistory: _initialHistory
5306
5411
  }) {
5307
- var _a;
5412
+ var _a, _b;
5308
5413
  const iframe = __spreadValues({
5309
5414
  enabled: true,
5310
5415
  waitForStyles: true
5311
5416
  }, _iframe);
5312
5417
  const [generatedAppState] = useState21(() => {
5313
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
5418
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
5314
5419
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
5315
5420
  let clientUiState = {};
5316
5421
  if (typeof window !== "undefined") {
@@ -5330,7 +5435,7 @@ function Puck({
5330
5435
  clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
5331
5436
  viewports: __spreadProps(__spreadValues({}, initial.viewports), {
5332
5437
  current: __spreadProps(__spreadValues({}, initial.viewports.current), {
5333
- height: ((_b = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b.height) || ((_c = viewports[closestViewport]) == null ? void 0 : _c.height) || "auto",
5438
+ height: ((_b2 = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b2.height) || ((_c = viewports[closestViewport]) == null ? void 0 : _c.height) || "auto",
5334
5439
  width: ((_e = (_d = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _d.current) == null ? void 0 : _e.width) || ((_f = viewports[closestViewport]) == null ? void 0 : _f.width)
5335
5440
  })
5336
5441
  })
@@ -5393,7 +5498,12 @@ function Puck({
5393
5498
  flushZones(initialAppState)
5394
5499
  );
5395
5500
  const { data, ui } = appState;
5396
- const history = usePuckHistory({ dispatch, initialAppState, historyStore });
5501
+ const history = usePuckHistory({
5502
+ dispatch,
5503
+ initialAppState,
5504
+ historyStore,
5505
+ iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
5506
+ });
5397
5507
  const [menuOpen, setMenuOpen] = useState21(false);
5398
5508
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
5399
5509
  const setItemSelector = useCallback11(
@@ -5451,28 +5561,28 @@ function Puck({
5451
5561
  window.removeEventListener("resize", handleResize);
5452
5562
  };
5453
5563
  }, []);
5454
- const defaultHeaderRender = useMemo15(() => {
5564
+ const defaultHeaderRender = useMemo16(() => {
5455
5565
  if (renderHeader) {
5456
5566
  console.warn(
5457
5567
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
5458
5568
  );
5459
5569
  const RenderHeader = (_a2) => {
5460
- var _b = _a2, { actions } = _b, props = __objRest(_b, ["actions"]);
5570
+ var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
5461
5571
  const Comp = renderHeader;
5462
- return /* @__PURE__ */ jsx38(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
5572
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
5463
5573
  };
5464
5574
  return RenderHeader;
5465
5575
  }
5466
5576
  return DefaultOverride;
5467
5577
  }, [renderHeader]);
5468
- const defaultHeaderActionsRender = useMemo15(() => {
5578
+ const defaultHeaderActionsRender = useMemo16(() => {
5469
5579
  if (renderHeaderActions) {
5470
5580
  console.warn(
5471
5581
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
5472
5582
  );
5473
5583
  const RenderHeader = (props) => {
5474
5584
  const Comp = renderHeaderActions;
5475
- return /* @__PURE__ */ jsx38(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
5585
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
5476
5586
  };
5477
5587
  return RenderHeader;
5478
5588
  }
@@ -5482,15 +5592,15 @@ function Puck({
5482
5592
  overrides,
5483
5593
  plugins
5484
5594
  });
5485
- const CustomPuck = useMemo15(
5595
+ const CustomPuck = useMemo16(
5486
5596
  () => loadedOverrides.puck || DefaultOverride,
5487
5597
  [loadedOverrides]
5488
5598
  );
5489
- const CustomHeader = useMemo15(
5599
+ const CustomHeader = useMemo16(
5490
5600
  () => loadedOverrides.header || defaultHeaderRender,
5491
5601
  [loadedOverrides]
5492
5602
  );
5493
- const CustomHeaderActions = useMemo15(
5603
+ const CustomHeaderActions = useMemo16(
5494
5604
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
5495
5605
  [loadedOverrides]
5496
5606
  );
@@ -5499,9 +5609,9 @@ function Puck({
5499
5609
  setMounted(true);
5500
5610
  }, []);
5501
5611
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
5502
- const selectedComponentLabel = selectedItem ? (_a = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _a : selectedItem.type.toString() : "";
5612
+ const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
5503
5613
  return /* @__PURE__ */ jsxs21("div", { className: `Puck ${getClassName27()}`, children: [
5504
- /* @__PURE__ */ jsx38(
5614
+ /* @__PURE__ */ jsx39(
5505
5615
  AppProvider,
5506
5616
  {
5507
5617
  value: {
@@ -5523,7 +5633,7 @@ function Puck({
5523
5633
  getPermissions: () => ({}),
5524
5634
  refreshPermissions: () => null
5525
5635
  },
5526
- children: /* @__PURE__ */ jsx38(appContext.Consumer, { children: ({ resolveData }) => /* @__PURE__ */ jsx38(
5636
+ children: /* @__PURE__ */ jsx39(appContext.Consumer, { children: ({ resolveData }) => /* @__PURE__ */ jsx39(
5527
5637
  DragDropContext,
5528
5638
  {
5529
5639
  autoScrollerOptions: { disabled: dnd == null ? void 0 : dnd.disableAutoScroll },
@@ -5575,7 +5685,7 @@ function Puck({
5575
5685
  });
5576
5686
  }
5577
5687
  },
5578
- children: /* @__PURE__ */ jsx38(
5688
+ children: /* @__PURE__ */ jsx39(
5579
5689
  DropZoneProvider,
5580
5690
  {
5581
5691
  value: {
@@ -5589,7 +5699,7 @@ function Puck({
5589
5699
  mode: "edit",
5590
5700
  areaId: "root"
5591
5701
  },
5592
- children: /* @__PURE__ */ jsx38(CustomPuck, { children: children || /* @__PURE__ */ jsx38(
5702
+ children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
5593
5703
  "div",
5594
5704
  {
5595
5705
  className: getLayoutClassName({
@@ -5599,57 +5709,57 @@ function Puck({
5599
5709
  rightSideBarVisible
5600
5710
  }),
5601
5711
  children: /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("inner"), children: [
5602
- /* @__PURE__ */ jsx38(
5712
+ /* @__PURE__ */ jsx39(
5603
5713
  CustomHeader,
5604
5714
  {
5605
- actions: /* @__PURE__ */ jsx38(Fragment19, { children: /* @__PURE__ */ jsx38(CustomHeaderActions, { children: /* @__PURE__ */ jsx38(
5715
+ actions: /* @__PURE__ */ jsx39(Fragment19, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
5606
5716
  Button,
5607
5717
  {
5608
5718
  onClick: () => {
5609
5719
  onPublish && onPublish(data);
5610
5720
  },
5611
- icon: /* @__PURE__ */ jsx38(Globe, { size: "14px" }),
5721
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
5612
5722
  children: "Publish"
5613
5723
  }
5614
5724
  ) }) }),
5615
- children: /* @__PURE__ */ jsx38("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("headerInner"), children: [
5725
+ children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("headerInner"), children: [
5616
5726
  /* @__PURE__ */ jsxs21(
5617
5727
  "div",
5618
5728
  {
5619
5729
  className: getLayoutClassName("headerToggle"),
5620
5730
  children: [
5621
- /* @__PURE__ */ jsx38(
5731
+ /* @__PURE__ */ jsx39(
5622
5732
  "div",
5623
5733
  {
5624
5734
  className: getLayoutClassName(
5625
5735
  "leftSideBarToggle"
5626
5736
  ),
5627
- children: /* @__PURE__ */ jsx38(
5737
+ children: /* @__PURE__ */ jsx39(
5628
5738
  IconButton,
5629
5739
  {
5630
5740
  onClick: () => {
5631
5741
  toggleSidebars("left");
5632
5742
  },
5633
5743
  title: "Toggle left sidebar",
5634
- children: /* @__PURE__ */ jsx38(PanelLeft, { focusable: "false" })
5744
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
5635
5745
  }
5636
5746
  )
5637
5747
  }
5638
5748
  ),
5639
- /* @__PURE__ */ jsx38(
5749
+ /* @__PURE__ */ jsx39(
5640
5750
  "div",
5641
5751
  {
5642
5752
  className: getLayoutClassName(
5643
5753
  "rightSideBarToggle"
5644
5754
  ),
5645
- children: /* @__PURE__ */ jsx38(
5755
+ children: /* @__PURE__ */ jsx39(
5646
5756
  IconButton,
5647
5757
  {
5648
5758
  onClick: () => {
5649
5759
  toggleSidebars("right");
5650
5760
  },
5651
5761
  title: "Toggle right sidebar",
5652
- children: /* @__PURE__ */ jsx38(PanelRight, { focusable: "false" })
5762
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
5653
5763
  }
5654
5764
  )
5655
5765
  }
@@ -5657,7 +5767,7 @@ function Puck({
5657
5767
  ]
5658
5768
  }
5659
5769
  ),
5660
- /* @__PURE__ */ jsx38(
5770
+ /* @__PURE__ */ jsx39(
5661
5771
  "div",
5662
5772
  {
5663
5773
  className: getLayoutClassName("headerTitle"),
@@ -5665,7 +5775,7 @@ function Puck({
5665
5775
  headerTitle || rootProps.title || "Page",
5666
5776
  headerPath && /* @__PURE__ */ jsxs21(Fragment19, { children: [
5667
5777
  " ",
5668
- /* @__PURE__ */ jsx38(
5778
+ /* @__PURE__ */ jsx39(
5669
5779
  "code",
5670
5780
  {
5671
5781
  className: getLayoutClassName(
@@ -5683,36 +5793,36 @@ function Puck({
5683
5793
  {
5684
5794
  className: getLayoutClassName("headerTools"),
5685
5795
  children: [
5686
- /* @__PURE__ */ jsx38(
5796
+ /* @__PURE__ */ jsx39(
5687
5797
  "div",
5688
5798
  {
5689
5799
  className: getLayoutClassName("menuButton"),
5690
- children: /* @__PURE__ */ jsx38(
5800
+ children: /* @__PURE__ */ jsx39(
5691
5801
  IconButton,
5692
5802
  {
5693
5803
  onClick: () => {
5694
5804
  return setMenuOpen(!menuOpen);
5695
5805
  },
5696
5806
  title: "Toggle menu bar",
5697
- children: menuOpen ? /* @__PURE__ */ jsx38(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx38(ChevronDown, { focusable: "false" })
5807
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
5698
5808
  }
5699
5809
  )
5700
5810
  }
5701
5811
  ),
5702
- /* @__PURE__ */ jsx38(
5812
+ /* @__PURE__ */ jsx39(
5703
5813
  MenuBar,
5704
5814
  {
5705
5815
  appState,
5706
5816
  dispatch,
5707
5817
  onPublish,
5708
5818
  menuOpen,
5709
- renderHeaderActions: () => /* @__PURE__ */ jsx38(CustomHeaderActions, { children: /* @__PURE__ */ jsx38(
5819
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
5710
5820
  Button,
5711
5821
  {
5712
5822
  onClick: () => {
5713
5823
  onPublish && onPublish(data);
5714
5824
  },
5715
- icon: /* @__PURE__ */ jsx38(Globe, { size: "14px" }),
5825
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
5716
5826
  children: "Publish"
5717
5827
  }
5718
5828
  ) }),
@@ -5726,18 +5836,18 @@ function Puck({
5726
5836
  }
5727
5837
  ),
5728
5838
  /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("leftSideBar"), children: [
5729
- /* @__PURE__ */ jsx38(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx38(Components, {}) }),
5730
- /* @__PURE__ */ jsx38(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx38(Outline, {}) })
5839
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
5840
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
5731
5841
  ] }),
5732
- /* @__PURE__ */ jsx38(Canvas, {}),
5733
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx38(
5842
+ /* @__PURE__ */ jsx39(Canvas, {}),
5843
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
5734
5844
  SidebarSection,
5735
5845
  {
5736
5846
  noPadding: true,
5737
5847
  noBorderTop: true,
5738
5848
  showBreadcrumbs: true,
5739
5849
  title: selectedItem ? selectedComponentLabel : "Page",
5740
- children: /* @__PURE__ */ jsx38(Fields, {})
5850
+ children: /* @__PURE__ */ jsx39(Fields, {})
5741
5851
  }
5742
5852
  ) })
5743
5853
  ] })
@@ -5749,7 +5859,7 @@ function Puck({
5749
5859
  ) })
5750
5860
  }
5751
5861
  ),
5752
- /* @__PURE__ */ jsx38("div", { id: "puck-portal-root", className: getClassName27("portal") })
5862
+ /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
5753
5863
  ] });
5754
5864
  }
5755
5865
  Puck.Components = Components;
@@ -5759,7 +5869,7 @@ Puck.Preview = Preview;
5759
5869
 
5760
5870
  // components/Render/index.tsx
5761
5871
  init_react_import();
5762
- import { jsx as jsx39 } from "react/jsx-runtime";
5872
+ import { jsx as jsx40 } from "react/jsx-runtime";
5763
5873
  function Render({
5764
5874
  config,
5765
5875
  data
@@ -5772,7 +5882,7 @@ function Render({
5772
5882
  const rootProps = defaultedData.root.props || defaultedData.root;
5773
5883
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
5774
5884
  if ((_a = config.root) == null ? void 0 : _a.render) {
5775
- return /* @__PURE__ */ jsx39(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ jsx39(
5885
+ return /* @__PURE__ */ jsx40(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ jsx40(
5776
5886
  config.root.render,
5777
5887
  __spreadProps(__spreadValues({}, rootProps), {
5778
5888
  puck: {
@@ -5782,11 +5892,11 @@ function Render({
5782
5892
  title,
5783
5893
  editMode: false,
5784
5894
  id: "puck-root",
5785
- children: /* @__PURE__ */ jsx39(DropZone, { zone: rootDroppableId })
5895
+ children: /* @__PURE__ */ jsx40(DropZone, { zone: rootDroppableId })
5786
5896
  })
5787
5897
  ) });
5788
5898
  }
5789
- return /* @__PURE__ */ jsx39(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ jsx39(DropZone, { zone: rootDroppableId }) });
5899
+ return /* @__PURE__ */ jsx40(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ jsx40(DropZone, { zone: rootDroppableId }) });
5790
5900
  }
5791
5901
 
5792
5902
  // lib/migrate.ts