@measured/puck 0.18.0-canary.066aba9 → 0.18.0-canary.4b589f6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
 
@@ -1085,7 +1086,7 @@ init_react_import();
1085
1086
  import { DragDropProvider } from "@dnd-kit/react";
1086
1087
  import { useState as useState5 } from "react";
1087
1088
 
1088
- // lib/dnd-kit/safe.ts
1089
+ // lib/dnd/dnd-kit/safe.ts
1089
1090
  init_react_import();
1090
1091
  import {
1091
1092
  useDraggable,
@@ -1165,8 +1166,53 @@ var Sortable = ({
1165
1166
  return children({ status, ref: sortableRef });
1166
1167
  };
1167
1168
 
1169
+ // components/AutoField/context.tsx
1170
+ init_react_import();
1171
+ import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
1172
+ import { jsx as jsx7 } from "react/jsx-runtime";
1173
+ var NestedFieldContext = createContext2({});
1174
+ var useNestedFieldContext = () => {
1175
+ const context = useContext2(NestedFieldContext);
1176
+ return __spreadProps(__spreadValues({}, context), {
1177
+ readOnlyFields: context.readOnlyFields || {}
1178
+ });
1179
+ };
1180
+ var NestedFieldProvider = ({
1181
+ children,
1182
+ name,
1183
+ subName,
1184
+ wildcardName = name,
1185
+ readOnlyFields
1186
+ }) => {
1187
+ const subPath = `${name}.${subName}`;
1188
+ const wildcardSubPath = `${wildcardName}.${subName}`;
1189
+ const subReadOnlyFields = useMemo(
1190
+ () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
1191
+ const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
1192
+ if (isLocal) {
1193
+ const subPathPattern = new RegExp(
1194
+ `^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
1195
+ );
1196
+ const localName = readOnlyKey.replace(subPathPattern, "");
1197
+ return __spreadProps(__spreadValues({}, acc), {
1198
+ [localName]: readOnlyFields[readOnlyKey]
1199
+ });
1200
+ }
1201
+ return acc;
1202
+ }, {}),
1203
+ [name, subName, wildcardName, readOnlyFields]
1204
+ );
1205
+ return /* @__PURE__ */ jsx7(
1206
+ NestedFieldContext.Provider,
1207
+ {
1208
+ value: { readOnlyFields: subReadOnlyFields, localName: subName },
1209
+ children
1210
+ }
1211
+ );
1212
+ };
1213
+
1168
1214
  // components/AutoField/fields/ArrayField/index.tsx
1169
- import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
1215
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
1170
1216
  var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
1171
1217
  var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
1172
1218
  var ArrayField = ({
@@ -1177,10 +1223,10 @@ var ArrayField = ({
1177
1223
  label,
1178
1224
  readOnly,
1179
1225
  id,
1180
- Label: Label2 = (props) => /* @__PURE__ */ jsx7("div", __spreadValues({}, props))
1226
+ Label: Label2 = (props) => /* @__PURE__ */ jsx8("div", __spreadValues({}, props))
1181
1227
  }) => {
1182
1228
  const { state, setUi, selectedItem, getPermissions } = useAppContext();
1183
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
1229
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
1184
1230
  const value = _value;
1185
1231
  const arrayState = state.ui.arrayState[id] || {
1186
1232
  items: Array.from(value || []).map((item, idx) => {
@@ -1240,14 +1286,14 @@ var ArrayField = ({
1240
1286
  return null;
1241
1287
  }
1242
1288
  const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
1243
- return /* @__PURE__ */ jsx7(
1289
+ return /* @__PURE__ */ jsx8(
1244
1290
  Label2,
1245
1291
  {
1246
1292
  label: label || name,
1247
- icon: /* @__PURE__ */ jsx7(List, { size: 16 }),
1293
+ icon: /* @__PURE__ */ jsx8(List, { size: 16 }),
1248
1294
  el: "div",
1249
1295
  readOnly,
1250
- children: /* @__PURE__ */ jsx7(
1296
+ children: /* @__PURE__ */ jsx8(
1251
1297
  SortableProvider,
1252
1298
  {
1253
1299
  onMove: (move) => {
@@ -1283,7 +1329,7 @@ var ArrayField = ({
1283
1329
  localState.arrayState.items.map((item, i) => {
1284
1330
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
1285
1331
  const data = Array.from(localState.value || [])[i] || {};
1286
- return /* @__PURE__ */ jsx7(
1332
+ return /* @__PURE__ */ jsx8(
1287
1333
  Sortable,
1288
1334
  {
1289
1335
  id: _arrayId,
@@ -1324,7 +1370,7 @@ var ArrayField = ({
1324
1370
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
1325
1371
  /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
1326
1372
  !readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
1327
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
1373
+ /* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
1328
1374
  IconButton,
1329
1375
  {
1330
1376
  type: "button",
@@ -1341,10 +1387,10 @@ var ArrayField = ({
1341
1387
  );
1342
1388
  },
1343
1389
  title: "Duplicate",
1344
- children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
1390
+ children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
1345
1391
  }
1346
1392
  ) }),
1347
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
1393
+ /* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
1348
1394
  IconButton,
1349
1395
  {
1350
1396
  type: "button",
@@ -1365,39 +1411,56 @@ var ArrayField = ({
1365
1411
  );
1366
1412
  },
1367
1413
  title: "Delete",
1368
- children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
1414
+ children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
1369
1415
  }
1370
1416
  ) })
1371
1417
  ] }),
1372
- /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(DragIcon, {}) })
1418
+ /* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(DragIcon, {}) })
1373
1419
  ] })
1374
1420
  ]
1375
1421
  }
1376
1422
  ),
1377
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((fieldName) => {
1378
- const subField = field.arrayFields[fieldName];
1379
- const subFieldName = `${name}[${i}].${fieldName}`;
1380
- const wildcardFieldName = `${name}[*].${fieldName}`;
1381
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
1382
- return /* @__PURE__ */ jsx7(
1383
- 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,
1384
1435
  {
1385
- name: subFieldName,
1386
- label: subField.label || fieldName,
1387
- id: `${_arrayId}_${fieldName}`,
1388
- readOnly: subReadOnly,
1389
- field: subField,
1390
- value: data[fieldName],
1391
- onChange: (val, ui) => {
1392
- onChange(
1393
- replace(value, i, __spreadProps(__spreadValues({}, data), {
1394
- [fieldName]: val
1395
- })),
1396
- ui
1397
- );
1398
- }
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
+ )
1399
1462
  },
1400
- subFieldName
1463
+ subPath
1401
1464
  );
1402
1465
  }) }) })
1403
1466
  ]
@@ -1407,7 +1470,7 @@ var ArrayField = ({
1407
1470
  _arrayId
1408
1471
  );
1409
1472
  }),
1410
- !addDisabled && /* @__PURE__ */ jsx7(
1473
+ !addDisabled && /* @__PURE__ */ jsx8(
1411
1474
  "button",
1412
1475
  {
1413
1476
  type: "button",
@@ -1421,7 +1484,7 @@ var ArrayField = ({
1421
1484
  const newArrayState = regenerateArrayState(newValue);
1422
1485
  onChange(newValue, mapArrayStateToUi(newArrayState));
1423
1486
  },
1424
- children: /* @__PURE__ */ jsx7(Plus, { size: 21 })
1487
+ children: /* @__PURE__ */ jsx8(Plus, { size: 21 })
1425
1488
  }
1426
1489
  )
1427
1490
  ]
@@ -1435,7 +1498,7 @@ var ArrayField = ({
1435
1498
 
1436
1499
  // components/AutoField/fields/DefaultField/index.tsx
1437
1500
  init_react_import();
1438
- 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";
1439
1502
  var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
1440
1503
  var DefaultField = ({
1441
1504
  field,
@@ -1447,16 +1510,16 @@ var DefaultField = ({
1447
1510
  Label: Label2,
1448
1511
  id
1449
1512
  }) => {
1450
- return /* @__PURE__ */ jsx8(
1513
+ return /* @__PURE__ */ jsx9(
1451
1514
  Label2,
1452
1515
  {
1453
1516
  label: label || name,
1454
1517
  icon: /* @__PURE__ */ jsxs4(Fragment2, { children: [
1455
- field.type === "text" && /* @__PURE__ */ jsx8(Type, { size: 16 }),
1456
- 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 })
1457
1520
  ] }),
1458
1521
  readOnly,
1459
- children: /* @__PURE__ */ jsx8(
1522
+ children: /* @__PURE__ */ jsx9(
1460
1523
  "input",
1461
1524
  {
1462
1525
  className: getClassName6("input"),
@@ -1467,7 +1530,14 @@ var DefaultField = ({
1467
1530
  value: typeof value === "undefined" ? "" : value.toString(),
1468
1531
  onChange: (e) => {
1469
1532
  if (field.type === "number") {
1470
- 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);
1471
1541
  } else {
1472
1542
  onChange(e.currentTarget.value);
1473
1543
  }
@@ -1490,7 +1560,7 @@ import { useEffect as useEffect8 } from "react";
1490
1560
  // components/ExternalInput/index.tsx
1491
1561
  init_react_import();
1492
1562
  import {
1493
- useMemo,
1563
+ useMemo as useMemo2,
1494
1564
  useEffect as useEffect7,
1495
1565
  useState as useState9,
1496
1566
  useCallback as useCallback4,
@@ -1511,7 +1581,7 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
1511
1581
 
1512
1582
  // components/Modal/index.tsx
1513
1583
  import { createPortal } from "react-dom";
1514
- import { jsx as jsx9 } from "react/jsx-runtime";
1584
+ import { jsx as jsx10 } from "react/jsx-runtime";
1515
1585
  var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
1516
1586
  var Modal = ({
1517
1587
  children,
@@ -1523,10 +1593,10 @@ var Modal = ({
1523
1593
  setRootEl(document.getElementById("puck-portal-root"));
1524
1594
  }, []);
1525
1595
  if (!rootEl) {
1526
- return /* @__PURE__ */ jsx9("div", {});
1596
+ return /* @__PURE__ */ jsx10("div", {});
1527
1597
  }
1528
1598
  return createPortal(
1529
- /* @__PURE__ */ jsx9("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx9(
1599
+ /* @__PURE__ */ jsx10("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx10(
1530
1600
  "div",
1531
1601
  {
1532
1602
  className: getClassName7("inner"),
@@ -1546,11 +1616,11 @@ init_react_import();
1546
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" };
1547
1617
 
1548
1618
  // components/Heading/index.tsx
1549
- import { jsx as jsx10 } from "react/jsx-runtime";
1619
+ import { jsx as jsx11 } from "react/jsx-runtime";
1550
1620
  var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
1551
1621
  var Heading = ({ children, rank, size = "m" }) => {
1552
1622
  const Tag = rank ? `h${rank}` : "span";
1553
- return /* @__PURE__ */ jsx10(
1623
+ return /* @__PURE__ */ jsx11(
1554
1624
  Tag,
1555
1625
  {
1556
1626
  className: getClassName8({
@@ -1586,7 +1656,7 @@ var filterDataAttrs = (props) => {
1586
1656
  };
1587
1657
 
1588
1658
  // components/Button/Button.tsx
1589
- import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
1659
+ import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
1590
1660
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
1591
1661
  var Button = (_a) => {
1592
1662
  var _b = _a, {
@@ -1645,9 +1715,9 @@ var Button = (_a) => {
1645
1715
  href
1646
1716
  }, dataAttrs), {
1647
1717
  children: [
1648
- icon && /* @__PURE__ */ jsx11("div", { className: getClassName9("icon"), children: icon }),
1718
+ icon && /* @__PURE__ */ jsx12("div", { className: getClassName9("icon"), children: icon }),
1649
1719
  children,
1650
- 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 }) })
1651
1721
  ]
1652
1722
  })
1653
1723
  );
@@ -1655,7 +1725,7 @@ var Button = (_a) => {
1655
1725
  };
1656
1726
 
1657
1727
  // components/ExternalInput/index.tsx
1658
- 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";
1659
1729
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
1660
1730
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
1661
1731
  var dataCache = {};
@@ -1678,10 +1748,10 @@ var ExternalInput = ({
1678
1748
  const hasFilterFields = !!filterFields;
1679
1749
  const [filters, setFilters] = useState9(field.initialFilters || {});
1680
1750
  const [filtersToggled, setFiltersToggled] = useState9(hasFilterFields);
1681
- const mappedData = useMemo(() => {
1751
+ const mappedData = useMemo2(() => {
1682
1752
  return data.map(mapRow);
1683
1753
  }, [data]);
1684
- const keys = useMemo(() => {
1754
+ const keys = useMemo2(() => {
1685
1755
  const validKeys = /* @__PURE__ */ new Set();
1686
1756
  for (const item of mappedData) {
1687
1757
  for (const key of Object.keys(item)) {
@@ -1728,7 +1798,7 @@ var ExternalInput = ({
1728
1798
  id,
1729
1799
  children: [
1730
1800
  /* @__PURE__ */ jsxs6("div", { className: getClassName10("actions"), children: [
1731
- /* @__PURE__ */ jsx12(
1801
+ /* @__PURE__ */ jsx13(
1732
1802
  "button",
1733
1803
  {
1734
1804
  type: "button",
@@ -1736,12 +1806,12 @@ var ExternalInput = ({
1736
1806
  className: getClassName10("button"),
1737
1807
  disabled: readOnly,
1738
1808
  children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs6(Fragment3, { children: [
1739
- /* @__PURE__ */ jsx12(Link, { size: "16" }),
1740
- /* @__PURE__ */ jsx12("span", { children: field.placeholder })
1809
+ /* @__PURE__ */ jsx13(Link, { size: "16" }),
1810
+ /* @__PURE__ */ jsx13("span", { children: field.placeholder })
1741
1811
  ] })
1742
1812
  }
1743
1813
  ),
1744
- value && /* @__PURE__ */ jsx12(
1814
+ value && /* @__PURE__ */ jsx13(
1745
1815
  "button",
1746
1816
  {
1747
1817
  type: "button",
@@ -1750,11 +1820,11 @@ var ExternalInput = ({
1750
1820
  onChange(null);
1751
1821
  },
1752
1822
  disabled: readOnly,
1753
- children: /* @__PURE__ */ jsx12(LockOpen, { size: 16 })
1823
+ children: /* @__PURE__ */ jsx13(LockOpen, { size: 16 })
1754
1824
  }
1755
1825
  )
1756
1826
  ] }),
1757
- /* @__PURE__ */ jsx12(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
1827
+ /* @__PURE__ */ jsx13(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
1758
1828
  "form",
1759
1829
  {
1760
1830
  className: getClassNameModal({
@@ -1768,11 +1838,11 @@ var ExternalInput = ({
1768
1838
  search(searchQuery, filters);
1769
1839
  },
1770
1840
  children: [
1771
- /* @__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: [
1772
1842
  /* @__PURE__ */ jsxs6("label", { className: getClassNameModal("search"), children: [
1773
- /* @__PURE__ */ jsx12("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
1774
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx12(Search, { size: "18" }) }),
1775
- /* @__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(
1776
1846
  "input",
1777
1847
  {
1778
1848
  className: getClassNameModal("searchInput"),
@@ -1788,8 +1858,8 @@ var ExternalInput = ({
1788
1858
  )
1789
1859
  ] }),
1790
1860
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchActions"), children: [
1791
- /* @__PURE__ */ jsx12(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
1792
- 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(
1793
1863
  IconButton,
1794
1864
  {
1795
1865
  title: "Toggle filters",
@@ -1798,15 +1868,15 @@ var ExternalInput = ({
1798
1868
  e.stopPropagation();
1799
1869
  setFiltersToggled(!filtersToggled);
1800
1870
  },
1801
- children: /* @__PURE__ */ jsx12(SlidersHorizontal, { size: 20 })
1871
+ children: /* @__PURE__ */ jsx13(SlidersHorizontal, { size: 20 })
1802
1872
  }
1803
1873
  ) })
1804
1874
  ] })
1805
- ] }) : /* @__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" }) }),
1806
1876
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("grid"), children: [
1807
- 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) => {
1808
1878
  const filterField = filterFields[fieldName];
1809
- return /* @__PURE__ */ jsx12(
1879
+ return /* @__PURE__ */ jsx13(
1810
1880
  AutoFieldPrivate,
1811
1881
  {
1812
1882
  field: filterField,
@@ -1825,7 +1895,7 @@ var ExternalInput = ({
1825
1895
  }) }),
1826
1896
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("tableWrapper"), children: [
1827
1897
  /* @__PURE__ */ jsxs6("table", { className: getClassNameModal("table"), children: [
1828
- /* @__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(
1829
1899
  "th",
1830
1900
  {
1831
1901
  className: getClassNameModal("th"),
@@ -1834,8 +1904,8 @@ var ExternalInput = ({
1834
1904
  },
1835
1905
  key
1836
1906
  )) }) }),
1837
- /* @__PURE__ */ jsx12("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
1838
- return /* @__PURE__ */ jsx12(
1907
+ /* @__PURE__ */ jsx13("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
1908
+ return /* @__PURE__ */ jsx13(
1839
1909
  "tr",
1840
1910
  {
1841
1911
  style: { whiteSpace: "nowrap" },
@@ -1844,16 +1914,16 @@ var ExternalInput = ({
1844
1914
  onChange(mapProp(data[i]));
1845
1915
  setOpen(false);
1846
1916
  },
1847
- 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))
1848
1918
  },
1849
1919
  i
1850
1920
  );
1851
1921
  }) })
1852
1922
  ] }),
1853
- /* @__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 }) })
1854
1924
  ] })
1855
1925
  ] }),
1856
- /* @__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 }) })
1857
1927
  ]
1858
1928
  }
1859
1929
  ) })
@@ -1863,7 +1933,7 @@ var ExternalInput = ({
1863
1933
  };
1864
1934
 
1865
1935
  // components/AutoField/fields/ExternalField/index.tsx
1866
- import { jsx as jsx13 } from "react/jsx-runtime";
1936
+ import { jsx as jsx14 } from "react/jsx-runtime";
1867
1937
  var ExternalField = ({
1868
1938
  field,
1869
1939
  onChange,
@@ -1887,7 +1957,7 @@ var ExternalField = ({
1887
1957
  if (field.type !== "external") {
1888
1958
  return null;
1889
1959
  }
1890
- 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(
1891
1961
  ExternalInput,
1892
1962
  {
1893
1963
  name,
@@ -1912,7 +1982,7 @@ var ExternalField = ({
1912
1982
 
1913
1983
  // components/AutoField/fields/RadioField/index.tsx
1914
1984
  init_react_import();
1915
- import { useMemo as useMemo2 } from "react";
1985
+ import { useMemo as useMemo3 } from "react";
1916
1986
 
1917
1987
  // lib/safe-json-parse.ts
1918
1988
  init_react_import();
@@ -1926,7 +1996,7 @@ var safeJsonParse = (str) => {
1926
1996
  };
1927
1997
 
1928
1998
  // components/AutoField/fields/RadioField/index.tsx
1929
- import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1999
+ import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
1930
2000
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
1931
2001
  var RadioField = ({
1932
2002
  field,
@@ -1938,26 +2008,26 @@ var RadioField = ({
1938
2008
  label,
1939
2009
  Label: Label2
1940
2010
  }) => {
1941
- const flatOptions = useMemo2(
2011
+ const flatOptions = useMemo3(
1942
2012
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
1943
2013
  [field]
1944
2014
  );
1945
2015
  if (field.type !== "radio" || !field.options) {
1946
2016
  return null;
1947
2017
  }
1948
- return /* @__PURE__ */ jsx14(
2018
+ return /* @__PURE__ */ jsx15(
1949
2019
  Label2,
1950
2020
  {
1951
- icon: /* @__PURE__ */ jsx14(CircleCheckBig, { size: 16 }),
2021
+ icon: /* @__PURE__ */ jsx15(CircleCheckBig, { size: 16 }),
1952
2022
  label: label || name,
1953
2023
  readOnly,
1954
2024
  el: "div",
1955
- 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(
1956
2026
  "label",
1957
2027
  {
1958
2028
  className: getClassName11("radio"),
1959
2029
  children: [
1960
- /* @__PURE__ */ jsx14(
2030
+ /* @__PURE__ */ jsx15(
1961
2031
  "input",
1962
2032
  {
1963
2033
  type: "radio",
@@ -1977,7 +2047,7 @@ var RadioField = ({
1977
2047
  checked: value === option.value
1978
2048
  }
1979
2049
  ),
1980
- /* @__PURE__ */ jsx14("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2050
+ /* @__PURE__ */ jsx15("div", { className: getClassName11("radioInner"), children: option.label || option.value })
1981
2051
  ]
1982
2052
  },
1983
2053
  option.label + option.value
@@ -1988,8 +2058,8 @@ var RadioField = ({
1988
2058
 
1989
2059
  // components/AutoField/fields/SelectField/index.tsx
1990
2060
  init_react_import();
1991
- import { useMemo as useMemo3 } from "react";
1992
- import { jsx as jsx15 } from "react/jsx-runtime";
2061
+ import { useMemo as useMemo4 } from "react";
2062
+ import { jsx as jsx16 } from "react/jsx-runtime";
1993
2063
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
1994
2064
  var SelectField = ({
1995
2065
  field,
@@ -2001,20 +2071,20 @@ var SelectField = ({
2001
2071
  readOnly,
2002
2072
  id
2003
2073
  }) => {
2004
- const flatOptions = useMemo3(
2074
+ const flatOptions = useMemo4(
2005
2075
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
2006
2076
  [field]
2007
2077
  );
2008
2078
  if (field.type !== "select" || !field.options) {
2009
2079
  return null;
2010
2080
  }
2011
- return /* @__PURE__ */ jsx15(
2081
+ return /* @__PURE__ */ jsx16(
2012
2082
  Label2,
2013
2083
  {
2014
2084
  label: label || name,
2015
- icon: /* @__PURE__ */ jsx15(ChevronDown, { size: 16 }),
2085
+ icon: /* @__PURE__ */ jsx16(ChevronDown, { size: 16 }),
2016
2086
  readOnly,
2017
- children: /* @__PURE__ */ jsx15(
2087
+ children: /* @__PURE__ */ jsx16(
2018
2088
  "select",
2019
2089
  {
2020
2090
  id,
@@ -2031,7 +2101,7 @@ var SelectField = ({
2031
2101
  }
2032
2102
  },
2033
2103
  value,
2034
- children: field.options.map((option) => /* @__PURE__ */ jsx15(
2104
+ children: field.options.map((option) => /* @__PURE__ */ jsx16(
2035
2105
  "option",
2036
2106
  {
2037
2107
  label: option.label,
@@ -2047,7 +2117,7 @@ var SelectField = ({
2047
2117
 
2048
2118
  // components/AutoField/fields/TextareaField/index.tsx
2049
2119
  init_react_import();
2050
- import { jsx as jsx16 } from "react/jsx-runtime";
2120
+ import { jsx as jsx17 } from "react/jsx-runtime";
2051
2121
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
2052
2122
  var TextareaField = ({
2053
2123
  onChange,
@@ -2058,7 +2128,7 @@ var TextareaField = ({
2058
2128
  Label: Label2,
2059
2129
  id
2060
2130
  }) => {
2061
- 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(
2062
2132
  "textarea",
2063
2133
  {
2064
2134
  id,
@@ -2085,7 +2155,7 @@ init_react_import();
2085
2155
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
2086
2156
 
2087
2157
  // components/AutoField/fields/ObjectField/index.tsx
2088
- import { jsx as jsx17 } from "react/jsx-runtime";
2158
+ import { jsx as jsx18 } from "react/jsx-runtime";
2089
2159
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
2090
2160
  var ObjectField = ({
2091
2161
  field,
@@ -2097,43 +2167,54 @@ var ObjectField = ({
2097
2167
  readOnly,
2098
2168
  id
2099
2169
  }) => {
2100
- const { selectedItem } = useAppContext();
2170
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
2101
2171
  if (field.type !== "object" || !field.objectFields) {
2102
2172
  return null;
2103
2173
  }
2104
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
2105
2174
  const data = value || {};
2106
- return /* @__PURE__ */ jsx17(
2175
+ return /* @__PURE__ */ jsx18(
2107
2176
  Label2,
2108
2177
  {
2109
2178
  label: label || name,
2110
- icon: /* @__PURE__ */ jsx17(EllipsisVertical, { size: 16 }),
2179
+ icon: /* @__PURE__ */ jsx18(EllipsisVertical, { size: 16 }),
2111
2180
  el: "div",
2112
2181
  readOnly,
2113
- children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((fieldName) => {
2114
- const subField = field.objectFields[fieldName];
2115
- const subFieldName = `${name}.${fieldName}`;
2116
- const wildcardFieldName = `${name}.${fieldName}`;
2117
- const subReadOnly = readOnly ? readOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
2118
- return /* @__PURE__ */ jsx17(
2119
- 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,
2120
2190
  {
2121
- name: subFieldName,
2122
- label: subField.label || fieldName,
2123
- id: `${id}_${fieldName}`,
2124
- readOnly: subReadOnly,
2125
- field: subField,
2126
- value: data[fieldName],
2127
- onChange: (val, ui) => {
2128
- onChange(
2129
- __spreadProps(__spreadValues({}, data), {
2130
- [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
2131
2204
  }),
2132
- ui
2133
- );
2134
- }
2205
+ value: data[subName],
2206
+ onChange: (val, ui) => {
2207
+ onChange(
2208
+ __spreadProps(__spreadValues({}, data), {
2209
+ [subName]: val
2210
+ }),
2211
+ ui
2212
+ );
2213
+ }
2214
+ }
2215
+ )
2135
2216
  },
2136
- subFieldName
2217
+ subPath
2137
2218
  );
2138
2219
  }) }) })
2139
2220
  }
@@ -2159,7 +2240,7 @@ var useSafeId = () => {
2159
2240
  };
2160
2241
 
2161
2242
  // components/AutoField/index.tsx
2162
- 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";
2163
2244
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2164
2245
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2165
2246
  var FieldLabel = ({
@@ -2173,14 +2254,14 @@ var FieldLabel = ({
2173
2254
  const El = el;
2174
2255
  return /* @__PURE__ */ jsxs8(El, { className, children: [
2175
2256
  /* @__PURE__ */ jsxs8("div", { className: getClassName15("label"), children: [
2176
- 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, {}),
2177
2258
  label,
2178
- 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" }) })
2179
2260
  ] }),
2180
2261
  children
2181
2262
  ] });
2182
2263
  };
2183
- var FieldLabelInternal2 = ({
2264
+ var FieldLabelInternal = ({
2184
2265
  children,
2185
2266
  icon,
2186
2267
  label,
@@ -2188,14 +2269,14 @@ var FieldLabelInternal2 = ({
2188
2269
  readOnly
2189
2270
  }) => {
2190
2271
  const { overrides } = useAppContext();
2191
- const Wrapper = useMemo4(
2272
+ const Wrapper = useMemo5(
2192
2273
  () => overrides.fieldLabel || FieldLabel,
2193
2274
  [overrides]
2194
2275
  );
2195
2276
  if (!label) {
2196
- return /* @__PURE__ */ jsx18(Fragment4, { children });
2277
+ return /* @__PURE__ */ jsx19(Fragment4, { children });
2197
2278
  }
2198
- return /* @__PURE__ */ jsx18(
2279
+ return /* @__PURE__ */ jsx19(
2199
2280
  Wrapper,
2200
2281
  {
2201
2282
  label,
@@ -2209,8 +2290,9 @@ var FieldLabelInternal2 = ({
2209
2290
  };
2210
2291
  function AutoFieldInternal(props) {
2211
2292
  var _a, _b, _c, _d, _e, _f, _g, _h;
2212
- const { dispatch, overrides } = useAppContext();
2213
- const { id, Label: Label2 = FieldLabelInternal2 } = props;
2293
+ const { dispatch, overrides, selectedItem } = useAppContext();
2294
+ const nestedFieldContext = useContext3(NestedFieldContext);
2295
+ const { id, Label: Label2 = FieldLabelInternal } = props;
2214
2296
  const field = props.field;
2215
2297
  const label = field.label;
2216
2298
  const defaultId = useSafeId();
@@ -2270,20 +2352,29 @@ function AutoFieldInternal(props) {
2270
2352
  return null;
2271
2353
  }
2272
2354
  const CustomField = field.render;
2273
- 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)) }) });
2274
2356
  }
2275
2357
  const children = defaultFields[field.type](mergedProps);
2276
2358
  const Render2 = render[field.type];
2277
- return /* @__PURE__ */ jsx18(
2278
- "div",
2359
+ return /* @__PURE__ */ jsx19(
2360
+ NestedFieldContext.Provider,
2279
2361
  {
2280
- className: getClassNameWrapper(),
2281
- onFocus,
2282
- onBlur,
2283
- onClick: (e) => {
2284
- e.stopPropagation();
2362
+ value: {
2363
+ readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
2364
+ localName: nestedFieldContext.localName
2285
2365
  },
2286
- 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
+ )
2287
2378
  }
2288
2379
  );
2289
2380
  }
@@ -2311,11 +2402,11 @@ function AutoFieldPrivate(props) {
2311
2402
  value: localValue,
2312
2403
  onChange: onChangeLocal
2313
2404
  };
2314
- return /* @__PURE__ */ jsx18(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2405
+ return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2315
2406
  }
2316
2407
  function AutoField(props) {
2317
- const DefaultLabel = useMemo4(() => {
2318
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx18(
2408
+ const DefaultLabel = useMemo5(() => {
2409
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx19(
2319
2410
  "div",
2320
2411
  __spreadProps(__spreadValues({}, labelProps), {
2321
2412
  className: getClassName15({ readOnly: props.readOnly })
@@ -2323,7 +2414,7 @@ function AutoField(props) {
2323
2414
  );
2324
2415
  return DefaultLabel2;
2325
2416
  }, [props.readOnly]);
2326
- return /* @__PURE__ */ jsx18(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2417
+ return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2327
2418
  }
2328
2419
 
2329
2420
  // components/Drawer/index.tsx
@@ -2334,18 +2425,19 @@ init_react_import();
2334
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" };
2335
2426
 
2336
2427
  // components/Drawer/index.tsx
2337
- import { useMemo as useMemo8, useState as useState17 } from "react";
2428
+ import { useMemo as useMemo9, useState as useState18 } from "react";
2338
2429
 
2339
2430
  // components/DragDropContext/index.tsx
2340
2431
  init_react_import();
2341
2432
  import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
2342
2433
  import {
2343
- createContext as createContext3,
2344
- useCallback as useCallback9,
2345
- useContext as useContext4,
2346
- useEffect as useEffect13,
2347
- useRef as useRef5,
2348
- useState as useState16
2434
+ createContext as createContext4,
2435
+ useCallback as useCallback11,
2436
+ useContext as useContext7,
2437
+ useEffect as useEffect15,
2438
+ useId,
2439
+ useRef as useRef4,
2440
+ useState as useState17
2349
2441
  } from "react";
2350
2442
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
2351
2443
 
@@ -2353,23 +2445,22 @@ import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
2353
2445
  init_react_import();
2354
2446
  import {
2355
2447
  forwardRef as forwardRef3,
2356
- useCallback as useCallback8,
2357
- useContext as useContext3,
2358
- useEffect as useEffect12,
2359
- useMemo as useMemo7,
2360
- useRef as useRef4,
2361
- useState as useState15
2448
+ useCallback as useCallback10,
2449
+ useContext as useContext6,
2450
+ useEffect as useEffect14,
2451
+ useMemo as useMemo8,
2452
+ useRef as useRef3
2362
2453
  } from "react";
2363
2454
 
2364
2455
  // components/DraggableComponent/index.tsx
2365
2456
  init_react_import();
2366
2457
  import {
2367
- useCallback as useCallback6,
2368
- useContext as useContext2,
2458
+ useCallback as useCallback7,
2459
+ useContext as useContext5,
2369
2460
  useEffect as useEffect10,
2370
- useMemo as useMemo5,
2371
- useRef as useRef3,
2372
- useState as useState12
2461
+ useMemo as useMemo7,
2462
+ useRef as useRef2,
2463
+ useState as useState13
2373
2464
  } from "react";
2374
2465
 
2375
2466
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
@@ -2379,18 +2470,18 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
2379
2470
  // components/DraggableComponent/index.tsx
2380
2471
  import { createPortal as createPortal2 } from "react-dom";
2381
2472
 
2382
- // components/DraggableComponent/collision/dynamic/index.ts
2473
+ // lib/dnd/collision/dynamic/index.ts
2383
2474
  init_react_import();
2384
2475
  import {
2385
2476
  CollisionPriority as CollisionPriority7,
2386
2477
  CollisionType as CollisionType7
2387
2478
  } from "@dnd-kit/abstract";
2388
2479
 
2389
- // components/DraggableComponent/collision/directional/index.ts
2480
+ // lib/dnd/collision/directional/index.ts
2390
2481
  init_react_import();
2391
2482
  import { CollisionType } from "@dnd-kit/abstract";
2392
2483
 
2393
- // components/DraggableComponent/collision/collision-debug.ts
2484
+ // lib/dnd/collision/collision-debug.ts
2394
2485
  init_react_import();
2395
2486
  var DEBUG = false;
2396
2487
  var debugElements = {};
@@ -2439,7 +2530,7 @@ var collisionDebug = (a, b, id, color, label) => {
2439
2530
  });
2440
2531
  };
2441
2532
 
2442
- // components/DraggableComponent/collision/directional/index.ts
2533
+ // lib/dnd/collision/directional/index.ts
2443
2534
  var distanceChange = "increasing";
2444
2535
  var directionalCollision = (input, previous) => {
2445
2536
  var _a;
@@ -2472,7 +2563,7 @@ var directionalCollision = (input, previous) => {
2472
2563
  return null;
2473
2564
  };
2474
2565
 
2475
- // components/DraggableComponent/collision/dynamic/get-direction.ts
2566
+ // lib/dnd/collision/dynamic/get-direction.ts
2476
2567
  init_react_import();
2477
2568
  var getDirection = (dragAxis, delta) => {
2478
2569
  if (dragAxis === "dynamic") {
@@ -2487,7 +2578,7 @@ var getDirection = (dragAxis, delta) => {
2487
2578
  return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2488
2579
  };
2489
2580
 
2490
- // components/DraggableComponent/collision/dynamic/get-midpoint-impact.ts
2581
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
2491
2582
  init_react_import();
2492
2583
  var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
2493
2584
  const dragRect = dragShape.boundingRectangle;
@@ -2506,7 +2597,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2506
2597
  return dragRect.right - offset >= dropCenter.x;
2507
2598
  };
2508
2599
 
2509
- // components/DraggableComponent/collision/dynamic/track-movement-interval.ts
2600
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
2510
2601
  init_react_import();
2511
2602
  import { Point } from "@dnd-kit/geometry";
2512
2603
  var INTERVAL_SENSITIVITY = 10;
@@ -2610,7 +2701,14 @@ var closestCorners = (input) => {
2610
2701
  };
2611
2702
  };
2612
2703
 
2613
- // 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
2614
2712
  var flushNext = "";
2615
2713
  var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2616
2714
  var _a, _b, _c, _d, _e;
@@ -2622,6 +2720,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2622
2720
  return null;
2623
2721
  }
2624
2722
  const { center: dragCenter } = dragShape;
2723
+ const { fallbackEnabled } = collisionStore.getState();
2625
2724
  const interval = trackMovementInterval(position.current, dragAxis);
2626
2725
  dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2627
2726
  direction: interval.direction
@@ -2667,7 +2766,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2667
2766
  flushNext = "";
2668
2767
  return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2669
2768
  }
2670
- if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2769
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2671
2770
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2672
2771
  const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2673
2772
  if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
@@ -2728,8 +2827,107 @@ function getDeepScrollPosition(element) {
2728
2827
  return totalScroll;
2729
2828
  }
2730
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
+
2731
2929
  // components/DraggableComponent/index.tsx
2732
- import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
2930
+ import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
2733
2931
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
2734
2932
  var DEBUG2 = false;
2735
2933
  var space = 8;
@@ -2743,9 +2941,9 @@ var DefaultActionBar = ({
2743
2941
  }) => /* @__PURE__ */ jsxs9(ActionBar, { children: [
2744
2942
  /* @__PURE__ */ jsxs9(ActionBar.Group, { children: [
2745
2943
  parentAction,
2746
- label && /* @__PURE__ */ jsx19(ActionBar.Label, { label })
2944
+ label && /* @__PURE__ */ jsx21(ActionBar.Label, { label })
2747
2945
  ] }),
2748
- /* @__PURE__ */ jsx19(ActionBar.Group, { children })
2946
+ /* @__PURE__ */ jsx21(ActionBar.Group, { children })
2749
2947
  ] });
2750
2948
  var convertIdToSelector = (id, zoneCompound, data) => {
2751
2949
  const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
@@ -2780,9 +2978,9 @@ var DraggableComponent = ({
2780
2978
  iframe,
2781
2979
  state
2782
2980
  } = useAppContext();
2783
- const ctx = useContext2(dropZoneContext);
2784
- const [localZones, setLocalZones] = useState12({});
2785
- const registerLocalZone = useCallback6(
2981
+ const ctx = useContext5(dropZoneContext);
2982
+ const [localZones, setLocalZones] = useState13({});
2983
+ const registerLocalZone = useCallback7(
2786
2984
  (zoneCompound2, active) => {
2787
2985
  var _a;
2788
2986
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -2792,7 +2990,7 @@ var DraggableComponent = ({
2792
2990
  },
2793
2991
  [setLocalZones]
2794
2992
  );
2795
- const unregisterLocalZone = useCallback6(
2993
+ const unregisterLocalZone = useCallback7(
2796
2994
  (zoneCompound2) => {
2797
2995
  var _a;
2798
2996
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -2806,7 +3004,7 @@ var DraggableComponent = ({
2806
3004
  );
2807
3005
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
2808
3006
  const { path = [] } = ctx || {};
2809
- const [canDrag, setCanDrag] = useState12(false);
3007
+ const [canDrag, setCanDrag] = useState13(false);
2810
3008
  useEffect10(() => {
2811
3009
  var _a;
2812
3010
  const item = getItem({ index, zone: zoneCompound }, state.data);
@@ -2817,10 +3015,13 @@ var DraggableComponent = ({
2817
3015
  setCanDrag((_a = perms.drag) != null ? _a : true);
2818
3016
  }
2819
3017
  }, [state, index, zoneCompound, getPermissions]);
2820
- const userIsDragging = !!(ctx == null ? void 0 : ctx.draggedItem);
3018
+ const userIsDragging = useContextStore(
3019
+ ZoneStoreContext,
3020
+ (s) => !!s.draggedItem
3021
+ );
2821
3022
  const canCollide = canDrag || userIsDragging;
2822
3023
  const disabled = !isEnabled || !canCollide;
2823
- const [dragAxis, setDragAxis] = useState12(userDragAxis || autoDragAxis);
3024
+ const [dragAxis, setDragAxis] = useState13(userDragAxis || autoDragAxis);
2824
3025
  const { ref: sortableRef, status } = useSortableSafe({
2825
3026
  id,
2826
3027
  index,
@@ -2846,8 +3047,8 @@ var DraggableComponent = ({
2846
3047
  }
2847
3048
  });
2848
3049
  const thisIsDragging = status === "dragging";
2849
- const ref = useRef3(null);
2850
- const refSetter = useCallback6(
3050
+ const ref = useRef2(null);
3051
+ const refSetter = useCallback7(
2851
3052
  (el) => {
2852
3053
  sortableRef(el);
2853
3054
  if (el) {
@@ -2856,14 +3057,14 @@ var DraggableComponent = ({
2856
3057
  },
2857
3058
  [sortableRef]
2858
3059
  );
2859
- const [portalEl, setPortalEl] = useState12();
3060
+ const [portalEl, setPortalEl] = useState13();
2860
3061
  useEffect10(() => {
2861
3062
  var _a, _b, _c;
2862
3063
  setPortalEl(
2863
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
2864
3065
  );
2865
3066
  }, [iframe.enabled, ref.current]);
2866
- const getStyle = useCallback6(() => {
3067
+ const getStyle = useCallback7(() => {
2867
3068
  var _a, _b, _c;
2868
3069
  if (!ref.current) return;
2869
3070
  const rect = ref.current.getBoundingClientRect();
@@ -2883,8 +3084,8 @@ var DraggableComponent = ({
2883
3084
  };
2884
3085
  return style2;
2885
3086
  }, [ref.current]);
2886
- const [style, setStyle] = useState12();
2887
- const sync = useCallback6(() => {
3087
+ const [style, setStyle] = useState13();
3088
+ const sync = useCallback7(() => {
2888
3089
  setStyle(getStyle());
2889
3090
  }, [ref.current, iframe]);
2890
3091
  useEffect10(() => {
@@ -2897,19 +3098,21 @@ var DraggableComponent = ({
2897
3098
  }
2898
3099
  }, [ref.current]);
2899
3100
  useEffect10(() => {
2900
- ctx == null ? void 0 : ctx.registerPath({
2901
- index,
2902
- zone: zoneCompound
2903
- });
3101
+ if (isSelected) {
3102
+ ctx == null ? void 0 : ctx.registerPath({
3103
+ index,
3104
+ zone: zoneCompound
3105
+ });
3106
+ }
2904
3107
  }, [isSelected]);
2905
- const CustomActionBar = useMemo5(
3108
+ const CustomActionBar = useMemo7(
2906
3109
  () => overrides.actionBar || DefaultActionBar,
2907
3110
  [overrides.actionBar]
2908
3111
  );
2909
3112
  const permissions = getPermissions({
2910
3113
  item: selectedItem
2911
3114
  });
2912
- const onClick = useCallback6(
3115
+ const onClick = useCallback7(
2913
3116
  (e) => {
2914
3117
  e.stopPropagation();
2915
3118
  dispatch({
@@ -2921,7 +3124,7 @@ var DraggableComponent = ({
2921
3124
  },
2922
3125
  [index, zoneCompound, id]
2923
3126
  );
2924
- const onSelectParent = useCallback6(() => {
3127
+ const onSelectParent = useCallback7(() => {
2925
3128
  if (!(ctx == null ? void 0 : ctx.areaId)) {
2926
3129
  return;
2927
3130
  }
@@ -2939,21 +3142,21 @@ var DraggableComponent = ({
2939
3142
  }
2940
3143
  });
2941
3144
  }, [ctx, path]);
2942
- const onDuplicate = useCallback6(() => {
3145
+ const onDuplicate = useCallback7(() => {
2943
3146
  dispatch({
2944
3147
  type: "duplicate",
2945
3148
  sourceIndex: index,
2946
3149
  sourceZone: zoneCompound
2947
3150
  });
2948
3151
  }, [index, zoneCompound]);
2949
- const onDelete = useCallback6(() => {
3152
+ const onDelete = useCallback7(() => {
2950
3153
  dispatch({
2951
3154
  type: "remove",
2952
3155
  index,
2953
3156
  zone: zoneCompound
2954
3157
  });
2955
3158
  }, [index, zoneCompound]);
2956
- const [hover, setHover] = useState12(false);
3159
+ const [hover, setHover] = useState13(false);
2957
3160
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
2958
3161
  useEffect10(() => {
2959
3162
  if (!ref.current) {
@@ -3014,7 +3217,7 @@ var DraggableComponent = ({
3014
3217
  };
3015
3218
  }
3016
3219
  }, [disabled, ref]);
3017
- const [isVisible, setIsVisible] = useState12(false);
3220
+ const [isVisible, setIsVisible] = useState13(false);
3018
3221
  useEffect10(() => {
3019
3222
  sync();
3020
3223
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
@@ -3023,7 +3226,7 @@ var DraggableComponent = ({
3023
3226
  setIsVisible(false);
3024
3227
  }
3025
3228
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3026
- const syncActionsPosition = useCallback6(
3229
+ const syncActionsPosition = useCallback7(
3027
3230
  (el) => {
3028
3231
  if (el) {
3029
3232
  const view = el.ownerDocument.defaultView;
@@ -3054,7 +3257,7 @@ var DraggableComponent = ({
3054
3257
  }
3055
3258
  setDragAxis(autoDragAxis);
3056
3259
  }, [ref, userDragAxis, autoDragAxis]);
3057
- 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 }) });
3058
3261
  return /* @__PURE__ */ jsxs9(
3059
3262
  DropZoneProvider,
3060
3263
  {
@@ -3081,15 +3284,15 @@ var DraggableComponent = ({
3081
3284
  "data-puck-overlay": true,
3082
3285
  children: [
3083
3286
  debug,
3084
- isLoading && /* @__PURE__ */ jsx19("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx19(Loader, {}) }),
3085
- /* @__PURE__ */ jsx19(
3287
+ isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
3288
+ /* @__PURE__ */ jsx21(
3086
3289
  "div",
3087
3290
  {
3088
3291
  className: getClassName16("actionsOverlay"),
3089
3292
  style: {
3090
3293
  top: actionsOverlayTop / zoomConfig.zoom
3091
3294
  },
3092
- children: /* @__PURE__ */ jsx19(
3295
+ children: /* @__PURE__ */ jsx21(
3093
3296
  "div",
3094
3297
  {
3095
3298
  className: getClassName16("actions"),
@@ -3107,8 +3310,8 @@ var DraggableComponent = ({
3107
3310
  parentAction,
3108
3311
  label: DEBUG2 ? id : label,
3109
3312
  children: [
3110
- permissions.duplicate && /* @__PURE__ */ jsx19(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx19(Copy, { size: 16 }) }),
3111
- 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 }) })
3112
3315
  ]
3113
3316
  }
3114
3317
  )
@@ -3116,7 +3319,7 @@ var DraggableComponent = ({
3116
3319
  )
3117
3320
  }
3118
3321
  ),
3119
- /* @__PURE__ */ jsx19("div", { className: getClassName16("overlay") })
3322
+ /* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
3120
3323
  ]
3121
3324
  }
3122
3325
  ),
@@ -3132,98 +3335,26 @@ var DraggableComponent = ({
3132
3335
  init_react_import();
3133
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" };
3134
3337
 
3135
- // components/DropZone/context.tsx
3136
- init_react_import();
3137
- import {
3138
- createContext as createContext2,
3139
- useCallback as useCallback7,
3140
- useMemo as useMemo6,
3141
- useState as useState13
3142
- } from "react";
3143
- import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
3144
- var dropZoneContext = createContext2(null);
3145
- var DropZoneProvider = ({
3146
- children,
3147
- value
3148
- }) => {
3149
- const [hoveringComponent, setHoveringComponent] = useState13();
3150
- const [areasWithZones, setAreasWithZones] = useState13(
3151
- {}
3152
- );
3153
- const [activeZones, setActiveZones] = useState13({});
3154
- const { dispatch } = useAppContext();
3155
- const registerZoneArea = useCallback7(
3156
- (area) => {
3157
- setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
3158
- },
3159
- [setAreasWithZones]
3160
- );
3161
- const registerZone = useCallback7(
3162
- (zoneCompound) => {
3163
- if (!dispatch) {
3164
- return;
3165
- }
3166
- dispatch({
3167
- type: "registerZone",
3168
- zone: zoneCompound
3169
- });
3170
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
3171
- },
3172
- [setActiveZones, dispatch]
3173
- );
3174
- const unregisterZone = useCallback7(
3175
- (zoneCompound) => {
3176
- if (!dispatch) {
3177
- return;
3178
- }
3179
- dispatch({
3180
- type: "unregisterZone",
3181
- zone: zoneCompound
3182
- });
3183
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
3184
- [zoneCompound]: false
3185
- }));
3186
- },
3187
- [setActiveZones, dispatch]
3188
- );
3189
- const memoValue = useMemo6(
3190
- () => __spreadValues({
3191
- hoveringComponent,
3192
- setHoveringComponent,
3193
- registerZoneArea,
3194
- areasWithZones,
3195
- registerZone,
3196
- unregisterZone,
3197
- activeZones
3198
- }, value),
3199
- [value, hoveringComponent, areasWithZones, activeZones]
3200
- );
3201
- return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
3202
- };
3203
-
3204
- // lib/insert.ts
3205
- init_react_import();
3206
- var insert = (list, index, item) => {
3207
- const result = Array.from(list);
3208
- result.splice(index, 0, item);
3209
- return result;
3210
- };
3211
-
3212
- // components/DropZone/use-min-empty-height.ts
3338
+ // components/DropZone/lib/use-min-empty-height.ts
3213
3339
  init_react_import();
3214
3340
  import { useEffect as useEffect11, useState as useState14 } from "react";
3215
3341
  var useMinEmptyHeight = ({
3216
- draggedItem,
3217
3342
  zoneCompound,
3218
3343
  userMinEmptyHeight,
3219
3344
  ref
3220
3345
  }) => {
3221
3346
  const [prevHeight, setPrevHeight] = useState14(0);
3222
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
+ });
3223
3355
  useEffect11(() => {
3224
3356
  if (draggedItem && ref.current) {
3225
- const componentData = draggedItem.data;
3226
- if (componentData.zone === zoneCompound) {
3357
+ if (isZone) {
3227
3358
  const rect = ref.current.getBoundingClientRect();
3228
3359
  setPrevHeight(rect.height);
3229
3360
  setIsAnimating(true);
@@ -3253,13 +3384,128 @@ function assignRefs(refs, node) {
3253
3384
  });
3254
3385
  }
3255
3386
 
3256
- // components/DropZone/index.tsx
3257
- import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
3258
- var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3259
- 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";
3260
3471
  var GRID_DRAG_AXIS = "dynamic";
3261
3472
  var FLEX_ROW_DRAG_AXIS = "x";
3262
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;
3263
3509
  var DropZoneEdit = forwardRef3(
3264
3510
  function DropZoneEdit2({
3265
3511
  zone,
@@ -3271,31 +3517,50 @@ var DropZoneEdit = forwardRef3(
3271
3517
  collisionAxis
3272
3518
  }, userRef) {
3273
3519
  const appContext2 = useAppContext();
3274
- const ctx = useContext3(dropZoneContext);
3520
+ const ctx = useContext6(dropZoneContext);
3275
3521
  const {
3276
3522
  // These all need setting via context
3277
3523
  data,
3278
3524
  config,
3279
3525
  areaId,
3280
- draggedItem,
3281
3526
  registerZoneArea,
3282
3527
  depth,
3283
3528
  registerLocalZone,
3284
3529
  unregisterLocalZone,
3285
- deepestZone = rootDroppableId,
3286
- deepestArea,
3287
- nextDeepestArea,
3288
3530
  path = [],
3289
3531
  activeZones
3290
3532
  } = ctx;
3291
- const { itemSelector } = appContext2.state.ui;
3292
3533
  let zoneCompound = rootDroppableId;
3293
- useEffect12(() => {
3534
+ if (areaId) {
3535
+ if (zone !== rootDroppableId) {
3536
+ zoneCompound = `${areaId}:${zone}`;
3537
+ }
3538
+ }
3539
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3540
+ const {
3541
+ isDeepestZone,
3542
+ inNextDeepestArea,
3543
+ draggedComponentType,
3544
+ userIsDragging,
3545
+ preview
3546
+ } = useContextStore(ZoneStoreContext, (s) => {
3547
+ var _a, _b, _c;
3548
+ return {
3549
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3550
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3551
+ draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3552
+ draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3553
+ userIsDragging: !!s.draggedItem,
3554
+ preview: s.previewIndex[zoneCompound]
3555
+ };
3556
+ });
3557
+ const { itemSelector } = appContext2.state.ui;
3558
+ useEffect14(() => {
3294
3559
  if (areaId && registerZoneArea) {
3295
3560
  registerZoneArea(areaId);
3296
3561
  }
3297
3562
  }, [areaId]);
3298
- useEffect12(() => {
3563
+ useEffect14(() => {
3299
3564
  if (ctx == null ? void 0 : ctx.registerZone) {
3300
3565
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3301
3566
  }
@@ -3305,25 +3570,18 @@ var DropZoneEdit = forwardRef3(
3305
3570
  }
3306
3571
  };
3307
3572
  }, []);
3308
- if (areaId) {
3309
- if (zone !== rootDroppableId) {
3310
- zoneCompound = `${areaId}:${zone}`;
3311
- }
3312
- }
3313
- const content = useMemo7(() => {
3573
+ const content = useMemo8(() => {
3314
3574
  if (areaId && zone !== rootDroppableId) {
3315
3575
  return setupZone(data, zoneCompound).zones[zoneCompound];
3316
3576
  }
3317
3577
  return data.content || [];
3318
3578
  }, [data, zoneCompound]);
3319
- const ref = useRef4(null);
3320
- const acceptsTarget = useCallback8(
3321
- (target) => {
3322
- if (!target) {
3579
+ const ref = useRef3(null);
3580
+ const acceptsTarget = useCallback10(
3581
+ (componentType) => {
3582
+ if (!componentType) {
3323
3583
  return true;
3324
3584
  }
3325
- const data2 = target.data;
3326
- const { componentType } = data2;
3327
3585
  if (disallow) {
3328
3586
  const defaultedAllow = allow || [];
3329
3587
  const filteredDisallow = (disallow || []).filter(
@@ -3341,49 +3599,26 @@ var DropZoneEdit = forwardRef3(
3341
3599
  },
3342
3600
  [allow, disallow]
3343
3601
  );
3344
- useEffect12(() => {
3602
+ useEffect14(() => {
3345
3603
  if (registerLocalZone) {
3346
- registerLocalZone(zoneCompound, acceptsTarget(draggedItem));
3604
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3347
3605
  }
3348
3606
  return () => {
3349
3607
  if (unregisterLocalZone) {
3350
3608
  unregisterLocalZone(zoneCompound);
3351
3609
  }
3352
3610
  };
3353
- }, [draggedItem, zoneCompound]);
3354
- const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3355
- const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
3356
- const userIsDragging = !!draggedItem;
3611
+ }, [draggedComponentType, zoneCompound]);
3612
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3357
3613
  let isEnabled = true;
3358
- if (draggedItem) {
3359
- isEnabled = deepestZone === zoneCompound;
3614
+ if (userIsDragging) {
3615
+ isEnabled = isDeepestZone;
3360
3616
  }
3361
3617
  if (isEnabled) {
3362
- isEnabled = acceptsTarget(draggedItem);
3363
- }
3364
- const preview = useContext3(previewContext);
3365
- const previewInZone = (preview == null ? void 0 : preview.zone) === zoneCompound;
3366
- const contentWithPreview = useMemo7(() => {
3367
- let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
3368
- if (previewInZone) {
3369
- contentWithPreview2 = content.filter(
3370
- (item) => item.props.id !== preview.props.id
3371
- );
3372
- if (preview.type === "insert") {
3373
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3374
- type: "preview",
3375
- props: { id: preview.props.id }
3376
- });
3377
- } else {
3378
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3379
- type: preview.componentType,
3380
- props: preview.props
3381
- });
3382
- }
3383
- }
3384
- return contentWithPreview2;
3385
- }, [preview, content]);
3386
- const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3618
+ isEnabled = acceptsTarget(draggedComponentType);
3619
+ }
3620
+ const contentWithPreview = useContentWithPreview(content, zoneCompound);
3621
+ const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3387
3622
  const droppableConfig = {
3388
3623
  id: zoneCompound,
3389
3624
  collisionPriority: isEnabled ? depth : 0,
@@ -3393,45 +3628,20 @@ var DropZoneEdit = forwardRef3(
3393
3628
  data: {
3394
3629
  areaId,
3395
3630
  depth,
3396
- isDroppableTarget: acceptsTarget(draggedItem),
3631
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3397
3632
  path
3398
3633
  }
3399
3634
  };
3400
3635
  const { ref: dropRef } = useDroppableSafe(droppableConfig);
3401
3636
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3402
3637
  const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
3403
- const [dragAxis, setDragAxis] = useState15(
3404
- collisionAxis || DEFAULT_DRAG_AXIS
3405
- );
3406
- const calculateDragAxis = useCallback8(() => {
3407
- if (ref.current) {
3408
- const computedStyle = window.getComputedStyle(ref.current);
3409
- if (computedStyle.display === "grid") {
3410
- setDragAxis(GRID_DRAG_AXIS);
3411
- } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3412
- setDragAxis(FLEX_ROW_DRAG_AXIS);
3413
- } else {
3414
- setDragAxis(DEFAULT_DRAG_AXIS);
3415
- }
3416
- }
3417
- }, [ref.current]);
3418
- useEffect12(calculateDragAxis, [appContext2.status, collisionAxis]);
3419
- useEffect12(() => {
3420
- const onViewportChange = () => {
3421
- calculateDragAxis();
3422
- };
3423
- window.addEventListener("viewportchange", onViewportChange);
3424
- return () => {
3425
- window.removeEventListener("viewportchange", onViewportChange);
3426
- };
3427
- }, []);
3638
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3428
3639
  const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3429
- draggedItem,
3430
3640
  zoneCompound,
3431
3641
  userMinEmptyHeight,
3432
3642
  ref
3433
3643
  });
3434
- return /* @__PURE__ */ jsxs10(
3644
+ return /* @__PURE__ */ jsx22(
3435
3645
  "div",
3436
3646
  {
3437
3647
  className: `${getClassName17({
@@ -3451,88 +3661,83 @@ var DropZoneEdit = forwardRef3(
3451
3661
  "data-puck-dropzone": zoneCompound,
3452
3662
  "data-puck-dnd": zoneCompound,
3453
3663
  style: __spreadProps(__spreadValues({}, style), {
3454
- "--min-empty-height": `${minEmptyHeight}px`
3664
+ "--min-empty-height": `${minEmptyHeight}px`,
3665
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3455
3666
  }),
3456
- children: [
3457
- isRootZone && DEBUG3 && /* @__PURE__ */ jsxs10("div", { "data-puck-component": true, children: [
3458
- /* @__PURE__ */ jsx21("p", { children: deepestZone || rootDroppableId }),
3459
- /* @__PURE__ */ jsx21("p", { children: deepestArea || "No area" })
3460
- ] }),
3461
- contentWithPreview.map((item, i) => {
3462
- var _a, _b, _c, _d, _e;
3463
- const componentId = item.props.id;
3464
- const puckProps = {
3465
- renderDropZone: DropZone,
3466
- isEditing: true,
3467
- dragRef: null
3667
+ children: contentWithPreview.map((item, i) => {
3668
+ var _a, _b, _c, _d, _e;
3669
+ const componentId = item.props.id;
3670
+ const puckProps = {
3671
+ renderDropZone: DropZone,
3672
+ isEditing: true,
3673
+ dragRef: null
3674
+ };
3675
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3676
+ puck: puckProps,
3677
+ editMode: true
3678
+ // DEPRECATED
3679
+ });
3680
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3681
+ let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
3682
+ "No configuration for ",
3683
+ item.type
3684
+ ] });
3685
+ const componentConfig = config.components[item.type];
3686
+ let componentType = item.type;
3687
+ let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3688
+ if (item.type === "preview" && preview) {
3689
+ let Preview4 = function() {
3690
+ return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3468
3691
  };
3469
- const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3470
- puck: puckProps,
3471
- editMode: true
3472
- // DEPRECATED
3473
- });
3474
- const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3475
- let Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
3476
- "No configuration for ",
3477
- item.type
3478
- ] });
3479
- const componentConfig = config.components[item.type];
3480
- let componentType = item.type;
3481
- let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3482
- if (item.type === "preview") {
3483
- let Preview3 = function() {
3484
- return /* @__PURE__ */ jsx21(DrawerItemInner, { name: label });
3485
- };
3486
- var Preview2 = Preview3;
3487
- componentType = preview.componentType;
3488
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3489
- Render2 = Preview3;
3490
- }
3491
- return /* @__PURE__ */ jsx21(
3492
- DropZoneProvider,
3493
- {
3494
- value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3495
- children: /* @__PURE__ */ jsx21(
3496
- DraggableComponent,
3497
- {
3498
- id: componentId,
3499
- componentType,
3500
- zoneCompound,
3501
- depth: depth + 1,
3502
- index: i,
3503
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3504
- isSelected,
3505
- label,
3506
- isEnabled,
3507
- autoDragAxis: dragAxis,
3508
- userDragAxis: collisionAxis,
3509
- inDroppableZone: acceptsTarget(draggedItem),
3510
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx21(
3511
- Render2,
3512
- __spreadProps(__spreadValues({}, defaultedProps), {
3513
- puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3514
- dragRef
3515
- })
3692
+ var Preview3 = Preview4;
3693
+ componentType = preview.componentType;
3694
+ label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3695
+ Render2 = Preview4;
3696
+ }
3697
+ return /* @__PURE__ */ jsx22(
3698
+ DropZoneProvider,
3699
+ {
3700
+ value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3701
+ children: /* @__PURE__ */ jsx22(
3702
+ DraggableComponent,
3703
+ {
3704
+ id: componentId,
3705
+ componentType,
3706
+ zoneCompound,
3707
+ depth: depth + 1,
3708
+ index: i,
3709
+ isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3710
+ isSelected,
3711
+ label,
3712
+ isEnabled,
3713
+ autoDragAxis: dragAxis,
3714
+ userDragAxis: collisionAxis,
3715
+ inDroppableZone: acceptsTarget(draggedComponentType),
3716
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx22(
3717
+ Render2,
3718
+ __spreadProps(__spreadValues({}, defaultedProps), {
3719
+ puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3720
+ dragRef
3516
3721
  })
3517
- ) : /* @__PURE__ */ jsx21("div", { ref: dragRef, children: /* @__PURE__ */ jsx21(Render2, __spreadValues({}, defaultedProps)) })
3518
- }
3519
- )
3520
- },
3521
- componentId
3522
- );
3523
- })
3524
- ]
3722
+ })
3723
+ ) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
3724
+ }
3725
+ )
3726
+ },
3727
+ componentId
3728
+ );
3729
+ })
3525
3730
  }
