@measured/puck 0.18.0-canary.d253d54 → 0.18.0-canary.f27871b

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  resolveRootData,
17
17
  rootDroppableId,
18
18
  setupZone
19
- } from "./chunk-EXKSBUY5.mjs";
19
+ } from "./chunk-CHWFBYEM.mjs";
20
20
 
21
21
  // ../../node_modules/classnames/index.js
22
22
  var require_classnames = __commonJS({
@@ -210,8 +210,9 @@ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input":
210
210
  // components/AutoField/index.tsx
211
211
  import {
212
212
  useCallback as useCallback5,
213
+ useContext as useContext3,
213
214
  useEffect as useEffect9,
214
- useMemo as useMemo4,
215
+ useMemo as useMemo5,
215
216
  useState as useState11
216
217
  } from "react";
217
218
 
@@ -962,6 +963,7 @@ var defaultAppState = {
962
963
  itemSelector: null,
963
964
  componentList: {},
964
965
  isDragging: false,
966
+ previewMode: "edit",
965
967
  viewports: {
966
968
  current: {
967
969
  width: defaultViewports[0].width,
@@ -1084,7 +1086,7 @@ init_react_import();
1084
1086
  import { DragDropProvider } from "@dnd-kit/react";
1085
1087
  import { useState as useState5 } from "react";
1086
1088
 
1087
- // lib/dnd-kit/safe.ts
1089
+ // lib/dnd/dnd-kit/safe.ts
1088
1090
  init_react_import();
1089
1091
  import {
1090
1092
  useDraggable,
@@ -1164,8 +1166,53 @@ var Sortable = ({
1164
1166
  return children({ status, ref: sortableRef });
1165
1167
  };
1166
1168
 
1169
+ // components/AutoField/context.tsx
1170
+ init_react_import();
1171
+ import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
1172
+ import { jsx as jsx7 } from "react/jsx-runtime";
1173
+ var NestedFieldContext = createContext2({});
1174
+ var useNestedFieldContext = () => {
1175
+ const context = useContext2(NestedFieldContext);
1176
+ return __spreadProps(__spreadValues({}, context), {
1177
+ readOnlyFields: context.readOnlyFields || {}
1178
+ });
1179
+ };
1180
+ var NestedFieldProvider = ({
1181
+ children,
1182
+ name,
1183
+ subName,
1184
+ wildcardName = name,
1185
+ readOnlyFields
1186
+ }) => {
1187
+ const subPath = `${name}.${subName}`;
1188
+ const wildcardSubPath = `${wildcardName}.${subName}`;
1189
+ const subReadOnlyFields = useMemo(
1190
+ () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
1191
+ const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
1192
+ if (isLocal) {
1193
+ const subPathPattern = new RegExp(
1194
+ `^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
1195
+ );
1196
+ const localName = readOnlyKey.replace(subPathPattern, "");
1197
+ return __spreadProps(__spreadValues({}, acc), {
1198
+ [localName]: readOnlyFields[readOnlyKey]
1199
+ });
1200
+ }
1201
+ return acc;
1202
+ }, {}),
1203
+ [name, subName, wildcardName, readOnlyFields]
1204
+ );
1205
+ return /* @__PURE__ */ jsx7(
1206
+ NestedFieldContext.Provider,
1207
+ {
1208
+ value: { readOnlyFields: subReadOnlyFields, localName: subName },
1209
+ children
1210
+ }
1211
+ );
1212
+ };
1213
+
1167
1214
  // components/AutoField/fields/ArrayField/index.tsx
1168
- import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
1215
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
1169
1216
  var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
1170
1217
  var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
1171
1218
  var ArrayField = ({
@@ -1176,10 +1223,10 @@ var ArrayField = ({
1176
1223
  label,
1177
1224
  readOnly,
1178
1225
  id,
1179
- Label: Label2 = (props) => /* @__PURE__ */ jsx7("div", __spreadValues({}, props))
1226
+ Label: Label2 = (props) => /* @__PURE__ */ jsx8("div", __spreadValues({}, props))
1180
1227
  }) => {
1181
1228
  const { state, setUi, selectedItem, getPermissions } = useAppContext();
1182
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
1229
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
1183
1230
  const value = _value;
1184
1231
  const arrayState = state.ui.arrayState[id] || {
1185
1232
  items: Array.from(value || []).map((item, idx) => {
@@ -1239,14 +1286,14 @@ var ArrayField = ({
1239
1286
  return null;
1240
1287
  }
1241
1288
  const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
1242
- return /* @__PURE__ */ jsx7(
1289
+ return /* @__PURE__ */ jsx8(
1243
1290
  Label2,
1244
1291
  {
1245
1292
  label: label || name,
1246
- icon: /* @__PURE__ */ jsx7(List, { size: 16 }),
1293
+ icon: /* @__PURE__ */ jsx8(List, { size: 16 }),
1247
1294
  el: "div",
1248
1295
  readOnly,
1249
- children: /* @__PURE__ */ jsx7(
1296
+ children: /* @__PURE__ */ jsx8(
1250
1297
  SortableProvider,
1251
1298
  {
1252
1299
  onMove: (move) => {
@@ -1282,7 +1329,7 @@ var ArrayField = ({
1282
1329
  localState.arrayState.items.map((item, i) => {
1283
1330
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
1284
1331
  const data = Array.from(localState.value || [])[i] || {};
1285
- return /* @__PURE__ */ jsx7(
1332
+ return /* @__PURE__ */ jsx8(
1286
1333
  Sortable,
1287
1334
  {
1288
1335
  id: _arrayId,
@@ -1323,7 +1370,7 @@ var ArrayField = ({
1323
1370
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
1324
1371
  /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
1325
1372
  !readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
1326
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
1373
+ /* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
1327
1374
  IconButton,
1328
1375
  {
1329
1376
  type: "button",
@@ -1340,10 +1387,10 @@ var ArrayField = ({
1340
1387
  );
1341
1388
  },
1342
1389
  title: "Duplicate",
1343
- children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
1390
+ children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
1344
1391
  }
1345
1392
  ) }),
1346
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
1393
+ /* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
1347
1394
  IconButton,
1348
1395
  {
1349
1396
  type: "button",
@@ -1364,39 +1411,56 @@ var ArrayField = ({
1364
1411
  );
1365
1412
  },
1366
1413
  title: "Delete",
1367
- children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
1414
+ children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
1368
1415
  }
1369
1416
  ) })
1370
1417
  ] }),
1371
- /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(DragIcon, {}) })
1418
+ /* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(DragIcon, {}) })
1372
1419
  ] })
1373
1420
  ]
1374
1421
  }
1375
1422
  ),
1376
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((fieldName) => {
1377
- const subField = field.arrayFields[fieldName];
1378
- const subFieldName = `${name}[${i}].${fieldName}`;
1379
- const wildcardFieldName = `${name}[*].${fieldName}`;
1380
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
1381
- return /* @__PURE__ */ jsx7(
1382
- AutoFieldPrivate,
1423
+ /* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
1424
+ const subField = field.arrayFields[subName];
1425
+ const indexName = `${name}[${i}]`;
1426
+ const subPath = `${indexName}.${subName}`;
1427
+ const localIndexName = `${localName}[${i}]`;
1428
+ const localWildcardName = `${localName}[*]`;
1429
+ const localSubPath = `${localIndexName}.${subName}`;
1430
+ const localWildcardSubPath = `${localWildcardName}.${subName}`;
1431
+ const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
1432
+ const label2 = subField.label || subName;
1433
+ return /* @__PURE__ */ jsx8(
1434
+ NestedFieldProvider,
1383
1435
  {
1384
- name: subFieldName,
1385
- label: subField.label || fieldName,
1386
- id: `${_arrayId}_${fieldName}`,
1387
- readOnly: subReadOnly,
1388
- field: subField,
1389
- value: data[fieldName],
1390
- onChange: (val, ui) => {
1391
- onChange(
1392
- replace(value, i, __spreadProps(__spreadValues({}, data), {
1393
- [fieldName]: val
1394
- })),
1395
- ui
1396
- );
1397
- }
1436
+ name: localIndexName,
1437
+ wildcardName: localWildcardName,
1438
+ subName,
1439
+ readOnlyFields,
1440
+ children: /* @__PURE__ */ jsx8(
1441
+ AutoFieldPrivate,
1442
+ {
1443
+ name: subPath,
1444
+ label: label2,
1445
+ id: `${_arrayId}_${subName}`,
1446
+ readOnly: subReadOnly,
1447
+ field: __spreadProps(__spreadValues({}, subField), {
1448
+ label: label2
1449
+ // May be used by custom fields
1450
+ }),
1451
+ value: data[subName],
1452
+ onChange: (val, ui) => {
1453
+ onChange(
1454
+ replace(value, i, __spreadProps(__spreadValues({}, data), {
1455
+ [subName]: val
1456
+ })),
1457
+ ui
1458
+ );
1459
+ }
1460
+ }
1461
+ )
1398
1462
  },
1399
- subFieldName
1463
+ subPath
1400
1464
  );
1401
1465
  }) }) })
1402
1466
  ]
@@ -1406,7 +1470,7 @@ var ArrayField = ({
1406
1470
  _arrayId
1407
1471
  );
1408
1472
  }),
1409
- !addDisabled && /* @__PURE__ */ jsx7(
1473
+ !addDisabled && /* @__PURE__ */ jsx8(
1410
1474
  "button",
1411
1475
  {
1412
1476
  type: "button",
@@ -1420,7 +1484,7 @@ var ArrayField = ({
1420
1484
  const newArrayState = regenerateArrayState(newValue);
1421
1485
  onChange(newValue, mapArrayStateToUi(newArrayState));
1422
1486
  },
1423
- children: /* @__PURE__ */ jsx7(Plus, { size: 21 })
1487
+ children: /* @__PURE__ */ jsx8(Plus, { size: 21 })
1424
1488
  }
1425
1489
  )
1426
1490
  ]
@@ -1434,7 +1498,7 @@ var ArrayField = ({
1434
1498
 
1435
1499
  // components/AutoField/fields/DefaultField/index.tsx
1436
1500
  init_react_import();
1437
- import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1501
+ import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
1438
1502
  var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
1439
1503
  var DefaultField = ({
1440
1504
  field,
@@ -1446,16 +1510,16 @@ var DefaultField = ({
1446
1510
  Label: Label2,
1447
1511
  id
1448
1512
  }) => {
1449
- return /* @__PURE__ */ jsx8(
1513
+ return /* @__PURE__ */ jsx9(
1450
1514
  Label2,
1451
1515
  {
1452
1516
  label: label || name,
1453
1517
  icon: /* @__PURE__ */ jsxs4(Fragment2, { children: [
1454
- field.type === "text" && /* @__PURE__ */ jsx8(Type, { size: 16 }),
1455
- field.type === "number" && /* @__PURE__ */ jsx8(Hash, { size: 16 })
1518
+ field.type === "text" && /* @__PURE__ */ jsx9(Type, { size: 16 }),
1519
+ field.type === "number" && /* @__PURE__ */ jsx9(Hash, { size: 16 })
1456
1520
  ] }),
1457
1521
  readOnly,
1458
- children: /* @__PURE__ */ jsx8(
1522
+ children: /* @__PURE__ */ jsx9(
1459
1523
  "input",
1460
1524
  {
1461
1525
  className: getClassName6("input"),
@@ -1466,7 +1530,14 @@ var DefaultField = ({
1466
1530
  value: typeof value === "undefined" ? "" : value.toString(),
1467
1531
  onChange: (e) => {
1468
1532
  if (field.type === "number") {
1469
- onChange(Number(e.currentTarget.value));
1533
+ const numberValue = Number(e.currentTarget.value);
1534
+ if (typeof field.min !== "undefined" && numberValue < field.min) {
1535
+ return;
1536
+ }
1537
+ if (typeof field.max !== "undefined" && numberValue > field.max) {
1538
+ return;
1539
+ }
1540
+ onChange(numberValue);
1470
1541
  } else {
1471
1542
  onChange(e.currentTarget.value);
1472
1543
  }
@@ -1489,7 +1560,7 @@ import { useEffect as useEffect8 } from "react";
1489
1560
  // components/ExternalInput/index.tsx
1490
1561
  init_react_import();
1491
1562
  import {
1492
- useMemo,
1563
+ useMemo as useMemo2,
1493
1564
  useEffect as useEffect7,
1494
1565
  useState as useState9,
1495
1566
  useCallback as useCallback4,
@@ -1510,7 +1581,7 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
1510
1581
 
1511
1582
  // components/Modal/index.tsx
1512
1583
  import { createPortal } from "react-dom";
1513
- import { jsx as jsx9 } from "react/jsx-runtime";
1584
+ import { jsx as jsx10 } from "react/jsx-runtime";
1514
1585
  var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
1515
1586
  var Modal = ({
1516
1587
  children,
@@ -1522,10 +1593,10 @@ var Modal = ({
1522
1593
  setRootEl(document.getElementById("puck-portal-root"));
1523
1594
  }, []);
1524
1595
  if (!rootEl) {
1525
- return /* @__PURE__ */ jsx9("div", {});
1596
+ return /* @__PURE__ */ jsx10("div", {});
1526
1597
  }
1527
1598
  return createPortal(
1528
- /* @__PURE__ */ jsx9("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx9(
1599
+ /* @__PURE__ */ jsx10("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx10(
1529
1600
  "div",
1530
1601
  {
1531
1602
  className: getClassName7("inner"),
@@ -1545,11 +1616,11 @@ init_react_import();
1545
1616
  var styles_module_default8 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
1546
1617
 
1547
1618
  // components/Heading/index.tsx
1548
- import { jsx as jsx10 } from "react/jsx-runtime";
1619
+ import { jsx as jsx11 } from "react/jsx-runtime";
1549
1620
  var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
1550
1621
  var Heading = ({ children, rank, size = "m" }) => {
1551
1622
  const Tag = rank ? `h${rank}` : "span";
1552
- return /* @__PURE__ */ jsx10(
1623
+ return /* @__PURE__ */ jsx11(
1553
1624
  Tag,
1554
1625
  {
1555
1626
  className: getClassName8({
@@ -1585,7 +1656,7 @@ var filterDataAttrs = (props) => {
1585
1656
  };
1586
1657
 
1587
1658
  // components/Button/Button.tsx
1588
- import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
1659
+ import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
1589
1660
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
1590
1661
  var Button = (_a) => {
1591
1662
  var _b = _a, {
@@ -1644,9 +1715,9 @@ var Button = (_a) => {
1644
1715
  href
1645
1716
  }, dataAttrs), {
1646
1717
  children: [
1647
- icon && /* @__PURE__ */ jsx11("div", { className: getClassName9("icon"), children: icon }),
1718
+ icon && /* @__PURE__ */ jsx12("div", { className: getClassName9("icon"), children: icon }),
1648
1719
  children,
1649
- loading && /* @__PURE__ */ jsx11("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx11(Loader, { size: 14 }) })
1720
+ loading && /* @__PURE__ */ jsx12("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx12(Loader, { size: 14 }) })
1650
1721
  ]
1651
1722
  })
1652
1723
  );
@@ -1654,7 +1725,7 @@ var Button = (_a) => {
1654
1725
  };
1655
1726
 
1656
1727
  // components/ExternalInput/index.tsx
1657
- import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
1728
+ import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
1658
1729
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
1659
1730
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
1660
1731
  var dataCache = {};
@@ -1677,10 +1748,10 @@ var ExternalInput = ({
1677
1748
  const hasFilterFields = !!filterFields;
1678
1749
  const [filters, setFilters] = useState9(field.initialFilters || {});
1679
1750
  const [filtersToggled, setFiltersToggled] = useState9(hasFilterFields);
1680
- const mappedData = useMemo(() => {
1751
+ const mappedData = useMemo2(() => {
1681
1752
  return data.map(mapRow);
1682
1753
  }, [data]);
1683
- const keys = useMemo(() => {
1754
+ const keys = useMemo2(() => {
1684
1755
  const validKeys = /* @__PURE__ */ new Set();
1685
1756
  for (const item of mappedData) {
1686
1757
  for (const key of Object.keys(item)) {
@@ -1727,7 +1798,7 @@ var ExternalInput = ({
1727
1798
  id,
1728
1799
  children: [
1729
1800
  /* @__PURE__ */ jsxs6("div", { className: getClassName10("actions"), children: [
1730
- /* @__PURE__ */ jsx12(
1801
+ /* @__PURE__ */ jsx13(
1731
1802
  "button",
1732
1803
  {
1733
1804
  type: "button",
@@ -1735,12 +1806,12 @@ var ExternalInput = ({
1735
1806
  className: getClassName10("button"),
1736
1807
  disabled: readOnly,
1737
1808
  children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs6(Fragment3, { children: [
1738
- /* @__PURE__ */ jsx12(Link, { size: "16" }),
1739
- /* @__PURE__ */ jsx12("span", { children: field.placeholder })
1809
+ /* @__PURE__ */ jsx13(Link, { size: "16" }),
1810
+ /* @__PURE__ */ jsx13("span", { children: field.placeholder })
1740
1811
  ] })
1741
1812
  }
1742
1813
  ),
1743
- value && /* @__PURE__ */ jsx12(
1814
+ value && /* @__PURE__ */ jsx13(
1744
1815
  "button",
1745
1816
  {
1746
1817
  type: "button",
@@ -1749,11 +1820,11 @@ var ExternalInput = ({
1749
1820
  onChange(null);
1750
1821
  },
1751
1822
  disabled: readOnly,
1752
- children: /* @__PURE__ */ jsx12(LockOpen, { size: 16 })
1823
+ children: /* @__PURE__ */ jsx13(LockOpen, { size: 16 })
1753
1824
  }
1754
1825
  )
1755
1826
  ] }),
1756
- /* @__PURE__ */ jsx12(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
1827
+ /* @__PURE__ */ jsx13(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
1757
1828
  "form",
1758
1829
  {
1759
1830
  className: getClassNameModal({
@@ -1767,11 +1838,11 @@ var ExternalInput = ({
1767
1838
  search(searchQuery, filters);
1768
1839
  },
1769
1840
  children: [
1770
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
1841
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
1771
1842
  /* @__PURE__ */ jsxs6("label", { className: getClassNameModal("search"), children: [
1772
- /* @__PURE__ */ jsx12("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
1773
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx12(Search, { size: "18" }) }),
1774
- /* @__PURE__ */ jsx12(
1843
+ /* @__PURE__ */ jsx13("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
1844
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx13(Search, { size: "18" }) }),
1845
+ /* @__PURE__ */ jsx13(
1775
1846
  "input",
1776
1847
  {
1777
1848
  className: getClassNameModal("searchInput"),
@@ -1787,8 +1858,8 @@ var ExternalInput = ({
1787
1858
  )
1788
1859
  ] }),
1789
1860
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchActions"), children: [
1790
- /* @__PURE__ */ jsx12(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
1791
- hasFilterFields && /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx12(
1861
+ /* @__PURE__ */ jsx13(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
1862
+ hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx13(
1792
1863
  IconButton,
1793
1864
  {
1794
1865
  title: "Toggle filters",
@@ -1797,15 +1868,15 @@ var ExternalInput = ({
1797
1868
  e.stopPropagation();
1798
1869
  setFiltersToggled(!filtersToggled);
1799
1870
  },
1800
- children: /* @__PURE__ */ jsx12(SlidersHorizontal, { size: 20 })
1871
+ children: /* @__PURE__ */ jsx13(SlidersHorizontal, { size: 20 })
1801
1872
  }
1802
1873
  ) })
1803
1874
  ] })
1804
- ] }) : /* @__PURE__ */ jsx12(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
1875
+ ] }) : /* @__PURE__ */ jsx13(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
1805
1876
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("grid"), children: [
1806
- hasFilterFields && /* @__PURE__ */ jsx12("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1877
+ hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1807
1878
  const filterField = filterFields[fieldName];
1808
- return /* @__PURE__ */ jsx12(
1879
+ return /* @__PURE__ */ jsx13(
1809
1880
  AutoFieldPrivate,
1810
1881
  {
1811
1882
  field: filterField,
@@ -1824,7 +1895,7 @@ var ExternalInput = ({
1824
1895
  }) }),
1825
1896
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("tableWrapper"), children: [
1826
1897
  /* @__PURE__ */ jsxs6("table", { className: getClassNameModal("table"), children: [
1827
- /* @__PURE__ */ jsx12("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx12("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx12(
1898
+ /* @__PURE__ */ jsx13("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx13("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx13(
1828
1899
  "th",
1829
1900
  {
1830
1901
  className: getClassNameModal("th"),
@@ -1833,8 +1904,8 @@ var ExternalInput = ({
1833
1904
  },
1834
1905
  key
1835
1906
  )) }) }),
1836
- /* @__PURE__ */ jsx12("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
1837
- return /* @__PURE__ */ jsx12(
1907
+ /* @__PURE__ */ jsx13("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
1908
+ return /* @__PURE__ */ jsx13(
1838
1909
  "tr",
1839
1910
  {
1840
1911
  style: { whiteSpace: "nowrap" },
@@ -1843,16 +1914,16 @@ var ExternalInput = ({
1843
1914
  onChange(mapProp(data[i]));
1844
1915
  setOpen(false);
1845
1916
  },
1846
- children: keys.map((key) => /* @__PURE__ */ jsx12("td", { className: getClassNameModal("td"), children: item[key] }, key))
1917
+ children: keys.map((key) => /* @__PURE__ */ jsx13("td", { className: getClassNameModal("td"), children: item[key] }, key))
1847
1918
  },
1848
1919
  i
1849
1920
  );
1850
1921
  }) })
1851
1922
  ] }),
1852
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx12(Loader, { size: 24 }) })
1923
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx13(Loader, { size: 24 }) })
1853
1924
  ] })
1854
1925
  ] }),
1855
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx12(Footer, { items: mappedData }) })
1926
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx13(Footer, { items: mappedData }) })
1856
1927
  ]
1857
1928
  }
1858
1929
  ) })
@@ -1862,7 +1933,7 @@ var ExternalInput = ({
1862
1933
  };
1863
1934
 
1864
1935
  // components/AutoField/fields/ExternalField/index.tsx
1865
- import { jsx as jsx13 } from "react/jsx-runtime";
1936
+ import { jsx as jsx14 } from "react/jsx-runtime";
1866
1937
  var ExternalField = ({
1867
1938
  field,
1868
1939
  onChange,
@@ -1886,7 +1957,7 @@ var ExternalField = ({
1886
1957
  if (field.type !== "external") {
1887
1958
  return null;
1888
1959
  }
1889
- return /* @__PURE__ */ jsx13(Label2, { label: label || name, icon: /* @__PURE__ */ jsx13(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx13(
1960
+ return /* @__PURE__ */ jsx14(Label2, { label: label || name, icon: /* @__PURE__ */ jsx14(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx14(
1890
1961
  ExternalInput,
1891
1962
  {
1892
1963
  name,
@@ -1911,7 +1982,7 @@ var ExternalField = ({
1911
1982
 
1912
1983
  // components/AutoField/fields/RadioField/index.tsx
1913
1984
  init_react_import();
1914
- import { useMemo as useMemo2 } from "react";
1985
+ import { useMemo as useMemo3 } from "react";
1915
1986
 
1916
1987
  // lib/safe-json-parse.ts
1917
1988
  init_react_import();
@@ -1925,7 +1996,7 @@ var safeJsonParse = (str) => {
1925
1996
  };
1926
1997
 
1927
1998
  // components/AutoField/fields/RadioField/index.tsx
1928
- import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1999
+ import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
1929
2000
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
1930
2001
  var RadioField = ({
1931
2002
  field,
@@ -1937,26 +2008,26 @@ var RadioField = ({
1937
2008
  label,
1938
2009
  Label: Label2
1939
2010
  }) => {
1940
- const flatOptions = useMemo2(
2011
+ const flatOptions = useMemo3(
1941
2012
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
1942
2013
  [field]
1943
2014
  );
1944
2015
  if (field.type !== "radio" || !field.options) {
1945
2016
  return null;
1946
2017
  }
1947
- return /* @__PURE__ */ jsx14(
2018
+ return /* @__PURE__ */ jsx15(
1948
2019
  Label2,
1949
2020
  {
1950
- icon: /* @__PURE__ */ jsx14(CircleCheckBig, { size: 16 }),
2021
+ icon: /* @__PURE__ */ jsx15(CircleCheckBig, { size: 16 }),
1951
2022
  label: label || name,
1952
2023
  readOnly,
1953
2024
  el: "div",
1954
- children: /* @__PURE__ */ jsx14("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs7(
2025
+ children: /* @__PURE__ */ jsx15("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs7(
1955
2026
  "label",
1956
2027
  {
1957
2028
  className: getClassName11("radio"),
1958
2029
  children: [
1959
- /* @__PURE__ */ jsx14(
2030
+ /* @__PURE__ */ jsx15(
1960
2031
  "input",
1961
2032
  {
1962
2033
  type: "radio",
@@ -1976,7 +2047,7 @@ var RadioField = ({
1976
2047
  checked: value === option.value
1977
2048
  }
1978
2049
  ),
1979
- /* @__PURE__ */ jsx14("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2050
+ /* @__PURE__ */ jsx15("div", { className: getClassName11("radioInner"), children: option.label || option.value })
1980
2051
  ]
1981
2052
  },
1982
2053
  option.label + option.value
@@ -1987,8 +2058,8 @@ var RadioField = ({
1987
2058
 
1988
2059
  // components/AutoField/fields/SelectField/index.tsx
1989
2060
  init_react_import();
1990
- import { useMemo as useMemo3 } from "react";
1991
- import { jsx as jsx15 } from "react/jsx-runtime";
2061
+ import { useMemo as useMemo4 } from "react";
2062
+ import { jsx as jsx16 } from "react/jsx-runtime";
1992
2063
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
1993
2064
  var SelectField = ({
1994
2065
  field,
@@ -2000,20 +2071,20 @@ var SelectField = ({
2000
2071
  readOnly,
2001
2072
  id
2002
2073
  }) => {
2003
- const flatOptions = useMemo3(
2074
+ const flatOptions = useMemo4(
2004
2075
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
2005
2076
  [field]
2006
2077
  );
2007
2078
  if (field.type !== "select" || !field.options) {
2008
2079
  return null;
2009
2080
  }
2010
- return /* @__PURE__ */ jsx15(
2081
+ return /* @__PURE__ */ jsx16(
2011
2082
  Label2,
2012
2083
  {
2013
2084
  label: label || name,
2014
- icon: /* @__PURE__ */ jsx15(ChevronDown, { size: 16 }),
2085
+ icon: /* @__PURE__ */ jsx16(ChevronDown, { size: 16 }),
2015
2086
  readOnly,
2016
- children: /* @__PURE__ */ jsx15(
2087
+ children: /* @__PURE__ */ jsx16(
2017
2088
  "select",
2018
2089
  {
2019
2090
  id,
@@ -2030,7 +2101,7 @@ var SelectField = ({
2030
2101
  }
2031
2102
  },
2032
2103
  value,
2033
- children: field.options.map((option) => /* @__PURE__ */ jsx15(
2104
+ children: field.options.map((option) => /* @__PURE__ */ jsx16(
2034
2105
  "option",
2035
2106
  {
2036
2107
  label: option.label,
@@ -2046,7 +2117,7 @@ var SelectField = ({
2046
2117
 
2047
2118
  // components/AutoField/fields/TextareaField/index.tsx
2048
2119
  init_react_import();
2049
- import { jsx as jsx16 } from "react/jsx-runtime";
2120
+ import { jsx as jsx17 } from "react/jsx-runtime";
2050
2121
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
2051
2122
  var TextareaField = ({
2052
2123
  onChange,
@@ -2057,7 +2128,7 @@ var TextareaField = ({
2057
2128
  Label: Label2,
2058
2129
  id
2059
2130
  }) => {
2060
- return /* @__PURE__ */ jsx16(Label2, { label: label || name, icon: /* @__PURE__ */ jsx16(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx16(
2131
+ return /* @__PURE__ */ jsx17(Label2, { label: label || name, icon: /* @__PURE__ */ jsx17(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx17(
2061
2132
  "textarea",
2062
2133
  {
2063
2134
  id,
@@ -2084,7 +2155,7 @@ init_react_import();
2084
2155
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
2085
2156
 
2086
2157
  // components/AutoField/fields/ObjectField/index.tsx
2087
- import { jsx as jsx17 } from "react/jsx-runtime";
2158
+ import { jsx as jsx18 } from "react/jsx-runtime";
2088
2159
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
2089
2160
  var ObjectField = ({
2090
2161
  field,
@@ -2096,43 +2167,54 @@ var ObjectField = ({
2096
2167
  readOnly,
2097
2168
  id
2098
2169
  }) => {
2099
- const { selectedItem } = useAppContext();
2170
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
2100
2171
  if (field.type !== "object" || !field.objectFields) {
2101
2172
  return null;
2102
2173
  }
2103
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
2104
2174
  const data = value || {};
2105
- return /* @__PURE__ */ jsx17(
2175
+ return /* @__PURE__ */ jsx18(
2106
2176
  Label2,
2107
2177
  {
2108
2178
  label: label || name,
2109
- icon: /* @__PURE__ */ jsx17(EllipsisVertical, { size: 16 }),
2179
+ icon: /* @__PURE__ */ jsx18(EllipsisVertical, { size: 16 }),
2110
2180
  el: "div",
2111
2181
  readOnly,
2112
- children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((fieldName) => {
2113
- const subField = field.objectFields[fieldName];
2114
- const subFieldName = `${name}.${fieldName}`;
2115
- const wildcardFieldName = `${name}.${fieldName}`;
2116
- const subReadOnly = readOnly ? readOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
2117
- return /* @__PURE__ */ jsx17(
2118
- AutoFieldPrivate,
2182
+ children: /* @__PURE__ */ jsx18("div", { className: getClassName14(), children: /* @__PURE__ */ jsx18("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
2183
+ const subField = field.objectFields[subName];
2184
+ const subPath = `${name}.${subName}`;
2185
+ const localSubPath = `${localName || name}.${subName}`;
2186
+ const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
2187
+ const label2 = subField.label || subName;
2188
+ return /* @__PURE__ */ jsx18(
2189
+ NestedFieldProvider,
2119
2190
  {
2120
- name: subFieldName,
2121
- label: subField.label || fieldName,
2122
- id: `${id}_${fieldName}`,
2123
- readOnly: subReadOnly,
2124
- field: subField,
2125
- value: data[fieldName],
2126
- onChange: (val, ui) => {
2127
- onChange(
2128
- __spreadProps(__spreadValues({}, data), {
2129
- [fieldName]: val
2191
+ name: localName || id,
2192
+ subName,
2193
+ readOnlyFields,
2194
+ children: /* @__PURE__ */ jsx18(
2195
+ AutoFieldPrivate,
2196
+ {
2197
+ name: subPath,
2198
+ label: subPath,
2199
+ id: `${id}_${subName}`,
2200
+ readOnly: subReadOnly,
2201
+ field: __spreadProps(__spreadValues({}, subField), {
2202
+ label: label2
2203
+ // May be used by custom fields
2130
2204
  }),
2131
- ui
2132
- );
2133
- }
2205
+ value: data[subName],
2206
+ onChange: (val, ui) => {
2207
+ onChange(
2208
+ __spreadProps(__spreadValues({}, data), {
2209
+ [subName]: val
2210
+ }),
2211
+ ui
2212
+ );
2213
+ }
2214
+ }
2215
+ )
2134
2216
  },
2135
- subFieldName
2217
+ subPath
2136
2218
  );
2137
2219
  }) }) })
2138
2220
  }
@@ -2158,7 +2240,7 @@ var useSafeId = () => {
2158
2240
  };
2159
2241
 
2160
2242
  // components/AutoField/index.tsx
2161
- import { Fragment as Fragment4, jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
2243
+ import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
2162
2244
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2163
2245
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2164
2246
  var FieldLabel = ({
@@ -2172,14 +2254,14 @@ var FieldLabel = ({
2172
2254
  const El = el;
2173
2255
  return /* @__PURE__ */ jsxs8(El, { className, children: [
2174
2256
  /* @__PURE__ */ jsxs8("div", { className: getClassName15("label"), children: [
2175
- icon ? /* @__PURE__ */ jsx18("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx18(Fragment4, {}),
2257
+ icon ? /* @__PURE__ */ jsx19("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx19(Fragment4, {}),
2176
2258
  label,
2177
- readOnly && /* @__PURE__ */ jsx18("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx18(Lock, { size: "12" }) })
2259
+ readOnly && /* @__PURE__ */ jsx19("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx19(Lock, { size: "12" }) })
2178
2260
  ] }),
2179
2261
  children
2180
2262
  ] });
2181
2263
  };
2182
- var FieldLabelInternal2 = ({
2264
+ var FieldLabelInternal = ({
2183
2265
  children,
2184
2266
  icon,
2185
2267
  label,
@@ -2187,14 +2269,14 @@ var FieldLabelInternal2 = ({
2187
2269
  readOnly
2188
2270
  }) => {
2189
2271
  const { overrides } = useAppContext();
2190
- const Wrapper = useMemo4(
2272
+ const Wrapper = useMemo5(
2191
2273
  () => overrides.fieldLabel || FieldLabel,
2192
2274
  [overrides]
2193
2275
  );
2194
2276
  if (!label) {
2195
- return /* @__PURE__ */ jsx18(Fragment4, { children });
2277
+ return /* @__PURE__ */ jsx19(Fragment4, { children });
2196
2278
  }
2197
- return /* @__PURE__ */ jsx18(
2279
+ return /* @__PURE__ */ jsx19(
2198
2280
  Wrapper,
2199
2281
  {
2200
2282
  label,
@@ -2208,8 +2290,9 @@ var FieldLabelInternal2 = ({
2208
2290
  };
2209
2291
  function AutoFieldInternal(props) {
2210
2292
  var _a, _b, _c, _d, _e, _f, _g, _h;
2211
- const { dispatch, overrides } = useAppContext();
2212
- const { id, Label: Label2 = FieldLabelInternal2 } = props;
2293
+ const { dispatch, overrides, selectedItem } = useAppContext();
2294
+ const nestedFieldContext = useContext3(NestedFieldContext);
2295
+ const { id, Label: Label2 = FieldLabelInternal } = props;
2213
2296
  const field = props.field;
2214
2297
  const label = field.label;
2215
2298
  const defaultId = useSafeId();
@@ -2269,20 +2352,29 @@ function AutoFieldInternal(props) {
2269
2352
  return null;
2270
2353
  }
2271
2354
  const CustomField = field.render;
2272
- return /* @__PURE__ */ jsx18("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx18("div", { className: getClassName15(), children: /* @__PURE__ */ jsx18(CustomField, __spreadValues({}, mergedProps)) }) });
2355
+ return /* @__PURE__ */ jsx19("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx19("div", { className: getClassName15(), children: /* @__PURE__ */ jsx19(CustomField, __spreadValues({}, mergedProps)) }) });
2273
2356
  }
2274
2357
  const children = defaultFields[field.type](mergedProps);
2275
2358
  const Render2 = render[field.type];
2276
- return /* @__PURE__ */ jsx18(
2277
- "div",
2359
+ return /* @__PURE__ */ jsx19(
2360
+ NestedFieldContext.Provider,
2278
2361
  {
2279
- className: getClassNameWrapper(),
2280
- onFocus,
2281
- onBlur,
2282
- onClick: (e) => {
2283
- e.stopPropagation();
2362
+ value: {
2363
+ readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
2364
+ localName: nestedFieldContext.localName
2284
2365
  },
2285
- children: /* @__PURE__ */ jsx18(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2366
+ children: /* @__PURE__ */ jsx19(
2367
+ "div",
2368
+ {
2369
+ className: getClassNameWrapper(),
2370
+ onFocus,
2371
+ onBlur,
2372
+ onClick: (e) => {
2373
+ e.stopPropagation();
2374
+ },
2375
+ children: /* @__PURE__ */ jsx19(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2376
+ }
2377
+ )
2286
2378
  }
2287
2379
  );
2288
2380
  }
@@ -2310,11 +2402,11 @@ function AutoFieldPrivate(props) {
2310
2402
  value: localValue,
2311
2403
  onChange: onChangeLocal
2312
2404
  };
2313
- return /* @__PURE__ */ jsx18(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2405
+ return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2314
2406
  }
2315
2407
  function AutoField(props) {
2316
- const DefaultLabel = useMemo4(() => {
2317
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx18(
2408
+ const DefaultLabel = useMemo5(() => {
2409
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx19(
2318
2410
  "div",
2319
2411
  __spreadProps(__spreadValues({}, labelProps), {
2320
2412
  className: getClassName15({ readOnly: props.readOnly })
@@ -2322,7 +2414,7 @@ function AutoField(props) {
2322
2414
  );
2323
2415
  return DefaultLabel2;
2324
2416
  }, [props.readOnly]);
2325
- return /* @__PURE__ */ jsx18(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2417
+ return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2326
2418
  }
2327
2419
 
2328
2420
  // components/Drawer/index.tsx
@@ -2333,17 +2425,18 @@ init_react_import();
2333
2425
  var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
2334
2426
 
2335
2427
  // components/Drawer/index.tsx
2336
- import { useMemo as useMemo8, useState as useState18 } from "react";
2428
+ import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
2337
2429
 
2338
2430
  // components/DragDropContext/index.tsx
2339
2431
  init_react_import();
2340
2432
  import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
2341
2433
  import {
2342
- createContext as createContext3,
2343
- useCallback as useCallback9,
2344
- useContext as useContext4,
2345
- useEffect as useEffect14,
2346
- useRef as useRef5,
2434
+ createContext as createContext4,
2435
+ useCallback as useCallback11,
2436
+ useContext as useContext7,
2437
+ useEffect as useEffect15,
2438
+ useId,
2439
+ useRef as useRef4,
2347
2440
  useState as useState17
2348
2441
  } from "react";
2349
2442
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
@@ -2352,22 +2445,21 @@ import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
2352
2445
  init_react_import();
2353
2446
  import {
2354
2447
  forwardRef as forwardRef3,
2355
- useCallback as useCallback8,
2356
- useContext as useContext3,
2357
- useEffect as useEffect13,
2358
- useMemo as useMemo7,
2359
- useRef as useRef4,
2360
- useState as useState16
2448
+ useCallback as useCallback10,
2449
+ useContext as useContext6,
2450
+ useEffect as useEffect14,
2451
+ useMemo as useMemo8,
2452
+ useRef as useRef3
2361
2453
  } from "react";
2362
2454
 
2363
2455
  // components/DraggableComponent/index.tsx
2364
2456
  init_react_import();
2365
2457
  import {
2366
- useCallback as useCallback6,
2367
- useContext as useContext2,
2368
- useEffect as useEffect11,
2369
- useMemo as useMemo5,
2370
- useRef as useRef3,
2458
+ useCallback as useCallback7,
2459
+ useContext as useContext5,
2460
+ useEffect as useEffect10,
2461
+ useMemo as useMemo7,
2462
+ useRef as useRef2,
2371
2463
  useState as useState13
2372
2464
  } from "react";
2373
2465
 
@@ -2375,47 +2467,21 @@ import {
2375
2467
  init_react_import();
2376
2468
  var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
2377
2469
 
2378
- // lib/use-modifier-held.ts
2379
- init_react_import();
2380
- import { useEffect as useEffect10, useState as useState12 } from "react";
2381
- var useModifierHeld = (modifier) => {
2382
- const [modifierHeld, setModifierHeld] = useState12(false);
2383
- useEffect10(() => {
2384
- function downHandler({ key }) {
2385
- if (key === modifier) {
2386
- setModifierHeld(true);
2387
- }
2388
- }
2389
- function upHandler({ key }) {
2390
- if (key === modifier) {
2391
- setModifierHeld(false);
2392
- }
2393
- }
2394
- window.addEventListener("keydown", downHandler);
2395
- window.addEventListener("keyup", upHandler);
2396
- return () => {
2397
- window.removeEventListener("keydown", downHandler);
2398
- window.removeEventListener("keyup", upHandler);
2399
- };
2400
- }, [modifier]);
2401
- return modifierHeld;
2402
- };
2403
-
2404
2470
  // components/DraggableComponent/index.tsx
2405
2471
  import { createPortal as createPortal2 } from "react-dom";
2406
2472
 
2407
- // components/DraggableComponent/collision/dynamic/index.ts
2473
+ // lib/dnd/collision/dynamic/index.ts
2408
2474
  init_react_import();
2409
2475
  import {
2410
2476
  CollisionPriority as CollisionPriority7,
2411
2477
  CollisionType as CollisionType7
2412
2478
  } from "@dnd-kit/abstract";
2413
2479
 
2414
- // components/DraggableComponent/collision/directional/index.ts
2480
+ // lib/dnd/collision/directional/index.ts
2415
2481
  init_react_import();
2416
2482
  import { CollisionType } from "@dnd-kit/abstract";
2417
2483
 
2418
- // components/DraggableComponent/collision/collision-debug.ts
2484
+ // lib/dnd/collision/collision-debug.ts
2419
2485
  init_react_import();
2420
2486
  var DEBUG = false;
2421
2487
  var debugElements = {};
@@ -2464,7 +2530,7 @@ var collisionDebug = (a, b, id, color, label) => {
2464
2530
  });
2465
2531
  };
2466
2532
 
2467
- // components/DraggableComponent/collision/directional/index.ts
2533
+ // lib/dnd/collision/directional/index.ts
2468
2534
  var distanceChange = "increasing";
2469
2535
  var directionalCollision = (input, previous) => {
2470
2536
  var _a;
@@ -2497,7 +2563,7 @@ var directionalCollision = (input, previous) => {
2497
2563
  return null;
2498
2564
  };
2499
2565
 
2500
- // components/DraggableComponent/collision/dynamic/get-direction.ts
2566
+ // lib/dnd/collision/dynamic/get-direction.ts
2501
2567
  init_react_import();
2502
2568
  var getDirection = (dragAxis, delta) => {
2503
2569
  if (dragAxis === "dynamic") {
@@ -2512,7 +2578,7 @@ var getDirection = (dragAxis, delta) => {
2512
2578
  return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2513
2579
  };
2514
2580
 
2515
- // components/DraggableComponent/collision/dynamic/get-midpoint-impact.ts
2581
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
2516
2582
  init_react_import();
2517
2583
  var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
2518
2584
  const dragRect = dragShape.boundingRectangle;
@@ -2531,7 +2597,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2531
2597
  return dragRect.right - offset >= dropCenter.x;
2532
2598
  };
2533
2599
 
2534
- // components/DraggableComponent/collision/dynamic/track-movement-interval.ts
2600
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
2535
2601
  init_react_import();
2536
2602
  import { Point } from "@dnd-kit/geometry";
2537
2603
  var INTERVAL_SENSITIVITY = 10;
@@ -2635,7 +2701,14 @@ var closestCorners = (input) => {
2635
2701
  };
2636
2702
  };
2637
2703
 
2638
- // components/DraggableComponent/collision/dynamic/index.ts
2704
+ // lib/dnd/collision/dynamic/store.ts
2705
+ init_react_import();
2706
+ import { createStore } from "zustand/vanilla";
2707
+ var collisionStore = createStore(() => ({
2708
+ fallbackEnabled: false
2709
+ }));
2710
+
2711
+ // lib/dnd/collision/dynamic/index.ts
2639
2712
  var flushNext = "";
2640
2713
  var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2641
2714
  var _a, _b, _c, _d, _e;
@@ -2647,6 +2720,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2647
2720
  return null;
2648
2721
  }
2649
2722
  const { center: dragCenter } = dragShape;
2723
+ const { fallbackEnabled } = collisionStore.getState();
2650
2724
  const interval = trackMovementInterval(position.current, dragAxis);
2651
2725
  dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2652
2726
  direction: interval.direction
@@ -2692,7 +2766,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2692
2766
  flushNext = "";
2693
2767
  return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2694
2768
  }
2695
- if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2769
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2696
2770
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2697
2771
  const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2698
2772
  if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
@@ -2753,8 +2827,107 @@ function getDeepScrollPosition(element) {
2753
2827
  return totalScroll;
2754
2828
  }
2755
2829
 
2830
+ // components/DropZone/context.tsx
2831
+ init_react_import();
2832
+ import {
2833
+ createContext as createContext3,
2834
+ useCallback as useCallback6,
2835
+ useMemo as useMemo6,
2836
+ useState as useState12
2837
+ } from "react";
2838
+ import { createStore as createStore2 } from "zustand";
2839
+ import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
2840
+ var dropZoneContext = createContext3(null);
2841
+ var ZoneStoreContext = createContext3(
2842
+ createStore2(() => ({
2843
+ zoneDepthIndex: {},
2844
+ nextZoneDepthIndex: {},
2845
+ areaDepthIndex: {},
2846
+ nextAreaDepthIndex: {},
2847
+ draggedItem: null,
2848
+ previewIndex: {}
2849
+ }))
2850
+ );
2851
+ var ZoneStoreProvider = ({
2852
+ children,
2853
+ store
2854
+ }) => {
2855
+ return /* @__PURE__ */ jsx20(ZoneStoreContext.Provider, { value: store, children });
2856
+ };
2857
+ var DropZoneProvider = ({
2858
+ children,
2859
+ value
2860
+ }) => {
2861
+ const [hoveringComponent, setHoveringComponent] = useState12();
2862
+ const [areasWithZones, setAreasWithZones] = useState12(
2863
+ {}
2864
+ );
2865
+ const [activeZones, setActiveZones] = useState12({});
2866
+ const { dispatch } = useAppContext();
2867
+ const registerZoneArea = useCallback6(
2868
+ (area) => {
2869
+ setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
2870
+ },
2871
+ [setAreasWithZones]
2872
+ );
2873
+ const registerZone = useCallback6(
2874
+ (zoneCompound) => {
2875
+ if (!dispatch) {
2876
+ return;
2877
+ }
2878
+ dispatch({
2879
+ type: "registerZone",
2880
+ zone: zoneCompound
2881
+ });
2882
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
2883
+ },
2884
+ [setActiveZones, dispatch]
2885
+ );
2886
+ const unregisterZone = useCallback6(
2887
+ (zoneCompound) => {
2888
+ if (!dispatch) {
2889
+ return;
2890
+ }
2891
+ dispatch({
2892
+ type: "unregisterZone",
2893
+ zone: zoneCompound
2894
+ });
2895
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
2896
+ [zoneCompound]: false
2897
+ }));
2898
+ },
2899
+ [setActiveZones, dispatch]
2900
+ );
2901
+ const memoValue = useMemo6(
2902
+ () => __spreadValues({
2903
+ hoveringComponent,
2904
+ setHoveringComponent,
2905
+ registerZoneArea,
2906
+ areasWithZones,
2907
+ registerZone,
2908
+ unregisterZone,
2909
+ activeZones
2910
+ }, value),
2911
+ [value, hoveringComponent, areasWithZones, activeZones]
2912
+ );
2913
+ return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
2914
+ };
2915
+
2916
+ // lib/use-context-store.ts
2917
+ init_react_import();
2918
+ import { useContext as useContext4 } from "react";
2919
+ import { useStore } from "zustand";
2920
+ import { useShallow } from "zustand/react/shallow";
2921
+ function useContextStore(context, selector) {
2922
+ const store = useContext4(context);
2923
+ if (!store) {
2924
+ throw new Error("useContextStore must be used inside context");
2925
+ }
2926
+ return useStore(store, useShallow(selector));
2927
+ }
2928
+
2756
2929
  // components/DraggableComponent/index.tsx
2757
- import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
2930
+ import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
2758
2931
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
2759
2932
  var DEBUG2 = false;
2760
2933
  var space = 8;
@@ -2768,9 +2941,9 @@ var DefaultActionBar = ({
2768
2941
  }) => /* @__PURE__ */ jsxs9(ActionBar, { children: [
2769
2942
  /* @__PURE__ */ jsxs9(ActionBar.Group, { children: [
2770
2943
  parentAction,
2771
- label && /* @__PURE__ */ jsx19(ActionBar.Label, { label })
2944
+ label && /* @__PURE__ */ jsx21(ActionBar.Label, { label })
2772
2945
  ] }),
2773
- /* @__PURE__ */ jsx19(ActionBar.Group, { children })
2946
+ /* @__PURE__ */ jsx21(ActionBar.Group, { children })
2774
2947
  ] });
2775
2948
  var convertIdToSelector = (id, zoneCompound, data) => {
2776
2949
  const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
@@ -2805,10 +2978,9 @@ var DraggableComponent = ({
2805
2978
  iframe,
2806
2979
  state
2807
2980
  } = useAppContext();
2808
- const isModifierHeld = useModifierHeld("Alt");
2809
- const ctx = useContext2(dropZoneContext);
2981
+ const ctx = useContext5(dropZoneContext);
2810
2982
  const [localZones, setLocalZones] = useState13({});
2811
- const registerLocalZone = useCallback6(
2983
+ const registerLocalZone = useCallback7(
2812
2984
  (zoneCompound2, active) => {
2813
2985
  var _a;
2814
2986
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -2818,7 +2990,7 @@ var DraggableComponent = ({
2818
2990
  },
2819
2991
  [setLocalZones]
2820
2992
  );
2821
- const unregisterLocalZone = useCallback6(
2993
+ const unregisterLocalZone = useCallback7(
2822
2994
  (zoneCompound2) => {
2823
2995
  var _a;
2824
2996
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -2833,7 +3005,7 @@ var DraggableComponent = ({
2833
3005
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
2834
3006
  const { path = [] } = ctx || {};
2835
3007
  const [canDrag, setCanDrag] = useState13(false);
2836
- useEffect11(() => {
3008
+ useEffect10(() => {
2837
3009
  var _a;
2838
3010
  const item = getItem({ index, zone: zoneCompound }, state.data);
2839
3011
  if (item) {
@@ -2843,7 +3015,10 @@ var DraggableComponent = ({
2843
3015
  setCanDrag((_a = perms.drag) != null ? _a : true);
2844
3016
  }
2845
3017
  }, [state, index, zoneCompound, getPermissions]);
2846
- const userIsDragging = !!(ctx == null ? void 0 : ctx.draggedItem);
3018
+ const userIsDragging = useContextStore(
3019
+ ZoneStoreContext,
3020
+ (s) => !!s.draggedItem
3021
+ );
2847
3022
  const canCollide = canDrag || userIsDragging;
2848
3023
  const disabled = !isEnabled || !canCollide;
2849
3024
  const [dragAxis, setDragAxis] = useState13(userDragAxis || autoDragAxis);
@@ -2872,8 +3047,8 @@ var DraggableComponent = ({
2872
3047
  }
2873
3048
  });
2874
3049
  const thisIsDragging = status === "dragging";
2875
- const ref = useRef3(null);
2876
- const refSetter = useCallback6(
3050
+ const ref = useRef2(null);
3051
+ const refSetter = useCallback7(
2877
3052
  (el) => {
2878
3053
  sortableRef(el);
2879
3054
  if (el) {
@@ -2883,13 +3058,13 @@ var DraggableComponent = ({
2883
3058
  [sortableRef]
2884
3059
  );
2885
3060
  const [portalEl, setPortalEl] = useState13();
2886
- useEffect11(() => {
3061
+ useEffect10(() => {
2887
3062
  var _a, _b, _c;
2888
3063
  setPortalEl(
2889
3064
  iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
2890
3065
  );
2891
3066
  }, [iframe.enabled, ref.current]);
2892
- const getStyle = useCallback6(() => {
3067
+ const getStyle = useCallback7(() => {
2893
3068
  var _a, _b, _c;
2894
3069
  if (!ref.current) return;
2895
3070
  const rect = ref.current.getBoundingClientRect();
@@ -2910,10 +3085,10 @@ var DraggableComponent = ({
2910
3085
  return style2;
2911
3086
  }, [ref.current]);
2912
3087
  const [style, setStyle] = useState13();
2913
- const sync = useCallback6(() => {
3088
+ const sync = useCallback7(() => {
2914
3089
  setStyle(getStyle());
2915
3090
  }, [ref.current, iframe]);
2916
- useEffect11(() => {
3091
+ useEffect10(() => {
2917
3092
  if (ref.current) {
2918
3093
  const observer = new ResizeObserver(sync);
2919
3094
  observer.observe(ref.current);
@@ -2922,20 +3097,22 @@ var DraggableComponent = ({
2922
3097
  };
2923
3098
  }
2924
3099
  }, [ref.current]);
2925
- useEffect11(() => {
2926
- ctx == null ? void 0 : ctx.registerPath({
2927
- index,
2928
- zone: zoneCompound
2929
- });
3100
+ useEffect10(() => {
3101
+ if (isSelected) {
3102
+ ctx == null ? void 0 : ctx.registerPath({
3103
+ index,
3104
+ zone: zoneCompound
3105
+ });
3106
+ }
2930
3107
  }, [isSelected]);
2931
- const CustomActionBar = useMemo5(
3108
+ const CustomActionBar = useMemo7(
2932
3109
  () => overrides.actionBar || DefaultActionBar,
2933
3110
  [overrides.actionBar]
2934
3111
  );
2935
3112
  const permissions = getPermissions({
2936
3113
  item: selectedItem
2937
3114
  });
2938
- const onClick = useCallback6(
3115
+ const onClick = useCallback7(
2939
3116
  (e) => {
2940
3117
  e.stopPropagation();
2941
3118
  dispatch({
@@ -2947,7 +3124,7 @@ var DraggableComponent = ({
2947
3124
  },
2948
3125
  [index, zoneCompound, id]
2949
3126
  );
2950
- const onSelectParent = useCallback6(() => {
3127
+ const onSelectParent = useCallback7(() => {
2951
3128
  if (!(ctx == null ? void 0 : ctx.areaId)) {
2952
3129
  return;
2953
3130
  }
@@ -2965,14 +3142,14 @@ var DraggableComponent = ({
2965
3142
  }
2966
3143
  });
2967
3144
  }, [ctx, path]);
2968
- const onDuplicate = useCallback6(() => {
3145
+ const onDuplicate = useCallback7(() => {
2969
3146
  dispatch({
2970
3147
  type: "duplicate",
2971
3148
  sourceIndex: index,
2972
3149
  sourceZone: zoneCompound
2973
3150
  });
2974
3151
  }, [index, zoneCompound]);
2975
- const onDelete = useCallback6(() => {
3152
+ const onDelete = useCallback7(() => {
2976
3153
  dispatch({
2977
3154
  type: "remove",
2978
3155
  index,
@@ -2981,7 +3158,7 @@ var DraggableComponent = ({
2981
3158
  }, [index, zoneCompound]);
2982
3159
  const [hover, setHover] = useState13(false);
2983
3160
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
2984
- useEffect11(() => {
3161
+ useEffect10(() => {
2985
3162
  if (!ref.current) {
2986
3163
  return;
2987
3164
  }
@@ -3031,7 +3208,7 @@ var DraggableComponent = ({
3031
3208
  thisIsDragging,
3032
3209
  inDroppableZone
3033
3210
  ]);
3034
- useEffect11(() => {
3211
+ useEffect10(() => {
3035
3212
  if (ref.current && disabled) {
3036
3213
  ref.current.setAttribute("data-puck-disabled", "");
3037
3214
  return () => {
@@ -3041,7 +3218,7 @@ var DraggableComponent = ({
3041
3218
  }
3042
3219
  }, [disabled, ref]);
3043
3220
  const [isVisible, setIsVisible] = useState13(false);
3044
- useEffect11(() => {
3221
+ useEffect10(() => {
3045
3222
  sync();
3046
3223
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
3047
3224
  setIsVisible(true);
@@ -3049,7 +3226,7 @@ var DraggableComponent = ({
3049
3226
  setIsVisible(false);
3050
3227
  }
3051
3228
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3052
- const syncActionsPosition = useCallback6(
3229
+ const syncActionsPosition = useCallback7(
3053
3230
  (el) => {
3054
3231
  if (el) {
3055
3232
  const view = el.ownerDocument.defaultView;
@@ -3066,7 +3243,7 @@ var DraggableComponent = ({
3066
3243
  },
3067
3244
  [zoomConfig]
3068
3245
  );
3069
- useEffect11(() => {
3246
+ useEffect10(() => {
3070
3247
  if (userDragAxis) {
3071
3248
  setDragAxis(userDragAxis);
3072
3249
  return;
@@ -3080,7 +3257,7 @@ var DraggableComponent = ({
3080
3257
  }
3081
3258
  setDragAxis(autoDragAxis);
3082
3259
  }, [ref, userDragAxis, autoDragAxis]);
3083
- const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx19(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx19(CornerLeftUp, { size: 16 }) });
3260
+ const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx21(CornerLeftUp, { size: 16 }) });
3084
3261
  return /* @__PURE__ */ jsxs9(
3085
3262
  DropZoneProvider,
3086
3263
  {
@@ -3101,22 +3278,21 @@ var DraggableComponent = ({
3101
3278
  className: getClassName16({
3102
3279
  isSelected,
3103
3280
  isDragging: thisIsDragging,
3104
- isModifierHeld,
3105
3281
  hover: hover || indicativeHover
3106
3282
  }),
3107
3283
  style: __spreadValues({}, style),
3108
3284
  "data-puck-overlay": true,
3109
3285
  children: [
3110
3286
  debug,
3111
- isLoading && /* @__PURE__ */ jsx19("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx19(Loader, {}) }),
3112
- /* @__PURE__ */ jsx19(
3287
+ isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
3288
+ /* @__PURE__ */ jsx21(
3113
3289
  "div",
3114
3290
  {
3115
3291
  className: getClassName16("actionsOverlay"),
3116
3292
  style: {
3117
3293
  top: actionsOverlayTop / zoomConfig.zoom
3118
3294
  },
3119
- children: /* @__PURE__ */ jsx19(
3295
+ children: /* @__PURE__ */ jsx21(
3120
3296
  "div",
3121
3297
  {
3122
3298
  className: getClassName16("actions"),
@@ -3134,8 +3310,8 @@ var DraggableComponent = ({
3134
3310
  parentAction,
3135
3311
  label: DEBUG2 ? id : label,
3136
3312
  children: [
3137
- permissions.duplicate && /* @__PURE__ */ jsx19(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx19(Copy, { size: 16 }) }),
3138
- permissions.delete && /* @__PURE__ */ jsx19(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx19(Trash, { size: 16 }) })
3313
+ permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
3314
+ permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
3139
3315
  ]
3140
3316
  }
3141
3317
  )
@@ -3143,7 +3319,7 @@ var DraggableComponent = ({
3143
3319
  )
3144
3320
  }
3145
3321
  ),
3146
- /* @__PURE__ */ jsx19("div", { className: getClassName16("overlay") })
3322
+ /* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
3147
3323
  ]
3148
3324
  }
3149
3325
  ),
@@ -3159,98 +3335,26 @@ var DraggableComponent = ({
3159
3335
  init_react_import();
3160
3336
  var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isActive": "_DropZone--isActive_kmkdc_10", "DropZone--hasChildren": "_DropZone--hasChildren_kmkdc_14", "DropZone--userIsDragging": "_DropZone--userIsDragging_kmkdc_22", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_kmkdc_26", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_kmkdc_27", "DropZone--isRootZone": "_DropZone--isRootZone_kmkdc_27", "DropZone--isDestination": "_DropZone--isDestination_kmkdc_37", "DropZone-item": "_DropZone-item_kmkdc_49", "DropZone-hitbox": "_DropZone-hitbox_kmkdc_53", "DropZone--isEnabled": "_DropZone--isEnabled_kmkdc_61", "DropZone--isAnimating": "_DropZone--isAnimating_kmkdc_70" };
3161
3337
 
3162
- // components/DropZone/context.tsx
3338
+ // components/DropZone/lib/use-min-empty-height.ts
3163
3339
  init_react_import();
3164
- import {
3165
- createContext as createContext2,
3166
- useCallback as useCallback7,
3167
- useMemo as useMemo6,
3168
- useState as useState14
3169
- } from "react";
3170
- import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
3171
- var dropZoneContext = createContext2(null);
3172
- var DropZoneProvider = ({
3173
- children,
3174
- value
3175
- }) => {
3176
- const [hoveringComponent, setHoveringComponent] = useState14();
3177
- const [areasWithZones, setAreasWithZones] = useState14(
3178
- {}
3179
- );
3180
- const [activeZones, setActiveZones] = useState14({});
3181
- const { dispatch = null } = value ? value : {};
3182
- const registerZoneArea = useCallback7(
3183
- (area) => {
3184
- setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
3185
- },
3186
- [setAreasWithZones]
3187
- );
3188
- const registerZone = useCallback7(
3189
- (zoneCompound) => {
3190
- if (!dispatch) {
3191
- return;
3192
- }
3193
- dispatch({
3194
- type: "registerZone",
3195
- zone: zoneCompound
3196
- });
3197
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
3198
- },
3199
- [setActiveZones, dispatch]
3200
- );
3201
- const unregisterZone = useCallback7(
3202
- (zoneCompound) => {
3203
- if (!dispatch) {
3204
- return;
3205
- }
3206
- dispatch({
3207
- type: "unregisterZone",
3208
- zone: zoneCompound
3209
- });
3210
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
3211
- [zoneCompound]: false
3212
- }));
3213
- },
3214
- [setActiveZones, dispatch]
3215
- );
3216
- const memoValue = useMemo6(
3217
- () => __spreadValues({
3218
- hoveringComponent,
3219
- setHoveringComponent,
3220
- registerZoneArea,
3221
- areasWithZones,
3222
- registerZone,
3223
- unregisterZone,
3224
- activeZones
3225
- }, value),
3226
- [value, hoveringComponent, areasWithZones, activeZones]
3227
- );
3228
- return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
3229
- };
3230
-
3231
- // lib/insert.ts
3232
- init_react_import();
3233
- var insert = (list, index, item) => {
3234
- const result = Array.from(list);
3235
- result.splice(index, 0, item);
3236
- return result;
3237
- };
3238
-
3239
- // components/DropZone/use-min-empty-height.ts
3240
- init_react_import();
3241
- import { useEffect as useEffect12, useState as useState15 } from "react";
3340
+ import { useEffect as useEffect11, useState as useState14 } from "react";
3242
3341
  var useMinEmptyHeight = ({
3243
- draggedItem,
3244
3342
  zoneCompound,
3245
3343
  userMinEmptyHeight,
3246
3344
  ref
3247
3345
  }) => {
3248
- const [prevHeight, setPrevHeight] = useState15(0);
3249
- const [isAnimating, setIsAnimating] = useState15(false);
3250
- useEffect12(() => {
3346
+ const [prevHeight, setPrevHeight] = useState14(0);
3347
+ const [isAnimating, setIsAnimating] = useState14(false);
3348
+ const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3349
+ var _a, _b;
3350
+ return {
3351
+ draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
3352
+ isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3353
+ };
3354
+ });
3355
+ useEffect11(() => {
3251
3356
  if (draggedItem && ref.current) {
3252
- const componentData = draggedItem.data;
3253
- if (componentData.zone === zoneCompound) {
3357
+ if (isZone) {
3254
3358
  const rect = ref.current.getBoundingClientRect();
3255
3359
  setPrevHeight(rect.height);
3256
3360
  setIsAnimating(true);
@@ -3280,15 +3384,131 @@ function assignRefs(refs, node) {
3280
3384
  });
3281
3385
  }
3282
3386
 
3283
- // components/DropZone/index.tsx
3284
- import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
3285
- var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3286
- var DEBUG3 = false;
3387
+ // components/DropZone/lib/use-content-with-preview.ts
3388
+ init_react_import();
3389
+ import { useEffect as useEffect12, useState as useState15 } from "react";
3390
+
3391
+ // lib/dnd/use-rendered-callback.ts
3392
+ init_react_import();
3393
+ import { useDragDropManager } from "@dnd-kit/react";
3394
+ import { useCallback as useCallback8 } from "react";
3395
+ function useRenderedCallback(callback, deps) {
3396
+ const manager = useDragDropManager();
3397
+ return useCallback8(
3398
+ (...args) => __async(this, null, function* () {
3399
+ yield manager == null ? void 0 : manager.renderer.rendering;
3400
+ return callback(...args);
3401
+ }),
3402
+ [...deps, manager]
3403
+ );
3404
+ }
3405
+
3406
+ // lib/insert.ts
3407
+ init_react_import();
3408
+ var insert = (list, index, item) => {
3409
+ const result = Array.from(list);
3410
+ result.splice(index, 0, item);
3411
+ return result;
3412
+ };
3413
+
3414
+ // components/DropZone/lib/use-content-with-preview.ts
3415
+ var useContentWithPreview = (content, zoneCompound) => {
3416
+ const { draggedItemId, preview, previewExists } = useContextStore(
3417
+ ZoneStoreContext,
3418
+ (s) => {
3419
+ var _a;
3420
+ return {
3421
+ draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
3422
+ preview: s.previewIndex[zoneCompound],
3423
+ previewExists: Object.keys(s.previewIndex || {}).length > 0
3424
+ };
3425
+ }
3426
+ );
3427
+ const [contentWithPreview, setContentWithPreview] = useState15(content);
3428
+ const updateContent = useRenderedCallback(
3429
+ (content2, preview2) => {
3430
+ if (preview2) {
3431
+ if (preview2.type === "insert") {
3432
+ setContentWithPreview(
3433
+ insert(
3434
+ content2.filter((item) => item.props.id !== preview2.props.id),
3435
+ preview2.index,
3436
+ {
3437
+ type: "preview",
3438
+ props: { id: preview2.props.id }
3439
+ }
3440
+ )
3441
+ );
3442
+ } else {
3443
+ setContentWithPreview(
3444
+ insert(
3445
+ content2.filter((item) => item.props.id !== preview2.props.id),
3446
+ preview2.index,
3447
+ {
3448
+ type: preview2.componentType,
3449
+ props: preview2.props
3450
+ }
3451
+ )
3452
+ );
3453
+ }
3454
+ } else {
3455
+ setContentWithPreview(
3456
+ previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3457
+ );
3458
+ }
3459
+ },
3460
+ [draggedItemId, previewExists]
3461
+ );
3462
+ useEffect12(() => {
3463
+ updateContent(content, preview);
3464
+ }, [content, preview]);
3465
+ return contentWithPreview;
3466
+ };
3467
+
3468
+ // components/DropZone/lib/use-drag-axis.ts
3469
+ init_react_import();
3470
+ import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
3287
3471
  var GRID_DRAG_AXIS = "dynamic";
3288
3472
  var FLEX_ROW_DRAG_AXIS = "x";
3289
3473
  var DEFAULT_DRAG_AXIS = "y";
3474
+ var useDragAxis = (ref, collisionAxis) => {
3475
+ const { status } = useAppContext();
3476
+ const [dragAxis, setDragAxis] = useState16(
3477
+ collisionAxis || DEFAULT_DRAG_AXIS
3478
+ );
3479
+ const calculateDragAxis = useCallback9(() => {
3480
+ if (ref.current) {
3481
+ const computedStyle = window.getComputedStyle(ref.current);
3482
+ if (computedStyle.display === "grid") {
3483
+ setDragAxis(GRID_DRAG_AXIS);
3484
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3485
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3486
+ } else {
3487
+ setDragAxis(DEFAULT_DRAG_AXIS);
3488
+ }
3489
+ }
3490
+ }, [ref.current]);
3491
+ useEffect13(() => {
3492
+ const onViewportChange = () => {
3493
+ calculateDragAxis();
3494
+ };
3495
+ window.addEventListener("viewportchange", onViewportChange);
3496
+ return () => {
3497
+ window.removeEventListener("viewportchange", onViewportChange);
3498
+ };
3499
+ }, []);
3500
+ useEffect13(calculateDragAxis, [status, collisionAxis]);
3501
+ return [dragAxis, calculateDragAxis];
3502
+ };
3503
+
3504
+ // components/DropZone/index.tsx
3505
+ import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
3506
+ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3507
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3508
+ var RENDER_DEBUG = false;
3509
+ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
3290
3510
  var DropZoneEdit = forwardRef3(
3291
- function DropZoneEdit2({
3511
+ function DropZoneEditInternal({
3292
3512
  zone,
3293
3513
  allow,
3294
3514
  disallow,
@@ -3298,31 +3518,50 @@ var DropZoneEdit = forwardRef3(
3298
3518
  collisionAxis
3299
3519
  }, userRef) {
3300
3520
  const appContext2 = useAppContext();
3301
- const ctx = useContext3(dropZoneContext);
3521
+ const ctx = useContext6(dropZoneContext);
3302
3522
  const {
3303
3523
  // These all need setting via context
3304
3524
  data,
3305
3525
  config,
3306
3526
  areaId,
3307
- draggedItem,
3308
3527
  registerZoneArea,
3309
3528
  depth,
3310
3529
  registerLocalZone,
3311
3530
  unregisterLocalZone,
3312
- deepestZone = rootDroppableId,
3313
- deepestArea,
3314
- nextDeepestArea,
3315
3531
  path = [],
3316
3532
  activeZones
3317
3533
  } = ctx;
3318
- const { itemSelector } = appContext2.state.ui;
3319
3534
  let zoneCompound = rootDroppableId;
3320
- useEffect13(() => {
3535
+ if (areaId) {
3536
+ if (zone !== rootDroppableId) {
3537
+ zoneCompound = `${areaId}:${zone}`;
3538
+ }
3539
+ }
3540
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3541
+ const {
3542
+ isDeepestZone,
3543
+ inNextDeepestArea,
3544
+ draggedComponentType,
3545
+ userIsDragging,
3546
+ preview
3547
+ } = useContextStore(ZoneStoreContext, (s) => {
3548
+ var _a, _b, _c;
3549
+ return {
3550
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3551
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3552
+ draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3553
+ draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3554
+ userIsDragging: !!s.draggedItem,
3555
+ preview: s.previewIndex[zoneCompound]
3556
+ };
3557
+ });
3558
+ const { itemSelector } = appContext2.state.ui;
3559
+ useEffect14(() => {
3321
3560
  if (areaId && registerZoneArea) {
3322
3561
  registerZoneArea(areaId);
3323
3562
  }
3324
3563
  }, [areaId]);
3325
- useEffect13(() => {
3564
+ useEffect14(() => {
3326
3565
  if (ctx == null ? void 0 : ctx.registerZone) {
3327
3566
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3328
3567
  }
@@ -3332,25 +3571,18 @@ var DropZoneEdit = forwardRef3(
3332
3571
  }
3333
3572
  };
3334
3573
  }, []);
3335
- if (areaId) {
3336
- if (zone !== rootDroppableId) {
3337
- zoneCompound = `${areaId}:${zone}`;
3338
- }
3339
- }
3340
- const content = useMemo7(() => {
3574
+ const content = useMemo8(() => {
3341
3575
  if (areaId && zone !== rootDroppableId) {
3342
3576
  return setupZone(data, zoneCompound).zones[zoneCompound];
3343
3577
  }
3344
3578
  return data.content || [];
3345
3579
  }, [data, zoneCompound]);
3346
- const ref = useRef4(null);
3347
- const acceptsTarget = useCallback8(
3348
- (target) => {
3349
- if (!target) {
3580
+ const ref = useRef3(null);
3581
+ const acceptsTarget = useCallback10(
3582
+ (componentType) => {
3583
+ if (!componentType) {
3350
3584
  return true;
3351
3585
  }
3352
- const data2 = target.data;
3353
- const { componentType } = data2;
3354
3586
  if (disallow) {
3355
3587
  const defaultedAllow = allow || [];
3356
3588
  const filteredDisallow = (disallow || []).filter(
@@ -3368,49 +3600,26 @@ var DropZoneEdit = forwardRef3(
3368
3600
  },
3369
3601
  [allow, disallow]
3370
3602
  );
3371
- useEffect13(() => {
3603
+ useEffect14(() => {
3372
3604
  if (registerLocalZone) {
3373
- registerLocalZone(zoneCompound, acceptsTarget(draggedItem));
3605
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3374
3606
  }
3375
3607
  return () => {
3376
3608
  if (unregisterLocalZone) {
3377
3609
  unregisterLocalZone(zoneCompound);
3378
3610
  }
3379
3611
  };
3380
- }, [draggedItem, zoneCompound]);
3381
- const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3382
- const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
3383
- const userIsDragging = !!draggedItem;
3612
+ }, [draggedComponentType, zoneCompound]);
3613
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3384
3614
  let isEnabled = true;
3385
- if (draggedItem) {
3386
- isEnabled = deepestZone === zoneCompound;
3615
+ if (userIsDragging) {
3616
+ isEnabled = isDeepestZone;
3387
3617
  }
3388
3618
  if (isEnabled) {
3389
- isEnabled = acceptsTarget(draggedItem);
3390
- }
3391
- const preview = useContext3(previewContext);
3392
- const previewInZone = (preview == null ? void 0 : preview.zone) === zoneCompound;
3393
- const contentWithPreview = useMemo7(() => {
3394
- let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
3395
- if (previewInZone) {
3396
- contentWithPreview2 = content.filter(
3397
- (item) => item.props.id !== preview.props.id
3398
- );
3399
- if (preview.type === "insert") {
3400
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3401
- type: "preview",
3402
- props: { id: preview.props.id }
3403
- });
3404
- } else {
3405
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3406
- type: preview.componentType,
3407
- props: preview.props
3408
- });
3409
- }
3410
- }
3411
- return contentWithPreview2;
3412
- }, [preview, content]);
3413
- const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3619
+ isEnabled = acceptsTarget(draggedComponentType);
3620
+ }
3621
+ const contentWithPreview = useContentWithPreview(content, zoneCompound);
3622
+ const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3414
3623
  const droppableConfig = {
3415
3624
  id: zoneCompound,
3416
3625
  collisionPriority: isEnabled ? depth : 0,
@@ -3420,45 +3629,20 @@ var DropZoneEdit = forwardRef3(
3420
3629
  data: {
3421
3630
  areaId,
3422
3631
  depth,
3423
- isDroppableTarget: acceptsTarget(draggedItem),
3632
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3424
3633
  path
3425
3634
  }
3426
3635
  };
3427
3636
  const { ref: dropRef } = useDroppableSafe(droppableConfig);
3428
3637
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3429
3638
  const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
3430
- const [dragAxis, setDragAxis] = useState16(
3431
- collisionAxis || DEFAULT_DRAG_AXIS
3432
- );
3433
- const calculateDragAxis = useCallback8(() => {
3434
- if (ref.current) {
3435
- const computedStyle = window.getComputedStyle(ref.current);
3436
- if (computedStyle.display === "grid") {
3437
- setDragAxis(GRID_DRAG_AXIS);
3438
- } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3439
- setDragAxis(FLEX_ROW_DRAG_AXIS);
3440
- } else {
3441
- setDragAxis(DEFAULT_DRAG_AXIS);
3442
- }
3443
- }
3444
- }, [ref.current]);
3445
- useEffect13(calculateDragAxis, [appContext2.status, collisionAxis]);
3446
- useEffect13(() => {
3447
- const onViewportChange = () => {
3448
- calculateDragAxis();
3449
- };
3450
- window.addEventListener("viewportchange", onViewportChange);
3451
- return () => {
3452
- window.removeEventListener("viewportchange", onViewportChange);
3453
- };
3454
- }, []);
3639
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3455
3640
  const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3456
- draggedItem,
3457
3641
  zoneCompound,
3458
3642
  userMinEmptyHeight,
3459
3643
  ref
3460
3644
  });
3461
- return /* @__PURE__ */ jsxs10(
3645
+ return /* @__PURE__ */ jsx22(
3462
3646
  "div",
3463
3647
  {
3464
3648
  className: `${getClassName17({
@@ -3478,87 +3662,93 @@ var DropZoneEdit = forwardRef3(
3478
3662
  "data-puck-dropzone": zoneCompound,
3479
3663
  "data-puck-dnd": zoneCompound,
3480
3664
  style: __spreadProps(__spreadValues({}, style), {
3481
- "--min-empty-height": `${minEmptyHeight}px`
3665
+ "--min-empty-height": `${minEmptyHeight}px`,
3666
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3482
3667
  }),
3483
- children: [
3484
- isRootZone && DEBUG3 && /* @__PURE__ */ jsxs10("div", { "data-puck-component": true, children: [
3485
- /* @__PURE__ */ jsx21("p", { children: deepestZone || rootDroppableId }),
3486
- /* @__PURE__ */ jsx21("p", { children: deepestArea || "No area" })
3487
- ] }),
3488
- contentWithPreview.map((item, i) => {
3489
- var _a, _b, _c, _d, _e;
3490
- const componentId = item.props.id;
3491
- const puckProps = {
3492
- renderDropZone: DropZone,
3493
- isEditing: true,
3494
- dragRef: null
3668
+ children: contentWithPreview.map((item, i) => {
3669
+ var _a, _b, _c, _d, _e, _f, _g;
3670
+ const componentId = item.props.id;
3671
+ const puckProps = {
3672
+ renderDropZone: DropZoneEditPure,
3673
+ isEditing: true,
3674
+ dragRef: null
3675
+ };
3676
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3677
+ puck: puckProps,
3678
+ editMode: true
3679
+ // DEPRECATED
3680
+ });
3681
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3682
+ let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
3683
+ "No configuration for ",
3684
+ item.type
3685
+ ] });
3686
+ const componentConfig = config.components[item.type];
3687
+ let componentType = item.type;
3688
+ let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3689
+ if (item.type === "preview") {
3690
+ let Preview4 = function() {
3691
+ return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3495
3692
  };
3496
- const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3497
- puck: puckProps,
3498
- editMode: true
3499
- // DEPRECATED
3500
- });
3501
- const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3502
- let Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
3503
- "No configuration for ",
3504
- item.type
3505
- ] });
3506
- const componentConfig = config.components[item.type];
3507
- let componentType = item.type;
3508
- let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3509
- if (item.type === "preview") {
3510
- let Preview3 = function() {
3511
- return /* @__PURE__ */ jsx21(DrawerItemInner, { name: label });
3512
- };
3513
- var Preview2 = Preview3;
3514
- componentType = preview.componentType;
3515
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3516
- Render2 = Preview3;
3517
- }
3518
- return /* @__PURE__ */ jsx21(
3519
- DropZoneProvider,
3520
- {
3521
- value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3522
- children: /* @__PURE__ */ jsx21(
3523
- DraggableComponent,
3524
- {
3525
- id: componentId,
3526
- componentType,
3527
- zoneCompound,
3528
- depth: depth + 1,
3529
- index: i,
3530
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3531
- isSelected,
3532
- label,
3533
- isEnabled,
3534
- autoDragAxis: dragAxis,
3535
- userDragAxis: collisionAxis,
3536
- inDroppableZone: acceptsTarget(draggedItem),
3537
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx21(
3538
- Render2,
3539
- __spreadProps(__spreadValues({}, defaultedProps), {
3540
- puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3541
- dragRef
3542
- })
3693
+ var Preview3 = Preview4;
3694
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3695
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3696
+ Render2 = Preview4;
3697
+ }
3698
+ return /* @__PURE__ */ jsx22(
3699
+ DropZoneProvider,
3700
+ {
3701
+ value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3702
+ children: /* @__PURE__ */ jsx22(
3703
+ DraggableComponent,
3704
+ {
3705
+ id: componentId,
3706
+ componentType,
3707
+ zoneCompound,
3708
+ depth: depth + 1,
3709
+ index: i,
3710
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3711
+ isSelected,
3712
+ label,
3713
+ isEnabled,
3714
+ autoDragAxis: dragAxis,
3715
+ userDragAxis: collisionAxis,
3716
+ inDroppableZone: acceptsTarget(draggedComponentType),
3717
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx22(
3718
+ Render2,
3719
+ __spreadProps(__spreadValues({}, defaultedProps), {
3720
+ puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3721
+ dragRef
3543
3722
  })
3544
- ) : /* @__PURE__ */ jsx21("div", { ref: dragRef, children: /* @__PURE__ */ jsx21(Render2, __spreadValues({}, defaultedProps)) })
3545
- }
3546
- )
3547
- },
3548
- componentId
3549
- );
3550
- })
3551
- ]
3723
+ })
3724
+ ) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
3725
+ }
3726
+ )
3727
+ },
3728
+ componentId
3729
+ );
3730
+ })
3552
3731
  }
3553
3732
  );
3554
3733
  }
3555
3734
  );