3526
3731
  );
3527
3732
  }
3528
3733
  );
3529
3734
  var DropZoneRender = forwardRef3(
3530
3735
  function DropZoneRender2({ className, style, zone }, ref) {
3531
- const ctx = useContext3(dropZoneContext);
3736
+ const ctx = useContext6(dropZoneContext);
3532
3737
  const { data, areaId = "root", config } = ctx || {};
3533
3738
  let zoneCompound = rootDroppableId;
3534
3739
  let content = (data == null ? void 0 : data.content) || [];
3535
- useEffect12(() => {
3740
+ useEffect14(() => {
3536
3741
  if (ctx == null ? void 0 : ctx.registerZone) {
3537
3742
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3538
3743
  }
@@ -3549,10 +3754,10 @@ var DropZoneRender = forwardRef3(
3549
3754
  zoneCompound = `${areaId}:${zone}`;
3550
3755
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3551
3756
  }
3552
- return /* @__PURE__ */ jsx21("div", { className, style, ref, children: content.map((item) => {
3757
+ return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
3553
3758
  const Component = config.components[item.type];
3554
3759
  if (Component) {
3555
- return /* @__PURE__ */ jsx21(
3760
+ return /* @__PURE__ */ jsx22(
3556
3761
  DropZoneProvider,
3557
3762
  {
3558
3763
  value: {
@@ -3562,7 +3767,7 @@ var DropZoneRender = forwardRef3(
3562
3767
  depth: 1,
3563
3768
  path: []
3564
3769
  },
3565
- children: /* @__PURE__ */ jsx21(
3770
+ children: /* @__PURE__ */ jsx22(
3566
3771
  Component.render,
3567
3772
  __spreadProps(__spreadValues({}, item.props), {
3568
3773
  puck: { renderDropZone: DropZoneRender2 }
@@ -3578,11 +3783,11 @@ var DropZoneRender = forwardRef3(
3578
3783
  );
3579
3784
  var DropZone = forwardRef3(
3580
3785
  function DropZone2(props, ref) {
3581
- const ctx = useContext3(dropZoneContext);
3786
+ const ctx = useContext6(dropZoneContext);
3582
3787
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3583
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3788
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3584
3789
  }
3585
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3790
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3586
3791
  }
3587
3792
  );
3588
3793
 
@@ -3598,7 +3803,7 @@ var getZoneId = (zoneCompound) => {
3598
3803
  return [rootDroppableId, zoneCompound];
3599
3804
  };
3600
3805
 
3601
- // components/DragDropContext/NestedDroppablePlugin.ts
3806
+ // lib/dnd/NestedDroppablePlugin.ts
3602
3807
  init_react_import();
3603
3808
  import { Plugin } from "@dnd-kit/abstract";
3604
3809
  import { effects } from "@dnd-kit/state";
@@ -3640,7 +3845,7 @@ var getFrame = () => {
3640
3845
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3641
3846
  };
3642
3847
 
3643
- // components/DragDropContext/NestedDroppablePlugin.ts
3848
+ // lib/dnd/NestedDroppablePlugin.ts
3644
3849
  var depthSort = (candidates) => {
3645
3850
  return candidates.sort((a, b) => {
3646
3851
  const aData = a.data;
@@ -3755,9 +3960,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
3755
3960
  area: null
3756
3961
  };
3757
3962
  };
3758
- var createNestedDroppablePlugin = ({
3759
- onChange
3760
- }) => class NestedDroppablePlugin extends Plugin {
3963
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
3761
3964
  constructor(manager, options) {
3762
3965
  super(manager);
3763
3966
  if (typeof window === "undefined") {
@@ -3771,10 +3974,17 @@ var createNestedDroppablePlugin = ({
3771
3974
  };
3772
3975
  const target = event.originalTarget || event.target;
3773
3976
  const ownerDocument = target == null ? void 0 : target.ownerDocument;
3774
- onChange(
3775
- findDeepestCandidate(position, manager, ownerDocument),
3776
- manager
3977
+ const elements = document.elementsFromPoint(
3978
+ event.clientX,
3979
+ event.clientY
3777
3980
  );
3981
+ const overEl = elements.some((el) => el.id === id);
3982
+ if (overEl) {
3983
+ onChange(
3984
+ findDeepestCandidate(position, manager, ownerDocument),
3985
+ manager
3986
+ );
3987
+ }
3778
3988
  };
3779
3989
  const handleMoveThrottled = throttle(handleMove, 50);
3780
3990
  const handlePointerMove = (event) => {
@@ -4191,7 +4401,7 @@ var insertComponent = (componentType, zone, index, {
4191
4401
  import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4192
4402
  import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
4193
4403
 
4194
- // components/DragDropContext/PointerSensor.ts
4404
+ // lib/dnd/PointerSensor.ts
4195
4405
  init_react_import();
4196
4406
  import { batch, effect } from "@dnd-kit/state";
4197
4407
  import { Sensor, configurator } from "@dnd-kit/abstract";
@@ -4462,13 +4672,15 @@ function patchWindow(window2) {
4462
4672
  }
4463
4673
 
4464
4674
  // components/DragDropContext/index.tsx
4465
- import { jsx as jsx22 } from "react/jsx-runtime";
4466
- var dragListenerContext = createContext3({
4675
+ import { createStore as createStore3 } from "zustand";
4676
+ import { jsx as jsx23 } from "react/jsx-runtime";
4677
+ var DEBUG3 = false;
4678
+ var dragListenerContext = createContext4({
4467
4679
  dragListeners: {}
4468
4680
  });
4469
4681
  function useDragListener(type, fn, deps = []) {
4470
- const { setDragListeners } = useContext4(dragListenerContext);
4471
- useEffect13(() => {
4682
+ const { setDragListeners } = useContext7(dragListenerContext);
4683
+ useEffect15(() => {
4472
4684
  if (setDragListeners) {
4473
4685
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
4474
4686
  [type]: [...old[type] || [], fn]
@@ -4476,80 +4688,147 @@ function useDragListener(type, fn, deps = []) {
4476
4688
  }
4477
4689
  }, deps);
4478
4690
  }
4479
- var previewContext = createContext3(null);
4480
4691
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4692
+ var useTempDisableFallback = (timeout3) => {
4693
+ const lastFallbackDisable = useRef4(null);
4694
+ return useCallback11((manager) => {
4695
+ collisionStore.setState({ fallbackEnabled: false });
4696
+ const fallbackId = generateId();
4697
+ lastFallbackDisable.current = fallbackId;
4698
+ setTimeout(() => {
4699
+ if (lastFallbackDisable.current === fallbackId) {
4700
+ collisionStore.setState({ fallbackEnabled: true });
4701
+ manager.collisionObserver.forceUpdate(true);
4702
+ }
4703
+ }, timeout3);
4704
+ }, []);
4705
+ };
4481
4706
  var DragDropContextClient = ({
4482
4707
  children,
4483
4708
  disableAutoScroll
4484
4709
  }) => {
4485
4710
  const { state, config, dispatch, resolveData } = useAppContext();
4486
- const [preview, setPreview] = useState16(null);
4487
- const previewRef = useRef5(null);
4711
+ const id = useId();
4488
4712
  const { data } = state;
4489
- const [deepest, setDeepest] = useState16(null);
4490
- const [nextDeepest, setNextDeepest] = useState16(null);
4491
- const deepestRef = useRef5(deepest);
4492
- const debouncedParamsRef = useRef5(null);
4493
- const setDeepestAndCollide = useCallback9(
4713
+ const debouncedParamsRef = useRef4(null);
4714
+ const tempDisableFallback = useTempDisableFallback(100);
4715
+ const [zoneStore] = useState17(
4716
+ () => createStore3(() => ({
4717
+ zoneDepthIndex: {},
4718
+ nextZoneDepthIndex: {},
4719
+ areaDepthIndex: {},
4720
+ nextAreaDepthIndex: {},
4721
+ draggedItem: null,
4722
+ previewIndex: {}
4723
+ }))
4724
+ );
4725
+ const getChanged2 = useCallback11(
4726
+ (params, id2) => {
4727
+ const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
4728
+ const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
4729
+ const stateHasArea = Object.keys(areaDepthIndex).length > 0;
4730
+ let zoneChanged = false;
4731
+ let areaChanged = false;
4732
+ if (params.zone && !zoneDepthIndex[params.zone]) {
4733
+ zoneChanged = true;
4734
+ } else if (!params.zone && stateHasZone) {
4735
+ zoneChanged = true;
4736
+ }
4737
+ if (params.area && !areaDepthIndex[params.area]) {
4738
+ areaChanged = true;
4739
+ } else if (!params.area && stateHasArea) {
4740
+ areaChanged = true;
4741
+ }
4742
+ return { zoneChanged, areaChanged };
4743
+ },
4744
+ [zoneStore]
4745
+ );
4746
+ const setDeepestAndCollide = useCallback11(
4494
4747
  (params, manager) => {
4495
- setDeepest(params);
4748
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4749
+ if (!zoneChanged && !areaChanged) return;
4750
+ zoneStore.setState({
4751
+ zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
4752
+ areaDepthIndex: params.area ? { [params.area]: true } : {}
4753
+ });
4754
+ tempDisableFallback(manager);
4496
4755
  setTimeout(() => {
4497
4756
  manager.collisionObserver.forceUpdate(true);
4498
4757
  }, 50);
4499
4758
  debouncedParamsRef.current = null;
4500
4759
  },
4501
- []
4760
+ [zoneStore]
4502
4761
  );
4503
4762
  const setDeepestDb = useDebouncedCallback2(
4504
4763
  setDeepestAndCollide,
4505
4764
  AREA_CHANGE_DEBOUNCE_MS
4506
4765
  );
4507
- useEffect13(() => {
4508
- deepestRef.current = deepest;
4509
- }, [deepest]);
4510
4766
  const cancelDb = () => {
4511
4767
  setDeepestDb.cancel();
4512
4768
  debouncedParamsRef.current = null;
4513
4769
  };
4514
- const [plugins] = useState16(() => [
4515
- ...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
4516
- createNestedDroppablePlugin({
4517
- onChange: (params, manager) => {
4518
- const lastParams = deepestRef.current;
4519
- const areaChanged = params.area !== (lastParams == null ? void 0 : lastParams.area);
4520
- const zoneChanged = params.zone !== (lastParams == null ? void 0 : lastParams.zone);
4521
- const isDragging = manager.dragOperation.status.dragging;
4522
- if (areaChanged || zoneChanged) {
4523
- setNextDeepest(params);
4524
- }
4525
- if (params.zone !== "void" && (lastParams == null ? void 0 : lastParams.zone) === "void") {
4526
- setDeepest(params);
4527
- manager.collisionObserver.forceUpdate(true);
4528
- return;
4770
+ useEffect15(() => {
4771
+ if (DEBUG3) {
4772
+ zoneStore.subscribe(
4773
+ (s) => {
4774
+ var _a, _b;
4775
+ return console.log(
4776
+ s.previewIndex,
4777
+ (_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
4778
+ (_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
4779
+ );
4529
4780
  }
4530
- if (areaChanged) {
4531
- if (isDragging) {
4532
- const debouncedParams = debouncedParamsRef.current;
4533
- const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4534
- if (!isSameParams) {
4781
+ );
4782
+ }
4783
+ }, []);
4784
+ const [plugins] = useState17(() => [
4785
+ ...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
4786
+ createNestedDroppablePlugin(
4787
+ {
4788
+ onChange: (params, manager) => {
4789
+ const state2 = zoneStore.getState();
4790
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4791
+ const isDragging = manager.dragOperation.status.dragging;
4792
+ if (areaChanged || zoneChanged) {
4793
+ let nextZoneDepthIndex = {};
4794
+ let nextAreaDepthIndex = {};
4795
+ if (params.zone) {
4796
+ nextZoneDepthIndex = { [params.zone]: true };
4797
+ }
4798
+ if (params.area) {
4799
+ nextAreaDepthIndex = { [params.area]: true };
4800
+ }
4801
+ zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
4802
+ }
4803
+ if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
4804
+ setDeepestAndCollide(params, manager);
4805
+ return;
4806
+ }
4807
+ if (areaChanged) {
4808
+ if (isDragging) {
4809
+ const debouncedParams = debouncedParamsRef.current;
4810
+ const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4811
+ if (!isSameParams) {
4812
+ cancelDb();
4813
+ setDeepestDb(params, manager);
4814
+ debouncedParamsRef.current = params;
4815
+ }
4816
+ } else {
4535
4817
  cancelDb();
4536
- setDeepestDb(params, manager);
4537
- debouncedParamsRef.current = params;
4818
+ setDeepestAndCollide(params, manager);
4538
4819
  }
4539
- } else {
4540
- cancelDb();
4820
+ return;
4821
+ }
4822
+ if (zoneChanged) {
4541
4823
  setDeepestAndCollide(params, manager);
4542
4824
  }
4543
- return;
4825
+ cancelDb();
4544
4826
  }
4545
- if (zoneChanged) {
4546
- setDeepestAndCollide(params, manager);
4547
- }
4548
- cancelDb();
4549
- }
4550
- })
4827
+ },
4828
+ id
4829
+ )
4551
4830
  ]);
4552
- const [sensors] = useState16(() => [
4831
+ const [sensors] = useState17(() => [
4553
4832
  PointerSensor.configure({
4554
4833
  activationConstraints(event, source) {
4555
4834
  var _a;
@@ -4568,11 +4847,10 @@ var DragDropContextClient = ({
4568
4847
  }
4569
4848
  })
4570
4849
  ]);
4571
- const [draggedItem, setDraggedItem] = useState16();
4572
- const [dragListeners, setDragListeners] = useState16({});
4573
- const [pathData, setPathData] = useState16();
4574
- const dragMode = useRef5(null);
4575
- const registerPath = useCallback9(
4850
+ const [dragListeners, setDragListeners] = useState17({});
4851
+ const [pathData, setPathData] = useState17();
4852
+ const dragMode = useRef4(null);
4853
+ const registerPath = useCallback11(
4576
4854
  (selector) => {
4577
4855
  const item = getItem(selector, data);
4578
4856
  if (!item) {
@@ -4594,41 +4872,41 @@ var DragDropContextClient = ({
4594
4872
  },
4595
4873
  [data, setPathData]
4596
4874
  );
4597
- const initialSelector = useRef5(void 0);
4598
- return /* @__PURE__ */ jsx22(
4875
+ const initialSelector = useRef4(void 0);
4876
+ return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
4599
4877
  dragListenerContext.Provider,
4600
4878
  {
4601
4879
  value: {
4602
4880
  dragListeners,
4603
4881
  setDragListeners
4604
4882
  },
4605
- children: /* @__PURE__ */ jsx22(previewContext.Provider, { value: preview, children: /* @__PURE__ */ jsx22(
4883
+ children: /* @__PURE__ */ jsx23(
4606
4884
  DragDropProvider2,
4607
4885
  {
4608
4886
  plugins,
4609
4887
  sensors,
4610
4888
  onDragEnd: (event, manager) => {
4889
+ var _a;
4611
4890
  const { source, target } = event.operation;
4612
- deepestRef.current = null;
4613
4891
  if (!source) {
4614
- setDraggedItem(null);
4892
+ zoneStore.setState({ draggedItem: null });
4615
4893
  return;
4616
4894
  }
4617
4895
  const { zone, index } = source.data;
4618
- const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
4619
- previewRef.current = null;
4896
+ const { previewIndex = {} } = zoneStore.getState() || {};
4897
+ const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
4620
4898
  setTimeout(() => {
4621
- var _a, _b;
4622
- setDraggedItem(null);
4899
+ var _a2, _b;
4900
+ zoneStore.setState({ draggedItem: null });
4623
4901
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4624
- setPreview(null);
4625
- (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
4902
+ zoneStore.setState({ previewIndex: {} });
4903
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
4626
4904
  fn(event, manager);
4627
4905
  });
4628
4906
  return;
4629
4907
  }
4630
4908
  if (thisPreview) {
4631
- setPreview(null);
4909
+ zoneStore.setState({ previewIndex: {} });
4632
4910
  if (thisPreview.type === "insert") {
4633
4911
  insertComponent(
4634
4912
  thisPreview.componentType,
@@ -4663,8 +4941,9 @@ var DragDropContextClient = ({
4663
4941
  }, 250);
4664
4942
  },
4665
4943
  onDragOver: (event, manager) => {
4666
- var _a, _b, _c, _d;
4944
+ var _a, _b, _c, _d, _e;
4667
4945
  event.preventDefault();
4946
+ const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
4668
4947
  if (!draggedItem) return;
4669
4948
  cancelDb();
4670
4949
  const { source, target } = event.operation;
@@ -4680,7 +4959,7 @@ var DragDropContextClient = ({
4680
4959
  const targetData = target.data;
4681
4960
  targetZone = targetData.zone;
4682
4961
  targetIndex = targetData.index;
4683
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
4962
+ const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
4684
4963
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
4685
4964
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
4686
4965
  targetIndex = targetIndex - 1;
@@ -4692,23 +4971,26 @@ var DragDropContextClient = ({
4692
4971
  targetZone = target.id.toString();
4693
4972
  targetIndex = 0;
4694
4973
  }
4695
- if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
4974
+ if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
4696
4975
  const [pathId] = path.split(":");
4697
4976
  return pathId === sourceId;
4698
4977
  }))) {
4699
4978
  return;
4700
4979
  }
4701
4980
  if (dragMode.current === "new") {
4702
- previewRef.current = {
4703
- componentType: sourceData.componentType,
4704
- type: "insert",
4705
- index: targetIndex,
4706
- zone: targetZone,
4707
- props: {
4708
- id: source.id.toString()
4981
+ zoneStore.setState({
4982
+ previewIndex: {
4983
+ [targetZone]: {
4984
+ componentType: sourceData.componentType,
4985
+ type: "insert",
4986
+ index: targetIndex,
4987
+ zone: targetZone,
4988
+ props: {
4989
+ id: source.id.toString()
4990
+ }
4991
+ }
4709
4992
  }
4710
- };
4711
- setPreview(previewRef.current);
4993
+ });
4712
4994
  } else {
4713
4995
  if (!initialSelector.current) {
4714
4996
  initialSelector.current = {
@@ -4718,17 +5000,20 @@ var DragDropContextClient = ({
4718
5000
  }
4719
5001
  const item = getItem(initialSelector.current, data);
4720
5002
  if (item) {
4721
- previewRef.current = {
4722
- componentType: sourceData.componentType,
4723
- type: "move",
4724
- index: targetIndex,
4725
- zone: targetZone,
4726
- props: item.props
4727
- };
4728
- setPreview(previewRef.current);
5003
+ zoneStore.setState({
5004
+ previewIndex: {
5005
+ [targetZone]: {
5006
+ componentType: sourceData.componentType,
5007
+ type: "move",
5008
+ index: targetIndex,
5009
+ zone: targetZone,
5010
+ props: item.props
5011
+ }
5012
+ }
5013
+ });
4729
5014
  }
4730
5015
  }
4731
- (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
5016
+ (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
4732
5017
  fn(event, manager);
4733
5018
  });
4734
5019
  },
@@ -4738,45 +5023,61 @@ var DragDropContextClient = ({
4738
5023
  type: "setUi",
4739
5024
  ui: { itemSelector: null, isDragging: true }
4740
5025
  });
5026
+ const { source } = event.operation;
5027
+ if (source && source.type !== "void") {
5028
+ const sourceData = source.data;
5029
+ const item = getItem(
5030
+ {
5031
+ zone: sourceData.zone,
5032
+ index: sourceData.index
5033
+ },
5034
+ data
5035
+ );
5036
+ if (item) {
5037
+ zoneStore.setState({
5038
+ previewIndex: {
5039
+ [sourceData.zone]: {
5040
+ componentType: sourceData.componentType,
5041
+ type: "move",
5042
+ index: sourceData.index,
5043
+ zone: sourceData.zone,
5044
+ props: item.props
5045
+ }
5046
+ }
5047
+ });
5048
+ }
5049
+ }
4741
5050
  (_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
4742
5051
  fn(event, manager);
4743
5052
  });
4744
5053
  },
4745
5054
  onBeforeDragStart: (event) => {
4746
5055
  var _a;
4747
- if (draggedItem) {
4748
- console.warn("New drag started before previous drag cleaned up");
4749
- }
4750
5056
  const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
4751
5057
  dragMode.current = isNewComponent ? "new" : "existing";
4752
5058
  initialSelector.current = void 0;
4753
- setDraggedItem(event.operation.source);
5059
+ zoneStore.setState({ draggedItem: event.operation.source });
4754
5060
  },
4755
- children: /* @__PURE__ */ jsx22(
5061
+ children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
4756
5062
  DropZoneProvider,
4757
5063
  {
4758
5064
  value: {
4759
5065
  data,
4760
5066
  config,
4761
- draggedItem,
4762
5067
  mode: "edit",
4763
5068
  areaId: "root",
4764
5069
  depth: 0,
4765
5070
  registerPath,
4766
5071
  pathData,
4767
- deepestZone: deepest == null ? void 0 : deepest.zone,
4768
- deepestArea: deepest == null ? void 0 : deepest.area,
4769
- nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
4770
- nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
4771
5072
  path: []
4772
5073
  },
4773
5074
  children
4774
5075
  }
4775
- )
5076
+ ) })
4776
5077
  }
4777
- ) })
5078
+ )
4778
5079
  }
4779
- );
5080
+ ) });
4780
5081
  };
4781
5082
  var DragDropContext = ({
4782
5083
  children,
@@ -4786,11 +5087,11 @@ var DragDropContext = ({
4786
5087
  if (status === "LOADING") {
4787
5088
  return children;
4788
5089
  }
4789
- return /* @__PURE__ */ jsx22(DragDropContextClient, { disableAutoScroll, children });
5090
+ return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
4790
5091
  };
4791
5092
 
4792
5093
  // components/Drawer/index.tsx
4793
- import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
5094
+ import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
4794
5095
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
4795
5096
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
4796
5097
  var DrawerItemInner = ({
@@ -4800,11 +5101,11 @@ var DrawerItemInner = ({
4800
5101
  dragRef,
4801
5102
  isDragDisabled
4802
5103
  }) => {
4803
- const CustomInner = useMemo8(
4804
- () => children || (({ children: children2 }) => /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("default"), children: children2 })),
5104
+ const CustomInner = useMemo9(
5105
+ () => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
4805
5106
  [children]
4806
5107
  );
4807
- return /* @__PURE__ */ jsx23(
5108
+ return /* @__PURE__ */ jsx24(
4808
5109
  "div",
4809
5110
  {
4810
5111
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -4812,9 +5113,9 @@ var DrawerItemInner = ({
4812
5113
  onMouseDown: (e) => e.preventDefault(),
4813
5114
  "data-testid": dragRef ? `drawer-item:${name}` : "",
4814
5115
  "data-puck-drawer-item": true,
4815
- children: /* @__PURE__ */ jsx23(CustomInner, { name, children: /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
4816
- /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
4817
- /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx23(DragIcon, {}) })
5116
+ children: /* @__PURE__ */ jsx24(CustomInner, { name, children: /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
5117
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5118
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx24(DragIcon, {}) })
4818
5119
  ] }) }) })
4819
5120
  }
4820
5121
  );
@@ -4832,8 +5133,8 @@ var DrawerItemDraggable = ({
4832
5133
  disabled: isDragDisabled
4833
5134
  });
4834
5135
  return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
4835
- /* @__PURE__ */ jsx23("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx23(DrawerItemInner, { name, label, children }) }),
4836
- /* @__PURE__ */ jsx23("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx23(
5136
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx24(DrawerItemInner, { name, label, children }) }),
5137
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx24(
4837
5138
  DrawerItemInner,
4838
5139
  {
4839
5140
  name,
@@ -4854,7 +5155,7 @@ var DrawerItem = ({
4854
5155
  isDragDisabled
4855
5156
  }) => {
4856
5157
  const resolvedId = id || name;
4857
- const [dynamicId, setDynamicId] = useState17(generateId(resolvedId));
5158
+ const [dynamicId, setDynamicId] = useState18(generateId(resolvedId));
4858
5159
  if (typeof index !== "undefined") {
4859
5160
  console.error(
4860
5161
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -4867,7 +5168,7 @@ var DrawerItem = ({
4867
5168
  },
4868
5169
  [resolvedId]
4869
5170
  );
4870
- return /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
5171
+ return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
4871
5172
  DrawerItemDraggable,
4872
5173
  {
4873
5174
  name,
@@ -4893,14 +5194,14 @@ var Drawer = ({
4893
5194
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
4894
5195
  );
4895
5196
  }
4896
- const [id] = useState17(generateId());
5197
+ const [id] = useState18(generateId());
4897
5198
  const { ref } = useDroppableSafe({
4898
5199
  id,
4899
5200
  type: "void",
4900
5201
  collisionPriority: 0
4901
5202
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
4902
5203
  });
4903
- return /* @__PURE__ */ jsx23(
5204
+ return /* @__PURE__ */ jsx24(
4904
5205
  "div",
4905
5206
  {
4906
5207
  className: getClassName18(),
@@ -4916,11 +5217,11 @@ Drawer.Item = DrawerItem;
4916
5217
  // components/Puck/index.tsx
4917
5218
  init_react_import();
4918
5219
  import {
4919
- useCallback as useCallback15,
4920
- useEffect as useEffect21,
4921
- useMemo as useMemo17,
5220
+ useCallback as useCallback17,
5221
+ useEffect as useEffect23,
5222
+ useMemo as useMemo18,
4922
5223
  useReducer,
4923
- useState as useState25
5224
+ useState as useState26
4924
5225
  } from "react";
4925
5226
 
4926
5227
  // components/SidebarSection/index.tsx
@@ -4932,7 +5233,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
4932
5233
 
4933
5234
  // lib/use-breadcrumbs.ts
4934
5235
  init_react_import();
4935
- import { useContext as useContext5, useMemo as useMemo9 } from "react";
5236
+ import { useContext as useContext8, useMemo as useMemo10 } from "react";
4936
5237
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
4937
5238
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
4938
5239
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -4982,8 +5283,8 @@ var useBreadcrumbs = (renderCount) => {
4982
5283
  state: { data },
4983
5284
  selectedItem
4984
5285
  } = useAppContext();
4985
- const dzContext = useContext5(dropZoneContext);
4986
- return useMemo9(() => {
5286
+ const dzContext = useContext8(dropZoneContext);
5287
+ return useMemo10(() => {
4987
5288
  const breadcrumbs = convertPathDataToBreadcrumbs(
4988
5289
  selectedItem,
4989
5290
  dzContext == null ? void 0 : dzContext.pathData,
@@ -4997,7 +5298,7 @@ var useBreadcrumbs = (renderCount) => {
4997
5298
  };
4998
5299
 
4999
5300
  // components/SidebarSection/index.tsx
5000
- import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
5301
+ import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
5001
5302
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5002
5303
  var SidebarSection = ({
5003
5304
  children,
@@ -5016,9 +5317,9 @@ var SidebarSection = ({
5016
5317
  className: getClassName19({ noBorderTop, noPadding }),
5017
5318
  style: { background },
5018
5319
  children: [
5019
- /* @__PURE__ */ jsx24("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5320
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5020
5321
  showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
5021
- /* @__PURE__ */ jsx24(
5322
+ /* @__PURE__ */ jsx25(
5022
5323
  "button",
5023
5324
  {
5024
5325
  type: "button",
@@ -5027,12 +5328,12 @@ var SidebarSection = ({
5027
5328
  children: breadcrumb.label
5028
5329
  }
5029
5330
  ),
5030
- /* @__PURE__ */ jsx24(ChevronRight, { size: 16 })
5331
+ /* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
5031
5332
  ] }, i)) : null,
5032
- /* @__PURE__ */ jsx24("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx24(Heading, { rank: "2", size: "xs", children: title }) })
5333
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
5033
5334
  ] }) }),
5034
- /* @__PURE__ */ jsx24("div", { className: getClassName19("content"), children }),
5035
- isLoading && /* @__PURE__ */ jsx24("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx24(Loader, { size: 32 }) })
5335
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
5336
+ isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
5036
5337
  ]
5037
5338
  }
5038
5339
  );
@@ -5063,7 +5364,7 @@ init_react_import();
5063
5364
  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" };
5064
5365
 
5065
5366
  // components/MenuBar/index.tsx
5066
- import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
5367
+ import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
5067
5368
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5068
5369
  function MenuBar({
5069
5370
  appState,
@@ -5077,7 +5378,7 @@ function MenuBar({
5077
5378
  history: { back, forward, historyStore }
5078
5379
  } = useAppContext();
5079
5380
  const { hasFuture = false, hasPast = false } = historyStore || {};
5080
- return /* @__PURE__ */ jsx25(
5381
+ return /* @__PURE__ */ jsx26(
5081
5382
  "div",
5082
5383
  {
5083
5384
  className: getClassName20({ menuOpen }),
@@ -5093,10 +5394,10 @@ function MenuBar({
5093
5394
  },
5094
5395
  children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
5095
5396
  /* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
5096
- /* @__PURE__ */ jsx25(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx25(Undo2, { size: 21 }) }),
5097
- /* @__PURE__ */ jsx25(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx25(Redo2, { size: 21 }) })
5397
+ /* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
5398
+ /* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
5098
5399
  ] }),
5099
- /* @__PURE__ */ jsx25(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5400
+ /* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5100
5401
  state: appState,
5101
5402
  dispatch
5102
5403
  }) })
@@ -5107,7 +5408,7 @@ function MenuBar({
5107
5408
 
5108
5409
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5109
5410
  init_react_import();
5110
- 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" };
5411
+ 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" };
5111
5412
 
5112
5413
  // components/Puck/components/Fields/index.tsx
5113
5414
  init_react_import();
@@ -5117,15 +5418,15 @@ init_react_import();
5117
5418
  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" };
5118
5419
 
5119
5420
  // components/Puck/components/Fields/index.tsx
5120
- import { useCallback as useCallback10, useEffect as useEffect14, useMemo as useMemo10, useState as useState18 } from "react";
5421
+ import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo11, useState as useState19 } from "react";
5121
5422
 
5122
5423
  // lib/use-parent.ts
5123
5424
  init_react_import();
5124
- import { useContext as useContext6 } from "react";
5425
+ import { useContext as useContext9 } from "react";
5125
5426
  var useParent = (itemSelector) => {
5126
5427
  var _a;
5127
5428
  const { selectedItem, state } = useAppContext();
5128
- const { pathData } = useContext6(dropZoneContext) || {};
5429
+ const { pathData } = useContext9(dropZoneContext) || {};
5129
5430
  const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5130
5431
  const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5131
5432
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
@@ -5134,7 +5435,7 @@ var useParent = (itemSelector) => {
5134
5435
  };
5135
5436
 
5136
5437
  // components/Puck/components/Fields/index.tsx
5137
- import { Fragment as Fragment8, jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
5438
+ import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5138
5439
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5139
5440
  var defaultPageFields = {
5140
5441
  title: { type: "text" }
@@ -5142,7 +5443,7 @@ var defaultPageFields = {
5142
5443
  var DefaultFields = ({
5143
5444
  children
5144
5445
  }) => {
5145
- return /* @__PURE__ */ jsx26(Fragment8, { children });
5446
+ return /* @__PURE__ */ jsx27(Fragment8, { children });
5146
5447
  };
5147
5448
  var useResolvedFields = () => {
5148
5449
  var _a, _b;
@@ -5151,20 +5452,20 @@ var useResolvedFields = () => {
5151
5452
  const { data } = state;
5152
5453
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5153
5454
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5154
- const defaultFields = useMemo10(
5455
+ const defaultFields = useMemo11(
5155
5456
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5156
5457
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5157
5458
  );
5158
5459
  const rootProps = data.root.props || data.root;
5159
- const [lastSelectedData, setLastSelectedData] = useState18({});
5160
- const [resolvedFields, setResolvedFields] = useState18(defaultFields);
5161
- const [fieldsLoading, setFieldsLoading] = useState18(false);
5460
+ const [lastSelectedData, setLastSelectedData] = useState19({});
5461
+ const [resolvedFields, setResolvedFields] = useState19(defaultFields);
5462
+ const [fieldsLoading, setFieldsLoading] = useState19(false);
5162
5463
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5163
5464
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5164
5465
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5165
5466
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5166
5467
  const hasResolver = hasComponentResolver || hasRootResolver;
5167
- const resolveFields = useCallback10(
5468
+ const resolveFields = useCallback12(
5168
5469
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5169
5470
  var _a2;
5170
5471
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5202,7 +5503,7 @@ var useResolvedFields = () => {
5202
5503
  }),
5203
5504
  [data, config, componentData, selectedItem, resolvedFields, state]
5204
5505
  );
5205
- useEffect14(() => {
5506
+ useEffect16(() => {
5206
5507
  if (hasResolver) {
5207
5508
  setFieldsLoading(true);
5208
5509
  resolveFields(defaultFields).then((fields) => {
@@ -5233,7 +5534,7 @@ var Fields = () => {
5233
5534
  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;
5234
5535
  const isLoading = fieldsResolving || componentResolving;
5235
5536
  const rootProps = data.root.props || data.root;
5236
- const Wrapper = useMemo10(() => overrides.fields || DefaultFields, [overrides]);
5537
+ const Wrapper = useMemo11(() => overrides.fields || DefaultFields, [overrides]);
5237
5538
  return /* @__PURE__ */ jsxs14(
5238
5539
  "form",
5239
5540
  {
@@ -5242,7 +5543,7 @@ var Fields = () => {
5242
5543
  e.preventDefault();
5243
5544
  },
5244
5545
  children: [
5245
- /* @__PURE__ */ jsx26(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5546
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5246
5547
  const field = fields[fieldName];
5247
5548
  if (!(field == null ? void 0 : field.type)) return null;
5248
5549
  const onChange = (value, updatedUi) => {
@@ -5313,7 +5614,7 @@ var Fields = () => {
5313
5614
  item: selectedItem
5314
5615
  });
5315
5616
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5316
- return /* @__PURE__ */ jsx26(
5617
+ return /* @__PURE__ */ jsx27(
5317
5618
  AutoFieldPrivate,
5318
5619
  {
5319
5620
  field,
@@ -5331,7 +5632,7 @@ var Fields = () => {
5331
5632
  root: true
5332
5633
  });
5333
5634
  const id = `root_${field.type}_${fieldName}`;
5334
- return /* @__PURE__ */ jsx26(
5635
+ return /* @__PURE__ */ jsx27(
5335
5636
  AutoFieldPrivate,
5336
5637
  {
5337
5638
  field,
@@ -5345,7 +5646,7 @@ var Fields = () => {
5345
5646
  );
5346
5647
  }
5347
5648
  }) }),
5348
- isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx26(Loader, { size: 16 }) }) })
5649
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
5349
5650
  ]
5350
5651
  }
5351
5652
  );
@@ -5356,7 +5657,7 @@ init_react_import();
5356
5657
 
5357
5658
  // lib/use-component-list.tsx
5358
5659
  init_react_import();
5359
- import { useEffect as useEffect15, useState as useState19 } from "react";
5660
+ import { useEffect as useEffect17, useState as useState20 } from "react";
5360
5661
 
5361
5662
  // components/ComponentList/index.tsx
5362
5663
  init_react_import();
@@ -5366,7 +5667,7 @@ init_react_import();
5366
5667
  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" };
5367
5668
 
5368
5669
  // components/ComponentList/index.tsx
5369
- import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
5670
+ import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
5370
5671
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
5371
5672
  var ComponentListItem = ({
5372
5673
  name,
@@ -5376,7 +5677,7 @@ var ComponentListItem = ({
5376
5677
  const canInsert = getPermissions({
5377
5678
  type: name
5378
5679
  }).insert;
5379
- return /* @__PURE__ */ jsx27(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5680
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5380
5681
  };
5381
5682
  var ComponentList = ({
5382
5683
  children,
@@ -5400,14 +5701,14 @@ var ComponentList = ({
5400
5701
  }),
5401
5702
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
5402
5703
  children: [
5403
- /* @__PURE__ */ jsx27("div", { children: title }),
5404
- /* @__PURE__ */ jsx27("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx27(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx27(ChevronDown, { size: 12 }) })
5704
+ /* @__PURE__ */ jsx28("div", { children: title }),
5705
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
5405
5706
  ]
5406
5707
  }
5407
5708
  ),
5408
- /* @__PURE__ */ jsx27("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx27(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5709
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5409
5710
  var _a;
5410
- return /* @__PURE__ */ jsx27(
5711
+ return /* @__PURE__ */ jsx28(
5411
5712
  ComponentListItem,
5412
5713
  {
5413
5714
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -5421,10 +5722,10 @@ var ComponentList = ({
5421
5722
  ComponentList.Item = ComponentListItem;
5422
5723
 
5423
5724
  // lib/use-component-list.tsx
5424
- import { jsx as jsx28 } from "react/jsx-runtime";
5725
+ import { jsx as jsx29 } from "react/jsx-runtime";
5425
5726
  var useComponentList = (config, ui) => {
5426
- const [componentList, setComponentList] = useState19();
5427
- useEffect15(() => {
5727
+ const [componentList, setComponentList] = useState20();
5728
+ useEffect17(() => {
5428
5729
  var _a, _b, _c;
5429
5730
  if (Object.keys(ui.componentList).length > 0) {
5430
5731
  const matchedComponents = [];
@@ -5434,7 +5735,7 @@ var useComponentList = (config, ui) => {
5434
5735
  if (category.visible === false || !category.components) {
5435
5736
  return null;
5436
5737
  }
5437
- return /* @__PURE__ */ jsx28(
5738
+ return /* @__PURE__ */ jsx29(
5438
5739
  ComponentList,
5439
5740
  {
5440
5741
  id: categoryKey,
@@ -5443,7 +5744,7 @@ var useComponentList = (config, ui) => {
5443
5744
  var _a2;
5444
5745
  matchedComponents.push(componentName);
5445
5746
  const componentConf = config.components[componentName] || {};
5446
- return /* @__PURE__ */ jsx28(
5747
+ return /* @__PURE__ */ jsx29(
5447
5748
  ComponentList.Item,
5448
5749
  {
5449
5750
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -5463,7 +5764,7 @@ var useComponentList = (config, ui) => {
5463
5764
  );
5464
5765
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
5465
5766
  _componentList.push(
5466
- /* @__PURE__ */ jsx28(
5767
+ /* @__PURE__ */ jsx29(
5467
5768
  ComponentList,
5468
5769
  {
5469
5770
  id: "other",
@@ -5471,7 +5772,7 @@ var useComponentList = (config, ui) => {
5471
5772
  children: remainingComponents.map((componentName, i) => {
5472
5773
  var _a2;
5473
5774
  const componentConf = config.components[componentName] || {};
5474
- return /* @__PURE__ */ jsx28(
5775
+ return /* @__PURE__ */ jsx29(
5475
5776
  ComponentList.Item,
5476
5777
  {
5477
5778
  name: componentName,
@@ -5493,30 +5794,30 @@ var useComponentList = (config, ui) => {
5493
5794
  };
5494
5795
 
5495
5796
  // components/Puck/components/Components/index.tsx
5496
- import { useMemo as useMemo11 } from "react";
5497
- import { jsx as jsx29 } from "react/jsx-runtime";
5797
+ import { useMemo as useMemo12 } from "react";
5798
+ import { jsx as jsx30 } from "react/jsx-runtime";
5498
5799
  var Components = () => {
5499
5800
  const { config, state, overrides } = useAppContext();
5500
5801
  const componentList = useComponentList(config, state.ui);
5501
- const Wrapper = useMemo11(() => overrides.components || "div", [overrides]);
5502
- return /* @__PURE__ */ jsx29(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx29(ComponentList, { id: "all" }) });
5802
+ const Wrapper = useMemo12(() => overrides.components || "div", [overrides]);
5803
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
5503
5804
  };
5504
5805
 
5505
5806
  // components/Puck/components/Preview/index.tsx
5506
5807
  init_react_import();
5507
- import { useCallback as useCallback11, useEffect as useEffect17, useRef as useRef7, useMemo as useMemo12 } from "react";
5808
+ import { useCallback as useCallback13, useEffect as useEffect19, useRef as useRef6, useMemo as useMemo13 } from "react";
5508
5809
 
5509
5810
  // components/AutoFrame/index.tsx
5510
5811
  init_react_import();
5511
5812
  import {
5512
- createContext as createContext4,
5513
- useContext as useContext7,
5514
- useEffect as useEffect16,
5515
- useState as useState20
5813
+ createContext as createContext5,
5814
+ useContext as useContext10,
5815
+ useEffect as useEffect18,
5816
+ useState as useState21
5516
5817
  } from "react";
5517
5818
  import hash from "object-hash";
5518
5819
  import { createPortal as createPortal3 } from "react-dom";
5519
- import { Fragment as Fragment9, jsx as jsx30 } from "react/jsx-runtime";
5820
+ import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
5520
5821
  var styleSelector = 'style, link[rel="stylesheet"]';
5521
5822
  var collectStyles = (doc) => {
5522
5823
  const collected = [];
@@ -5559,7 +5860,7 @@ var CopyHostStyles = ({
5559
5860
  onStylesLoaded = () => null
5560
5861
  }) => {
5561
5862
  const { document: doc, window: win } = useFrame();
5562
- useEffect16(() => {
5863
+ useEffect18(() => {
5563
5864
  if (!win || !doc) {
5564
5865
  return () => {
5565
5866
  };
@@ -5716,10 +6017,10 @@ var CopyHostStyles = ({
5716
6017
  observer.disconnect();
5717
6018
  };
5718
6019
  }, []);
5719
- return /* @__PURE__ */ jsx30(Fragment9, { children });
6020
+ return /* @__PURE__ */ jsx31(Fragment9, { children });
5720
6021
  };
5721
- var autoFrameContext = createContext4({});
5722
- var useFrame = () => useContext7(autoFrameContext);
6022
+ var autoFrameContext = createContext5({});
6023
+ var useFrame = () => useContext10(autoFrameContext);
5723
6024
  function AutoFrame(_a) {
5724
6025
  var _b = _a, {
5725
6026
  children,
@@ -5736,10 +6037,10 @@ function AutoFrame(_a) {
5736
6037
  "onStylesLoaded",
5737
6038
  "frameRef"
5738
6039
  ]);
5739
- const [loaded, setLoaded] = useState20(false);
5740
- const [ctx, setCtx] = useState20({});
5741
- const [mountTarget, setMountTarget] = useState20();
5742
- useEffect16(() => {
6040
+ const [loaded, setLoaded] = useState21(false);
6041
+ const [ctx, setCtx] = useState21({});
6042
+ const [mountTarget, setMountTarget] = useState21();
6043
+ useEffect18(() => {
5743
6044
  var _a2;
5744
6045
  if (frameRef.current) {
5745
6046
  setCtx({
@@ -5751,7 +6052,7 @@ function AutoFrame(_a) {
5751
6052
  );
5752
6053
  }
5753
6054
  }, [frameRef, loaded]);
5754
- return /* @__PURE__ */ jsx30(
6055
+ return /* @__PURE__ */ jsx31(
5755
6056
  "iframe",
5756
6057
  __spreadProps(__spreadValues({}, props), {
5757
6058
  className,
@@ -5761,7 +6062,7 @@ function AutoFrame(_a) {
5761
6062
  onLoad: () => {
5762
6063
  setLoaded(true);
5763
6064
  },
5764
- children: /* @__PURE__ */ jsx30(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx30(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
6065
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
5765
6066
  })
5766
6067
  );
5767
6068
  }
@@ -5774,7 +6075,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
5774
6075
 
5775
6076
  // components/Render/index.tsx
5776
6077
  init_react_import();
5777
- import { jsx as jsx31 } from "react/jsx-runtime";
6078
+ import { jsx as jsx32 } from "react/jsx-runtime";
5778
6079
  function Render({
5779
6080
  config,
5780
6081
  data
@@ -5787,7 +6088,7 @@ function Render({
5787
6088
  const rootProps = defaultedData.root.props || defaultedData.root;
5788
6089
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
5789
6090
  if ((_a = config.root) == null ? void 0 : _a.render) {
5790
- return /* @__PURE__ */ jsx31(
6091
+ return /* @__PURE__ */ jsx32(
5791
6092
  DropZoneProvider,
5792
6093
  {
5793
6094
  value: {
@@ -5797,7 +6098,7 @@ function Render({
5797
6098
  depth: 0,
5798
6099
  path: []
5799
6100
  },
5800
- children: /* @__PURE__ */ jsx31(
6101
+ children: /* @__PURE__ */ jsx32(
5801
6102
  config.root.render,
5802
6103
  __spreadProps(__spreadValues({}, rootProps), {
5803
6104
  puck: {
@@ -5807,13 +6108,13 @@ function Render({
5807
6108
  title,
5808
6109
  editMode: false,
5809
6110
  id: "puck-root",
5810
- children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
6111
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
5811
6112
  })
5812
6113
  )
5813
6114
  }
5814
6115
  );
5815
6116
  }
5816
- return /* @__PURE__ */ jsx31(
6117
+ return /* @__PURE__ */ jsx32(
5817
6118
  DropZoneProvider,
5818
6119
  {
5819
6120
  value: {
@@ -5823,17 +6124,17 @@ function Render({
5823
6124
  depth: 0,
5824
6125
  path: []
5825
6126
  },
5826
- children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
6127
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
5827
6128
  }
5828
6129
  );
5829
6130
  }
5830
6131
 
5831
6132
  // components/Puck/components/Preview/index.tsx
5832
- import { Fragment as Fragment10, jsx as jsx32 } from "react/jsx-runtime";
6133
+ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
5833
6134
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
5834
6135
  var useBubbleIframeEvents = (ref) => {
5835
6136
  const { status } = useAppContext();
5836
- useEffect17(() => {
6137
+ useEffect19(() => {
5837
6138
  var _a;
5838
6139
  if (ref.current && status === "READY") {
5839
6140
  const iframe = ref.current;
@@ -5870,22 +6171,22 @@ var useBubbleIframeEvents = (ref) => {
5870
6171
  }
5871
6172
  }, [status]);
5872
6173
  };
5873
- var Preview = ({ id = "puck-preview" }) => {
6174
+ var Preview2 = ({ id = "puck-preview" }) => {
5874
6175
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
5875
- const Page = useCallback11(
6176
+ const Page = useCallback13(
5876
6177
  (pageProps) => {
5877
6178
  var _a, _b;
5878
6179
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
5879
6180
  id: "puck-root"
5880
- }, pageProps)) : /* @__PURE__ */ jsx32(Fragment10, { children: pageProps.children });
6181
+ }, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
5881
6182
  },
5882
6183
  [config.root]
5883
6184
  );
5884
- const Frame = useMemo12(() => overrides.iframe, [overrides]);
6185
+ const Frame = useMemo13(() => overrides.iframe, [overrides]);
5885
6186
  const rootProps = state.data.root.props || state.data.root;
5886
- const ref = useRef7(null);
6187
+ const ref = useRef6(null);
5887
6188
  useBubbleIframeEvents(ref);
5888
- const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx32(
6189
+ const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
5889
6190
  Page,
5890
6191
  __spreadProps(__spreadValues({}, rootProps), {
5891
6192
  puck: {
@@ -5894,10 +6195,10 @@ var Preview = ({ id = "puck-preview" }) => {
5894
6195
  dragRef: null
5895
6196
  },
5896
6197
  editMode: true,
5897
- children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6198
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
5898
6199
  })
5899
- ) : /* @__PURE__ */ jsx32(Render, { data: state.data, config });
5900
- return /* @__PURE__ */ jsx32(
6200
+ ) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
6201
+ return /* @__PURE__ */ jsx33(
5901
6202
  "div",
5902
6203
  {
5903
6204
  className: getClassName23(),
@@ -5906,7 +6207,7 @@ var Preview = ({ id = "puck-preview" }) => {
5906
6207
  onClick: () => {
5907
6208
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
5908
6209
  },
5909
- children: iframe.enabled ? /* @__PURE__ */ jsx32(
6210
+ children: iframe.enabled ? /* @__PURE__ */ jsx33(
5910
6211
  AutoFrame_default,
5911
6212
  {
5912
6213
  id: "preview-frame",
@@ -5916,14 +6217,14 @@ var Preview = ({ id = "puck-preview" }) => {
5916
6217
  setStatus("READY");
5917
6218
  },
5918
6219
  frameRef: ref,
5919
- children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6220
+ children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
5920
6221
  if (Frame) {
5921
- return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
6222
+ return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
5922
6223
  }
5923
6224
  return inner;
5924
6225
  } })
5925
6226
  }
5926
- ) : /* @__PURE__ */ jsx32(
6227
+ ) : /* @__PURE__ */ jsx33(
5927
6228
  "div",
5928
6229
  {
5929
6230
  id: "preview-frame",
@@ -5980,7 +6281,7 @@ var scrollIntoView = (el) => {
5980
6281
  };
5981
6282
 
5982
6283
  // components/LayerTree/index.tsx
5983
- import { useContext as useContext8 } from "react";
6284
+ import { useContext as useContext11 } from "react";
5984
6285
 
5985
6286
  // lib/is-child-of-zone.ts
5986
6287
  init_react_import();
@@ -6013,7 +6314,7 @@ var onScrollEnd = (frame, cb) => {
6013
6314
  };
6014
6315
 
6015
6316
  // components/LayerTree/index.tsx
6016
- import { Fragment as Fragment11, jsx as jsx33, jsxs as jsxs16 } from "react/jsx-runtime";
6317
+ import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
6017
6318
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
6018
6319
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
6019
6320
  var LayerTree = ({
@@ -6026,15 +6327,15 @@ var LayerTree = ({
6026
6327
  label
6027
6328
  }) => {
6028
6329
  const zones = data.zones || {};
6029
- const ctx = useContext8(dropZoneContext);
6330
+ const ctx = useContext11(dropZoneContext);
6030
6331
  return /* @__PURE__ */ jsxs16(Fragment11, { children: [
6031
6332
  label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
6032
- /* @__PURE__ */ jsx33("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
6333
+ /* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
6033
6334
  " ",
6034
6335
  label
6035
6336
  ] }),
6036
6337
  /* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
6037
- zoneContent.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName24("helper"), children: "No items" }),
6338
+ zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
6038
6339
  zoneContent.map((item, i) => {
6039
6340
  var _a;
6040
6341
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -6057,7 +6358,7 @@ var LayerTree = ({
6057
6358
  childIsSelected
6058
6359
  }),
6059
6360
  children: [
6060
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6361
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6061
6362
  "button",
6062
6363
  {
6063
6364
  type: "button",
@@ -6096,22 +6397,22 @@ var LayerTree = ({
6096
6397
  setHoveringComponent(null);
6097
6398
  },
6098
6399
  children: [
6099
- containsZone && /* @__PURE__ */ jsx33(
6400
+ containsZone && /* @__PURE__ */ jsx34(
6100
6401
  "div",
6101
6402
  {
6102
6403
  className: getClassNameLayer("chevron"),
6103
6404
  title: isSelected ? "Collapse" : "Expand",
6104
- children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
6405
+ children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
6105
6406
  }
6106
6407
  ),
6107
6408
  /* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
6108
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
6109
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label2 })
6409
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
6410
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
6110
6411
  ] })
6111
6412
  ]
6112
6413
  }
6113
6414
  ) }),
6114
- containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(
6415
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
6115
6416
  LayerTree,
6116
6417
  {
6117
6418
  config,
@@ -6133,13 +6434,13 @@ var LayerTree = ({
6133
6434
  };
6134
6435
 
6135
6436
  // components/Puck/components/Outline/index.tsx
6136
- import { useCallback as useCallback12, useMemo as useMemo13 } from "react";
6137
- import { Fragment as Fragment12, jsx as jsx34, jsxs as jsxs17 } from "react/jsx-runtime";
6437
+ import { useCallback as useCallback14, useMemo as useMemo14 } from "react";
6438
+ import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
6138
6439
  var Outline = () => {
6139
6440
  const { dispatch, state, overrides, config } = useAppContext();
6140
6441
  const { data, ui } = state;
6141
6442
  const { itemSelector } = ui;
6142
- const setItemSelector = useCallback12(
6443
+ const setItemSelector = useCallback14(
6143
6444
  (newItemSelector) => {
6144
6445
  dispatch({
6145
6446
  type: "setUi",
@@ -6148,9 +6449,9 @@ var Outline = () => {
6148
6449
  },
6149
6450
  []
6150
6451
  );
6151
- const Wrapper = useMemo13(() => overrides.outline || "div", [overrides]);
6152
- return /* @__PURE__ */ jsx34(Wrapper, { children: /* @__PURE__ */ jsx34(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6153
- (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx34(
6452
+ const Wrapper = useMemo14(() => overrides.outline || "div", [overrides]);
6453
+ return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6454
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
6154
6455
  LayerTree,
6155
6456
  {
6156
6457
  config,
@@ -6163,7 +6464,7 @@ var Outline = () => {
6163
6464
  ),
6164
6465
  Object.entries(findZonesForArea(data, "root")).map(
6165
6466
  ([zoneKey, zone]) => {
6166
- return /* @__PURE__ */ jsx34(
6467
+ return /* @__PURE__ */ jsx35(
6167
6468
  LayerTree,
6168
6469
  {
6169
6470
  config,
@@ -6262,19 +6563,19 @@ function usePuckHistory({
6262
6563
 
6263
6564
  // lib/use-history-store.ts
6264
6565
  init_react_import();
6265
- import { useState as useState21 } from "react";
6566
+ import { useState as useState22 } from "react";
6266
6567
  import { useDebouncedCallback as useDebouncedCallback3 } from "use-debounce";
6267
6568
  var EMPTY_HISTORY_INDEX = 0;
6268
6569
  function useHistoryStore(initialHistory) {
6269
6570
  var _a, _b;
6270
- const [histories, setHistories] = useState21(
6571
+ const [histories, setHistories] = useState22(
6271
6572
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
6272
6573
  );
6273
6574
  const updateHistories = (histories2) => {
6274
6575
  setHistories(histories2);
6275
6576
  setIndex(histories2.length - 1);
6276
6577
  };
6277
- const [index, setIndex] = useState21(
6578
+ const [index, setIndex] = useState22(
6278
6579
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
6279
6580
  );
6280
6581
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -6435,27 +6736,27 @@ var getBox = function getBox2(el) {
6435
6736
 
6436
6737
  // components/Puck/components/Canvas/index.tsx
6437
6738
  import {
6438
- useCallback as useCallback13,
6439
- useEffect as useEffect19,
6440
- useMemo as useMemo15,
6441
- useRef as useRef8,
6442
- useState as useState23
6739
+ useCallback as useCallback15,
6740
+ useEffect as useEffect21,
6741
+ useMemo as useMemo16,
6742
+ useRef as useRef7,
6743
+ useState as useState24
6443
6744
  } from "react";
6444
6745
 
6445
6746
  // components/ViewportControls/index.tsx
6446
6747
  init_react_import();
6447
- import { useEffect as useEffect18, useMemo as useMemo14, useState as useState22 } from "react";
6748
+ import { useEffect as useEffect20, useMemo as useMemo15, useState as useState23 } from "react";
6448
6749
 
6449
6750
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6450
6751
  init_react_import();
6451
6752
  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" };
6452
6753
 
6453
6754
  // components/ViewportControls/index.tsx
6454
- import { jsx as jsx35, jsxs as jsxs18 } from "react/jsx-runtime";
6755
+ import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
6455
6756
  var icons = {
6456
- Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
6457
- Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
6458
- Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
6757
+ Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
6758
+ Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
6759
+ Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
6459
6760
  };
6460
6761
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
6461
6762
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -6467,11 +6768,11 @@ var ViewportButton = ({
6467
6768
  onClick
6468
6769
  }) => {
6469
6770
  const { state } = useAppContext();
6470
- const [isActive, setIsActive] = useState22(false);
6471
- useEffect18(() => {
6771
+ const [isActive, setIsActive] = useState23(false);
6772
+ useEffect20(() => {
6472
6773
  setIsActive(width === state.ui.viewports.current.width);
6473
6774
  }, [width, state.ui.viewports.current.width]);
6474
- return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
6775
+ return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
6475
6776
  IconButton,
6476
6777
  {
6477
6778
  title,
@@ -6480,7 +6781,7 @@ var ViewportButton = ({
6480
6781
  e.stopPropagation();
6481
6782
  onClick({ width, height });
6482
6783
  },
6483
- children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
6784
+ children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
6484
6785
  }
6485
6786
  ) });
6486
6787
  };
@@ -6504,7 +6805,7 @@ var ViewportControls = ({
6504
6805
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6505
6806
  (option) => option.value === autoZoom
6506
6807
  );
6507
- const zoomOptions = useMemo14(
6808
+ const zoomOptions = useMemo15(
6508
6809
  () => [
6509
6810
  ...defaultZoomOptions,
6510
6811
  ...defaultsContainAutoZoom ? [] : [
@@ -6517,7 +6818,7 @@ var ViewportControls = ({
6517
6818
  [autoZoom]
6518
6819
  );
6519
6820
  return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
6520
- viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
6821
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
6521
6822
  ViewportButton,
6522
6823
  {
6523
6824
  height: viewport.height,
@@ -6528,8 +6829,8 @@ var ViewportControls = ({
6528
6829
  },
6529
6830
  i
6530
6831
  )),
6531
- /* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
6532
- /* @__PURE__ */ jsx35(
6832
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6833
+ /* @__PURE__ */ jsx36(
6533
6834
  IconButton,
6534
6835
  {
6535
6836
  title: "Zoom viewport out",
@@ -6543,10 +6844,10 @@ var ViewportControls = ({
6543
6844
  )].value
6544
6845
  );
6545
6846
  },
6546
- children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
6847
+ children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
6547
6848
  }
6548
6849
  ),
6549
- /* @__PURE__ */ jsx35(
6850
+ /* @__PURE__ */ jsx36(
6550
6851
  IconButton,
6551
6852
  {
6552
6853
  title: "Zoom viewport in",
@@ -6560,11 +6861,11 @@ var ViewportControls = ({
6560
6861
  )].value
6561
6862
  );
6562
6863
  },
6563
- children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
6864
+ children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
6564
6865
  }
6565
6866
  ),
6566
- /* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
6567
- /* @__PURE__ */ jsx35(
6867
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6868
+ /* @__PURE__ */ jsx36(
6568
6869
  "select",
6569
6870
  {
6570
6871
  className: getClassName25("zoomSelect"),
@@ -6572,7 +6873,7 @@ var ViewportControls = ({
6572
6873
  onChange: (e) => {
6573
6874
  onZoom(parseFloat(e.currentTarget.value));
6574
6875
  },
6575
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
6876
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
6576
6877
  "option",
6577
6878
  {
6578
6879
  value: option.value,
@@ -6620,24 +6921,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
6620
6921
  };
6621
6922
 
6622
6923
  // components/Puck/components/Canvas/index.tsx
6623
- import { Fragment as Fragment13, jsx as jsx36, jsxs as jsxs19 } from "react/jsx-runtime";
6924
+ import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
6624
6925
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
6625
6926
  var ZOOM_ON_CHANGE = true;
6626
6927
  var Canvas = () => {
6627
6928
  const { status, iframe } = useAppContext();
6628
6929
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
6629
6930
  const { ui } = state;
6630
- const frameRef = useRef8(null);
6631
- const [showTransition, setShowTransition] = useState23(false);
6632
- const defaultRender = useMemo15(() => {
6633
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment13, { children });
6931
+ const frameRef = useRef7(null);
6932
+ const [showTransition, setShowTransition] = useState24(false);
6933
+ const defaultRender = useMemo16(() => {
6934
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
6634
6935
  return PuckDefault;
6635
6936
  }, []);
6636
- const CustomPreview = useMemo15(
6937
+ const CustomPreview = useMemo16(
6637
6938
  () => overrides.preview || defaultRender,
6638
6939
  [overrides]
6639
6940
  );
6640
- const getFrameDimensions = useCallback13(() => {
6941
+ const getFrameDimensions = useCallback15(() => {
6641
6942
  if (frameRef.current) {
6642
6943
  const frame = frameRef.current;
6643
6944
  const box = getBox(frame);
@@ -6645,7 +6946,7 @@ var Canvas = () => {
6645
6946
  }
6646
6947
  return { width: 0, height: 0 };
6647
6948
  }, [frameRef]);
6648
- const resetAutoZoom = useCallback13(
6949
+ const resetAutoZoom = useCallback15(
6649
6950
  (ui2 = state.ui) => {
6650
6951
  if (frameRef.current) {
6651
6952
  setZoomConfig(
@@ -6655,11 +6956,11 @@ var Canvas = () => {
6655
6956
  },
6656
6957
  [frameRef, zoomConfig, state.ui]
6657
6958
  );
6658
- useEffect19(() => {
6959
+ useEffect21(() => {
6659
6960
  setShowTransition(false);
6660
6961
  resetAutoZoom();
6661
6962
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6662
- useEffect19(() => {
6963
+ useEffect21(() => {
6663
6964
  const { height: frameHeight } = getFrameDimensions();
6664
6965
  if (ui.viewports.current.height === "auto") {
6665
6966
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6667,13 +6968,13 @@ var Canvas = () => {
6667
6968
  }));
6668
6969
  }
6669
6970
  }, [zoomConfig.zoom]);
6670
- useEffect19(() => {
6971
+ useEffect21(() => {
6671
6972
  if (ZOOM_ON_CHANGE) {
6672
6973
  setShowTransition(true);
6673
6974
  resetAutoZoom(ui);
6674
6975
  }
6675
6976
  }, [ui.viewports.current.width]);
6676
- useEffect19(() => {
6977
+ useEffect21(() => {
6677
6978
  const cb = () => {
6678
6979
  setShowTransition(false);
6679
6980
  resetAutoZoom();
@@ -6683,8 +6984,8 @@ var Canvas = () => {
6683
6984
  window.removeEventListener("resize", cb);
6684
6985
  };
6685
6986
  }, []);
6686
- const [showLoader, setShowLoader] = useState23(false);
6687
- useEffect19(() => {
6987
+ const [showLoader, setShowLoader] = useState24(false);
6988
+ useEffect21(() => {
6688
6989
  setTimeout(() => {
6689
6990
  setShowLoader(true);
6690
6991
  }, 500);
@@ -6702,7 +7003,7 @@ var Canvas = () => {
6702
7003
  recordHistory: true
6703
7004
  }),
6704
7005
  children: [
6705
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx36(
7006
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
6706
7007
  ViewportControls,
6707
7008
  {
6708
7009
  autoZoom: zoomConfig.autoZoom,
@@ -6729,7 +7030,7 @@ var Canvas = () => {
6729
7030
  }
6730
7031
  ) }),
6731
7032
  /* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
6732
- /* @__PURE__ */ jsx36(
7033
+ /* @__PURE__ */ jsx37(
6733
7034
  "div",
6734
7035
  {
6735
7036
  className: getClassName26("root"),
@@ -6750,10 +7051,10 @@ var Canvas = () => {
6750
7051
  })
6751
7052
  );
6752
7053
  },
6753
- children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview, {}) })
7054
+ children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
6754
7055
  }
6755
7056
  ),
6756
- /* @__PURE__ */ jsx36("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
7057
+ /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
6757
7058
  ] })
6758
7059
  ]
6759
7060
  }
@@ -6762,7 +7063,7 @@ var Canvas = () => {
6762
7063
 
6763
7064
  // lib/use-loaded-overrides.ts
6764
7065
  init_react_import();
6765
- import { useMemo as useMemo16 } from "react";
7066
+ import { useMemo as useMemo17 } from "react";
6766
7067
 
6767
7068
  // lib/load-overrides.ts
6768
7069
  init_react_import();
@@ -6801,26 +7102,26 @@ var useLoadedOverrides = ({
6801
7102
  overrides,
6802
7103
  plugins
6803
7104
  }) => {
6804
- return useMemo16(() => {
7105
+ return useMemo17(() => {
6805
7106
  return loadOverrides({ overrides, plugins });
6806
7107
  }, [plugins, overrides]);
6807
7108
  };
6808
7109
 
6809
7110
  // components/DefaultOverride/index.tsx
6810
7111
  init_react_import();
6811
- import { Fragment as Fragment14, jsx as jsx37 } from "react/jsx-runtime";
6812
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment14, { children });
7112
+ import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
7113
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
6813
7114
 
6814
7115
  // lib/use-inject-css.ts
6815
7116
  init_react_import();
6816
- import { useEffect as useEffect20, useState as useState24 } from "react";
7117
+ import { useEffect as useEffect22, useState as useState25 } from "react";
6817
7118
  var styles = ``;
6818
7119
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
6819
- const [el, setEl] = useState24();
6820
- useEffect20(() => {
7120
+ const [el, setEl] = useState25();
7121
+ useEffect22(() => {
6821
7122
  setEl(document.createElement("style"));
6822
7123
  }, []);
6823
- useEffect20(() => {
7124
+ useEffect22(() => {
6824
7125
  var _a;
6825
7126
  if (!el || typeof window === "undefined") {
6826
7127
  return;
@@ -6840,10 +7141,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
6840
7141
 
6841
7142
  // lib/use-preview-mode-hotkeys.ts
6842
7143
  init_react_import();
6843
- import { useCallback as useCallback14 } from "react";
7144
+ import { useCallback as useCallback16 } from "react";
6844
7145
  import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
6845
7146
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
6846
- const toggleInteractive = useCallback14(() => {
7147
+ const toggleInteractive = useCallback16(() => {
6847
7148
  dispatch({
6848
7149
  type: "setUi",
6849
7150
  ui: (ui) => ({
@@ -6866,7 +7167,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
6866
7167
  };
6867
7168
 
6868
7169
  // components/Puck/index.tsx
6869
- import { Fragment as Fragment15, jsx as jsx38, jsxs as jsxs20 } from "react/jsx-runtime";
7170
+ import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
6870
7171
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
6871
7172
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
6872
7173
  function Puck({
@@ -6895,7 +7196,7 @@ function Puck({
6895
7196
  waitForStyles: true
6896
7197
  }, _iframe);
6897
7198
  useInjectGlobalCss(iframe.enabled);
6898
- const [generatedAppState] = useState25(() => {
7199
+ const [generatedAppState] = useState26(() => {
6899
7200
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
6900
7201
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
6901
7202
  let clientUiState = {};
@@ -6967,7 +7268,7 @@ function Puck({
6967
7268
  histories,
6968
7269
  index: initialHistoryIndex
6969
7270
  });
6970
- const [reducer] = useState25(
7271
+ const [reducer] = useState26(
6971
7272
  () => createReducer({
6972
7273
  config,
6973
7274
  record: historyStore.record,
@@ -6985,14 +7286,14 @@ function Puck({
6985
7286
  historyStore,
6986
7287
  iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
6987
7288
  });
6988
- const [menuOpen, setMenuOpen] = useState25(false);
7289
+ const [menuOpen, setMenuOpen] = useState26(false);
6989
7290
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
6990
7291
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
6991
- useEffect21(() => {
7292
+ useEffect23(() => {
6992
7293
  if (onChange) onChange(data);
6993
7294
  }, [data]);
6994
7295
  const rootProps = data.root.props || data.root;
6995
- const toggleSidebars = useCallback15(
7296
+ const toggleSidebars = useCallback17(
6996
7297
  (sidebar) => {
6997
7298
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
6998
7299
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7006,7 +7307,7 @@ function Puck({
7006
7307
  },
7007
7308
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7008
7309
  );
7009
- useEffect21(() => {
7310
+ useEffect23(() => {
7010
7311
  if (!window.matchMedia("(min-width: 638px)").matches) {
7011
7312
  dispatch({
7012
7313
  type: "setUi",
@@ -7029,7 +7330,7 @@ function Puck({
7029
7330
  window.removeEventListener("resize", handleResize);
7030
7331
  };
7031
7332
  }, []);
7032
- const defaultHeaderRender = useMemo17(() => {
7333
+ const defaultHeaderRender = useMemo18(() => {
7033
7334
  if (renderHeader) {
7034
7335
  console.warn(
7035
7336
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7037,20 +7338,20 @@ function Puck({
7037
7338
  const RenderHeader = (_a2) => {
7038
7339
  var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
7039
7340
  const Comp = renderHeader;
7040
- return /* @__PURE__ */ jsx38(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7341
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7041
7342
  };
7042
7343
  return RenderHeader;
7043
7344
  }
7044
7345
  return DefaultOverride;
7045
7346
  }, [renderHeader]);
7046
- const defaultHeaderActionsRender = useMemo17(() => {
7347
+ const defaultHeaderActionsRender = useMemo18(() => {
7047
7348
  if (renderHeaderActions) {
7048
7349
  console.warn(
7049
7350
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7050
7351
  );
7051
7352
  const RenderHeader = (props) => {
7052
7353
  const Comp = renderHeaderActions;
7053
- return /* @__PURE__ */ jsx38(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7354
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7054
7355
  };
7055
7356
  return RenderHeader;
7056
7357
  }
@@ -7060,27 +7361,27 @@ function Puck({
7060
7361
  overrides,
7061
7362
  plugins
7062
7363
  });
7063
- const CustomPuck = useMemo17(
7364
+ const CustomPuck = useMemo18(
7064
7365
  () => loadedOverrides.puck || DefaultOverride,
7065
7366
  [loadedOverrides]
7066
7367
  );
7067
- const CustomHeader = useMemo17(
7368
+ const CustomHeader = useMemo18(
7068
7369
  () => loadedOverrides.header || defaultHeaderRender,
7069
7370
  [loadedOverrides]
7070
7371
  );
7071
- const CustomHeaderActions = useMemo17(
7372
+ const CustomHeaderActions = useMemo18(
7072
7373
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7073
7374
  [loadedOverrides]
7074
7375
  );
7075
- const [mounted, setMounted] = useState25(false);
7076
- useEffect21(() => {
7376
+ const [mounted, setMounted] = useState26(false);
7377
+ useEffect23(() => {
7077
7378
  setMounted(true);
7078
7379
  }, []);
7079
7380
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
7080
7381
  const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
7081
7382
  usePreviewModeHotkeys(dispatch, iframe.enabled);
7082
7383
  return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
7083
- /* @__PURE__ */ jsx38(
7384
+ /* @__PURE__ */ jsx39(
7084
7385
  AppProvider,
7085
7386
  {
7086
7387
  value: {
@@ -7102,7 +7403,7 @@ function Puck({
7102
7403
  getPermissions: () => ({}),
7103
7404
  refreshPermissions: () => null
7104
7405
  },
7105
- children: /* @__PURE__ */ jsx38(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx38(CustomPuck, { children: children || /* @__PURE__ */ jsx38(
7406
+ children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
7106
7407
  "div",
7107
7408
  {
7108
7409
  className: getLayoutClassName({
@@ -7112,59 +7413,59 @@ function Puck({
7112
7413
  rightSideBarVisible
7113
7414
  }),
7114
7415
  children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
7115
- /* @__PURE__ */ jsx38(
7416
+ /* @__PURE__ */ jsx39(
7116
7417
  CustomHeader,
7117
7418
  {
7118
- actions: /* @__PURE__ */ jsx38(Fragment15, { children: /* @__PURE__ */ jsx38(CustomHeaderActions, { children: /* @__PURE__ */ jsx38(
7419
+ actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7119
7420
  Button,
7120
7421
  {
7121
7422
  onClick: () => {
7122
7423
  onPublish && onPublish(data);
7123
7424
  },
7124
- icon: /* @__PURE__ */ jsx38(Globe, { size: "14px" }),
7425
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7125
7426
  children: "Publish"
7126
7427
  }
7127
7428
  ) }) }),
7128
- children: /* @__PURE__ */ jsx38("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7429
+ children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7129
7430
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
7130
- /* @__PURE__ */ jsx38(
7431
+ /* @__PURE__ */ jsx39(
7131
7432
  "div",
7132
7433
  {
7133
7434
  className: getLayoutClassName("leftSideBarToggle"),
7134
- children: /* @__PURE__ */ jsx38(
7435
+ children: /* @__PURE__ */ jsx39(
7135
7436
  IconButton,
7136
7437
  {
7137
7438
  onClick: () => {
7138
7439
  toggleSidebars("left");
7139
7440
  },
7140
7441
  title: "Toggle left sidebar",
7141
- children: /* @__PURE__ */ jsx38(PanelLeft, { focusable: "false" })
7442
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7142
7443
  }
7143
7444
  )
7144
7445
  }
7145
7446
  ),
7146
- /* @__PURE__ */ jsx38(
7447
+ /* @__PURE__ */ jsx39(
7147
7448
  "div",
7148
7449
  {
7149
7450
  className: getLayoutClassName("rightSideBarToggle"),
7150
- children: /* @__PURE__ */ jsx38(
7451
+ children: /* @__PURE__ */ jsx39(
7151
7452
  IconButton,
7152
7453
  {
7153
7454
  onClick: () => {
7154
7455
  toggleSidebars("right");
7155
7456
  },
7156
7457
  title: "Toggle right sidebar",
7157
- children: /* @__PURE__ */ jsx38(PanelRight, { focusable: "false" })
7458
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7158
7459
  }
7159
7460
  )
7160
7461
  }
7161
7462
  )
7162
7463
  ] }),
7163
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7464
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7164
7465
  headerTitle || rootProps.title || "Page",
7165
7466
  headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
7166
7467
  " ",
7167
- /* @__PURE__ */ jsx38(
7468
+ /* @__PURE__ */ jsx39(
7168
7469
  "code",
7169
7470
  {
7170
7471
  className: getLayoutClassName("headerPath"),
@@ -7174,30 +7475,30 @@ function Puck({
7174
7475
  ] })
7175
7476
  ] }) }),
7176
7477
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
7177
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx38(
7478
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
7178
7479
  IconButton,
7179
7480
  {
7180
7481
  onClick: () => {
7181
7482
  return setMenuOpen(!menuOpen);
7182
7483
  },
7183
7484
  title: "Toggle menu bar",
7184
- children: menuOpen ? /* @__PURE__ */ jsx38(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx38(ChevronDown, { focusable: "false" })
7485
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7185
7486
  }
7186
7487
  ) }),
7187
- /* @__PURE__ */ jsx38(
7488
+ /* @__PURE__ */ jsx39(
7188
7489
  MenuBar,
7189
7490
  {
7190
7491
  appState,
7191
7492
  dispatch,
7192
7493
  onPublish,
7193
7494
  menuOpen,
7194
- renderHeaderActions: () => /* @__PURE__ */ jsx38(CustomHeaderActions, { children: /* @__PURE__ */ jsx38(
7495
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7195
7496
  Button,
7196
7497
  {
7197
7498
  onClick: () => {
7198
7499
  onPublish && onPublish(data);
7199
7500
  },
7200
- icon: /* @__PURE__ */ jsx38(Globe, { size: "14px" }),
7501
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7201
7502
  children: "Publish"
7202
7503
  }
7203
7504
  ) }),
@@ -7209,18 +7510,18 @@ function Puck({
7209
7510
  }
7210
7511
  ),
7211
7512
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
7212
- /* @__PURE__ */ jsx38(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx38(Components, {}) }),
7213
- /* @__PURE__ */ jsx38(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx38(Outline, {}) })
7513
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
7514
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
7214
7515
  ] }),
7215
- /* @__PURE__ */ jsx38(Canvas, {}),
7216
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx38(
7516
+ /* @__PURE__ */ jsx39(Canvas, {}),
7517
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
7217
7518
  SidebarSection,
7218
7519
  {
7219
7520
  noPadding: true,
7220
7521
  noBorderTop: true,
7221
7522
  showBreadcrumbs: true,
7222
7523
  title: selectedItem ? selectedComponentLabel : "Page",
7223
- children: /* @__PURE__ */ jsx38(Fields, {})
7524
+ children: /* @__PURE__ */ jsx39(Fields, {})
7224
7525
  }
7225
7526
  ) })
7226
7527
  ] })
@@ -7228,13 +7529,13 @@ function Puck({
7228
7529
  ) }) })
7229
7530
  }
7230
7531
  ),
7231
- /* @__PURE__ */ jsx38("div", { id: "puck-portal-root", className: getClassName27("portal") })
7532
+ /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
7232
7533
  ] });
7233
7534
  }
7234
7535
  Puck.Components = Components;
7235
7536
  Puck.Fields = Fields;
7236
7537
  Puck.Outline = Outline;
7237
- Puck.Preview = Preview;
7538
+ Puck.Preview = Preview2;
7238
7539
 
7239
7540
  // lib/migrate.ts
7240
7541
  init_react_import();