3735
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
3556
3736
  var DropZoneRender = forwardRef3(
3557
- function DropZoneRender2({ className, style, zone }, ref) {
3558
- const ctx = useContext3(dropZoneContext);
3737
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3738
+ const ctx = useContext6(dropZoneContext);
3559
3739
  const { data, areaId = "root", config } = ctx || {};
3560
3740
  let zoneCompound = rootDroppableId;
3561
3741
  let content = (data == null ? void 0 : data.content) || [];
3742
+ useEffect14(() => {
3743
+ if (ctx == null ? void 0 : ctx.registerZone) {
3744
+ ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3745
+ }
3746
+ return () => {
3747
+ if (ctx == null ? void 0 : ctx.unregisterZone) {
3748
+ ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
3749
+ }
3750
+ };
3751
+ }, []);
3562
3752
  if (!data || !config) {
3563
3753
  return null;
3564
3754
  }
@@ -3566,10 +3756,10 @@ var DropZoneRender = forwardRef3(
3566
3756
  zoneCompound = `${areaId}:${zone}`;
3567
3757
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3568
3758
  }
3569
- return /* @__PURE__ */ jsx21("div", { className, style, ref, children: content.map((item) => {
3759
+ return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
3570
3760
  const Component = config.components[item.type];
3571
3761
  if (Component) {
3572
- return /* @__PURE__ */ jsx21(
3762
+ return /* @__PURE__ */ jsx22(
3573
3763
  DropZoneProvider,
3574
3764
  {
3575
3765
  value: {
@@ -3579,10 +3769,12 @@ var DropZoneRender = forwardRef3(
3579
3769
  depth: 1,
3580
3770
  path: []
3581
3771
  },
3582
- children: /* @__PURE__ */ jsx21(
3772
+ children: /* @__PURE__ */ jsx22(
3583
3773
  Component.render,
3584
3774
  __spreadProps(__spreadValues({}, item.props), {
3585
- puck: { renderDropZone: DropZoneRender2 }
3775
+ puck: {
3776
+ renderDropZone: DropZoneRenderPure
3777
+ }
3586
3778
  })
3587
3779
  )
3588
3780
  },
@@ -3595,11 +3787,11 @@ var DropZoneRender = forwardRef3(
3595
3787
  );
3596
3788
  var DropZone = forwardRef3(
3597
3789
  function DropZone2(props, ref) {
3598
- const ctx = useContext3(dropZoneContext);
3790
+ const ctx = useContext6(dropZoneContext);
3599
3791
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3600
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3792
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3601
3793
  }
3602
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3794
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3603
3795
  }
3604
3796
  );
3605
3797
 
@@ -3615,7 +3807,7 @@ var getZoneId = (zoneCompound) => {
3615
3807
  return [rootDroppableId, zoneCompound];
3616
3808
  };
3617
3809
 
3618
- // components/DragDropContext/NestedDroppablePlugin.ts
3810
+ // lib/dnd/NestedDroppablePlugin.ts
3619
3811
  init_react_import();
3620
3812
  import { Plugin } from "@dnd-kit/abstract";
3621
3813
  import { effects } from "@dnd-kit/state";
@@ -3654,10 +3846,52 @@ var getFrame = () => {
3654
3846
  if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
3655
3847
  return frameEl.contentDocument || document;
3656
3848
  }
3657
- return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3849
+ return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3850
+ };
3851
+
3852
+ // lib/global-position.ts
3853
+ init_react_import();
3854
+ var GlobalPosition = class {
3855
+ constructor(target, original) {
3856
+ this.scaleFactor = 1;
3857
+ this.frameEl = null;
3858
+ this.frameRect = null;
3859
+ var _a;
3860
+ this.target = target;
3861
+ this.original = original;
3862
+ this.frameEl = document.querySelector("iframe");
3863
+ if (this.frameEl) {
3864
+ this.frameRect = this.frameEl.getBoundingClientRect();
3865
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3866
+ }
3867
+ }
3868
+ get x() {
3869
+ return this.original.x;
3870
+ }
3871
+ get y() {
3872
+ return this.original.y;
3873
+ }
3874
+ get global() {
3875
+ if (document !== this.target.ownerDocument && this.frameRect) {
3876
+ return {
3877
+ x: this.x * this.scaleFactor + this.frameRect.left,
3878
+ y: this.y * this.scaleFactor + this.frameRect.top
3879
+ };
3880
+ }
3881
+ return this.original;
3882
+ }
3883
+ get frame() {
3884
+ if (document === this.target.ownerDocument && this.frameRect) {
3885
+ return {
3886
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
3887
+ y: (this.y - this.frameRect.top) / this.scaleFactor
3888
+ };
3889
+ }
3890
+ return this.original;
3891
+ }
3658
3892
  };
3659
3893
 
3660
- // components/DragDropContext/NestedDroppablePlugin.ts
3894
+ // lib/dnd/NestedDroppablePlugin.ts
3661
3895
  var depthSort = (candidates) => {
3662
3896
  return candidates.sort((a, b) => {
3663
3897
  const aData = a.data;
@@ -3686,10 +3920,12 @@ var getZoneId2 = (candidate) => {
3686
3920
  }
3687
3921
  return id;
3688
3922
  };
3689
- var getPointerCollisions = (position, manager, ownerDocument) => {
3690
- var _a;
3923
+ var getPointerCollisions = (position, manager) => {
3691
3924
  const candidates = [];
3692
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
3925
+ let elements = position.target.ownerDocument.elementsFromPoint(
3926
+ position.x,
3927
+ position.y
3928
+ );
3693
3929
  const previewFrame = elements.find(
3694
3930
  (el) => el.getAttribute("data-puck-preview")
3695
3931
  );
@@ -3698,17 +3934,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3698
3934
  elements = [drawer];
3699
3935
  }
3700
3936
  if (previewFrame) {
3701
- const iframe = previewFrame.querySelector("iframe");
3702
- if (iframe) {
3703
- const rect = iframe.getBoundingClientRect();
3704
- const frame = getFrame();
3705
- if (frame) {
3706
- const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3707
- elements = frame.elementsFromPoint(
3708
- (position.x - rect.left) / scaleFactor,
3709
- (position.y - rect.top) / scaleFactor
3710
- );
3711
- }
3937
+ const frame = getFrame();
3938
+ if (frame) {
3939
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3712
3940
  }
3713
3941
  }
3714
3942
  if (elements) {
@@ -3725,9 +3953,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3725
3953
  }
3726
3954
  return candidates;
3727
3955
  };
3728
- var findDeepestCandidate = (position, manager, ownerDocument) => {
3956
+ var findDeepestCandidate = (position, manager) => {
3729
3957
  var _a;
3730
- const candidates = getPointerCollisions(position, manager, ownerDocument);
3958
+ const candidates = getPointerCollisions(position, manager);
3731
3959
  if (candidates.length > 0) {
3732
3960
  const sortedCandidates = depthSort(candidates);
3733
3961
  const draggable = manager.dragOperation.source;
@@ -3772,9 +4000,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
3772
4000
  area: null
3773
4001
  };
3774
4002
  };
3775
- var createNestedDroppablePlugin = ({
3776
- onChange
3777
- }) => class NestedDroppablePlugin extends Plugin {
4003
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
3778
4004
  constructor(manager, options) {
3779
4005
  super(manager);
3780
4006
  if (typeof window === "undefined") {
@@ -3782,16 +4008,19 @@ var createNestedDroppablePlugin = ({
3782
4008
  }
3783
4009
  const cleanupEffect = effects(() => {
3784
4010
  const handleMove = (event) => {
3785
- const position = {
4011
+ const target = event.originalTarget || event.target;
4012
+ const position = new GlobalPosition(target, {
3786
4013
  x: event.clientX,
3787
4014
  y: event.clientY
3788
- };
3789
- const target = event.originalTarget || event.target;
3790
- const ownerDocument = target == null ? void 0 : target.ownerDocument;
3791
- onChange(
3792
- findDeepestCandidate(position, manager, ownerDocument),
3793
- manager
4015
+ });
4016
+ const elements = document.elementsFromPoint(
4017
+ position.global.x,
4018
+ position.global.y
3794
4019
  );
4020
+ const overEl = elements.some((el) => el.id === id);
4021
+ if (overEl) {
4022
+ onChange(findDeepestCandidate(position, manager), manager);
4023
+ }
3795
4024
  };
3796
4025
  const handleMoveThrottled = throttle(handleMove, 50);
3797
4026
  const handlePointerMove = (event) => {
@@ -4121,6 +4350,11 @@ var reduceUi = (ui, action) => {
4121
4350
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4122
4351
  });
4123
4352
  }
4353
+ if (action.type === "remove") {
4354
+ return __spreadProps(__spreadValues({}, ui), {
4355
+ itemSelector: null
4356
+ });
4357
+ }
4124
4358
  return ui;
4125
4359
  };
4126
4360
 
@@ -4208,7 +4442,7 @@ var insertComponent = (componentType, zone, index, {
4208
4442
  import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4209
4443
  import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
4210
4444
 
4211
- // components/DragDropContext/PointerSensor.ts
4445
+ // lib/dnd/PointerSensor.ts
4212
4446
  init_react_import();
4213
4447
  import { batch, effect } from "@dnd-kit/state";
4214
4448
  import { Sensor, configurator } from "@dnd-kit/abstract";
@@ -4380,6 +4614,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
4380
4614
  }
4381
4615
  }
4382
4616
  handlePointerUp(event) {
4617
+ if (!this.source) {
4618
+ return;
4619
+ }
4383
4620
  event.preventDefault();
4384
4621
  event.stopPropagation();
4385
4622
  const { status } = this.manager.dragOperation;
@@ -4479,13 +4716,15 @@ function patchWindow(window2) {
4479
4716
  }
4480
4717
 
4481
4718
  // components/DragDropContext/index.tsx
4482
- import { jsx as jsx22 } from "react/jsx-runtime";
4483
- var dragListenerContext = createContext3({
4719
+ import { createStore as createStore3 } from "zustand";
4720
+ import { jsx as jsx23 } from "react/jsx-runtime";
4721
+ var DEBUG3 = false;
4722
+ var dragListenerContext = createContext4({
4484
4723
  dragListeners: {}
4485
4724
  });
4486
4725
  function useDragListener(type, fn, deps = []) {
4487
- const { setDragListeners } = useContext4(dragListenerContext);
4488
- useEffect14(() => {
4726
+ const { setDragListeners } = useContext7(dragListenerContext);
4727
+ useEffect15(() => {
4489
4728
  if (setDragListeners) {
4490
4729
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
4491
4730
  [type]: [...old[type] || [], fn]
@@ -4493,78 +4732,145 @@ function useDragListener(type, fn, deps = []) {
4493
4732
  }
4494
4733
  }, deps);
4495
4734
  }
4496
- var previewContext = createContext3(null);
4497
4735
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4736
+ var useTempDisableFallback = (timeout3) => {
4737
+ const lastFallbackDisable = useRef4(null);
4738
+ return useCallback11((manager) => {
4739
+ collisionStore.setState({ fallbackEnabled: false });
4740
+ const fallbackId = generateId();
4741
+ lastFallbackDisable.current = fallbackId;
4742
+ setTimeout(() => {
4743
+ if (lastFallbackDisable.current === fallbackId) {
4744
+ collisionStore.setState({ fallbackEnabled: true });
4745
+ manager.collisionObserver.forceUpdate(true);
4746
+ }
4747
+ }, timeout3);
4748
+ }, []);
4749
+ };
4498
4750
  var DragDropContextClient = ({
4499
4751
  children,
4500
4752
  disableAutoScroll
4501
4753
  }) => {
4502
4754
  const { state, config, dispatch, resolveData } = useAppContext();
4503
- const [preview, setPreview] = useState17(null);
4504
- const previewRef = useRef5(null);
4755
+ const id = useId();
4505
4756
  const { data } = state;
4506
- const [deepest, setDeepest] = useState17(null);
4507
- const [nextDeepest, setNextDeepest] = useState17(null);
4508
- const deepestRef = useRef5(deepest);
4509
- const debouncedParamsRef = useRef5(null);
4510
- const setDeepestAndCollide = useCallback9(
4757
+ const debouncedParamsRef = useRef4(null);
4758
+ const tempDisableFallback = useTempDisableFallback(100);
4759
+ const [zoneStore] = useState17(
4760
+ () => createStore3(() => ({
4761
+ zoneDepthIndex: {},
4762
+ nextZoneDepthIndex: {},
4763
+ areaDepthIndex: {},
4764
+ nextAreaDepthIndex: {},
4765
+ draggedItem: null,
4766
+ previewIndex: {}
4767
+ }))
4768
+ );
4769
+ const getChanged2 = useCallback11(
4770
+ (params, id2) => {
4771
+ const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
4772
+ const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
4773
+ const stateHasArea = Object.keys(areaDepthIndex).length > 0;
4774
+ let zoneChanged = false;
4775
+ let areaChanged = false;
4776
+ if (params.zone && !zoneDepthIndex[params.zone]) {
4777
+ zoneChanged = true;
4778
+ } else if (!params.zone && stateHasZone) {
4779
+ zoneChanged = true;
4780
+ }
4781
+ if (params.area && !areaDepthIndex[params.area]) {
4782
+ areaChanged = true;
4783
+ } else if (!params.area && stateHasArea) {
4784
+ areaChanged = true;
4785
+ }
4786
+ return { zoneChanged, areaChanged };
4787
+ },
4788
+ [zoneStore]
4789
+ );
4790
+ const setDeepestAndCollide = useCallback11(
4511
4791
  (params, manager) => {
4512
- setDeepest(params);
4792
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4793
+ if (!zoneChanged && !areaChanged) return;
4794
+ zoneStore.setState({
4795
+ zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
4796
+ areaDepthIndex: params.area ? { [params.area]: true } : {}
4797
+ });
4798
+ tempDisableFallback(manager);
4513
4799
  setTimeout(() => {
4514
4800
  manager.collisionObserver.forceUpdate(true);
4515
4801
  }, 50);
4516
4802
  debouncedParamsRef.current = null;
4517
4803
  },
4518
- []
4804
+ [zoneStore]
4519
4805
  );
4520
4806
  const setDeepestDb = useDebouncedCallback2(
4521
4807
  setDeepestAndCollide,
4522
4808
  AREA_CHANGE_DEBOUNCE_MS
4523
4809
  );
4524
- useEffect14(() => {
4525
- deepestRef.current = deepest;
4526
- }, [deepest]);
4527
4810
  const cancelDb = () => {
4528
4811
  setDeepestDb.cancel();
4529
4812
  debouncedParamsRef.current = null;
4530
4813
  };
4814
+ useEffect15(() => {
4815
+ if (DEBUG3) {
4816
+ zoneStore.subscribe(
4817
+ (s) => {
4818
+ var _a, _b;
4819
+ return console.log(
4820
+ s.previewIndex,
4821
+ (_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
4822
+ (_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
4823
+ );
4824
+ }
4825
+ );
4826
+ }
4827
+ }, []);
4531
4828
  const [plugins] = useState17(() => [
4532
4829
  ...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
4533
- createNestedDroppablePlugin({
4534
- onChange: (params, manager) => {
4535
- const lastParams = deepestRef.current;
4536
- const areaChanged = params.area !== (lastParams == null ? void 0 : lastParams.area);
4537
- const zoneChanged = params.zone !== (lastParams == null ? void 0 : lastParams.zone);
4538
- const isDragging = manager.dragOperation.status.dragging;
4539
- if (areaChanged || zoneChanged) {
4540
- setNextDeepest(params);
4541
- }
4542
- if (params.zone !== "void" && (lastParams == null ? void 0 : lastParams.zone) === "void") {
4543
- setDeepest(params);
4544
- manager.collisionObserver.forceUpdate(true);
4545
- return;
4546
- }
4547
- if (areaChanged) {
4548
- if (isDragging) {
4549
- const debouncedParams = debouncedParamsRef.current;
4550
- const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4551
- if (!isSameParams) {
4830
+ createNestedDroppablePlugin(
4831
+ {
4832
+ onChange: (params, manager) => {
4833
+ const state2 = zoneStore.getState();
4834
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4835
+ const isDragging = manager.dragOperation.status.dragging;
4836
+ if (areaChanged || zoneChanged) {
4837
+ let nextZoneDepthIndex = {};
4838
+ let nextAreaDepthIndex = {};
4839
+ if (params.zone) {
4840
+ nextZoneDepthIndex = { [params.zone]: true };
4841
+ }
4842
+ if (params.area) {
4843
+ nextAreaDepthIndex = { [params.area]: true };
4844
+ }
4845
+ zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
4846
+ }
4847
+ if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
4848
+ setDeepestAndCollide(params, manager);
4849
+ return;
4850
+ }
4851
+ if (areaChanged) {
4852
+ if (isDragging) {
4853
+ const debouncedParams = debouncedParamsRef.current;
4854
+ const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4855
+ if (!isSameParams) {
4856
+ cancelDb();
4857
+ setDeepestDb(params, manager);
4858
+ debouncedParamsRef.current = params;
4859
+ }
4860
+ } else {
4552
4861
  cancelDb();
4553
- setDeepestDb(params, manager);
4554
- debouncedParamsRef.current = params;
4862
+ setDeepestAndCollide(params, manager);
4555
4863
  }
4556
- } else {
4557
- cancelDb();
4864
+ return;
4865
+ }
4866
+ if (zoneChanged) {
4558
4867
  setDeepestAndCollide(params, manager);
4559
4868
  }
4560
- return;
4869
+ cancelDb();
4561
4870
  }
4562
- if (zoneChanged) {
4563
- setDeepestAndCollide(params, manager);
4564
- }
4565
- cancelDb();
4566
- }
4567
- })
4871
+ },
4872
+ id
4873
+ )
4568
4874
  ]);
4569
4875
  const [sensors] = useState17(() => [
4570
4876
  PointerSensor.configure({
@@ -4585,11 +4891,10 @@ var DragDropContextClient = ({
4585
4891
  }
4586
4892
  })
4587
4893
  ]);
4588
- const [draggedItem, setDraggedItem] = useState17();
4589
4894
  const [dragListeners, setDragListeners] = useState17({});
4590
4895
  const [pathData, setPathData] = useState17();
4591
- const dragMode = useRef5(null);
4592
- const registerPath = useCallback9(
4896
+ const dragMode = useRef4(null);
4897
+ const registerPath = useCallback11(
4593
4898
  (selector) => {
4594
4899
  const item = getItem(selector, data);
4595
4900
  if (!item) {
@@ -4611,41 +4916,41 @@ var DragDropContextClient = ({
4611
4916
  },
4612
4917
  [data, setPathData]
4613
4918
  );
4614
- const initialSelector = useRef5(void 0);
4615
- return /* @__PURE__ */ jsx22(
4919
+ const initialSelector = useRef4(void 0);
4920
+ return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
4616
4921
  dragListenerContext.Provider,
4617
4922
  {
4618
4923
  value: {
4619
4924
  dragListeners,
4620
4925
  setDragListeners
4621
4926
  },
4622
- children: /* @__PURE__ */ jsx22(previewContext.Provider, { value: preview, children: /* @__PURE__ */ jsx22(
4927
+ children: /* @__PURE__ */ jsx23(
4623
4928
  DragDropProvider2,
4624
4929
  {
4625
4930
  plugins,
4626
4931
  sensors,
4627
4932
  onDragEnd: (event, manager) => {
4933
+ var _a;
4628
4934
  const { source, target } = event.operation;
4629
- deepestRef.current = null;
4630
4935
  if (!source) {
4631
- setDraggedItem(null);
4936
+ zoneStore.setState({ draggedItem: null });
4632
4937
  return;
4633
4938
  }
4634
4939
  const { zone, index } = source.data;
4635
- const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
4636
- previewRef.current = null;
4940
+ const { previewIndex = {} } = zoneStore.getState() || {};
4941
+ const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
4637
4942
  setTimeout(() => {
4638
- var _a, _b;
4639
- setDraggedItem(null);
4943
+ var _a2, _b;
4944
+ zoneStore.setState({ draggedItem: null });
4640
4945
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4641
- setPreview(null);
4642
- (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
4946
+ zoneStore.setState({ previewIndex: {} });
4947
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
4643
4948
  fn(event, manager);
4644
4949
  });
4645
4950
  return;
4646
4951
  }
4647
4952
  if (thisPreview) {
4648
- setPreview(null);
4953
+ zoneStore.setState({ previewIndex: {} });
4649
4954
  if (thisPreview.type === "insert") {
4650
4955
  insertComponent(
4651
4956
  thisPreview.componentType,
@@ -4680,8 +4985,9 @@ var DragDropContextClient = ({
4680
4985
  }, 250);
4681
4986
  },
4682
4987
  onDragOver: (event, manager) => {
4683
- var _a, _b, _c, _d;
4988
+ var _a, _b, _c, _d, _e;
4684
4989
  event.preventDefault();
4990
+ const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
4685
4991
  if (!draggedItem) return;
4686
4992
  cancelDb();
4687
4993
  const { source, target } = event.operation;
@@ -4697,7 +5003,7 @@ var DragDropContextClient = ({
4697
5003
  const targetData = target.data;
4698
5004
  targetZone = targetData.zone;
4699
5005
  targetIndex = targetData.index;
4700
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
5006
+ const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
4701
5007
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
4702
5008
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
4703
5009
  targetIndex = targetIndex - 1;
@@ -4709,23 +5015,26 @@ var DragDropContextClient = ({
4709
5015
  targetZone = target.id.toString();
4710
5016
  targetIndex = 0;
4711
5017
  }
4712
- if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
5018
+ if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
4713
5019
  const [pathId] = path.split(":");
4714
5020
  return pathId === sourceId;
4715
5021
  }))) {
4716
5022
  return;
4717
5023
  }
4718
5024
  if (dragMode.current === "new") {
4719
- previewRef.current = {
4720
- componentType: sourceData.componentType,
4721
- type: "insert",
4722
- index: targetIndex,
4723
- zone: targetZone,
4724
- props: {
4725
- id: source.id.toString()
5025
+ zoneStore.setState({
5026
+ previewIndex: {
5027
+ [targetZone]: {
5028
+ componentType: sourceData.componentType,
5029
+ type: "insert",
5030
+ index: targetIndex,
5031
+ zone: targetZone,
5032
+ props: {
5033
+ id: source.id.toString()
5034
+ }
5035
+ }
4726
5036
  }
4727
- };
4728
- setPreview(previewRef.current);
5037
+ });
4729
5038
  } else {
4730
5039
  if (!initialSelector.current) {
4731
5040
  initialSelector.current = {
@@ -4735,17 +5044,20 @@ var DragDropContextClient = ({
4735
5044
  }
4736
5045
  const item = getItem(initialSelector.current, data);
4737
5046
  if (item) {
4738
- previewRef.current = {
4739
- componentType: sourceData.componentType,
4740
- type: "move",
4741
- index: targetIndex,
4742
- zone: targetZone,
4743
- props: item.props
4744
- };
4745
- setPreview(previewRef.current);
5047
+ zoneStore.setState({
5048
+ previewIndex: {
5049
+ [targetZone]: {
5050
+ componentType: sourceData.componentType,
5051
+ type: "move",
5052
+ index: targetIndex,
5053
+ zone: targetZone,
5054
+ props: item.props
5055
+ }
5056
+ }
5057
+ });
4746
5058
  }
4747
5059
  }
4748
- (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
5060
+ (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
4749
5061
  fn(event, manager);
4750
5062
  });
4751
5063
  },
@@ -4755,46 +5067,61 @@ var DragDropContextClient = ({
4755
5067
  type: "setUi",
4756
5068
  ui: { itemSelector: null, isDragging: true }
4757
5069
  });
5070
+ const { source } = event.operation;
5071
+ if (source && source.type !== "void") {
5072
+ const sourceData = source.data;
5073
+ const item = getItem(
5074
+ {
5075
+ zone: sourceData.zone,
5076
+ index: sourceData.index
5077
+ },
5078
+ data
5079
+ );
5080
+ if (item) {
5081
+ zoneStore.setState({
5082
+ previewIndex: {
5083
+ [sourceData.zone]: {
5084
+ componentType: sourceData.componentType,
5085
+ type: "move",
5086
+ index: sourceData.index,
5087
+ zone: sourceData.zone,
5088
+ props: item.props
5089
+ }
5090
+ }
5091
+ });
5092
+ }
5093
+ }
4758
5094
  (_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
4759
5095
  fn(event, manager);
4760
5096
  });
4761
5097
  },
4762
5098
  onBeforeDragStart: (event) => {
4763
5099
  var _a;
4764
- if (draggedItem) {
4765
- console.warn("New drag started before previous drag cleaned up");
4766
- }
4767
5100
  const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
4768
5101
  dragMode.current = isNewComponent ? "new" : "existing";
4769
5102
  initialSelector.current = void 0;
4770
- setDraggedItem(event.operation.source);
5103
+ zoneStore.setState({ draggedItem: event.operation.source });
4771
5104
  },
4772
- children: /* @__PURE__ */ jsx22(
5105
+ children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
4773
5106
  DropZoneProvider,
4774
5107
  {
4775
5108
  value: {
4776
5109
  data,
4777
5110
  config,
4778
- dispatch,
4779
- draggedItem,
4780
5111
  mode: "edit",
4781
5112
  areaId: "root",
4782
5113
  depth: 0,
4783
5114
  registerPath,
4784
5115
  pathData,
4785
- deepestZone: deepest == null ? void 0 : deepest.zone,
4786
- deepestArea: deepest == null ? void 0 : deepest.area,
4787
- nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
4788
- nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
4789
5116
  path: []
4790
5117
  },
4791
5118
  children
4792
5119
  }
4793
- )
5120
+ ) })
4794
5121
  }
4795
- ) })
5122
+ )
4796
5123
  }
4797
- );
5124
+ ) });
4798
5125
  };
4799
5126
  var DragDropContext = ({
4800
5127
  children,
@@ -4804,11 +5131,11 @@ var DragDropContext = ({
4804
5131
  if (status === "LOADING") {
4805
5132
  return children;
4806
5133
  }
4807
- return /* @__PURE__ */ jsx22(DragDropContextClient, { disableAutoScroll, children });
5134
+ return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
4808
5135
  };
4809
5136
 
4810
5137
  // components/Drawer/index.tsx
4811
- import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
5138
+ import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
4812
5139
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
4813
5140
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
4814
5141
  var DrawerItemInner = ({
@@ -4818,11 +5145,11 @@ var DrawerItemInner = ({
4818
5145
  dragRef,
4819
5146
  isDragDisabled
4820
5147
  }) => {
4821
- const CustomInner = useMemo8(
4822
- () => children || (({ children: children2 }) => /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("default"), children: children2 })),
5148
+ const CustomInner = useMemo9(
5149
+ () => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
4823
5150
  [children]
4824
5151
  );
4825
- return /* @__PURE__ */ jsx23(
5152
+ return /* @__PURE__ */ jsx24(
4826
5153
  "div",
4827
5154
  {
4828
5155
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -4830,9 +5157,9 @@ var DrawerItemInner = ({
4830
5157
  onMouseDown: (e) => e.preventDefault(),
4831
5158
  "data-testid": dragRef ? `drawer-item:${name}` : "",
4832
5159
  "data-puck-drawer-item": true,
4833
- children: /* @__PURE__ */ jsx23(CustomInner, { name, children: /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
4834
- /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
4835
- /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx23(DragIcon, {}) })
5160
+ children: /* @__PURE__ */ jsx24(CustomInner, { name, children: /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
5161
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5162
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx24(DragIcon, {}) })
4836
5163
  ] }) }) })
4837
5164
  }
4838
5165
  );
@@ -4850,8 +5177,8 @@ var DrawerItemDraggable = ({
4850
5177
  disabled: isDragDisabled
4851
5178
  });
4852
5179
  return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
4853
- /* @__PURE__ */ jsx23("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx23(DrawerItemInner, { name, label, children }) }),
4854
- /* @__PURE__ */ jsx23("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx23(
5180
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx24(DrawerItemInner, { name, label, children }) }),
5181
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx24(
4855
5182
  DrawerItemInner,
4856
5183
  {
4857
5184
  name,
@@ -4885,7 +5212,7 @@ var DrawerItem = ({
4885
5212
  },
4886
5213
  [resolvedId]
4887
5214
  );
4888
- return /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
5215
+ return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
4889
5216
  DrawerItemDraggable,
4890
5217
  {
4891
5218
  name,
@@ -4911,14 +5238,14 @@ var Drawer = ({
4911
5238
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
4912
5239
  );
4913
5240
  }
4914
- const [id] = useState18(generateId());
5241
+ const id = useId2();
4915
5242
  const { ref } = useDroppableSafe({
4916
5243
  id,
4917
5244
  type: "void",
4918
5245
  collisionPriority: 0
4919
5246
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
4920
5247
  });
4921
- return /* @__PURE__ */ jsx23(
5248
+ return /* @__PURE__ */ jsx24(
4922
5249
  "div",
4923
5250
  {
4924
5251
  className: getClassName18(),
@@ -4934,9 +5261,9 @@ Drawer.Item = DrawerItem;
4934
5261
  // components/Puck/index.tsx
4935
5262
  init_react_import();
4936
5263
  import {
4937
- useCallback as useCallback14,
4938
- useEffect as useEffect22,
4939
- useMemo as useMemo17,
5264
+ useCallback as useCallback17,
5265
+ useEffect as useEffect23,
5266
+ useMemo as useMemo18,
4940
5267
  useReducer,
4941
5268
  useState as useState26
4942
5269
  } from "react";
@@ -4950,7 +5277,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
4950
5277
 
4951
5278
  // lib/use-breadcrumbs.ts
4952
5279
  init_react_import();
4953
- import { useContext as useContext5, useMemo as useMemo9 } from "react";
5280
+ import { useContext as useContext8, useMemo as useMemo10 } from "react";
4954
5281
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
4955
5282
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
4956
5283
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -5000,8 +5327,8 @@ var useBreadcrumbs = (renderCount) => {
5000
5327
  state: { data },
5001
5328
  selectedItem
5002
5329
  } = useAppContext();
5003
- const dzContext = useContext5(dropZoneContext);
5004
- return useMemo9(() => {
5330
+ const dzContext = useContext8(dropZoneContext);
5331
+ return useMemo10(() => {
5005
5332
  const breadcrumbs = convertPathDataToBreadcrumbs(
5006
5333
  selectedItem,
5007
5334
  dzContext == null ? void 0 : dzContext.pathData,
@@ -5015,7 +5342,7 @@ var useBreadcrumbs = (renderCount) => {
5015
5342
  };
5016
5343
 
5017
5344
  // components/SidebarSection/index.tsx
5018
- import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
5345
+ import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
5019
5346
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5020
5347
  var SidebarSection = ({
5021
5348
  children,
@@ -5034,9 +5361,9 @@ var SidebarSection = ({
5034
5361
  className: getClassName19({ noBorderTop, noPadding }),
5035
5362
  style: { background },
5036
5363
  children: [
5037
- /* @__PURE__ */ jsx24("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5364
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5038
5365
  showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
5039
- /* @__PURE__ */ jsx24(
5366
+ /* @__PURE__ */ jsx25(
5040
5367
  "button",
5041
5368
  {
5042
5369
  type: "button",
@@ -5045,12 +5372,12 @@ var SidebarSection = ({
5045
5372
  children: breadcrumb.label
5046
5373
  }
5047
5374
  ),
5048
- /* @__PURE__ */ jsx24(ChevronRight, { size: 16 })
5375
+ /* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
5049
5376
  ] }, i)) : null,
5050
- /* @__PURE__ */ jsx24("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx24(Heading, { rank: "2", size: "xs", children: title }) })
5377
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
5051
5378
  ] }) }),
5052
- /* @__PURE__ */ jsx24("div", { className: getClassName19("content"), children }),
5053
- isLoading && /* @__PURE__ */ jsx24("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx24(Loader, { size: 32 }) })
5379
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
5380
+ isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
5054
5381
  ]
5055
5382
  }
5056
5383
  );
@@ -5081,7 +5408,7 @@ init_react_import();
5081
5408
  var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
5082
5409
 
5083
5410
  // components/MenuBar/index.tsx
5084
- import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
5411
+ import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
5085
5412
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5086
5413
  function MenuBar({
5087
5414
  appState,
@@ -5095,7 +5422,7 @@ function MenuBar({
5095
5422
  history: { back, forward, historyStore }
5096
5423
  } = useAppContext();
5097
5424
  const { hasFuture = false, hasPast = false } = historyStore || {};
5098
- return /* @__PURE__ */ jsx25(
5425
+ return /* @__PURE__ */ jsx26(
5099
5426
  "div",
5100
5427
  {
5101
5428
  className: getClassName20({ menuOpen }),
@@ -5111,10 +5438,10 @@ function MenuBar({
5111
5438
  },
5112
5439
  children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
5113
5440
  /* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
5114
- /* @__PURE__ */ jsx25(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx25(Undo2, { size: 21 }) }),
5115
- /* @__PURE__ */ jsx25(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx25(Redo2, { size: 21 }) })
5441
+ /* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
5442
+ /* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
5116
5443
  ] }),
5117
- /* @__PURE__ */ jsx25(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5444
+ /* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5118
5445
  state: appState,
5119
5446
  dispatch
5120
5447
  }) })
@@ -5125,7 +5452,7 @@ function MenuBar({
5125
5452
 
5126
5453
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5127
5454
  init_react_import();
5128
- var styles_module_default15 = { "Puck": "_Puck_1g88c_19", "Puck-portal": "_Puck-portal_1g88c_24", "PuckLayout": "_PuckLayout_1g88c_31", "PuckLayout-inner": "_PuckLayout-inner_1g88c_39", "PuckLayout--mounted": "_PuckLayout--mounted_1g88c_51", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_1g88c_55", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_1g88c_61", "PuckLayout-mounted": "_PuckLayout-mounted_1g88c_75", "PuckLayout-header": "_PuckLayout-header_1g88c_116", "PuckLayout-headerInner": "_PuckLayout-headerInner_1g88c_125", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_1g88c_135", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_1g88c_142", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_1g88c_143", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_1g88c_147", "PuckLayout-headerPath": "_PuckLayout-headerPath_1g88c_151", "PuckLayout-headerTools": "_PuckLayout-headerTools_1g88c_158", "PuckLayout-menuButton": "_PuckLayout-menuButton_1g88c_164", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_1g88c_169", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_1g88c_143", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_1g88c_142" };
5455
+ var styles_module_default15 = { "Puck": "_Puck_12s9r_19", "Puck-portal": "_Puck-portal_12s9r_24", "PuckLayout-inner": "_PuckLayout-inner_12s9r_31", "PuckLayout--mounted": "_PuckLayout--mounted_12s9r_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_12s9r_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_12s9r_53", "PuckLayout-mounted": "_PuckLayout-mounted_12s9r_67", "PuckLayout": "_PuckLayout_12s9r_31", "PuckLayout-header": "_PuckLayout-header_12s9r_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_12s9r_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_12s9r_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_12s9r_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_12s9r_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_12s9r_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_12s9r_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_12s9r_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_12s9r_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_12s9r_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_12s9r_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_12s9r_134" };
5129
5456
 
5130
5457
  // components/Puck/components/Fields/index.tsx
5131
5458
  init_react_import();
@@ -5135,15 +5462,15 @@ init_react_import();
5135
5462
  var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
5136
5463
 
5137
5464
  // components/Puck/components/Fields/index.tsx
5138
- import { useCallback as useCallback10, useEffect as useEffect15, useMemo as useMemo10, useState as useState19 } from "react";
5465
+ import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo11, useState as useState19 } from "react";
5139
5466
 
5140
5467
  // lib/use-parent.ts
5141
5468
  init_react_import();
5142
- import { useContext as useContext6 } from "react";
5469
+ import { useContext as useContext9 } from "react";
5143
5470
  var useParent = (itemSelector) => {
5144
5471
  var _a;
5145
5472
  const { selectedItem, state } = useAppContext();
5146
- const { pathData } = useContext6(dropZoneContext) || {};
5473
+ const { pathData } = useContext9(dropZoneContext) || {};
5147
5474
  const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5148
5475
  const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5149
5476
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
@@ -5152,7 +5479,7 @@ var useParent = (itemSelector) => {
5152
5479
  };
5153
5480
 
5154
5481
  // components/Puck/components/Fields/index.tsx
5155
- import { Fragment as Fragment8, jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
5482
+ import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5156
5483
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5157
5484
  var defaultPageFields = {
5158
5485
  title: { type: "text" }
@@ -5160,7 +5487,7 @@ var defaultPageFields = {
5160
5487
  var DefaultFields = ({
5161
5488
  children
5162
5489
  }) => {
5163
- return /* @__PURE__ */ jsx26(Fragment8, { children });
5490
+ return /* @__PURE__ */ jsx27(Fragment8, { children });
5164
5491
  };
5165
5492
  var useResolvedFields = () => {
5166
5493
  var _a, _b;
@@ -5169,7 +5496,7 @@ var useResolvedFields = () => {
5169
5496
  const { data } = state;
5170
5497
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5171
5498
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5172
- const defaultFields = useMemo10(
5499
+ const defaultFields = useMemo11(
5173
5500
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5174
5501
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5175
5502
  );
@@ -5182,7 +5509,7 @@ var useResolvedFields = () => {
5182
5509
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5183
5510
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5184
5511
  const hasResolver = hasComponentResolver || hasRootResolver;
5185
- const resolveFields = useCallback10(
5512
+ const resolveFields = useCallback12(
5186
5513
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5187
5514
  var _a2;
5188
5515
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5218,19 +5545,33 @@ var useResolvedFields = () => {
5218
5545
  lastData
5219
5546
  });
5220
5547
  }),
5221
- [data, config, componentData, selectedItem, resolvedFields, state]
5548
+ [data, config, componentData, selectedItem, resolvedFields, state, parent]
5222
5549
  );
5223
- useEffect15(() => {
5224
- if (hasResolver) {
5225
- setFieldsLoading(true);
5226
- resolveFields(defaultFields).then((fields) => {
5227
- setResolvedFields(fields || {});
5228
- setFieldsLoading(false);
5229
- });
5230
- } else {
5231
- setResolvedFields(defaultFields);
5550
+ const [hasParent, setHasParent] = useState19(false);
5551
+ useEffect16(() => {
5552
+ setHasParent(!!parent);
5553
+ }, [parent]);
5554
+ useEffect16(() => {
5555
+ var _a2, _b2;
5556
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || hasParent) {
5557
+ if (hasResolver) {
5558
+ setFieldsLoading(true);
5559
+ resolveFields(defaultFields).then((fields) => {
5560
+ setResolvedFields(fields || {});
5561
+ setFieldsLoading(false);
5562
+ });
5563
+ } else {
5564
+ setResolvedFields(defaultFields);
5565
+ }
5232
5566
  }
5233
- }, [data, defaultFields, selectedItem, hasResolver]);
5567
+ }, [
5568
+ data,
5569
+ defaultFields,
5570
+ state.ui.itemSelector,
5571
+ selectedItem,
5572
+ hasResolver,
5573
+ hasParent
5574
+ ]);
5234
5575
  return [resolvedFields, fieldsLoading];
5235
5576
  };
5236
5577
  var Fields = () => {
@@ -5251,7 +5592,7 @@ var Fields = () => {
5251
5592
  const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
5252
5593
  const isLoading = fieldsResolving || componentResolving;
5253
5594
  const rootProps = data.root.props || data.root;
5254
- const Wrapper = useMemo10(() => overrides.fields || DefaultFields, [overrides]);
5595
+ const Wrapper = useMemo11(() => overrides.fields || DefaultFields, [overrides]);
5255
5596
  return /* @__PURE__ */ jsxs14(
5256
5597
  "form",
5257
5598
  {
@@ -5260,7 +5601,7 @@ var Fields = () => {
5260
5601
  e.preventDefault();
5261
5602
  },
5262
5603
  children: [
5263
- /* @__PURE__ */ jsx26(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5604
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5264
5605
  const field = fields[fieldName];
5265
5606
  if (!(field == null ? void 0 : field.type)) return null;
5266
5607
  const onChange = (value, updatedUi) => {
@@ -5331,7 +5672,7 @@ var Fields = () => {
5331
5672
  item: selectedItem
5332
5673
  });
5333
5674
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5334
- return /* @__PURE__ */ jsx26(
5675
+ return /* @__PURE__ */ jsx27(
5335
5676
  AutoFieldPrivate,
5336
5677
  {
5337
5678
  field,
@@ -5349,7 +5690,7 @@ var Fields = () => {
5349
5690
  root: true
5350
5691
  });
5351
5692
  const id = `root_${field.type}_${fieldName}`;
5352
- return /* @__PURE__ */ jsx26(
5693
+ return /* @__PURE__ */ jsx27(
5353
5694
  AutoFieldPrivate,
5354
5695
  {
5355
5696
  field,
@@ -5363,7 +5704,7 @@ var Fields = () => {
5363
5704
  );
5364
5705
  }
5365
5706
  }) }),
5366
- isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx26(Loader, { size: 16 }) }) })
5707
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
5367
5708
  ]
5368
5709
  }
5369
5710
  );
@@ -5374,7 +5715,7 @@ init_react_import();
5374
5715
 
5375
5716
  // lib/use-component-list.tsx
5376
5717
  init_react_import();
5377
- import { useEffect as useEffect16, useState as useState20 } from "react";
5718
+ import { useEffect as useEffect17, useState as useState20 } from "react";
5378
5719
 
5379
5720
  // components/ComponentList/index.tsx
5380
5721
  init_react_import();
@@ -5384,7 +5725,7 @@ init_react_import();
5384
5725
  var styles_module_default17 = { "ComponentList": "_ComponentList_odh9d_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_odh9d_5", "ComponentList-content": "_ComponentList-content_odh9d_9", "ComponentList-title": "_ComponentList-title_odh9d_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_odh9d_53" };
5385
5726
 
5386
5727
  // components/ComponentList/index.tsx
5387
- import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
5728
+ import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
5388
5729
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
5389
5730
  var ComponentListItem = ({
5390
5731
  name,
@@ -5394,7 +5735,7 @@ var ComponentListItem = ({
5394
5735
  const canInsert = getPermissions({
5395
5736
  type: name
5396
5737
  }).insert;
5397
- return /* @__PURE__ */ jsx27(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5738
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5398
5739
  };
5399
5740
  var ComponentList = ({
5400
5741
  children,
@@ -5418,14 +5759,14 @@ var ComponentList = ({
5418
5759
  }),
5419
5760
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
5420
5761
  children: [
5421
- /* @__PURE__ */ jsx27("div", { children: title }),
5422
- /* @__PURE__ */ jsx27("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx27(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx27(ChevronDown, { size: 12 }) })
5762
+ /* @__PURE__ */ jsx28("div", { children: title }),
5763
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
5423
5764
  ]
5424
5765
  }
5425
5766
  ),
5426
- /* @__PURE__ */ jsx27("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx27(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5767
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5427
5768
  var _a;
5428
- return /* @__PURE__ */ jsx27(
5769
+ return /* @__PURE__ */ jsx28(
5429
5770
  ComponentListItem,
5430
5771
  {
5431
5772
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -5439,10 +5780,10 @@ var ComponentList = ({
5439
5780
  ComponentList.Item = ComponentListItem;
5440
5781
 
5441
5782
  // lib/use-component-list.tsx
5442
- import { jsx as jsx28 } from "react/jsx-runtime";
5783
+ import { jsx as jsx29 } from "react/jsx-runtime";
5443
5784
  var useComponentList = (config, ui) => {
5444
5785
  const [componentList, setComponentList] = useState20();
5445
- useEffect16(() => {
5786
+ useEffect17(() => {
5446
5787
  var _a, _b, _c;
5447
5788
  if (Object.keys(ui.componentList).length > 0) {
5448
5789
  const matchedComponents = [];
@@ -5452,7 +5793,7 @@ var useComponentList = (config, ui) => {
5452
5793
  if (category.visible === false || !category.components) {
5453
5794
  return null;
5454
5795
  }
5455
- return /* @__PURE__ */ jsx28(
5796
+ return /* @__PURE__ */ jsx29(
5456
5797
  ComponentList,
5457
5798
  {
5458
5799
  id: categoryKey,
@@ -5461,7 +5802,7 @@ var useComponentList = (config, ui) => {
5461
5802
  var _a2;
5462
5803
  matchedComponents.push(componentName);
5463
5804
  const componentConf = config.components[componentName] || {};
5464
- return /* @__PURE__ */ jsx28(
5805
+ return /* @__PURE__ */ jsx29(
5465
5806
  ComponentList.Item,
5466
5807
  {
5467
5808
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -5481,7 +5822,7 @@ var useComponentList = (config, ui) => {
5481
5822
  );
5482
5823
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
5483
5824
  _componentList.push(
5484
- /* @__PURE__ */ jsx28(
5825
+ /* @__PURE__ */ jsx29(
5485
5826
  ComponentList,
5486
5827
  {
5487
5828
  id: "other",
@@ -5489,7 +5830,7 @@ var useComponentList = (config, ui) => {
5489
5830
  children: remainingComponents.map((componentName, i) => {
5490
5831
  var _a2;
5491
5832
  const componentConf = config.components[componentName] || {};
5492
- return /* @__PURE__ */ jsx28(
5833
+ return /* @__PURE__ */ jsx29(
5493
5834
  ComponentList.Item,
5494
5835
  {
5495
5836
  name: componentName,
@@ -5511,30 +5852,30 @@ var useComponentList = (config, ui) => {
5511
5852
  };
5512
5853
 
5513
5854
  // components/Puck/components/Components/index.tsx
5514
- import { useMemo as useMemo11 } from "react";
5515
- import { jsx as jsx29 } from "react/jsx-runtime";
5855
+ import { useMemo as useMemo12 } from "react";
5856
+ import { jsx as jsx30 } from "react/jsx-runtime";
5516
5857
  var Components = () => {
5517
5858
  const { config, state, overrides } = useAppContext();
5518
5859
  const componentList = useComponentList(config, state.ui);
5519
- const Wrapper = useMemo11(() => overrides.components || "div", [overrides]);
5520
- return /* @__PURE__ */ jsx29(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx29(ComponentList, { id: "all" }) });
5860
+ const Wrapper = useMemo12(() => overrides.components || "div", [overrides]);
5861
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
5521
5862
  };
5522
5863
 
5523
5864
  // components/Puck/components/Preview/index.tsx
5524
5865
  init_react_import();
5525
- import { useCallback as useCallback11, useEffect as useEffect18, useRef as useRef7, useMemo as useMemo12 } from "react";
5866
+ import { useCallback as useCallback13, useEffect as useEffect19, useRef as useRef6, useMemo as useMemo13 } from "react";
5526
5867
 
5527
5868
  // components/AutoFrame/index.tsx
5528
5869
  init_react_import();
5529
5870
  import {
5530
- createContext as createContext4,
5531
- useContext as useContext7,
5532
- useEffect as useEffect17,
5871
+ createContext as createContext5,
5872
+ useContext as useContext10,
5873
+ useEffect as useEffect18,
5533
5874
  useState as useState21
5534
5875
  } from "react";
5535
5876
  import hash from "object-hash";
5536
5877
  import { createPortal as createPortal3 } from "react-dom";
5537
- import { Fragment as Fragment9, jsx as jsx30 } from "react/jsx-runtime";
5878
+ import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
5538
5879
  var styleSelector = 'style, link[rel="stylesheet"]';
5539
5880
  var collectStyles = (doc) => {
5540
5881
  const collected = [];
@@ -5577,7 +5918,7 @@ var CopyHostStyles = ({
5577
5918
  onStylesLoaded = () => null
5578
5919
  }) => {
5579
5920
  const { document: doc, window: win } = useFrame();
5580
- useEffect17(() => {
5921
+ useEffect18(() => {
5581
5922
  if (!win || !doc) {
5582
5923
  return () => {
5583
5924
  };
@@ -5734,10 +6075,10 @@ var CopyHostStyles = ({
5734
6075
  observer.disconnect();
5735
6076
  };
5736
6077
  }, []);
5737
- return /* @__PURE__ */ jsx30(Fragment9, { children });
6078
+ return /* @__PURE__ */ jsx31(Fragment9, { children });
5738
6079
  };
5739
- var autoFrameContext = createContext4({});
5740
- var useFrame = () => useContext7(autoFrameContext);
6080
+ var autoFrameContext = createContext5({});
6081
+ var useFrame = () => useContext10(autoFrameContext);
5741
6082
  function AutoFrame(_a) {
5742
6083
  var _b = _a, {
5743
6084
  children,
@@ -5757,7 +6098,7 @@ function AutoFrame(_a) {
5757
6098
  const [loaded, setLoaded] = useState21(false);
5758
6099
  const [ctx, setCtx] = useState21({});
5759
6100
  const [mountTarget, setMountTarget] = useState21();
5760
- useEffect17(() => {
6101
+ useEffect18(() => {
5761
6102
  var _a2;
5762
6103
  if (frameRef.current) {
5763
6104
  setCtx({
@@ -5769,7 +6110,7 @@ function AutoFrame(_a) {
5769
6110
  );
5770
6111
  }
5771
6112
  }, [frameRef, loaded]);
5772
- return /* @__PURE__ */ jsx30(
6113
+ return /* @__PURE__ */ jsx31(
5773
6114
  "iframe",
5774
6115
  __spreadProps(__spreadValues({}, props), {
5775
6116
  className,
@@ -5779,7 +6120,7 @@ function AutoFrame(_a) {
5779
6120
  onLoad: () => {
5780
6121
  setLoaded(true);
5781
6122
  },
5782
- children: /* @__PURE__ */ jsx30(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx30(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
6123
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
5783
6124
  })
5784
6125
  );
5785
6126
  }
@@ -5790,12 +6131,68 @@ var AutoFrame_default = AutoFrame;
5790
6131
  init_react_import();
5791
6132
  var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
5792
6133
 
6134
+ // components/Render/index.tsx
6135
+ init_react_import();
6136
+ import { jsx as jsx32 } from "react/jsx-runtime";
6137
+ function Render({
6138
+ config,
6139
+ data
6140
+ }) {
6141
+ var _a;
6142
+ const defaultedData = __spreadProps(__spreadValues({}, data), {
6143
+ root: data.root || {},
6144
+ content: data.content || []
6145
+ });
6146
+ const rootProps = defaultedData.root.props || defaultedData.root;
6147
+ const title = (rootProps == null ? void 0 : rootProps.title) || "";
6148
+ if ((_a = config.root) == null ? void 0 : _a.render) {
6149
+ return /* @__PURE__ */ jsx32(
6150
+ DropZoneProvider,
6151
+ {
6152
+ value: {
6153
+ data: defaultedData,
6154
+ config,
6155
+ mode: "render",
6156
+ depth: 0,
6157
+ path: []
6158
+ },
6159
+ children: /* @__PURE__ */ jsx32(
6160
+ config.root.render,
6161
+ __spreadProps(__spreadValues({}, rootProps), {
6162
+ puck: {
6163
+ renderDropZone: DropZone,
6164
+ isEditing: false
6165
+ },
6166
+ title,
6167
+ editMode: false,
6168
+ id: "puck-root",
6169
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6170
+ })
6171
+ )
6172
+ }
6173
+ );
6174
+ }
6175
+ return /* @__PURE__ */ jsx32(
6176
+ DropZoneProvider,
6177
+ {
6178
+ value: {
6179
+ data: defaultedData,
6180
+ config,
6181
+ mode: "render",
6182
+ depth: 0,
6183
+ path: []
6184
+ },
6185
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6186
+ }
6187
+ );
6188
+ }
6189
+
5793
6190
  // components/Puck/components/Preview/index.tsx
5794
- import { Fragment as Fragment10, jsx as jsx31 } from "react/jsx-runtime";
6191
+ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
5795
6192
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
5796
6193
  var useBubbleIframeEvents = (ref) => {
5797
6194
  const { status } = useAppContext();
5798
- useEffect18(() => {
6195
+ useEffect19(() => {
5799
6196
  var _a;
5800
6197
  if (ref.current && status === "READY") {
5801
6198
  const iframe = ref.current;
@@ -5832,22 +6229,34 @@ var useBubbleIframeEvents = (ref) => {
5832
6229
  }
5833
6230
  }, [status]);
5834
6231
  };
5835
- var Preview = ({ id = "puck-preview" }) => {
6232
+ var Preview2 = ({ id = "puck-preview" }) => {
5836
6233
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
5837
- const Page = useCallback11(
6234
+ const Page = useCallback13(
5838
6235
  (pageProps) => {
5839
6236
  var _a, _b;
5840
6237
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
5841
6238
  id: "puck-root"
5842
- }, pageProps)) : /* @__PURE__ */ jsx31(Fragment10, { children: pageProps.children });
6239
+ }, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
5843
6240
  },
5844
6241
  [config.root]
5845
6242
  );
5846
- const Frame = useMemo12(() => overrides.iframe, [overrides]);
6243
+ const Frame = useMemo13(() => overrides.iframe, [overrides]);
5847
6244
  const rootProps = state.data.root.props || state.data.root;
5848
- const ref = useRef7(null);
6245
+ const ref = useRef6(null);
5849
6246
  useBubbleIframeEvents(ref);
5850
- return /* @__PURE__ */ jsx31(
6247
+ const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
6248
+ Page,
6249
+ __spreadProps(__spreadValues({}, rootProps), {
6250
+ puck: {
6251
+ renderDropZone: DropZone,
6252
+ isEditing: true,
6253
+ dragRef: null
6254
+ },
6255
+ editMode: true,
6256
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
6257
+ })
6258
+ ) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
6259
+ return /* @__PURE__ */ jsx33(
5851
6260
  "div",
5852
6261
  {
5853
6262
  className: getClassName23(),
@@ -5856,7 +6265,7 @@ var Preview = ({ id = "puck-preview" }) => {
5856
6265
  onClick: () => {
5857
6266
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
5858
6267
  },
5859
- children: iframe.enabled ? /* @__PURE__ */ jsx31(
6268
+ children: iframe.enabled ? /* @__PURE__ */ jsx33(
5860
6269
  AutoFrame_default,
5861
6270
  {
5862
6271
  id: "preview-frame",
@@ -5866,40 +6275,21 @@ var Preview = ({ id = "puck-preview" }) => {
5866
6275
  setStatus("READY");
5867
6276
  },
5868
6277
  frameRef: ref,
5869
- children: /* @__PURE__ */ jsx31(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
5870
- const inner = /* @__PURE__ */ jsx31(
5871
- Page,
5872
- __spreadProps(__spreadValues({}, rootProps), {
5873
- puck: {
5874
- renderDropZone: DropZone,
5875
- isEditing: true,
5876
- dragRef: null
5877
- },
5878
- editMode: true,
5879
- children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
5880
- })
5881
- );
6278
+ children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
5882
6279
  if (Frame) {
5883
- return /* @__PURE__ */ jsx31(Frame, { document: document2, children: inner });
6280
+ return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
5884
6281
  }
5885
6282
  return inner;
5886
6283
  } })
5887
6284
  }
5888
- ) : /* @__PURE__ */ jsx31(
6285
+ ) : /* @__PURE__ */ jsx33(
5889
6286
  "div",
5890
6287
  {
5891
6288
  id: "preview-frame",
5892
6289
  className: getClassName23("frame"),
5893
6290
  ref,
5894
6291
  "data-puck-entry": true,
5895
- children: /* @__PURE__ */ jsx31(
5896
- Page,
5897
- __spreadProps(__spreadValues({}, rootProps), {
5898
- puck: { renderDropZone: DropZone, isEditing: true, dragRef: null },
5899
- editMode: true,
5900
- children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
5901
- })
5902
- )
6292
+ children: inner
5903
6293
  }
5904
6294
  )
5905
6295
  }
@@ -5949,7 +6339,7 @@ var scrollIntoView = (el) => {
5949
6339
  };
5950
6340
 
5951
6341
  // components/LayerTree/index.tsx
5952
- import { useContext as useContext8 } from "react";
6342
+ import { useContext as useContext11 } from "react";
5953
6343
 
5954
6344
  // lib/is-child-of-zone.ts
5955
6345
  init_react_import();
@@ -5982,7 +6372,7 @@ var onScrollEnd = (frame, cb) => {
5982
6372
  };
5983
6373
 
5984
6374
  // components/LayerTree/index.tsx
5985
- import { Fragment as Fragment11, jsx as jsx32, jsxs as jsxs16 } from "react/jsx-runtime";
6375
+ import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
5986
6376
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
5987
6377
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
5988
6378
  var LayerTree = ({
@@ -5995,15 +6385,15 @@ var LayerTree = ({
5995
6385
  label
5996
6386
  }) => {
5997
6387
  const zones = data.zones || {};
5998
- const ctx = useContext8(dropZoneContext);
6388
+ const ctx = useContext11(dropZoneContext);
5999
6389
  return /* @__PURE__ */ jsxs16(Fragment11, { children: [
6000
6390
  label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
6001
- /* @__PURE__ */ jsx32("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx32(Layers, { size: "16" }) }),
6391
+ /* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
6002
6392
  " ",
6003
6393
  label
6004
6394
  ] }),
6005
6395
  /* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
6006
- zoneContent.length === 0 && /* @__PURE__ */ jsx32("div", { className: getClassName24("helper"), children: "No items" }),
6396
+ zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
6007
6397
  zoneContent.map((item, i) => {
6008
6398
  var _a;
6009
6399
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -6026,7 +6416,7 @@ var LayerTree = ({
6026
6416
  childIsSelected
6027
6417
  }),
6028
6418
  children: [
6029
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6419
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6030
6420
  "button",
6031
6421
  {
6032
6422
  type: "button",
@@ -6065,22 +6455,22 @@ var LayerTree = ({
6065
6455
  setHoveringComponent(null);
6066
6456
  },
6067
6457
  children: [
6068
- containsZone && /* @__PURE__ */ jsx32(
6458
+ containsZone && /* @__PURE__ */ jsx34(
6069
6459
  "div",
6070
6460
  {
6071
6461
  className: getClassNameLayer("chevron"),
6072
6462
  title: isSelected ? "Collapse" : "Expand",
6073
- children: /* @__PURE__ */ jsx32(ChevronDown, { size: "12" })
6463
+ children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
6074
6464
  }
6075
6465
  ),
6076
6466
  /* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
6077
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx32(Type, { size: "16" }) : /* @__PURE__ */ jsx32(LayoutGrid, { size: "16" }) }),
6078
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("name"), children: label2 })
6467
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
6468
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
6079
6469
  ] })
6080
6470
  ]
6081
6471
  }
6082
6472
  ) }),
6083
- containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx32(
6473
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
6084
6474
  LayerTree,
6085
6475
  {
6086
6476
  config,
@@ -6102,13 +6492,13 @@ var LayerTree = ({
6102
6492
  };
6103
6493
 
6104
6494
  // components/Puck/components/Outline/index.tsx
6105
- import { useCallback as useCallback12, useMemo as useMemo13 } from "react";
6106
- import { Fragment as Fragment12, jsx as jsx33, jsxs as jsxs17 } from "react/jsx-runtime";
6495
+ import { useCallback as useCallback14, useMemo as useMemo14 } from "react";
6496
+ import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
6107
6497
  var Outline = () => {
6108
6498
  const { dispatch, state, overrides, config } = useAppContext();
6109
6499
  const { data, ui } = state;
6110
6500
  const { itemSelector } = ui;
6111
- const setItemSelector = useCallback12(
6501
+ const setItemSelector = useCallback14(
6112
6502
  (newItemSelector) => {
6113
6503
  dispatch({
6114
6504
  type: "setUi",
@@ -6117,9 +6507,9 @@ var Outline = () => {
6117
6507
  },
6118
6508
  []
6119
6509
  );
6120
- const Wrapper = useMemo13(() => overrides.outline || "div", [overrides]);
6121
- return /* @__PURE__ */ jsx33(Wrapper, { children: /* @__PURE__ */ jsx33(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6122
- (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx33(
6510
+ const Wrapper = useMemo14(() => overrides.outline || "div", [overrides]);
6511
+ return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6512
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
6123
6513
  LayerTree,
6124
6514
  {
6125
6515
  config,
@@ -6132,7 +6522,7 @@ var Outline = () => {
6132
6522
  ),
6133
6523
  Object.entries(findZonesForArea(data, "root")).map(
6134
6524
  ([zoneKey, zone]) => {
6135
- return /* @__PURE__ */ jsx33(
6525
+ return /* @__PURE__ */ jsx35(
6136
6526
  LayerTree,
6137
6527
  {
6138
6528
  config,
@@ -6404,27 +6794,27 @@ var getBox = function getBox2(el) {
6404
6794
 
6405
6795
  // components/Puck/components/Canvas/index.tsx
6406
6796
  import {
6407
- useCallback as useCallback13,
6408
- useEffect as useEffect20,
6409
- useMemo as useMemo15,
6410
- useRef as useRef8,
6797
+ useCallback as useCallback15,
6798
+ useEffect as useEffect21,
6799
+ useMemo as useMemo16,
6800
+ useRef as useRef7,
6411
6801
  useState as useState24
6412
6802
  } from "react";
6413
6803
 
6414
6804
  // components/ViewportControls/index.tsx
6415
6805
  init_react_import();
6416
- import { useEffect as useEffect19, useMemo as useMemo14, useState as useState23 } from "react";
6806
+ import { useEffect as useEffect20, useMemo as useMemo15, useState as useState23 } from "react";
6417
6807
 
6418
6808
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6419
6809
  init_react_import();
6420
6810
  var styles_module_default20 = { "ViewportControls": "_ViewportControls_g1wgg_1", "ViewportControls-divider": "_ViewportControls-divider_g1wgg_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_g1wgg_21", "ViewportButton--isActive": "_ViewportButton--isActive_g1wgg_34", "ViewportButton-inner": "_ViewportButton-inner_g1wgg_34" };
6421
6811
 
6422
6812
  // components/ViewportControls/index.tsx
6423
- import { jsx as jsx34, jsxs as jsxs18 } from "react/jsx-runtime";
6813
+ import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
6424
6814
  var icons = {
6425
- Smartphone: /* @__PURE__ */ jsx34(Smartphone, { size: 16 }),
6426
- Tablet: /* @__PURE__ */ jsx34(Tablet, { size: 16 }),
6427
- Monitor: /* @__PURE__ */ jsx34(Monitor, { size: 16 })
6815
+ Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
6816
+ Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
6817
+ Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
6428
6818
  };
6429
6819
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
6430
6820
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -6437,10 +6827,10 @@ var ViewportButton = ({
6437
6827
  }) => {
6438
6828
  const { state } = useAppContext();
6439
6829
  const [isActive, setIsActive] = useState23(false);
6440
- useEffect19(() => {
6830
+ useEffect20(() => {
6441
6831
  setIsActive(width === state.ui.viewports.current.width);
6442
6832
  }, [width, state.ui.viewports.current.width]);
6443
- return /* @__PURE__ */ jsx34("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx34(
6833
+ return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
6444
6834
  IconButton,
6445
6835
  {
6446
6836
  title,
@@ -6449,7 +6839,7 @@ var ViewportButton = ({
6449
6839
  e.stopPropagation();
6450
6840
  onClick({ width, height });
6451
6841
  },
6452
- children: /* @__PURE__ */ jsx34("span", { className: getClassNameButton("inner"), children })
6842
+ children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
6453
6843
  }
6454
6844
  ) });
6455
6845
  };
@@ -6473,7 +6863,7 @@ var ViewportControls = ({
6473
6863
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6474
6864
  (option) => option.value === autoZoom
6475
6865
  );
6476
- const zoomOptions = useMemo14(
6866
+ const zoomOptions = useMemo15(
6477
6867
  () => [
6478
6868
  ...defaultZoomOptions,
6479
6869
  ...defaultsContainAutoZoom ? [] : [
@@ -6486,7 +6876,7 @@ var ViewportControls = ({
6486
6876
  [autoZoom]
6487
6877
  );
6488
6878
  return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
6489
- viewports.map((viewport, i) => /* @__PURE__ */ jsx34(
6879
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
6490
6880
  ViewportButton,
6491
6881
  {
6492
6882
  height: viewport.height,
@@ -6497,8 +6887,8 @@ var ViewportControls = ({
6497
6887
  },
6498
6888
  i
6499
6889
  )),
6500
- /* @__PURE__ */ jsx34("div", { className: getClassName25("divider") }),
6501
- /* @__PURE__ */ jsx34(
6890
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6891
+ /* @__PURE__ */ jsx36(
6502
6892
  IconButton,
6503
6893
  {
6504
6894
  title: "Zoom viewport out",
@@ -6512,10 +6902,10 @@ var ViewportControls = ({
6512
6902
  )].value
6513
6903
  );
6514
6904
  },
6515
- children: /* @__PURE__ */ jsx34(ZoomOut, { size: 16 })
6905
+ children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
6516
6906
  }
6517
6907
  ),
6518
- /* @__PURE__ */ jsx34(
6908
+ /* @__PURE__ */ jsx36(
6519
6909
  IconButton,
6520
6910
  {
6521
6911
  title: "Zoom viewport in",
@@ -6529,11 +6919,11 @@ var ViewportControls = ({
6529
6919
  )].value
6530
6920
  );
6531
6921
  },
6532
- children: /* @__PURE__ */ jsx34(ZoomIn, { size: 16 })
6922
+ children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
6533
6923
  }
6534
6924
  ),
6535
- /* @__PURE__ */ jsx34("div", { className: getClassName25("divider") }),
6536
- /* @__PURE__ */ jsx34(
6925
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6926
+ /* @__PURE__ */ jsx36(
6537
6927
  "select",
6538
6928
  {
6539
6929
  className: getClassName25("zoomSelect"),
@@ -6541,7 +6931,7 @@ var ViewportControls = ({
6541
6931
  onChange: (e) => {
6542
6932
  onZoom(parseFloat(e.currentTarget.value));
6543
6933
  },
6544
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx34(
6934
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
6545
6935
  "option",
6546
6936
  {
6547
6937
  value: option.value,
@@ -6589,24 +6979,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
6589
6979
  };
6590
6980
 
6591
6981
  // components/Puck/components/Canvas/index.tsx
6592
- import { Fragment as Fragment13, jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
6982
+ import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
6593
6983
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
6594
6984
  var ZOOM_ON_CHANGE = true;
6595
6985
  var Canvas = () => {
6596
6986
  const { status, iframe } = useAppContext();
6597
6987
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
6598
6988
  const { ui } = state;
6599
- const frameRef = useRef8(null);
6989
+ const frameRef = useRef7(null);
6600
6990
  const [showTransition, setShowTransition] = useState24(false);
6601
- const defaultRender = useMemo15(() => {
6602
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx35(Fragment13, { children });
6991
+ const defaultRender = useMemo16(() => {
6992
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
6603
6993
  return PuckDefault;
6604
6994
  }, []);
6605
- const CustomPreview = useMemo15(
6995
+ const CustomPreview = useMemo16(
6606
6996
  () => overrides.preview || defaultRender,
6607
6997
  [overrides]
6608
6998
  );
6609
- const getFrameDimensions = useCallback13(() => {
6999
+ const getFrameDimensions = useCallback15(() => {
6610
7000
  if (frameRef.current) {
6611
7001
  const frame = frameRef.current;
6612
7002
  const box = getBox(frame);
@@ -6614,7 +7004,7 @@ var Canvas = () => {
6614
7004
  }
6615
7005
  return { width: 0, height: 0 };
6616
7006
  }, [frameRef]);
6617
- const resetAutoZoom = useCallback13(
7007
+ const resetAutoZoom = useCallback15(
6618
7008
  (ui2 = state.ui) => {
6619
7009
  if (frameRef.current) {
6620
7010
  setZoomConfig(
@@ -6624,11 +7014,11 @@ var Canvas = () => {
6624
7014
  },
6625
7015
  [frameRef, zoomConfig, state.ui]
6626
7016
  );
6627
- useEffect20(() => {
7017
+ useEffect21(() => {
6628
7018
  setShowTransition(false);
6629
7019
  resetAutoZoom();
6630
7020
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6631
- useEffect20(() => {
7021
+ useEffect21(() => {
6632
7022
  const { height: frameHeight } = getFrameDimensions();
6633
7023
  if (ui.viewports.current.height === "auto") {
6634
7024
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6636,13 +7026,13 @@ var Canvas = () => {
6636
7026
  }));
6637
7027
  }
6638
7028
  }, [zoomConfig.zoom]);
6639
- useEffect20(() => {
7029
+ useEffect21(() => {
6640
7030
  if (ZOOM_ON_CHANGE) {
6641
7031
  setShowTransition(true);
6642
7032
  resetAutoZoom(ui);
6643
7033
  }
6644
7034
  }, [ui.viewports.current.width]);
6645
- useEffect20(() => {
7035
+ useEffect21(() => {
6646
7036
  const cb = () => {
6647
7037
  setShowTransition(false);
6648
7038
  resetAutoZoom();
@@ -6653,7 +7043,7 @@ var Canvas = () => {
6653
7043
  };
6654
7044
  }, []);
6655
7045
  const [showLoader, setShowLoader] = useState24(false);
6656
- useEffect20(() => {
7046
+ useEffect21(() => {
6657
7047
  setTimeout(() => {
6658
7048
  setShowLoader(true);
6659
7049
  }, 500);
@@ -6671,7 +7061,7 @@ var Canvas = () => {
6671
7061
  recordHistory: true
6672
7062
  }),
6673
7063
  children: [
6674
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx35("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx35(
7064
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
6675
7065
  ViewportControls,
6676
7066
  {
6677
7067
  autoZoom: zoomConfig.autoZoom,
@@ -6698,7 +7088,7 @@ var Canvas = () => {
6698
7088
  }
6699
7089
  ) }),
6700
7090
  /* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
6701
- /* @__PURE__ */ jsx35(
7091
+ /* @__PURE__ */ jsx37(
6702
7092
  "div",
6703
7093
  {
6704
7094
  className: getClassName26("root"),
@@ -6719,10 +7109,10 @@ var Canvas = () => {
6719
7109
  })
6720
7110
  );
6721
7111
  },
6722
- children: /* @__PURE__ */ jsx35(CustomPreview, { children: /* @__PURE__ */ jsx35(Preview, {}) })
7112
+ children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
6723
7113
  }
6724
7114
  ),
6725
- /* @__PURE__ */ jsx35("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx35(Loader, { size: 24 }) })
7115
+ /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
6726
7116
  ] })
6727
7117
  ]
6728
7118
  }
@@ -6731,7 +7121,7 @@ var Canvas = () => {
6731
7121
 
6732
7122
  // lib/use-loaded-overrides.ts
6733
7123
  init_react_import();
6734
- import { useMemo as useMemo16 } from "react";
7124
+ import { useMemo as useMemo17 } from "react";
6735
7125
 
6736
7126
  // lib/load-overrides.ts
6737
7127
  init_react_import();
@@ -6770,26 +7160,26 @@ var useLoadedOverrides = ({
6770
7160
  overrides,
6771
7161
  plugins
6772
7162
  }) => {
6773
- return useMemo16(() => {
7163
+ return useMemo17(() => {
6774
7164
  return loadOverrides({ overrides, plugins });
6775
7165
  }, [plugins, overrides]);
6776
7166
  };
6777
7167
 
6778
7168
  // components/DefaultOverride/index.tsx
6779
7169
  init_react_import();
6780
- import { Fragment as Fragment14, jsx as jsx36 } from "react/jsx-runtime";
6781
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx36(Fragment14, { children });
7170
+ import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
7171
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
6782
7172
 
6783
7173
  // lib/use-inject-css.ts
6784
7174
  init_react_import();
6785
- import { useEffect as useEffect21, useState as useState25 } from "react";
7175
+ import { useEffect as useEffect22, useState as useState25 } from "react";
6786
7176
  var styles = ``;
6787
7177
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
6788
7178
  const [el, setEl] = useState25();
6789
- useEffect21(() => {
7179
+ useEffect22(() => {
6790
7180
  setEl(document.createElement("style"));
6791
7181
  }, []);
6792
- useEffect21(() => {
7182
+ useEffect22(() => {
6793
7183
  var _a;
6794
7184
  if (!el || typeof window === "undefined") {
6795
7185
  return;
@@ -6807,8 +7197,35 @@ var useInjectGlobalCss = (iframeEnabled) => {
6807
7197
  return useInjectStyleSheet(styles, iframeEnabled);
6808
7198
  };
6809
7199
 
7200
+ // lib/use-preview-mode-hotkeys.ts
7201
+ init_react_import();
7202
+ import { useCallback as useCallback16 } from "react";
7203
+ import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
7204
+ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7205
+ const toggleInteractive = useCallback16(() => {
7206
+ dispatch({
7207
+ type: "setUi",
7208
+ ui: (ui) => ({
7209
+ previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
7210
+ })
7211
+ });
7212
+ }, [dispatch]);
7213
+ const toggleInteractiveIframe = () => {
7214
+ if (iframeEnabled) {
7215
+ toggleInteractive();
7216
+ }
7217
+ };
7218
+ const frame = getFrame();
7219
+ const resolvedFrame = typeof window !== "undefined" && frame !== document ? frame : void 0;
7220
+ useHotkeys2("meta+i", toggleInteractive, { preventDefault: true });
7221
+ useHotkeys2("meta+i", toggleInteractiveIframe, {
7222
+ preventDefault: true,
7223
+ document: resolvedFrame
7224
+ });
7225
+ };
7226
+
6810
7227
  // components/Puck/index.tsx
6811
- import { Fragment as Fragment15, jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
7228
+ import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
6812
7229
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
6813
7230
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
6814
7231
  function Puck({
@@ -6930,11 +7347,11 @@ function Puck({
6930
7347
  const [menuOpen, setMenuOpen] = useState26(false);
6931
7348
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
6932
7349
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
6933
- useEffect22(() => {
7350
+ useEffect23(() => {
6934
7351
  if (onChange) onChange(data);
6935
7352
  }, [data]);
6936
7353
  const rootProps = data.root.props || data.root;
6937
- const toggleSidebars = useCallback14(
7354
+ const toggleSidebars = useCallback17(
6938
7355
  (sidebar) => {
6939
7356
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
6940
7357
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -6948,7 +7365,7 @@ function Puck({
6948
7365
  },
6949
7366
  [dispatch, leftSideBarVisible, rightSideBarVisible]
6950
7367
  );
6951
- useEffect22(() => {
7368
+ useEffect23(() => {
6952
7369
  if (!window.matchMedia("(min-width: 638px)").matches) {
6953
7370
  dispatch({
6954
7371
  type: "setUi",
@@ -6971,7 +7388,7 @@ function Puck({
6971
7388
  window.removeEventListener("resize", handleResize);
6972
7389
  };
6973
7390
  }, []);
6974
- const defaultHeaderRender = useMemo17(() => {
7391
+ const defaultHeaderRender = useMemo18(() => {
6975
7392
  if (renderHeader) {
6976
7393
  console.warn(
6977
7394
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -6979,20 +7396,20 @@ function Puck({
6979
7396
  const RenderHeader = (_a2) => {
6980
7397
  var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
6981
7398
  const Comp = renderHeader;
6982
- return /* @__PURE__ */ jsx37(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7399
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
6983
7400
  };
6984
7401
  return RenderHeader;
6985
7402
  }
6986
7403
  return DefaultOverride;
6987
7404
  }, [renderHeader]);
6988
- const defaultHeaderActionsRender = useMemo17(() => {
7405
+ const defaultHeaderActionsRender = useMemo18(() => {
6989
7406
  if (renderHeaderActions) {
6990
7407
  console.warn(
6991
7408
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
6992
7409
  );
6993
7410
  const RenderHeader = (props) => {
6994
7411
  const Comp = renderHeaderActions;
6995
- return /* @__PURE__ */ jsx37(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7412
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
6996
7413
  };
6997
7414
  return RenderHeader;
6998
7415
  }
@@ -7002,26 +7419,27 @@ function Puck({
7002
7419
  overrides,
7003
7420
  plugins
7004
7421
  });
7005
- const CustomPuck = useMemo17(
7422
+ const CustomPuck = useMemo18(
7006
7423
  () => loadedOverrides.puck || DefaultOverride,
7007
7424
  [loadedOverrides]
7008
7425
  );
7009
- const CustomHeader = useMemo17(
7426
+ const CustomHeader = useMemo18(
7010
7427
  () => loadedOverrides.header || defaultHeaderRender,
7011
7428
  [loadedOverrides]
7012
7429
  );
7013
- const CustomHeaderActions = useMemo17(
7430
+ const CustomHeaderActions = useMemo18(
7014
7431
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7015
7432
  [loadedOverrides]
7016
7433
  );
7017
7434
  const [mounted, setMounted] = useState26(false);
7018
- useEffect22(() => {
7435
+ useEffect23(() => {
7019
7436
  setMounted(true);
7020
7437
  }, []);
7021
7438
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
7022
7439
  const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
7440
+ usePreviewModeHotkeys(dispatch, iframe.enabled);
7023
7441
  return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
7024
- /* @__PURE__ */ jsx37(
7442
+ /* @__PURE__ */ jsx39(
7025
7443
  AppProvider,
7026
7444
  {
7027
7445
  value: {
@@ -7043,7 +7461,7 @@ function Puck({
7043
7461
  getPermissions: () => ({}),
7044
7462
  refreshPermissions: () => null
7045
7463
  },
7046
- children: /* @__PURE__ */ jsx37(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx37(CustomPuck, { children: children || /* @__PURE__ */ jsx37(
7464
+ children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
7047
7465
  "div",
7048
7466
  {
7049
7467
  className: getLayoutClassName({
@@ -7053,59 +7471,59 @@ function Puck({
7053
7471
  rightSideBarVisible
7054
7472
  }),
7055
7473
  children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
7056
- /* @__PURE__ */ jsx37(
7474
+ /* @__PURE__ */ jsx39(
7057
7475
  CustomHeader,
7058
7476
  {
7059
- actions: /* @__PURE__ */ jsx37(Fragment15, { children: /* @__PURE__ */ jsx37(CustomHeaderActions, { children: /* @__PURE__ */ jsx37(
7477
+ actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7060
7478
  Button,
7061
7479
  {
7062
7480
  onClick: () => {
7063
7481
  onPublish && onPublish(data);
7064
7482
  },
7065
- icon: /* @__PURE__ */ jsx37(Globe, { size: "14px" }),
7483
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7066
7484
  children: "Publish"
7067
7485
  }
7068
7486
  ) }) }),
7069
- children: /* @__PURE__ */ jsx37("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7487
+ children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7070
7488
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
7071
- /* @__PURE__ */ jsx37(
7489
+ /* @__PURE__ */ jsx39(
7072
7490
  "div",
7073
7491
  {
7074
7492
  className: getLayoutClassName("leftSideBarToggle"),
7075
- children: /* @__PURE__ */ jsx37(
7493
+ children: /* @__PURE__ */ jsx39(
7076
7494
  IconButton,
7077
7495
  {
7078
7496
  onClick: () => {
7079
7497
  toggleSidebars("left");
7080
7498
  },
7081
7499
  title: "Toggle left sidebar",
7082
- children: /* @__PURE__ */ jsx37(PanelLeft, { focusable: "false" })
7500
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7083
7501
  }
7084
7502
  )
7085
7503
  }
7086
7504
  ),
7087
- /* @__PURE__ */ jsx37(
7505
+ /* @__PURE__ */ jsx39(
7088
7506
  "div",
7089
7507
  {
7090
7508
  className: getLayoutClassName("rightSideBarToggle"),
7091
- children: /* @__PURE__ */ jsx37(
7509
+ children: /* @__PURE__ */ jsx39(
7092
7510
  IconButton,
7093
7511
  {
7094
7512
  onClick: () => {
7095
7513
  toggleSidebars("right");
7096
7514
  },
7097
7515
  title: "Toggle right sidebar",
7098
- children: /* @__PURE__ */ jsx37(PanelRight, { focusable: "false" })
7516
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7099
7517
  }
7100
7518
  )
7101
7519
  }
7102
7520
  )
7103
7521
  ] }),
7104
- /* @__PURE__ */ jsx37("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7522
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7105
7523
  headerTitle || rootProps.title || "Page",
7106
7524
  headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
7107
7525
  " ",
7108
- /* @__PURE__ */ jsx37(
7526
+ /* @__PURE__ */ jsx39(
7109
7527
  "code",
7110
7528
  {
7111
7529
  className: getLayoutClassName("headerPath"),
@@ -7115,30 +7533,30 @@ function Puck({
7115
7533
  ] })
7116
7534
  ] }) }),
7117
7535
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
7118
- /* @__PURE__ */ jsx37("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx37(
7536
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
7119
7537
  IconButton,
7120
7538
  {
7121
7539
  onClick: () => {
7122
7540
  return setMenuOpen(!menuOpen);
7123
7541
  },
7124
7542
  title: "Toggle menu bar",
7125
- children: menuOpen ? /* @__PURE__ */ jsx37(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx37(ChevronDown, { focusable: "false" })
7543
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7126
7544
  }
7127
7545
  ) }),
7128
- /* @__PURE__ */ jsx37(
7546
+ /* @__PURE__ */ jsx39(
7129
7547
  MenuBar,
7130
7548
  {
7131
7549
  appState,
7132
7550
  dispatch,
7133
7551
  onPublish,
7134
7552
  menuOpen,
7135
- renderHeaderActions: () => /* @__PURE__ */ jsx37(CustomHeaderActions, { children: /* @__PURE__ */ jsx37(
7553
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7136
7554
  Button,
7137
7555
  {
7138
7556
  onClick: () => {
7139
7557
  onPublish && onPublish(data);
7140
7558
  },
7141
- icon: /* @__PURE__ */ jsx37(Globe, { size: "14px" }),
7559
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7142
7560
  children: "Publish"
7143
7561
  }
7144
7562
  ) }),
@@ -7150,18 +7568,18 @@ function Puck({
7150
7568
  }
7151
7569
  ),
7152
7570
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
7153
- /* @__PURE__ */ jsx37(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx37(Components, {}) }),
7154
- /* @__PURE__ */ jsx37(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx37(Outline, {}) })
7571
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
7572
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
7155
7573
  ] }),
7156
- /* @__PURE__ */ jsx37(Canvas, {}),
7157
- /* @__PURE__ */ jsx37("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx37(
7574
+ /* @__PURE__ */ jsx39(Canvas, {}),
7575
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
7158
7576
  SidebarSection,
7159
7577
  {
7160
7578
  noPadding: true,
7161
7579
  noBorderTop: true,
7162
7580
  showBreadcrumbs: true,
7163
7581
  title: selectedItem ? selectedComponentLabel : "Page",
7164
- children: /* @__PURE__ */ jsx37(Fields, {})
7582
+ children: /* @__PURE__ */ jsx39(Fields, {})
7165
7583
  }
7166
7584
  ) })
7167
7585
  ] })
@@ -7169,69 +7587,13 @@ function Puck({
7169
7587
  ) }) })
7170
7588
  }
7171
7589
  ),
7172
- /* @__PURE__ */ jsx37("div", { id: "puck-portal-root", className: getClassName27("portal") })
7590
+ /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
7173
7591
  ] });
7174
7592
  }
7175
7593
  Puck.Components = Components;
7176
7594
  Puck.Fields = Fields;
7177
7595
  Puck.Outline = Outline;
7178
- Puck.Preview = Preview;
7179
-
7180
- // components/Render/index.tsx
7181
- init_react_import();
7182
- import { jsx as jsx38 } from "react/jsx-runtime";
7183
- function Render({
7184
- config,
7185
- data
7186
- }) {
7187
- var _a;
7188
- const defaultedData = __spreadProps(__spreadValues({}, data), {
7189
- root: data.root || {},
7190
- content: data.content || []
7191
- });
7192
- const rootProps = defaultedData.root.props || defaultedData.root;
7193
- const title = (rootProps == null ? void 0 : rootProps.title) || "";
7194
- if ((_a = config.root) == null ? void 0 : _a.render) {
7195
- return /* @__PURE__ */ jsx38(
7196
- DropZoneProvider,
7197
- {
7198
- value: {
7199
- data: defaultedData,
7200
- config,
7201
- mode: "render",
7202
- depth: 0,
7203
- path: []
7204
- },
7205
- children: /* @__PURE__ */ jsx38(
7206
- config.root.render,
7207
- __spreadProps(__spreadValues({}, rootProps), {
7208
- puck: {
7209
- renderDropZone: DropZone,
7210
- isEditing: false
7211
- },
7212
- title,
7213
- editMode: false,
7214
- id: "puck-root",
7215
- children: /* @__PURE__ */ jsx38(DropZone, { zone: rootDroppableId })
7216
- })
7217
- )
7218
- }
7219
- );
7220
- }
7221
- return /* @__PURE__ */ jsx38(
7222
- DropZoneProvider,
7223
- {
7224
- value: {
7225
- data: defaultedData,
7226
- config,
7227
- mode: "render",
7228
- depth: 0,
7229
- path: []
7230
- },
7231
- children: /* @__PURE__ */ jsx38(DropZone, { zone: rootDroppableId })
7232
- }
7233
- );
7234
- }
7596
+ Puck.Preview = Preview2;
7235
7597
 
7236
7598
  // lib/migrate.ts
7237
7599
  init_react_import();