@measured/puck 0.18.0-canary.e6e29ad → 0.18.0-canary.f1dec0e

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({
@@ -205,13 +205,14 @@ init_react_import();
205
205
 
206
206
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
207
207
  init_react_import();
208
- var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
208
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
209
209
 
210
210
  // components/AutoField/index.tsx
211
211
  import {
212
212
  useCallback as useCallback5,
213
+ useContext as useContext3,
213
214
  useEffect as useEffect9,
214
- useMemo as useMemo4,
215
+ useMemo as useMemo5,
215
216
  useState as useState11
216
217
  } from "react";
217
218
 
@@ -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,28 +1498,29 @@ 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,
1442
1505
  onChange,
1443
1506
  readOnly,
1444
- value,
1507
+ value: _value,
1445
1508
  name,
1446
1509
  label,
1447
1510
  Label: Label2,
1448
1511
  id
1449
1512
  }) => {
1450
- return /* @__PURE__ */ jsx8(
1513
+ const value = _value;
1514
+ return /* @__PURE__ */ jsx9(
1451
1515
  Label2,
1452
1516
  {
1453
1517
  label: label || name,
1454
1518
  icon: /* @__PURE__ */ jsxs4(Fragment2, { children: [
1455
- field.type === "text" && /* @__PURE__ */ jsx8(Type, { size: 16 }),
1456
- field.type === "number" && /* @__PURE__ */ jsx8(Hash, { size: 16 })
1519
+ field.type === "text" && /* @__PURE__ */ jsx9(Type, { size: 16 }),
1520
+ field.type === "number" && /* @__PURE__ */ jsx9(Hash, { size: 16 })
1457
1521
  ] }),
1458
1522
  readOnly,
1459
- children: /* @__PURE__ */ jsx8(
1523
+ children: /* @__PURE__ */ jsx9(
1460
1524
  "input",
1461
1525
  {
1462
1526
  className: getClassName6("input"),
@@ -1464,10 +1528,17 @@ var DefaultField = ({
1464
1528
  type: field.type,
1465
1529
  title: label || name,
1466
1530
  name,
1467
- value: typeof value === "undefined" ? "" : value.toString(),
1531
+ value: (value == null ? void 0 : value.toString) ? value.toString() : "",
1468
1532
  onChange: (e) => {
1469
1533
  if (field.type === "number") {
1470
- onChange(Number(e.currentTarget.value));
1534
+ const numberValue = Number(e.currentTarget.value);
1535
+ if (typeof field.min !== "undefined" && numberValue < field.min) {
1536
+ return;
1537
+ }
1538
+ if (typeof field.max !== "undefined" && numberValue > field.max) {
1539
+ return;
1540
+ }
1541
+ onChange(numberValue);
1471
1542
  } else {
1472
1543
  onChange(e.currentTarget.value);
1473
1544
  }
@@ -1490,7 +1561,7 @@ import { useEffect as useEffect8 } from "react";
1490
1561
  // components/ExternalInput/index.tsx
1491
1562
  init_react_import();
1492
1563
  import {
1493
- useMemo,
1564
+ useMemo as useMemo2,
1494
1565
  useEffect as useEffect7,
1495
1566
  useState as useState9,
1496
1567
  useCallback as useCallback4,
@@ -1511,7 +1582,7 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
1511
1582
 
1512
1583
  // components/Modal/index.tsx
1513
1584
  import { createPortal } from "react-dom";
1514
- import { jsx as jsx9 } from "react/jsx-runtime";
1585
+ import { jsx as jsx10 } from "react/jsx-runtime";
1515
1586
  var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
1516
1587
  var Modal = ({
1517
1588
  children,
@@ -1523,10 +1594,10 @@ var Modal = ({
1523
1594
  setRootEl(document.getElementById("puck-portal-root"));
1524
1595
  }, []);
1525
1596
  if (!rootEl) {
1526
- return /* @__PURE__ */ jsx9("div", {});
1597
+ return /* @__PURE__ */ jsx10("div", {});
1527
1598
  }
1528
1599
  return createPortal(
1529
- /* @__PURE__ */ jsx9("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx9(
1600
+ /* @__PURE__ */ jsx10("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx10(
1530
1601
  "div",
1531
1602
  {
1532
1603
  className: getClassName7("inner"),
@@ -1546,11 +1617,11 @@ init_react_import();
1546
1617
  var styles_module_default8 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
1547
1618
 
1548
1619
  // components/Heading/index.tsx
1549
- import { jsx as jsx10 } from "react/jsx-runtime";
1620
+ import { jsx as jsx11 } from "react/jsx-runtime";
1550
1621
  var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
1551
1622
  var Heading = ({ children, rank, size = "m" }) => {
1552
1623
  const Tag = rank ? `h${rank}` : "span";
1553
- return /* @__PURE__ */ jsx10(
1624
+ return /* @__PURE__ */ jsx11(
1554
1625
  Tag,
1555
1626
  {
1556
1627
  className: getClassName8({
@@ -1586,7 +1657,7 @@ var filterDataAttrs = (props) => {
1586
1657
  };
1587
1658
 
1588
1659
  // components/Button/Button.tsx
1589
- import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
1660
+ import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
1590
1661
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
1591
1662
  var Button = (_a) => {
1592
1663
  var _b = _a, {
@@ -1645,9 +1716,9 @@ var Button = (_a) => {
1645
1716
  href
1646
1717
  }, dataAttrs), {
1647
1718
  children: [
1648
- icon && /* @__PURE__ */ jsx11("div", { className: getClassName9("icon"), children: icon }),
1719
+ icon && /* @__PURE__ */ jsx12("div", { className: getClassName9("icon"), children: icon }),
1649
1720
  children,
1650
- loading && /* @__PURE__ */ jsx11("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx11(Loader, { size: 14 }) })
1721
+ loading && /* @__PURE__ */ jsx12("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx12(Loader, { size: 14 }) })
1651
1722
  ]
1652
1723
  })
1653
1724
  );
@@ -1655,7 +1726,7 @@ var Button = (_a) => {
1655
1726
  };
1656
1727
 
1657
1728
  // components/ExternalInput/index.tsx
1658
- import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
1729
+ import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
1659
1730
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
1660
1731
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
1661
1732
  var dataCache = {};
@@ -1678,10 +1749,10 @@ var ExternalInput = ({
1678
1749
  const hasFilterFields = !!filterFields;
1679
1750
  const [filters, setFilters] = useState9(field.initialFilters || {});
1680
1751
  const [filtersToggled, setFiltersToggled] = useState9(hasFilterFields);
1681
- const mappedData = useMemo(() => {
1752
+ const mappedData = useMemo2(() => {
1682
1753
  return data.map(mapRow);
1683
1754
  }, [data]);
1684
- const keys = useMemo(() => {
1755
+ const keys = useMemo2(() => {
1685
1756
  const validKeys = /* @__PURE__ */ new Set();
1686
1757
  for (const item of mappedData) {
1687
1758
  for (const key of Object.keys(item)) {
@@ -1728,7 +1799,7 @@ var ExternalInput = ({
1728
1799
  id,
1729
1800
  children: [
1730
1801
  /* @__PURE__ */ jsxs6("div", { className: getClassName10("actions"), children: [
1731
- /* @__PURE__ */ jsx12(
1802
+ /* @__PURE__ */ jsx13(
1732
1803
  "button",
1733
1804
  {
1734
1805
  type: "button",
@@ -1736,12 +1807,12 @@ var ExternalInput = ({
1736
1807
  className: getClassName10("button"),
1737
1808
  disabled: readOnly,
1738
1809
  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 })
1810
+ /* @__PURE__ */ jsx13(Link, { size: "16" }),
1811
+ /* @__PURE__ */ jsx13("span", { children: field.placeholder })
1741
1812
  ] })
1742
1813
  }
1743
1814
  ),
1744
- value && /* @__PURE__ */ jsx12(
1815
+ value && /* @__PURE__ */ jsx13(
1745
1816
  "button",
1746
1817
  {
1747
1818
  type: "button",
@@ -1750,11 +1821,11 @@ var ExternalInput = ({
1750
1821
  onChange(null);
1751
1822
  },
1752
1823
  disabled: readOnly,
1753
- children: /* @__PURE__ */ jsx12(LockOpen, { size: 16 })
1824
+ children: /* @__PURE__ */ jsx13(LockOpen, { size: 16 })
1754
1825
  }
1755
1826
  )
1756
1827
  ] }),
1757
- /* @__PURE__ */ jsx12(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
1828
+ /* @__PURE__ */ jsx13(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
1758
1829
  "form",
1759
1830
  {
1760
1831
  className: getClassNameModal({
@@ -1768,11 +1839,11 @@ var ExternalInput = ({
1768
1839
  search(searchQuery, filters);
1769
1840
  },
1770
1841
  children: [
1771
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
1842
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
1772
1843
  /* @__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(
1844
+ /* @__PURE__ */ jsx13("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
1845
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx13(Search, { size: "18" }) }),
1846
+ /* @__PURE__ */ jsx13(
1776
1847
  "input",
1777
1848
  {
1778
1849
  className: getClassNameModal("searchInput"),
@@ -1788,8 +1859,8 @@ var ExternalInput = ({
1788
1859
  )
1789
1860
  ] }),
1790
1861
  /* @__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(
1862
+ /* @__PURE__ */ jsx13(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
1863
+ hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx13(
1793
1864
  IconButton,
1794
1865
  {
1795
1866
  title: "Toggle filters",
@@ -1798,15 +1869,15 @@ var ExternalInput = ({
1798
1869
  e.stopPropagation();
1799
1870
  setFiltersToggled(!filtersToggled);
1800
1871
  },
1801
- children: /* @__PURE__ */ jsx12(SlidersHorizontal, { size: 20 })
1872
+ children: /* @__PURE__ */ jsx13(SlidersHorizontal, { size: 20 })
1802
1873
  }
1803
1874
  ) })
1804
1875
  ] })
1805
- ] }) : /* @__PURE__ */ jsx12(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
1876
+ ] }) : /* @__PURE__ */ jsx13(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
1806
1877
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("grid"), children: [
1807
- hasFilterFields && /* @__PURE__ */ jsx12("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1878
+ hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1808
1879
  const filterField = filterFields[fieldName];
1809
- return /* @__PURE__ */ jsx12(
1880
+ return /* @__PURE__ */ jsx13(
1810
1881
  AutoFieldPrivate,
1811
1882
  {
1812
1883
  field: filterField,
@@ -1825,7 +1896,7 @@ var ExternalInput = ({
1825
1896
  }) }),
1826
1897
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("tableWrapper"), children: [
1827
1898
  /* @__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(
1899
+ /* @__PURE__ */ jsx13("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx13("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx13(
1829
1900
  "th",
1830
1901
  {
1831
1902
  className: getClassNameModal("th"),
@@ -1834,8 +1905,8 @@ var ExternalInput = ({
1834
1905
  },
1835
1906
  key
1836
1907
  )) }) }),
1837
- /* @__PURE__ */ jsx12("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
1838
- return /* @__PURE__ */ jsx12(
1908
+ /* @__PURE__ */ jsx13("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
1909
+ return /* @__PURE__ */ jsx13(
1839
1910
  "tr",
1840
1911
  {
1841
1912
  style: { whiteSpace: "nowrap" },
@@ -1844,16 +1915,16 @@ var ExternalInput = ({
1844
1915
  onChange(mapProp(data[i]));
1845
1916
  setOpen(false);
1846
1917
  },
1847
- children: keys.map((key) => /* @__PURE__ */ jsx12("td", { className: getClassNameModal("td"), children: item[key] }, key))
1918
+ children: keys.map((key) => /* @__PURE__ */ jsx13("td", { className: getClassNameModal("td"), children: item[key] }, key))
1848
1919
  },
1849
1920
  i
1850
1921
  );
1851
1922
  }) })
1852
1923
  ] }),
1853
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx12(Loader, { size: 24 }) })
1924
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx13(Loader, { size: 24 }) })
1854
1925
  ] })
1855
1926
  ] }),
1856
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx12(Footer, { items: mappedData }) })
1927
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx13(Footer, { items: mappedData }) })
1857
1928
  ]
1858
1929
  }
1859
1930
  ) })
@@ -1863,7 +1934,7 @@ var ExternalInput = ({
1863
1934
  };
1864
1935
 
1865
1936
  // components/AutoField/fields/ExternalField/index.tsx
1866
- import { jsx as jsx13 } from "react/jsx-runtime";
1937
+ import { jsx as jsx14 } from "react/jsx-runtime";
1867
1938
  var ExternalField = ({
1868
1939
  field,
1869
1940
  onChange,
@@ -1887,7 +1958,7 @@ var ExternalField = ({
1887
1958
  if (field.type !== "external") {
1888
1959
  return null;
1889
1960
  }
1890
- return /* @__PURE__ */ jsx13(Label2, { label: label || name, icon: /* @__PURE__ */ jsx13(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx13(
1961
+ return /* @__PURE__ */ jsx14(Label2, { label: label || name, icon: /* @__PURE__ */ jsx14(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx14(
1891
1962
  ExternalInput,
1892
1963
  {
1893
1964
  name,
@@ -1912,7 +1983,7 @@ var ExternalField = ({
1912
1983
 
1913
1984
  // components/AutoField/fields/RadioField/index.tsx
1914
1985
  init_react_import();
1915
- import { useMemo as useMemo2 } from "react";
1986
+ import { useMemo as useMemo3 } from "react";
1916
1987
 
1917
1988
  // lib/safe-json-parse.ts
1918
1989
  init_react_import();
@@ -1926,7 +1997,7 @@ var safeJsonParse = (str) => {
1926
1997
  };
1927
1998
 
1928
1999
  // components/AutoField/fields/RadioField/index.tsx
1929
- import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
2000
+ import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
1930
2001
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
1931
2002
  var RadioField = ({
1932
2003
  field,
@@ -1938,26 +2009,26 @@ var RadioField = ({
1938
2009
  label,
1939
2010
  Label: Label2
1940
2011
  }) => {
1941
- const flatOptions = useMemo2(
2012
+ const flatOptions = useMemo3(
1942
2013
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
1943
2014
  [field]
1944
2015
  );
1945
2016
  if (field.type !== "radio" || !field.options) {
1946
2017
  return null;
1947
2018
  }
1948
- return /* @__PURE__ */ jsx14(
2019
+ return /* @__PURE__ */ jsx15(
1949
2020
  Label2,
1950
2021
  {
1951
- icon: /* @__PURE__ */ jsx14(CircleCheckBig, { size: 16 }),
2022
+ icon: /* @__PURE__ */ jsx15(CircleCheckBig, { size: 16 }),
1952
2023
  label: label || name,
1953
2024
  readOnly,
1954
2025
  el: "div",
1955
- children: /* @__PURE__ */ jsx14("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs7(
2026
+ children: /* @__PURE__ */ jsx15("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs7(
1956
2027
  "label",
1957
2028
  {
1958
2029
  className: getClassName11("radio"),
1959
2030
  children: [
1960
- /* @__PURE__ */ jsx14(
2031
+ /* @__PURE__ */ jsx15(
1961
2032
  "input",
1962
2033
  {
1963
2034
  type: "radio",
@@ -1977,7 +2048,7 @@ var RadioField = ({
1977
2048
  checked: value === option.value
1978
2049
  }
1979
2050
  ),
1980
- /* @__PURE__ */ jsx14("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2051
+ /* @__PURE__ */ jsx15("div", { className: getClassName11("radioInner"), children: option.label || option.value })
1981
2052
  ]
1982
2053
  },
1983
2054
  option.label + option.value
@@ -1988,8 +2059,8 @@ var RadioField = ({
1988
2059
 
1989
2060
  // components/AutoField/fields/SelectField/index.tsx
1990
2061
  init_react_import();
1991
- import { useMemo as useMemo3 } from "react";
1992
- import { jsx as jsx15 } from "react/jsx-runtime";
2062
+ import { useMemo as useMemo4 } from "react";
2063
+ import { jsx as jsx16 } from "react/jsx-runtime";
1993
2064
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
1994
2065
  var SelectField = ({
1995
2066
  field,
@@ -2001,20 +2072,20 @@ var SelectField = ({
2001
2072
  readOnly,
2002
2073
  id
2003
2074
  }) => {
2004
- const flatOptions = useMemo3(
2075
+ const flatOptions = useMemo4(
2005
2076
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
2006
2077
  [field]
2007
2078
  );
2008
2079
  if (field.type !== "select" || !field.options) {
2009
2080
  return null;
2010
2081
  }
2011
- return /* @__PURE__ */ jsx15(
2082
+ return /* @__PURE__ */ jsx16(
2012
2083
  Label2,
2013
2084
  {
2014
2085
  label: label || name,
2015
- icon: /* @__PURE__ */ jsx15(ChevronDown, { size: 16 }),
2086
+ icon: /* @__PURE__ */ jsx16(ChevronDown, { size: 16 }),
2016
2087
  readOnly,
2017
- children: /* @__PURE__ */ jsx15(
2088
+ children: /* @__PURE__ */ jsx16(
2018
2089
  "select",
2019
2090
  {
2020
2091
  id,
@@ -2031,7 +2102,7 @@ var SelectField = ({
2031
2102
  }
2032
2103
  },
2033
2104
  value,
2034
- children: field.options.map((option) => /* @__PURE__ */ jsx15(
2105
+ children: field.options.map((option) => /* @__PURE__ */ jsx16(
2035
2106
  "option",
2036
2107
  {
2037
2108
  label: option.label,
@@ -2047,7 +2118,7 @@ var SelectField = ({
2047
2118
 
2048
2119
  // components/AutoField/fields/TextareaField/index.tsx
2049
2120
  init_react_import();
2050
- import { jsx as jsx16 } from "react/jsx-runtime";
2121
+ import { jsx as jsx17 } from "react/jsx-runtime";
2051
2122
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
2052
2123
  var TextareaField = ({
2053
2124
  onChange,
@@ -2058,7 +2129,7 @@ var TextareaField = ({
2058
2129
  Label: Label2,
2059
2130
  id
2060
2131
  }) => {
2061
- return /* @__PURE__ */ jsx16(Label2, { label: label || name, icon: /* @__PURE__ */ jsx16(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx16(
2132
+ return /* @__PURE__ */ jsx17(Label2, { label: label || name, icon: /* @__PURE__ */ jsx17(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx17(
2062
2133
  "textarea",
2063
2134
  {
2064
2135
  id,
@@ -2085,7 +2156,7 @@ init_react_import();
2085
2156
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
2086
2157
 
2087
2158
  // components/AutoField/fields/ObjectField/index.tsx
2088
- import { jsx as jsx17 } from "react/jsx-runtime";
2159
+ import { jsx as jsx18 } from "react/jsx-runtime";
2089
2160
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
2090
2161
  var ObjectField = ({
2091
2162
  field,
@@ -2097,43 +2168,54 @@ var ObjectField = ({
2097
2168
  readOnly,
2098
2169
  id
2099
2170
  }) => {
2100
- const { selectedItem } = useAppContext();
2171
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
2101
2172
  if (field.type !== "object" || !field.objectFields) {
2102
2173
  return null;
2103
2174
  }
2104
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
2105
2175
  const data = value || {};
2106
- return /* @__PURE__ */ jsx17(
2176
+ return /* @__PURE__ */ jsx18(
2107
2177
  Label2,
2108
2178
  {
2109
2179
  label: label || name,
2110
- icon: /* @__PURE__ */ jsx17(EllipsisVertical, { size: 16 }),
2180
+ icon: /* @__PURE__ */ jsx18(EllipsisVertical, { size: 16 }),
2111
2181
  el: "div",
2112
2182
  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,
2183
+ children: /* @__PURE__ */ jsx18("div", { className: getClassName14(), children: /* @__PURE__ */ jsx18("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
2184
+ const subField = field.objectFields[subName];
2185
+ const subPath = `${name}.${subName}`;
2186
+ const localSubPath = `${localName || name}.${subName}`;
2187
+ const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
2188
+ const label2 = subField.label || subName;
2189
+ return /* @__PURE__ */ jsx18(
2190
+ NestedFieldProvider,
2120
2191
  {
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
2192
+ name: localName || id,
2193
+ subName,
2194
+ readOnlyFields,
2195
+ children: /* @__PURE__ */ jsx18(
2196
+ AutoFieldPrivate,
2197
+ {
2198
+ name: subPath,
2199
+ label: subPath,
2200
+ id: `${id}_${subName}`,
2201
+ readOnly: subReadOnly,
2202
+ field: __spreadProps(__spreadValues({}, subField), {
2203
+ label: label2
2204
+ // May be used by custom fields
2131
2205
  }),
2132
- ui
2133
- );
2134
- }
2206
+ value: data[subName],
2207
+ onChange: (val, ui) => {
2208
+ onChange(
2209
+ __spreadProps(__spreadValues({}, data), {
2210
+ [subName]: val
2211
+ }),
2212
+ ui
2213
+ );
2214
+ }
2215
+ }
2216
+ )
2135
2217
  },
2136
- subFieldName
2218
+ subPath
2137
2219
  );
2138
2220
  }) }) })
2139
2221
  }
@@ -2159,7 +2241,7 @@ var useSafeId = () => {
2159
2241
  };
2160
2242
 
2161
2243
  // components/AutoField/index.tsx
2162
- import { Fragment as Fragment4, jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
2244
+ import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
2163
2245
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2164
2246
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2165
2247
  var FieldLabel = ({
@@ -2173,14 +2255,14 @@ var FieldLabel = ({
2173
2255
  const El = el;
2174
2256
  return /* @__PURE__ */ jsxs8(El, { className, children: [
2175
2257
  /* @__PURE__ */ jsxs8("div", { className: getClassName15("label"), children: [
2176
- icon ? /* @__PURE__ */ jsx18("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx18(Fragment4, {}),
2258
+ icon ? /* @__PURE__ */ jsx19("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx19(Fragment4, {}),
2177
2259
  label,
2178
- readOnly && /* @__PURE__ */ jsx18("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx18(Lock, { size: "12" }) })
2260
+ readOnly && /* @__PURE__ */ jsx19("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx19(Lock, { size: "12" }) })
2179
2261
  ] }),
2180
2262
  children
2181
2263
  ] });
2182
2264
  };
2183
- var FieldLabelInternal2 = ({
2265
+ var FieldLabelInternal = ({
2184
2266
  children,
2185
2267
  icon,
2186
2268
  label,
@@ -2188,14 +2270,14 @@ var FieldLabelInternal2 = ({
2188
2270
  readOnly
2189
2271
  }) => {
2190
2272
  const { overrides } = useAppContext();
2191
- const Wrapper = useMemo4(
2273
+ const Wrapper = useMemo5(
2192
2274
  () => overrides.fieldLabel || FieldLabel,
2193
2275
  [overrides]
2194
2276
  );
2195
2277
  if (!label) {
2196
- return /* @__PURE__ */ jsx18(Fragment4, { children });
2278
+ return /* @__PURE__ */ jsx19(Fragment4, { children });
2197
2279
  }
2198
- return /* @__PURE__ */ jsx18(
2280
+ return /* @__PURE__ */ jsx19(
2199
2281
  Wrapper,
2200
2282
  {
2201
2283
  label,
@@ -2209,8 +2291,9 @@ var FieldLabelInternal2 = ({
2209
2291
  };
2210
2292
  function AutoFieldInternal(props) {
2211
2293
  var _a, _b, _c, _d, _e, _f, _g, _h;
2212
- const { dispatch, overrides } = useAppContext();
2213
- const { id, Label: Label2 = FieldLabelInternal2 } = props;
2294
+ const { dispatch, overrides, selectedItem } = useAppContext();
2295
+ const nestedFieldContext = useContext3(NestedFieldContext);
2296
+ const { id, Label: Label2 = FieldLabelInternal } = props;
2214
2297
  const field = props.field;
2215
2298
  const label = field.label;
2216
2299
  const defaultId = useSafeId();
@@ -2270,20 +2353,29 @@ function AutoFieldInternal(props) {
2270
2353
  return null;
2271
2354
  }
2272
2355
  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)) }) });
2356
+ return /* @__PURE__ */ jsx19("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx19("div", { className: getClassName15(), children: /* @__PURE__ */ jsx19(CustomField, __spreadValues({}, mergedProps)) }) });
2274
2357
  }
2275
2358
  const children = defaultFields[field.type](mergedProps);
2276
2359
  const Render2 = render[field.type];
2277
- return /* @__PURE__ */ jsx18(
2278
- "div",
2360
+ return /* @__PURE__ */ jsx19(
2361
+ NestedFieldContext.Provider,
2279
2362
  {
2280
- className: getClassNameWrapper(),
2281
- onFocus,
2282
- onBlur,
2283
- onClick: (e) => {
2284
- e.stopPropagation();
2363
+ value: {
2364
+ readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
2365
+ localName: nestedFieldContext.localName
2285
2366
  },
2286
- children: /* @__PURE__ */ jsx18(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2367
+ children: /* @__PURE__ */ jsx19(
2368
+ "div",
2369
+ {
2370
+ className: getClassNameWrapper(),
2371
+ onFocus,
2372
+ onBlur,
2373
+ onClick: (e) => {
2374
+ e.stopPropagation();
2375
+ },
2376
+ children: /* @__PURE__ */ jsx19(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2377
+ }
2378
+ )
2287
2379
  }
2288
2380
  );
2289
2381
  }
@@ -2311,11 +2403,11 @@ function AutoFieldPrivate(props) {
2311
2403
  value: localValue,
2312
2404
  onChange: onChangeLocal
2313
2405
  };
2314
- return /* @__PURE__ */ jsx18(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2406
+ return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2315
2407
  }
2316
2408
  function AutoField(props) {
2317
- const DefaultLabel = useMemo4(() => {
2318
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx18(
2409
+ const DefaultLabel = useMemo5(() => {
2410
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx19(
2319
2411
  "div",
2320
2412
  __spreadProps(__spreadValues({}, labelProps), {
2321
2413
  className: getClassName15({ readOnly: props.readOnly })
@@ -2323,7 +2415,7 @@ function AutoField(props) {
2323
2415
  );
2324
2416
  return DefaultLabel2;
2325
2417
  }, [props.readOnly]);
2326
- return /* @__PURE__ */ jsx18(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2418
+ return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2327
2419
  }
2328
2420
 
2329
2421
  // components/Drawer/index.tsx
@@ -2334,18 +2426,19 @@ init_react_import();
2334
2426
  var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
2335
2427
 
2336
2428
  // components/Drawer/index.tsx
2337
- import { useMemo as useMemo8, useState as useState17 } from "react";
2429
+ import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
2338
2430
 
2339
2431
  // components/DragDropContext/index.tsx
2340
2432
  init_react_import();
2341
2433
  import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
2342
2434
  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
2435
+ createContext as createContext4,
2436
+ useCallback as useCallback11,
2437
+ useContext as useContext7,
2438
+ useEffect as useEffect15,
2439
+ useId,
2440
+ useRef as useRef3,
2441
+ useState as useState17
2349
2442
  } from "react";
2350
2443
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
2351
2444
 
@@ -2353,23 +2446,22 @@ import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
2353
2446
  init_react_import();
2354
2447
  import {
2355
2448
  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
2449
+ useCallback as useCallback10,
2450
+ useContext as useContext6,
2451
+ useEffect as useEffect14,
2452
+ useMemo as useMemo8,
2453
+ useRef as useRef2
2362
2454
  } from "react";
2363
2455
 
2364
2456
  // components/DraggableComponent/index.tsx
2365
2457
  init_react_import();
2366
2458
  import {
2367
- useCallback as useCallback6,
2368
- useContext as useContext2,
2459
+ useCallback as useCallback7,
2460
+ useContext as useContext5,
2369
2461
  useEffect as useEffect10,
2370
- useMemo as useMemo5,
2371
- useRef as useRef3,
2372
- useState as useState12
2462
+ useMemo as useMemo7,
2463
+ useRef,
2464
+ useState as useState13
2373
2465
  } from "react";
2374
2466
 
2375
2467
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
@@ -2379,18 +2471,18 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
2379
2471
  // components/DraggableComponent/index.tsx
2380
2472
  import { createPortal as createPortal2 } from "react-dom";
2381
2473
 
2382
- // components/DraggableComponent/collision/dynamic/index.ts
2474
+ // lib/dnd/collision/dynamic/index.ts
2383
2475
  init_react_import();
2384
2476
  import {
2385
2477
  CollisionPriority as CollisionPriority7,
2386
2478
  CollisionType as CollisionType7
2387
2479
  } from "@dnd-kit/abstract";
2388
2480
 
2389
- // components/DraggableComponent/collision/directional/index.ts
2481
+ // lib/dnd/collision/directional/index.ts
2390
2482
  init_react_import();
2391
2483
  import { CollisionType } from "@dnd-kit/abstract";
2392
2484
 
2393
- // components/DraggableComponent/collision/collision-debug.ts
2485
+ // lib/dnd/collision/collision-debug.ts
2394
2486
  init_react_import();
2395
2487
  var DEBUG = false;
2396
2488
  var debugElements = {};
@@ -2439,7 +2531,7 @@ var collisionDebug = (a, b, id, color, label) => {
2439
2531
  });
2440
2532
  };
2441
2533
 
2442
- // components/DraggableComponent/collision/directional/index.ts
2534
+ // lib/dnd/collision/directional/index.ts
2443
2535
  var distanceChange = "increasing";
2444
2536
  var directionalCollision = (input, previous) => {
2445
2537
  var _a;
@@ -2472,7 +2564,7 @@ var directionalCollision = (input, previous) => {
2472
2564
  return null;
2473
2565
  };
2474
2566
 
2475
- // components/DraggableComponent/collision/dynamic/get-direction.ts
2567
+ // lib/dnd/collision/dynamic/get-direction.ts
2476
2568
  init_react_import();
2477
2569
  var getDirection = (dragAxis, delta) => {
2478
2570
  if (dragAxis === "dynamic") {
@@ -2487,7 +2579,7 @@ var getDirection = (dragAxis, delta) => {
2487
2579
  return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2488
2580
  };
2489
2581
 
2490
- // components/DraggableComponent/collision/dynamic/get-midpoint-impact.ts
2582
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
2491
2583
  init_react_import();
2492
2584
  var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
2493
2585
  const dragRect = dragShape.boundingRectangle;
@@ -2506,7 +2598,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2506
2598
  return dragRect.right - offset >= dropCenter.x;
2507
2599
  };
2508
2600
 
2509
- // components/DraggableComponent/collision/dynamic/track-movement-interval.ts
2601
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
2510
2602
  init_react_import();
2511
2603
  import { Point } from "@dnd-kit/geometry";
2512
2604
  var INTERVAL_SENSITIVITY = 10;
@@ -2610,7 +2702,14 @@ var closestCorners = (input) => {
2610
2702
  };
2611
2703
  };
2612
2704
 
2613
- // components/DraggableComponent/collision/dynamic/index.ts
2705
+ // lib/dnd/collision/dynamic/store.ts
2706
+ init_react_import();
2707
+ import { createStore } from "zustand/vanilla";
2708
+ var collisionStore = createStore(() => ({
2709
+ fallbackEnabled: false
2710
+ }));
2711
+
2712
+ // lib/dnd/collision/dynamic/index.ts
2614
2713
  var flushNext = "";
2615
2714
  var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2616
2715
  var _a, _b, _c, _d, _e;
@@ -2622,6 +2721,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2622
2721
  return null;
2623
2722
  }
2624
2723
  const { center: dragCenter } = dragShape;
2724
+ const { fallbackEnabled } = collisionStore.getState();
2625
2725
  const interval = trackMovementInterval(position.current, dragAxis);
2626
2726
  dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2627
2727
  direction: interval.direction
@@ -2667,7 +2767,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2667
2767
  flushNext = "";
2668
2768
  return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2669
2769
  }
2670
- if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2770
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2671
2771
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2672
2772
  const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2673
2773
  if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
@@ -2728,8 +2828,107 @@ function getDeepScrollPosition(element) {
2728
2828
  return totalScroll;
2729
2829
  }
2730
2830
 
2831
+ // components/DropZone/context.tsx
2832
+ init_react_import();
2833
+ import {
2834
+ createContext as createContext3,
2835
+ useCallback as useCallback6,
2836
+ useMemo as useMemo6,
2837
+ useState as useState12
2838
+ } from "react";
2839
+ import { createStore as createStore2 } from "zustand";
2840
+ import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
2841
+ var dropZoneContext = createContext3(null);
2842
+ var ZoneStoreContext = createContext3(
2843
+ createStore2(() => ({
2844
+ zoneDepthIndex: {},
2845
+ nextZoneDepthIndex: {},
2846
+ areaDepthIndex: {},
2847
+ nextAreaDepthIndex: {},
2848
+ draggedItem: null,
2849
+ previewIndex: {}
2850
+ }))
2851
+ );
2852
+ var ZoneStoreProvider = ({
2853
+ children,
2854
+ store
2855
+ }) => {
2856
+ return /* @__PURE__ */ jsx20(ZoneStoreContext.Provider, { value: store, children });
2857
+ };
2858
+ var DropZoneProvider = ({
2859
+ children,
2860
+ value
2861
+ }) => {
2862
+ const [hoveringComponent, setHoveringComponent] = useState12();
2863
+ const [areasWithZones, setAreasWithZones] = useState12(
2864
+ {}
2865
+ );
2866
+ const [activeZones, setActiveZones] = useState12({});
2867
+ const { dispatch } = useAppContext();
2868
+ const registerZoneArea = useCallback6(
2869
+ (area) => {
2870
+ setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
2871
+ },
2872
+ [setAreasWithZones]
2873
+ );
2874
+ const registerZone = useCallback6(
2875
+ (zoneCompound) => {
2876
+ if (!dispatch) {
2877
+ return;
2878
+ }
2879
+ dispatch({
2880
+ type: "registerZone",
2881
+ zone: zoneCompound
2882
+ });
2883
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
2884
+ },
2885
+ [setActiveZones, dispatch]
2886
+ );
2887
+ const unregisterZone = useCallback6(
2888
+ (zoneCompound) => {
2889
+ if (!dispatch) {
2890
+ return;
2891
+ }
2892
+ dispatch({
2893
+ type: "unregisterZone",
2894
+ zone: zoneCompound
2895
+ });
2896
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
2897
+ [zoneCompound]: false
2898
+ }));
2899
+ },
2900
+ [setActiveZones, dispatch]
2901
+ );
2902
+ const memoValue = useMemo6(
2903
+ () => __spreadValues({
2904
+ hoveringComponent,
2905
+ setHoveringComponent,
2906
+ registerZoneArea,
2907
+ areasWithZones,
2908
+ registerZone,
2909
+ unregisterZone,
2910
+ activeZones
2911
+ }, value),
2912
+ [value, hoveringComponent, areasWithZones, activeZones]
2913
+ );
2914
+ return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
2915
+ };
2916
+
2917
+ // lib/use-context-store.ts
2918
+ init_react_import();
2919
+ import { useContext as useContext4 } from "react";
2920
+ import { useStore } from "zustand";
2921
+ import { useShallow } from "zustand/react/shallow";
2922
+ function useContextStore(context, selector) {
2923
+ const store = useContext4(context);
2924
+ if (!store) {
2925
+ throw new Error("useContextStore must be used inside context");
2926
+ }
2927
+ return useStore(store, useShallow(selector));
2928
+ }
2929
+
2731
2930
  // components/DraggableComponent/index.tsx
2732
- import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
2931
+ import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
2733
2932
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
2734
2933
  var DEBUG2 = false;
2735
2934
  var space = 8;
@@ -2743,9 +2942,9 @@ var DefaultActionBar = ({
2743
2942
  }) => /* @__PURE__ */ jsxs9(ActionBar, { children: [
2744
2943
  /* @__PURE__ */ jsxs9(ActionBar.Group, { children: [
2745
2944
  parentAction,
2746
- label && /* @__PURE__ */ jsx19(ActionBar.Label, { label })
2945
+ label && /* @__PURE__ */ jsx21(ActionBar.Label, { label })
2747
2946
  ] }),
2748
- /* @__PURE__ */ jsx19(ActionBar.Group, { children })
2947
+ /* @__PURE__ */ jsx21(ActionBar.Group, { children })
2749
2948
  ] });
2750
2949
  var convertIdToSelector = (id, zoneCompound, data) => {
2751
2950
  const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
@@ -2780,9 +2979,9 @@ var DraggableComponent = ({
2780
2979
  iframe,
2781
2980
  state
2782
2981
  } = useAppContext();
2783
- const ctx = useContext2(dropZoneContext);
2784
- const [localZones, setLocalZones] = useState12({});
2785
- const registerLocalZone = useCallback6(
2982
+ const ctx = useContext5(dropZoneContext);
2983
+ const [localZones, setLocalZones] = useState13({});
2984
+ const registerLocalZone = useCallback7(
2786
2985
  (zoneCompound2, active) => {
2787
2986
  var _a;
2788
2987
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -2792,7 +2991,7 @@ var DraggableComponent = ({
2792
2991
  },
2793
2992
  [setLocalZones]
2794
2993
  );
2795
- const unregisterLocalZone = useCallback6(
2994
+ const unregisterLocalZone = useCallback7(
2796
2995
  (zoneCompound2) => {
2797
2996
  var _a;
2798
2997
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -2806,7 +3005,7 @@ var DraggableComponent = ({
2806
3005
  );
2807
3006
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
2808
3007
  const { path = [] } = ctx || {};
2809
- const [canDrag, setCanDrag] = useState12(false);
3008
+ const [canDrag, setCanDrag] = useState13(false);
2810
3009
  useEffect10(() => {
2811
3010
  var _a;
2812
3011
  const item = getItem({ index, zone: zoneCompound }, state.data);
@@ -2817,10 +3016,13 @@ var DraggableComponent = ({
2817
3016
  setCanDrag((_a = perms.drag) != null ? _a : true);
2818
3017
  }
2819
3018
  }, [state, index, zoneCompound, getPermissions]);
2820
- const userIsDragging = !!(ctx == null ? void 0 : ctx.draggedItem);
3019
+ const userIsDragging = useContextStore(
3020
+ ZoneStoreContext,
3021
+ (s) => !!s.draggedItem
3022
+ );
2821
3023
  const canCollide = canDrag || userIsDragging;
2822
3024
  const disabled = !isEnabled || !canCollide;
2823
- const [dragAxis, setDragAxis] = useState12(userDragAxis || autoDragAxis);
3025
+ const [dragAxis, setDragAxis] = useState13(userDragAxis || autoDragAxis);
2824
3026
  const { ref: sortableRef, status } = useSortableSafe({
2825
3027
  id,
2826
3028
  index,
@@ -2846,8 +3048,8 @@ var DraggableComponent = ({
2846
3048
  }
2847
3049
  });
2848
3050
  const thisIsDragging = status === "dragging";
2849
- const ref = useRef3(null);
2850
- const refSetter = useCallback6(
3051
+ const ref = useRef(null);
3052
+ const refSetter = useCallback7(
2851
3053
  (el) => {
2852
3054
  sortableRef(el);
2853
3055
  if (el) {
@@ -2856,14 +3058,14 @@ var DraggableComponent = ({
2856
3058
  },
2857
3059
  [sortableRef]
2858
3060
  );
2859
- const [portalEl, setPortalEl] = useState12();
3061
+ const [portalEl, setPortalEl] = useState13();
2860
3062
  useEffect10(() => {
2861
3063
  var _a, _b, _c;
2862
3064
  setPortalEl(
2863
3065
  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
3066
  );
2865
3067
  }, [iframe.enabled, ref.current]);
2866
- const getStyle = useCallback6(() => {
3068
+ const getStyle = useCallback7(() => {
2867
3069
  var _a, _b, _c;
2868
3070
  if (!ref.current) return;
2869
3071
  const rect = ref.current.getBoundingClientRect();
@@ -2883,8 +3085,8 @@ var DraggableComponent = ({
2883
3085
  };
2884
3086
  return style2;
2885
3087
  }, [ref.current]);
2886
- const [style, setStyle] = useState12();
2887
- const sync = useCallback6(() => {
3088
+ const [style, setStyle] = useState13();
3089
+ const sync = useCallback7(() => {
2888
3090
  setStyle(getStyle());
2889
3091
  }, [ref.current, iframe]);
2890
3092
  useEffect10(() => {
@@ -2897,19 +3099,27 @@ var DraggableComponent = ({
2897
3099
  }
2898
3100
  }, [ref.current]);
2899
3101
  useEffect10(() => {
2900
- ctx == null ? void 0 : ctx.registerPath({
2901
- index,
2902
- zone: zoneCompound
2903
- });
2904
- }, [isSelected]);
2905
- const CustomActionBar = useMemo5(
3102
+ ctx == null ? void 0 : ctx.registerPath(
3103
+ id,
3104
+ {
3105
+ index,
3106
+ zone: zoneCompound
3107
+ },
3108
+ componentType
3109
+ );
3110
+ return () => {
3111
+ var _a;
3112
+ (_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
3113
+ };
3114
+ }, [id, zoneCompound, index, componentType]);
3115
+ const CustomActionBar = useMemo7(
2906
3116
  () => overrides.actionBar || DefaultActionBar,
2907
3117
  [overrides.actionBar]
2908
3118
  );
2909
3119
  const permissions = getPermissions({
2910
3120
  item: selectedItem
2911
3121
  });
2912
- const onClick = useCallback6(
3122
+ const onClick = useCallback7(
2913
3123
  (e) => {
2914
3124
  e.stopPropagation();
2915
3125
  dispatch({
@@ -2921,7 +3131,7 @@ var DraggableComponent = ({
2921
3131
  },
2922
3132
  [index, zoneCompound, id]
2923
3133
  );
2924
- const onSelectParent = useCallback6(() => {
3134
+ const onSelectParent = useCallback7(() => {
2925
3135
  if (!(ctx == null ? void 0 : ctx.areaId)) {
2926
3136
  return;
2927
3137
  }
@@ -2939,21 +3149,21 @@ var DraggableComponent = ({
2939
3149
  }
2940
3150
  });
2941
3151
  }, [ctx, path]);
2942
- const onDuplicate = useCallback6(() => {
3152
+ const onDuplicate = useCallback7(() => {
2943
3153
  dispatch({
2944
3154
  type: "duplicate",
2945
3155
  sourceIndex: index,
2946
3156
  sourceZone: zoneCompound
2947
3157
  });
2948
3158
  }, [index, zoneCompound]);
2949
- const onDelete = useCallback6(() => {
3159
+ const onDelete = useCallback7(() => {
2950
3160
  dispatch({
2951
3161
  type: "remove",
2952
3162
  index,
2953
3163
  zone: zoneCompound
2954
3164
  });
2955
3165
  }, [index, zoneCompound]);
2956
- const [hover, setHover] = useState12(false);
3166
+ const [hover, setHover] = useState13(false);
2957
3167
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
2958
3168
  useEffect10(() => {
2959
3169
  if (!ref.current) {
@@ -3014,7 +3224,7 @@ var DraggableComponent = ({
3014
3224
  };
3015
3225
  }
3016
3226
  }, [disabled, ref]);
3017
- const [isVisible, setIsVisible] = useState12(false);
3227
+ const [isVisible, setIsVisible] = useState13(false);
3018
3228
  useEffect10(() => {
3019
3229
  sync();
3020
3230
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
@@ -3023,7 +3233,7 @@ var DraggableComponent = ({
3023
3233
  setIsVisible(false);
3024
3234
  }
3025
3235
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3026
- const syncActionsPosition = useCallback6(
3236
+ const syncActionsPosition = useCallback7(
3027
3237
  (el) => {
3028
3238
  if (el) {
3029
3239
  const view = el.ownerDocument.defaultView;
@@ -3054,7 +3264,7 @@ var DraggableComponent = ({
3054
3264
  }
3055
3265
  setDragAxis(autoDragAxis);
3056
3266
  }, [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 }) });
3267
+ const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx21(CornerLeftUp, { size: 16 }) });
3058
3268
  return /* @__PURE__ */ jsxs9(
3059
3269
  DropZoneProvider,
3060
3270
  {
@@ -3081,15 +3291,15 @@ var DraggableComponent = ({
3081
3291
  "data-puck-overlay": true,
3082
3292
  children: [
3083
3293
  debug,
3084
- isLoading && /* @__PURE__ */ jsx19("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx19(Loader, {}) }),
3085
- /* @__PURE__ */ jsx19(
3294
+ isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
3295
+ /* @__PURE__ */ jsx21(
3086
3296
  "div",
3087
3297
  {
3088
3298
  className: getClassName16("actionsOverlay"),
3089
3299
  style: {
3090
3300
  top: actionsOverlayTop / zoomConfig.zoom
3091
3301
  },
3092
- children: /* @__PURE__ */ jsx19(
3302
+ children: /* @__PURE__ */ jsx21(
3093
3303
  "div",
3094
3304
  {
3095
3305
  className: getClassName16("actions"),
@@ -3107,8 +3317,8 @@ var DraggableComponent = ({
3107
3317
  parentAction,
3108
3318
  label: DEBUG2 ? id : label,
3109
3319
  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 }) })
3320
+ permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
3321
+ permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
3112
3322
  ]
3113
3323
  }
3114
3324
  )
@@ -3116,7 +3326,7 @@ var DraggableComponent = ({
3116
3326
  )
3117
3327
  }
3118
3328
  ),
3119
- /* @__PURE__ */ jsx19("div", { className: getClassName16("overlay") })
3329
+ /* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
3120
3330
  ]
3121
3331
  }
3122
3332
  ),
@@ -3132,98 +3342,26 @@ var DraggableComponent = ({
3132
3342
  init_react_import();
3133
3343
  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
3344
 
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
3345
+ // components/DropZone/lib/use-min-empty-height.ts
3213
3346
  init_react_import();
3214
3347
  import { useEffect as useEffect11, useState as useState14 } from "react";
3215
3348
  var useMinEmptyHeight = ({
3216
- draggedItem,
3217
3349
  zoneCompound,
3218
3350
  userMinEmptyHeight,
3219
3351
  ref
3220
3352
  }) => {
3221
3353
  const [prevHeight, setPrevHeight] = useState14(0);
3222
3354
  const [isAnimating, setIsAnimating] = useState14(false);
3355
+ const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3356
+ var _a, _b;
3357
+ return {
3358
+ draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
3359
+ isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3360
+ };
3361
+ });
3223
3362
  useEffect11(() => {
3224
3363
  if (draggedItem && ref.current) {
3225
- const componentData = draggedItem.data;
3226
- if (componentData.zone === zoneCompound) {
3364
+ if (isZone) {
3227
3365
  const rect = ref.current.getBoundingClientRect();
3228
3366
  setPrevHeight(rect.height);
3229
3367
  setIsAnimating(true);
@@ -3253,15 +3391,143 @@ function assignRefs(refs, node) {
3253
3391
  });
3254
3392
  }
3255
3393
 
3394
+ // components/DropZone/lib/use-content-with-preview.ts
3395
+ init_react_import();
3396
+ import { useEffect as useEffect12, useState as useState15 } from "react";
3397
+
3398
+ // lib/dnd/use-rendered-callback.ts
3399
+ init_react_import();
3400
+ import { useDragDropManager } from "@dnd-kit/react";
3401
+ import { useCallback as useCallback8 } from "react";
3402
+ function useRenderedCallback(callback, deps) {
3403
+ const manager = useDragDropManager();
3404
+ return useCallback8(
3405
+ (...args) => __async(this, null, function* () {
3406
+ yield manager == null ? void 0 : manager.renderer.rendering;
3407
+ return callback(...args);
3408
+ }),
3409
+ [...deps, manager]
3410
+ );
3411
+ }
3412
+
3413
+ // lib/insert.ts
3414
+ init_react_import();
3415
+ var insert = (list, index, item) => {
3416
+ const result = Array.from(list);
3417
+ result.splice(index, 0, item);
3418
+ return result;
3419
+ };
3420
+
3421
+ // components/DropZone/lib/use-content-with-preview.ts
3422
+ var useContentWithPreview = (content, zoneCompound) => {
3423
+ const { draggedItemId, preview, previewExists } = useContextStore(
3424
+ ZoneStoreContext,
3425
+ (s) => {
3426
+ var _a;
3427
+ return {
3428
+ draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
3429
+ preview: s.previewIndex[zoneCompound],
3430
+ previewExists: Object.keys(s.previewIndex || {}).length > 0
3431
+ };
3432
+ }
3433
+ );
3434
+ const {
3435
+ state: {
3436
+ ui: { isDragging }
3437
+ }
3438
+ } = useAppContext();
3439
+ const [contentWithPreview, setContentWithPreview] = useState15(content);
3440
+ const [localPreview, setLocalPreview] = useState15(
3441
+ preview
3442
+ );
3443
+ const updateContent = useRenderedCallback(
3444
+ (content2, preview2, isDragging2) => {
3445
+ if (isDragging2 && !previewExists) {
3446
+ return;
3447
+ }
3448
+ if (preview2) {
3449
+ if (preview2.type === "insert") {
3450
+ setContentWithPreview(
3451
+ insert(
3452
+ content2.filter((item) => item.props.id !== preview2.props.id),
3453
+ preview2.index,
3454
+ {
3455
+ type: "preview",
3456
+ props: { id: preview2.props.id }
3457
+ }
3458
+ )
3459
+ );
3460
+ } else {
3461
+ setContentWithPreview(
3462
+ insert(
3463
+ content2.filter((item) => item.props.id !== preview2.props.id),
3464
+ preview2.index,
3465
+ {
3466
+ type: preview2.componentType,
3467
+ props: preview2.props
3468
+ }
3469
+ )
3470
+ );
3471
+ }
3472
+ } else {
3473
+ setContentWithPreview(
3474
+ previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3475
+ );
3476
+ }
3477
+ setLocalPreview(preview2);
3478
+ },
3479
+ [draggedItemId, previewExists]
3480
+ );
3481
+ useEffect12(() => {
3482
+ updateContent(content, preview, isDragging);
3483
+ }, [content, preview, isDragging]);
3484
+ return [contentWithPreview, localPreview];
3485
+ };
3486
+
3487
+ // components/DropZone/lib/use-drag-axis.ts
3488
+ init_react_import();
3489
+ import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
3490
+ var GRID_DRAG_AXIS = "dynamic";
3491
+ var FLEX_ROW_DRAG_AXIS = "x";
3492
+ var DEFAULT_DRAG_AXIS = "y";
3493
+ var useDragAxis = (ref, collisionAxis) => {
3494
+ const { status } = useAppContext();
3495
+ const [dragAxis, setDragAxis] = useState16(
3496
+ collisionAxis || DEFAULT_DRAG_AXIS
3497
+ );
3498
+ const calculateDragAxis = useCallback9(() => {
3499
+ if (ref.current) {
3500
+ const computedStyle = window.getComputedStyle(ref.current);
3501
+ if (computedStyle.display === "grid") {
3502
+ setDragAxis(GRID_DRAG_AXIS);
3503
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3504
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3505
+ } else {
3506
+ setDragAxis(DEFAULT_DRAG_AXIS);
3507
+ }
3508
+ }
3509
+ }, [ref.current]);
3510
+ useEffect13(() => {
3511
+ const onViewportChange = () => {
3512
+ calculateDragAxis();
3513
+ };
3514
+ window.addEventListener("viewportchange", onViewportChange);
3515
+ return () => {
3516
+ window.removeEventListener("viewportchange", onViewportChange);
3517
+ };
3518
+ }, []);
3519
+ useEffect13(calculateDragAxis, [status, collisionAxis]);
3520
+ return [dragAxis, calculateDragAxis];
3521
+ };
3522
+
3256
3523
  // components/DropZone/index.tsx
3257
- import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
3524
+ import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
3258
3525
  var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3259
- var DEBUG3 = false;
3260
- var GRID_DRAG_AXIS = "dynamic";
3261
- var FLEX_ROW_DRAG_AXIS = "x";
3262
- var DEFAULT_DRAG_AXIS = "y";
3526
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3527
+ var RENDER_DEBUG = false;
3528
+ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
3263
3529
  var DropZoneEdit = forwardRef3(
3264
- function DropZoneEdit2({
3530
+ function DropZoneEditInternal({
3265
3531
  zone,
3266
3532
  allow,
3267
3533
  disallow,
@@ -3271,31 +3537,48 @@ var DropZoneEdit = forwardRef3(
3271
3537
  collisionAxis
3272
3538
  }, userRef) {
3273
3539
  const appContext2 = useAppContext();
3274
- const ctx = useContext3(dropZoneContext);
3540
+ const ctx = useContext6(dropZoneContext);
3275
3541
  const {
3276
3542
  // These all need setting via context
3277
3543
  data,
3278
3544
  config,
3279
3545
  areaId,
3280
- draggedItem,
3281
3546
  registerZoneArea,
3282
3547
  depth,
3283
3548
  registerLocalZone,
3284
3549
  unregisterLocalZone,
3285
- deepestZone = rootDroppableId,
3286
- deepestArea,
3287
- nextDeepestArea,
3288
3550
  path = [],
3289
3551
  activeZones
3290
3552
  } = ctx;
3291
- const { itemSelector } = appContext2.state.ui;
3292
3553
  let zoneCompound = rootDroppableId;
3293
- useEffect12(() => {
3554
+ if (areaId) {
3555
+ if (zone !== rootDroppableId) {
3556
+ zoneCompound = `${areaId}:${zone}`;
3557
+ }
3558
+ }
3559
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3560
+ const {
3561
+ isDeepestZone,
3562
+ inNextDeepestArea,
3563
+ draggedComponentType,
3564
+ userIsDragging
3565
+ } = useContextStore(ZoneStoreContext, (s) => {
3566
+ var _a, _b, _c;
3567
+ return {
3568
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3569
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3570
+ draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3571
+ draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3572
+ userIsDragging: !!s.draggedItem
3573
+ };
3574
+ });
3575
+ const { itemSelector } = appContext2.state.ui;
3576
+ useEffect14(() => {
3294
3577
  if (areaId && registerZoneArea) {
3295
3578
  registerZoneArea(areaId);
3296
3579
  }
3297
3580
  }, [areaId]);
3298
- useEffect12(() => {
3581
+ useEffect14(() => {
3299
3582
  if (ctx == null ? void 0 : ctx.registerZone) {
3300
3583
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3301
3584
  }
@@ -3305,25 +3588,18 @@ var DropZoneEdit = forwardRef3(
3305
3588
  }
3306
3589
  };
3307
3590
  }, []);
3308
- if (areaId) {
3309
- if (zone !== rootDroppableId) {
3310
- zoneCompound = `${areaId}:${zone}`;
3311
- }
3312
- }
3313
- const content = useMemo7(() => {
3591
+ const content = useMemo8(() => {
3314
3592
  if (areaId && zone !== rootDroppableId) {
3315
3593
  return setupZone(data, zoneCompound).zones[zoneCompound];
3316
3594
  }
3317
3595
  return data.content || [];
3318
3596
  }, [data, zoneCompound]);
3319
- const ref = useRef4(null);
3320
- const acceptsTarget = useCallback8(
3321
- (target) => {
3322
- if (!target) {
3597
+ const ref = useRef2(null);
3598
+ const acceptsTarget = useCallback10(
3599
+ (componentType) => {
3600
+ if (!componentType) {
3323
3601
  return true;
3324
3602
  }
3325
- const data2 = target.data;
3326
- const { componentType } = data2;
3327
3603
  if (disallow) {
3328
3604
  const defaultedAllow = allow || [];
3329
3605
  const filteredDisallow = (disallow || []).filter(
@@ -3341,49 +3617,29 @@ var DropZoneEdit = forwardRef3(
3341
3617
  },
3342
3618
  [allow, disallow]
3343
3619
  );
3344
- useEffect12(() => {
3620
+ useEffect14(() => {
3345
3621
  if (registerLocalZone) {
3346
- registerLocalZone(zoneCompound, acceptsTarget(draggedItem));
3622
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3347
3623
  }
3348
3624
  return () => {
3349
3625
  if (unregisterLocalZone) {
3350
3626
  unregisterLocalZone(zoneCompound);
3351
3627
  }
3352
3628
  };
3353
- }, [draggedItem, zoneCompound]);
3354
- const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3355
- const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
3356
- const userIsDragging = !!draggedItem;
3629
+ }, [draggedComponentType, zoneCompound]);
3630
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3357
3631
  let isEnabled = true;
3358
- if (draggedItem) {
3359
- isEnabled = deepestZone === zoneCompound;
3632
+ if (userIsDragging) {
3633
+ isEnabled = isDeepestZone;
3360
3634
  }
3361
3635
  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);
3636
+ isEnabled = acceptsTarget(draggedComponentType);
3637
+ }
3638
+ const [contentWithPreview, preview] = useContentWithPreview(
3639
+ content,
3640
+ zoneCompound
3641
+ );
3642
+ const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3387
3643
  const droppableConfig = {
3388
3644
  id: zoneCompound,
3389
3645
  collisionPriority: isEnabled ? depth : 0,
@@ -3393,45 +3649,20 @@ var DropZoneEdit = forwardRef3(
3393
3649
  data: {
3394
3650
  areaId,
3395
3651
  depth,
3396
- isDroppableTarget: acceptsTarget(draggedItem),
3652
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3397
3653
  path
3398
3654
  }
3399
3655
  };
3400
3656
  const { ref: dropRef } = useDroppableSafe(droppableConfig);
3401
3657
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3402
3658
  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
- }, []);
3659
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3428
3660
  const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3429
- draggedItem,
3430
3661
  zoneCompound,
3431
3662
  userMinEmptyHeight,
3432
3663
  ref
3433
3664
  });
3434
- return /* @__PURE__ */ jsxs10(
3665
+ return /* @__PURE__ */ jsx22(
3435
3666
  "div",
3436
3667
  {
3437
3668
  className: `${getClassName17({
@@ -3451,88 +3682,84 @@ var DropZoneEdit = forwardRef3(
3451
3682
  "data-puck-dropzone": zoneCompound,
3452
3683
  "data-puck-dnd": zoneCompound,
3453
3684
  style: __spreadProps(__spreadValues({}, style), {
3454
- "--min-empty-height": `${minEmptyHeight}px`
3685
+ "--min-empty-height": `${minEmptyHeight}px`,
3686
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3455
3687
  }),
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
3688
+ children: contentWithPreview.map((item, i) => {
3689
+ var _a, _b, _c, _d, _e, _f, _g;
3690
+ const componentId = item.props.id;
3691
+ const puckProps = {
3692
+ renderDropZone: DropZoneEditPure,
3693
+ isEditing: true,
3694
+ dragRef: null
3695
+ };
3696
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3697
+ puck: puckProps,
3698
+ editMode: true
3699
+ // DEPRECATED
3700
+ });
3701
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3702
+ let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
3703
+ "No configuration for ",
3704
+ item.type
3705
+ ] });
3706
+ const componentConfig = config.components[item.type];
3707
+ let componentType = item.type;
3708
+ let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3709
+ if (item.type === "preview") {
3710
+ let Preview4 = function() {
3711
+ return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3468
3712
  };
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
- })
3713
+ var Preview3 = Preview4;
3714
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3715
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3716
+ Render2 = Preview4;
3717
+ }
3718
+ return /* @__PURE__ */ jsx22(
3719
+ DropZoneProvider,
3720
+ {
3721
+ value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3722
+ children: /* @__PURE__ */ jsx22(
3723
+ DraggableComponent,
3724
+ {
3725
+ id: componentId,
3726
+ componentType,
3727
+ zoneCompound,
3728
+ depth: depth + 1,
3729
+ index: i,
3730
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3731
+ isSelected,
3732
+ label,
3733
+ isEnabled,
3734
+ autoDragAxis: dragAxis,
3735
+ userDragAxis: collisionAxis,
3736
+ inDroppableZone: acceptsTarget(draggedComponentType),
3737
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx22(
3738
+ Render2,
3739
+ __spreadProps(__spreadValues({}, defaultedProps), {
3740
+ puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3741
+ dragRef
3516
3742
  })
3517
- ) : /* @__PURE__ */ jsx21("div", { ref: dragRef, children: /* @__PURE__ */ jsx21(Render2, __spreadValues({}, defaultedProps)) })
3518
- }
3519
- )
3520
- },
3521
- componentId
3522
- );
3523
- })
3524
- ]
3743
+ })
3744
+ ) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
3745
+ }
3746
+ )
3747
+ },
3748
+ componentId
3749
+ );
3750
+ })
3525
3751
  }
3526
3752
  );
3527
3753
  }
3528
3754
  );
3755
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
3529
3756
  var DropZoneRender = forwardRef3(
3530
- function DropZoneRender2({ className, style, zone }, ref) {
3531
- const ctx = useContext3(dropZoneContext);
3757
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3758
+ const ctx = useContext6(dropZoneContext);
3532
3759
  const { data, areaId = "root", config } = ctx || {};
3533
3760
  let zoneCompound = rootDroppableId;
3534
3761
  let content = (data == null ? void 0 : data.content) || [];
3535
- useEffect12(() => {
3762
+ useEffect14(() => {
3536
3763
  if (ctx == null ? void 0 : ctx.registerZone) {
3537
3764
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3538
3765
  }
@@ -3549,10 +3776,10 @@ var DropZoneRender = forwardRef3(
3549
3776
  zoneCompound = `${areaId}:${zone}`;
3550
3777
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3551
3778
  }
3552
- return /* @__PURE__ */ jsx21("div", { className, style, ref, children: content.map((item) => {
3779
+ return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
3553
3780
  const Component = config.components[item.type];
3554
3781
  if (Component) {
3555
- return /* @__PURE__ */ jsx21(
3782
+ return /* @__PURE__ */ jsx22(
3556
3783
  DropZoneProvider,
3557
3784
  {
3558
3785
  value: {
@@ -3562,10 +3789,12 @@ var DropZoneRender = forwardRef3(
3562
3789
  depth: 1,
3563
3790
  path: []
3564
3791
  },
3565
- children: /* @__PURE__ */ jsx21(
3792
+ children: /* @__PURE__ */ jsx22(
3566
3793
  Component.render,
3567
3794
  __spreadProps(__spreadValues({}, item.props), {
3568
- puck: { renderDropZone: DropZoneRender2 }
3795
+ puck: {
3796
+ renderDropZone: DropZoneRenderPure
3797
+ }
3569
3798
  })
3570
3799
  )
3571
3800
  },
@@ -3578,11 +3807,11 @@ var DropZoneRender = forwardRef3(
3578
3807
  );
3579
3808
  var DropZone = forwardRef3(
3580
3809
  function DropZone2(props, ref) {
3581
- const ctx = useContext3(dropZoneContext);
3810
+ const ctx = useContext6(dropZoneContext);
3582
3811
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3583
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3812
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3584
3813
  }
3585
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3814
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3586
3815
  }
3587
3816
  );
3588
3817
 
@@ -3598,7 +3827,7 @@ var getZoneId = (zoneCompound) => {
3598
3827
  return [rootDroppableId, zoneCompound];
3599
3828
  };
3600
3829
 
3601
- // components/DragDropContext/NestedDroppablePlugin.ts
3830
+ // lib/dnd/NestedDroppablePlugin.ts
3602
3831
  init_react_import();
3603
3832
  import { Plugin } from "@dnd-kit/abstract";
3604
3833
  import { effects } from "@dnd-kit/state";
@@ -3640,7 +3869,49 @@ var getFrame = () => {
3640
3869
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3641
3870
  };
3642
3871
 
3643
- // components/DragDropContext/NestedDroppablePlugin.ts
3872
+ // lib/global-position.ts
3873
+ init_react_import();
3874
+ var GlobalPosition = class {
3875
+ constructor(target, original) {
3876
+ this.scaleFactor = 1;
3877
+ this.frameEl = null;
3878
+ this.frameRect = null;
3879
+ var _a;
3880
+ this.target = target;
3881
+ this.original = original;
3882
+ this.frameEl = document.querySelector("iframe");
3883
+ if (this.frameEl) {
3884
+ this.frameRect = this.frameEl.getBoundingClientRect();
3885
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3886
+ }
3887
+ }
3888
+ get x() {
3889
+ return this.original.x;
3890
+ }
3891
+ get y() {
3892
+ return this.original.y;
3893
+ }
3894
+ get global() {
3895
+ if (document !== this.target.ownerDocument && this.frameRect) {
3896
+ return {
3897
+ x: this.x * this.scaleFactor + this.frameRect.left,
3898
+ y: this.y * this.scaleFactor + this.frameRect.top
3899
+ };
3900
+ }
3901
+ return this.original;
3902
+ }
3903
+ get frame() {
3904
+ if (document === this.target.ownerDocument && this.frameRect) {
3905
+ return {
3906
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
3907
+ y: (this.y - this.frameRect.top) / this.scaleFactor
3908
+ };
3909
+ }
3910
+ return this.original;
3911
+ }
3912
+ };
3913
+
3914
+ // lib/dnd/NestedDroppablePlugin.ts
3644
3915
  var depthSort = (candidates) => {
3645
3916
  return candidates.sort((a, b) => {
3646
3917
  const aData = a.data;
@@ -3669,10 +3940,12 @@ var getZoneId2 = (candidate) => {
3669
3940
  }
3670
3941
  return id;
3671
3942
  };
3672
- var getPointerCollisions = (position, manager, ownerDocument) => {
3673
- var _a;
3943
+ var getPointerCollisions = (position, manager) => {
3674
3944
  const candidates = [];
3675
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
3945
+ let elements = position.target.ownerDocument.elementsFromPoint(
3946
+ position.x,
3947
+ position.y
3948
+ );
3676
3949
  const previewFrame = elements.find(
3677
3950
  (el) => el.getAttribute("data-puck-preview")
3678
3951
  );
@@ -3681,17 +3954,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3681
3954
  elements = [drawer];
3682
3955
  }
3683
3956
  if (previewFrame) {
3684
- const iframe = previewFrame.querySelector("iframe");
3685
- if (iframe) {
3686
- const rect = iframe.getBoundingClientRect();
3687
- const frame = getFrame();
3688
- if (frame) {
3689
- const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3690
- elements = frame.elementsFromPoint(
3691
- (position.x - rect.left) / scaleFactor,
3692
- (position.y - rect.top) / scaleFactor
3693
- );
3694
- }
3957
+ const frame = getFrame();
3958
+ if (frame) {
3959
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3695
3960
  }
3696
3961
  }
3697
3962
  if (elements) {
@@ -3708,9 +3973,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3708
3973
  }
3709
3974
  return candidates;
3710
3975
  };
3711
- var findDeepestCandidate = (position, manager, ownerDocument) => {
3976
+ var findDeepestCandidate = (position, manager) => {
3712
3977
  var _a;
3713
- const candidates = getPointerCollisions(position, manager, ownerDocument);
3978
+ const candidates = getPointerCollisions(position, manager);
3714
3979
  if (candidates.length > 0) {
3715
3980
  const sortedCandidates = depthSort(candidates);
3716
3981
  const draggable = manager.dragOperation.source;
@@ -3755,9 +4020,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
3755
4020
  area: null
3756
4021
  };
3757
4022
  };
3758
- var createNestedDroppablePlugin = ({
3759
- onChange
3760
- }) => class NestedDroppablePlugin extends Plugin {
4023
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
3761
4024
  constructor(manager, options) {
3762
4025
  super(manager);
3763
4026
  if (typeof window === "undefined") {
@@ -3765,16 +4028,19 @@ var createNestedDroppablePlugin = ({
3765
4028
  }
3766
4029
  const cleanupEffect = effects(() => {
3767
4030
  const handleMove = (event) => {
3768
- const position = {
4031
+ const target = event.originalTarget || event.target;
4032
+ const position = new GlobalPosition(target, {
3769
4033
  x: event.clientX,
3770
4034
  y: event.clientY
3771
- };
3772
- const target = event.originalTarget || event.target;
3773
- const ownerDocument = target == null ? void 0 : target.ownerDocument;
3774
- onChange(
3775
- findDeepestCandidate(position, manager, ownerDocument),
3776
- manager
4035
+ });
4036
+ const elements = document.elementsFromPoint(
4037
+ position.global.x,
4038
+ position.global.y
3777
4039
  );
4040
+ const overEl = elements.some((el) => el.id === id);
4041
+ if (overEl) {
4042
+ onChange(findDeepestCandidate(position, manager), manager);
4043
+ }
3778
4044
  };
3779
4045
  const handleMoveThrottled = throttle(handleMove, 50);
3780
4046
  const handlePointerMove = (event) => {
@@ -4104,6 +4370,11 @@ var reduceUi = (ui, action) => {
4104
4370
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4105
4371
  });
4106
4372
  }
4373
+ if (action.type === "remove") {
4374
+ return __spreadProps(__spreadValues({}, ui), {
4375
+ itemSelector: null
4376
+ });
4377
+ }
4107
4378
  return ui;
4108
4379
  };
4109
4380
 
@@ -4191,7 +4462,7 @@ var insertComponent = (componentType, zone, index, {
4191
4462
  import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4192
4463
  import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
4193
4464
 
4194
- // components/DragDropContext/PointerSensor.ts
4465
+ // lib/dnd/PointerSensor.ts
4195
4466
  init_react_import();
4196
4467
  import { batch, effect } from "@dnd-kit/state";
4197
4468
  import { Sensor, configurator } from "@dnd-kit/abstract";
@@ -4363,6 +4634,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
4363
4634
  }
4364
4635
  }
4365
4636
  handlePointerUp(event) {
4637
+ if (!this.source) {
4638
+ return;
4639
+ }
4366
4640
  event.preventDefault();
4367
4641
  event.stopPropagation();
4368
4642
  const { status } = this.manager.dragOperation;
@@ -4462,13 +4736,15 @@ function patchWindow(window2) {
4462
4736
  }
4463
4737
 
4464
4738
  // components/DragDropContext/index.tsx
4465
- import { jsx as jsx22 } from "react/jsx-runtime";
4466
- var dragListenerContext = createContext3({
4739
+ import { createStore as createStore3 } from "zustand";
4740
+ import { jsx as jsx23 } from "react/jsx-runtime";
4741
+ var DEBUG3 = false;
4742
+ var dragListenerContext = createContext4({
4467
4743
  dragListeners: {}
4468
4744
  });
4469
4745
  function useDragListener(type, fn, deps = []) {
4470
- const { setDragListeners } = useContext4(dragListenerContext);
4471
- useEffect13(() => {
4746
+ const { setDragListeners } = useContext7(dragListenerContext);
4747
+ useEffect15(() => {
4472
4748
  if (setDragListeners) {
4473
4749
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
4474
4750
  [type]: [...old[type] || [], fn]
@@ -4476,80 +4752,147 @@ function useDragListener(type, fn, deps = []) {
4476
4752
  }
4477
4753
  }, deps);
4478
4754
  }
4479
- var previewContext = createContext3(null);
4480
4755
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4756
+ var useTempDisableFallback = (timeout3) => {
4757
+ const lastFallbackDisable = useRef3(null);
4758
+ return useCallback11((manager) => {
4759
+ collisionStore.setState({ fallbackEnabled: false });
4760
+ const fallbackId = generateId();
4761
+ lastFallbackDisable.current = fallbackId;
4762
+ setTimeout(() => {
4763
+ if (lastFallbackDisable.current === fallbackId) {
4764
+ collisionStore.setState({ fallbackEnabled: true });
4765
+ manager.collisionObserver.forceUpdate(true);
4766
+ }
4767
+ }, timeout3);
4768
+ }, []);
4769
+ };
4481
4770
  var DragDropContextClient = ({
4482
4771
  children,
4483
4772
  disableAutoScroll
4484
4773
  }) => {
4485
4774
  const { state, config, dispatch, resolveData } = useAppContext();
4486
- const [preview, setPreview] = useState16(null);
4487
- const previewRef = useRef5(null);
4775
+ const id = useId();
4488
4776
  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(
4777
+ const debouncedParamsRef = useRef3(null);
4778
+ const tempDisableFallback = useTempDisableFallback(100);
4779
+ const [zoneStore] = useState17(
4780
+ () => createStore3(() => ({
4781
+ zoneDepthIndex: {},
4782
+ nextZoneDepthIndex: {},
4783
+ areaDepthIndex: {},
4784
+ nextAreaDepthIndex: {},
4785
+ draggedItem: null,
4786
+ previewIndex: {}
4787
+ }))
4788
+ );
4789
+ const getChanged2 = useCallback11(
4790
+ (params, id2) => {
4791
+ const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
4792
+ const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
4793
+ const stateHasArea = Object.keys(areaDepthIndex).length > 0;
4794
+ let zoneChanged = false;
4795
+ let areaChanged = false;
4796
+ if (params.zone && !zoneDepthIndex[params.zone]) {
4797
+ zoneChanged = true;
4798
+ } else if (!params.zone && stateHasZone) {
4799
+ zoneChanged = true;
4800
+ }
4801
+ if (params.area && !areaDepthIndex[params.area]) {
4802
+ areaChanged = true;
4803
+ } else if (!params.area && stateHasArea) {
4804
+ areaChanged = true;
4805
+ }
4806
+ return { zoneChanged, areaChanged };
4807
+ },
4808
+ [zoneStore]
4809
+ );
4810
+ const setDeepestAndCollide = useCallback11(
4494
4811
  (params, manager) => {
4495
- setDeepest(params);
4812
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4813
+ if (!zoneChanged && !areaChanged) return;
4814
+ zoneStore.setState({
4815
+ zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
4816
+ areaDepthIndex: params.area ? { [params.area]: true } : {}
4817
+ });
4818
+ tempDisableFallback(manager);
4496
4819
  setTimeout(() => {
4497
4820
  manager.collisionObserver.forceUpdate(true);
4498
4821
  }, 50);
4499
4822
  debouncedParamsRef.current = null;
4500
4823
  },
4501
- []
4824
+ [zoneStore]
4502
4825
  );
4503
4826
  const setDeepestDb = useDebouncedCallback2(
4504
4827
  setDeepestAndCollide,
4505
4828
  AREA_CHANGE_DEBOUNCE_MS
4506
4829
  );
4507
- useEffect13(() => {
4508
- deepestRef.current = deepest;
4509
- }, [deepest]);
4510
4830
  const cancelDb = () => {
4511
4831
  setDeepestDb.cancel();
4512
4832
  debouncedParamsRef.current = null;
4513
4833
  };
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;
4834
+ useEffect15(() => {
4835
+ if (DEBUG3) {
4836
+ zoneStore.subscribe(
4837
+ (s) => {
4838
+ var _a, _b;
4839
+ return console.log(
4840
+ s.previewIndex,
4841
+ (_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
4842
+ (_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
4843
+ );
4529
4844
  }
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) {
4845
+ );
4846
+ }
4847
+ }, []);
4848
+ const [plugins] = useState17(() => [
4849
+ ...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
4850
+ createNestedDroppablePlugin(
4851
+ {
4852
+ onChange: (params, manager) => {
4853
+ const state2 = zoneStore.getState();
4854
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4855
+ const isDragging = manager.dragOperation.status.dragging;
4856
+ if (areaChanged || zoneChanged) {
4857
+ let nextZoneDepthIndex = {};
4858
+ let nextAreaDepthIndex = {};
4859
+ if (params.zone) {
4860
+ nextZoneDepthIndex = { [params.zone]: true };
4861
+ }
4862
+ if (params.area) {
4863
+ nextAreaDepthIndex = { [params.area]: true };
4864
+ }
4865
+ zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
4866
+ }
4867
+ if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
4868
+ setDeepestAndCollide(params, manager);
4869
+ return;
4870
+ }
4871
+ if (areaChanged) {
4872
+ if (isDragging) {
4873
+ const debouncedParams = debouncedParamsRef.current;
4874
+ const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4875
+ if (!isSameParams) {
4876
+ cancelDb();
4877
+ setDeepestDb(params, manager);
4878
+ debouncedParamsRef.current = params;
4879
+ }
4880
+ } else {
4535
4881
  cancelDb();
4536
- setDeepestDb(params, manager);
4537
- debouncedParamsRef.current = params;
4882
+ setDeepestAndCollide(params, manager);
4538
4883
  }
4539
- } else {
4540
- cancelDb();
4884
+ return;
4885
+ }
4886
+ if (zoneChanged) {
4541
4887
  setDeepestAndCollide(params, manager);
4542
4888
  }
4543
- return;
4544
- }
4545
- if (zoneChanged) {
4546
- setDeepestAndCollide(params, manager);
4889
+ cancelDb();
4547
4890
  }
4548
- cancelDb();
4549
- }
4550
- })
4891
+ },
4892
+ id
4893
+ )
4551
4894
  ]);
4552
- const [sensors] = useState16(() => [
4895
+ const [sensors] = useState17(() => [
4553
4896
  PointerSensor.configure({
4554
4897
  activationConstraints(event, source) {
4555
4898
  var _a;
@@ -4568,67 +4911,72 @@ var DragDropContextClient = ({
4568
4911
  }
4569
4912
  })
4570
4913
  ]);
4571
- const [draggedItem, setDraggedItem] = useState16();
4572
- const [dragListeners, setDragListeners] = useState16({});
4573
- const [pathData, setPathData] = useState16();
4574
- const dragMode = useRef5(null);
4575
- const registerPath = useCallback9(
4576
- (selector) => {
4577
- const item = getItem(selector, data);
4578
- if (!item) {
4579
- return;
4580
- }
4914
+ const [dragListeners, setDragListeners] = useState17({});
4915
+ const [pathData, setPathData] = useState17();
4916
+ const dragMode = useRef3(null);
4917
+ const registerPath = useCallback11(
4918
+ (id2, selector, label) => {
4581
4919
  const [area] = getZoneId(selector.zone);
4582
4920
  setPathData((latestPathData = {}) => {
4583
4921
  const parentPathData = latestPathData[area] || { path: [] };
4584
4922
  return __spreadProps(__spreadValues({}, latestPathData), {
4585
- [item.props.id]: {
4923
+ [id2]: {
4586
4924
  path: [
4587
4925
  ...parentPathData.path,
4588
4926
  ...selector.zone ? [selector.zone] : []
4589
4927
  ],
4590
- label: item.type
4928
+ label
4591
4929
  }
4592
4930
  });
4593
4931
  });
4594
4932
  },
4595
4933
  [data, setPathData]
4596
4934
  );
4597
- const initialSelector = useRef5(void 0);
4598
- return /* @__PURE__ */ jsx22(
4935
+ const unregisterPath = useCallback11(
4936
+ (id2) => {
4937
+ setPathData((latestPathData = {}) => {
4938
+ const newPathData = __spreadValues({}, latestPathData);
4939
+ delete newPathData[id2];
4940
+ return newPathData;
4941
+ });
4942
+ },
4943
+ [data, setPathData]
4944
+ );
4945
+ const initialSelector = useRef3(void 0);
4946
+ return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
4599
4947
  dragListenerContext.Provider,
4600
4948
  {
4601
4949
  value: {
4602
4950
  dragListeners,
4603
4951
  setDragListeners
4604
4952
  },
4605
- children: /* @__PURE__ */ jsx22(previewContext.Provider, { value: preview, children: /* @__PURE__ */ jsx22(
4953
+ children: /* @__PURE__ */ jsx23(
4606
4954
  DragDropProvider2,
4607
4955
  {
4608
4956
  plugins,
4609
4957
  sensors,
4610
4958
  onDragEnd: (event, manager) => {
4959
+ var _a;
4611
4960
  const { source, target } = event.operation;
4612
- deepestRef.current = null;
4613
4961
  if (!source) {
4614
- setDraggedItem(null);
4962
+ zoneStore.setState({ draggedItem: null });
4615
4963
  return;
4616
4964
  }
4617
4965
  const { zone, index } = source.data;
4618
- const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
4619
- previewRef.current = null;
4966
+ const { previewIndex = {} } = zoneStore.getState() || {};
4967
+ const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
4620
4968
  setTimeout(() => {
4621
- var _a, _b;
4622
- setDraggedItem(null);
4969
+ var _a2, _b;
4970
+ zoneStore.setState({ draggedItem: null });
4623
4971
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4624
- setPreview(null);
4625
- (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
4972
+ zoneStore.setState({ previewIndex: {} });
4973
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
4626
4974
  fn(event, manager);
4627
4975
  });
4628
4976
  return;
4629
4977
  }
4630
4978
  if (thisPreview) {
4631
- setPreview(null);
4979
+ zoneStore.setState({ previewIndex: {} });
4632
4980
  if (thisPreview.type === "insert") {
4633
4981
  insertComponent(
4634
4982
  thisPreview.componentType,
@@ -4663,8 +5011,9 @@ var DragDropContextClient = ({
4663
5011
  }, 250);
4664
5012
  },
4665
5013
  onDragOver: (event, manager) => {
4666
- var _a, _b, _c, _d;
5014
+ var _a, _b, _c, _d, _e;
4667
5015
  event.preventDefault();
5016
+ const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
4668
5017
  if (!draggedItem) return;
4669
5018
  cancelDb();
4670
5019
  const { source, target } = event.operation;
@@ -4680,7 +5029,7 @@ var DragDropContextClient = ({
4680
5029
  const targetData = target.data;
4681
5030
  targetZone = targetData.zone;
4682
5031
  targetIndex = targetData.index;
4683
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
5032
+ const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
4684
5033
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
4685
5034
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
4686
5035
  targetIndex = targetIndex - 1;
@@ -4692,23 +5041,26 @@ var DragDropContextClient = ({
4692
5041
  targetZone = target.id.toString();
4693
5042
  targetIndex = 0;
4694
5043
  }
4695
- if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
5044
+ if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
4696
5045
  const [pathId] = path.split(":");
4697
5046
  return pathId === sourceId;
4698
5047
  }))) {
4699
5048
  return;
4700
5049
  }
4701
5050
  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()
5051
+ zoneStore.setState({
5052
+ previewIndex: {
5053
+ [targetZone]: {
5054
+ componentType: sourceData.componentType,
5055
+ type: "insert",
5056
+ index: targetIndex,
5057
+ zone: targetZone,
5058
+ props: {
5059
+ id: source.id.toString()
5060
+ }
5061
+ }
4709
5062
  }
4710
- };
4711
- setPreview(previewRef.current);
5063
+ });
4712
5064
  } else {
4713
5065
  if (!initialSelector.current) {
4714
5066
  initialSelector.current = {
@@ -4718,17 +5070,20 @@ var DragDropContextClient = ({
4718
5070
  }
4719
5071
  const item = getItem(initialSelector.current, data);
4720
5072
  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);
5073
+ zoneStore.setState({
5074
+ previewIndex: {
5075
+ [targetZone]: {
5076
+ componentType: sourceData.componentType,
5077
+ type: "move",
5078
+ index: targetIndex,
5079
+ zone: targetZone,
5080
+ props: item.props
5081
+ }
5082
+ }
5083
+ });
4729
5084
  }
4730
5085
  }
4731
- (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
5086
+ (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
4732
5087
  fn(event, manager);
4733
5088
  });
4734
5089
  },
@@ -4738,45 +5093,62 @@ var DragDropContextClient = ({
4738
5093
  type: "setUi",
4739
5094
  ui: { itemSelector: null, isDragging: true }
4740
5095
  });
5096
+ const { source } = event.operation;
5097
+ if (source && source.type !== "void") {
5098
+ const sourceData = source.data;
5099
+ const item = getItem(
5100
+ {
5101
+ zone: sourceData.zone,
5102
+ index: sourceData.index
5103
+ },
5104
+ data
5105
+ );
5106
+ if (item) {
5107
+ zoneStore.setState({
5108
+ previewIndex: {
5109
+ [sourceData.zone]: {
5110
+ componentType: sourceData.componentType,
5111
+ type: "move",
5112
+ index: sourceData.index,
5113
+ zone: sourceData.zone,
5114
+ props: item.props
5115
+ }
5116
+ }
5117
+ });
5118
+ }
5119
+ }
4741
5120
  (_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
4742
5121
  fn(event, manager);
4743
5122
  });
4744
5123
  },
4745
5124
  onBeforeDragStart: (event) => {
4746
5125
  var _a;
4747
- if (draggedItem) {
4748
- console.warn("New drag started before previous drag cleaned up");
4749
- }
4750
5126
  const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
4751
5127
  dragMode.current = isNewComponent ? "new" : "existing";
4752
5128
  initialSelector.current = void 0;
4753
- setDraggedItem(event.operation.source);
5129
+ zoneStore.setState({ draggedItem: event.operation.source });
4754
5130
  },
4755
- children: /* @__PURE__ */ jsx22(
5131
+ children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
4756
5132
  DropZoneProvider,
4757
5133
  {
4758
5134
  value: {
4759
5135
  data,
4760
5136
  config,
4761
- draggedItem,
4762
5137
  mode: "edit",
4763
5138
  areaId: "root",
4764
5139
  depth: 0,
4765
5140
  registerPath,
5141
+ unregisterPath,
4766
5142
  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
5143
  path: []
4772
5144
  },
4773
5145
  children
4774
5146
  }
4775
- )
5147
+ ) })
4776
5148
  }
4777
- ) })
5149
+ )
4778
5150
  }
4779
- );
5151
+ ) });
4780
5152
  };
4781
5153
  var DragDropContext = ({
4782
5154
  children,
@@ -4786,11 +5158,11 @@ var DragDropContext = ({
4786
5158
  if (status === "LOADING") {
4787
5159
  return children;
4788
5160
  }
4789
- return /* @__PURE__ */ jsx22(DragDropContextClient, { disableAutoScroll, children });
5161
+ return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
4790
5162
  };
4791
5163
 
4792
5164
  // components/Drawer/index.tsx
4793
- import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
5165
+ import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
4794
5166
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
4795
5167
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
4796
5168
  var DrawerItemInner = ({
@@ -4800,11 +5172,11 @@ var DrawerItemInner = ({
4800
5172
  dragRef,
4801
5173
  isDragDisabled
4802
5174
  }) => {
4803
- const CustomInner = useMemo8(
4804
- () => children || (({ children: children2 }) => /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("default"), children: children2 })),
5175
+ const CustomInner = useMemo9(
5176
+ () => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
4805
5177
  [children]
4806
5178
  );
4807
- return /* @__PURE__ */ jsx23(
5179
+ return /* @__PURE__ */ jsx24(
4808
5180
  "div",
4809
5181
  {
4810
5182
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -4812,9 +5184,9 @@ var DrawerItemInner = ({
4812
5184
  onMouseDown: (e) => e.preventDefault(),
4813
5185
  "data-testid": dragRef ? `drawer-item:${name}` : "",
4814
5186
  "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, {}) })
5187
+ children: /* @__PURE__ */ jsx24(CustomInner, { name, children: /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
5188
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5189
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx24(DragIcon, {}) })
4818
5190
  ] }) }) })
4819
5191
  }
4820
5192
  );
@@ -4832,8 +5204,8 @@ var DrawerItemDraggable = ({
4832
5204
  disabled: isDragDisabled
4833
5205
  });
4834
5206
  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(
5207
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx24(DrawerItemInner, { name, label, children }) }),
5208
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx24(
4837
5209
  DrawerItemInner,
4838
5210
  {
4839
5211
  name,
@@ -4854,7 +5226,7 @@ var DrawerItem = ({
4854
5226
  isDragDisabled
4855
5227
  }) => {
4856
5228
  const resolvedId = id || name;
4857
- const [dynamicId, setDynamicId] = useState17(generateId(resolvedId));
5229
+ const [dynamicId, setDynamicId] = useState18(generateId(resolvedId));
4858
5230
  if (typeof index !== "undefined") {
4859
5231
  console.error(
4860
5232
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -4867,7 +5239,7 @@ var DrawerItem = ({
4867
5239
  },
4868
5240
  [resolvedId]
4869
5241
  );
4870
- return /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
5242
+ return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
4871
5243
  DrawerItemDraggable,
4872
5244
  {
4873
5245
  name,
@@ -4893,14 +5265,14 @@ var Drawer = ({
4893
5265
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
4894
5266
  );
4895
5267
  }
4896
- const [id] = useState17(generateId());
5268
+ const id = useId2();
4897
5269
  const { ref } = useDroppableSafe({
4898
5270
  id,
4899
5271
  type: "void",
4900
5272
  collisionPriority: 0
4901
5273
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
4902
5274
  });
4903
- return /* @__PURE__ */ jsx23(
5275
+ return /* @__PURE__ */ jsx24(
4904
5276
  "div",
4905
5277
  {
4906
5278
  className: getClassName18(),
@@ -4916,11 +5288,11 @@ Drawer.Item = DrawerItem;
4916
5288
  // components/Puck/index.tsx
4917
5289
  init_react_import();
4918
5290
  import {
4919
- useCallback as useCallback15,
4920
- useEffect as useEffect21,
4921
- useMemo as useMemo17,
5291
+ useCallback as useCallback18,
5292
+ useEffect as useEffect24,
5293
+ useMemo as useMemo19,
4922
5294
  useReducer,
4923
- useState as useState25
5295
+ useState as useState26
4924
5296
  } from "react";
4925
5297
 
4926
5298
  // components/SidebarSection/index.tsx
@@ -4932,7 +5304,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
4932
5304
 
4933
5305
  // lib/use-breadcrumbs.ts
4934
5306
  init_react_import();
4935
- import { useContext as useContext5, useMemo as useMemo9 } from "react";
5307
+ import { useContext as useContext8, useMemo as useMemo10 } from "react";
4936
5308
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
4937
5309
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
4938
5310
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -4982,8 +5354,8 @@ var useBreadcrumbs = (renderCount) => {
4982
5354
  state: { data },
4983
5355
  selectedItem
4984
5356
  } = useAppContext();
4985
- const dzContext = useContext5(dropZoneContext);
4986
- return useMemo9(() => {
5357
+ const dzContext = useContext8(dropZoneContext);
5358
+ return useMemo10(() => {
4987
5359
  const breadcrumbs = convertPathDataToBreadcrumbs(
4988
5360
  selectedItem,
4989
5361
  dzContext == null ? void 0 : dzContext.pathData,
@@ -4997,7 +5369,7 @@ var useBreadcrumbs = (renderCount) => {
4997
5369
  };
4998
5370
 
4999
5371
  // components/SidebarSection/index.tsx
5000
- import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
5372
+ import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
5001
5373
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5002
5374
  var SidebarSection = ({
5003
5375
  children,
@@ -5016,9 +5388,9 @@ var SidebarSection = ({
5016
5388
  className: getClassName19({ noBorderTop, noPadding }),
5017
5389
  style: { background },
5018
5390
  children: [
5019
- /* @__PURE__ */ jsx24("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5391
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5020
5392
  showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
5021
- /* @__PURE__ */ jsx24(
5393
+ /* @__PURE__ */ jsx25(
5022
5394
  "button",
5023
5395
  {
5024
5396
  type: "button",
@@ -5027,12 +5399,12 @@ var SidebarSection = ({
5027
5399
  children: breadcrumb.label
5028
5400
  }
5029
5401
  ),
5030
- /* @__PURE__ */ jsx24(ChevronRight, { size: 16 })
5402
+ /* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
5031
5403
  ] }, i)) : null,
5032
- /* @__PURE__ */ jsx24("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx24(Heading, { rank: "2", size: "xs", children: title }) })
5404
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
5033
5405
  ] }) }),
5034
- /* @__PURE__ */ jsx24("div", { className: getClassName19("content"), children }),
5035
- isLoading && /* @__PURE__ */ jsx24("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx24(Loader, { size: 32 }) })
5406
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
5407
+ isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
5036
5408
  ]
5037
5409
  }
5038
5410
  );
@@ -5063,7 +5435,7 @@ init_react_import();
5063
5435
  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
5436
 
5065
5437
  // components/MenuBar/index.tsx
5066
- import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
5438
+ import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
5067
5439
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5068
5440
  function MenuBar({
5069
5441
  appState,
@@ -5077,7 +5449,7 @@ function MenuBar({
5077
5449
  history: { back, forward, historyStore }
5078
5450
  } = useAppContext();
5079
5451
  const { hasFuture = false, hasPast = false } = historyStore || {};
5080
- return /* @__PURE__ */ jsx25(
5452
+ return /* @__PURE__ */ jsx26(
5081
5453
  "div",
5082
5454
  {
5083
5455
  className: getClassName20({ menuOpen }),
@@ -5093,10 +5465,10 @@ function MenuBar({
5093
5465
  },
5094
5466
  children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
5095
5467
  /* @__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 }) })
5468
+ /* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
5469
+ /* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
5098
5470
  ] }),
5099
- /* @__PURE__ */ jsx25(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5471
+ /* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5100
5472
  state: appState,
5101
5473
  dispatch
5102
5474
  }) })
@@ -5107,43 +5479,68 @@ function MenuBar({
5107
5479
 
5108
5480
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5109
5481
  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" };
5482
+ 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
5483
 
5112
5484
  // components/Puck/components/Fields/index.tsx
5113
5485
  init_react_import();
5114
5486
 
5115
5487
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5116
5488
  init_react_import();
5117
- 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" };
5489
+ var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
5118
5490
 
5119
5491
  // components/Puck/components/Fields/index.tsx
5120
- import { useCallback as useCallback10, useEffect as useEffect14, useMemo as useMemo10, useState as useState18 } from "react";
5492
+ import { useMemo as useMemo12 } from "react";
5493
+
5494
+ // lib/use-resolved-fields.ts
5495
+ init_react_import();
5496
+ import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
5121
5497
 
5122
5498
  // lib/use-parent.ts
5123
5499
  init_react_import();
5124
- import { useContext as useContext6 } from "react";
5125
- var useParent = (itemSelector) => {
5500
+ import { useCallback as useCallback12, useContext as useContext9 } from "react";
5501
+ var getParent = (itemSelector, pathData, data) => {
5126
5502
  var _a;
5127
- const { selectedItem, state } = useAppContext();
5128
- const { pathData } = useContext6(dropZoneContext) || {};
5129
- const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5130
- const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5503
+ if (!itemSelector) return null;
5504
+ const item = getItem(itemSelector, data);
5505
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
5131
5506
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
5132
- const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
5507
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
5133
5508
  return parent || null;
5134
5509
  };
5510
+ var useGetParent = () => {
5511
+ const { state } = useAppContext();
5512
+ const { pathData } = useContext9(dropZoneContext) || {};
5513
+ return useCallback12(
5514
+ () => getParent(state.ui.itemSelector, pathData, state.data),
5515
+ [state.ui.itemSelector, pathData, state.data]
5516
+ );
5517
+ };
5518
+ var useParent = () => {
5519
+ return useGetParent()();
5520
+ };
5135
5521
 
5136
- // components/Puck/components/Fields/index.tsx
5137
- import { Fragment as Fragment8, jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
5138
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5522
+ // lib/use-on-value-change.ts
5523
+ init_react_import();
5524
+ import { useRef as useRef4, useEffect as useEffect16 } from "react";
5525
+ function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5526
+ const tracked = useRef4(value);
5527
+ useEffect16(() => {
5528
+ const oldValue = tracked.current;
5529
+ if (!compare(value, oldValue)) {
5530
+ tracked.current = value;
5531
+ onChange(value, oldValue);
5532
+ }
5533
+ }, [onChange, compare, value, ...deps]);
5534
+ }
5535
+
5536
+ // lib/selector-is.ts
5537
+ init_react_import();
5538
+ var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
5539
+
5540
+ // lib/use-resolved-fields.ts
5139
5541
  var defaultPageFields = {
5140
5542
  title: { type: "text" }
5141
5543
  };
5142
- var DefaultFields = ({
5143
- children
5144
- }) => {
5145
- return /* @__PURE__ */ jsx26(Fragment8, { children });
5146
- };
5147
5544
  var useResolvedFields = () => {
5148
5545
  var _a, _b;
5149
5546
  const { selectedItem, state, config } = useAppContext();
@@ -5151,20 +5548,21 @@ var useResolvedFields = () => {
5151
5548
  const { data } = state;
5152
5549
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5153
5550
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5154
- const defaultFields = useMemo10(
5551
+ const defaultFields = useMemo11(
5155
5552
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5156
5553
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5157
5554
  );
5158
5555
  const rootProps = data.root.props || data.root;
5159
- const [lastSelectedData, setLastSelectedData] = useState18({});
5160
- const [resolvedFields, setResolvedFields] = useState18(defaultFields);
5161
- const [fieldsLoading, setFieldsLoading] = useState18(false);
5556
+ const [lastSelectedData, setLastSelectedData] = useState19({});
5557
+ const [resolvedFields, setResolvedFields] = useState19(defaultFields);
5558
+ const [fieldsLoading, setFieldsLoading] = useState19(false);
5559
+ const lastFields = useRef5(defaultFields);
5162
5560
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5163
5561
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5164
5562
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5165
5563
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5166
5564
  const hasResolver = hasComponentResolver || hasRootResolver;
5167
- const resolveFields = useCallback10(
5565
+ const resolveFields = useCallback13(
5168
5566
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5169
5567
  var _a2;
5170
5568
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5176,7 +5574,7 @@ var useResolvedFields = () => {
5176
5574
  {
5177
5575
  changed,
5178
5576
  fields,
5179
- lastFields: resolvedFields,
5577
+ lastFields: lastFields.current,
5180
5578
  lastData,
5181
5579
  appState: state,
5182
5580
  parent
@@ -5187,7 +5585,7 @@ var useResolvedFields = () => {
5187
5585
  return yield config.root.resolveFields(componentData, {
5188
5586
  changed,
5189
5587
  fields,
5190
- lastFields: resolvedFields,
5588
+ lastFields: lastFields.current,
5191
5589
  lastData,
5192
5590
  appState: state,
5193
5591
  parent
@@ -5196,26 +5594,56 @@ var useResolvedFields = () => {
5196
5594
  return defaultResolveFields(componentData, {
5197
5595
  changed,
5198
5596
  fields,
5199
- lastFields: resolvedFields,
5597
+ lastFields: lastFields.current,
5200
5598
  lastData
5201
5599
  });
5202
5600
  }),
5203
- [data, config, componentData, selectedItem, resolvedFields, state]
5601
+ [data, config, componentData, selectedItem, state, parent]
5204
5602
  );
5205
- useEffect14(() => {
5206
- if (hasResolver) {
5207
- setFieldsLoading(true);
5208
- resolveFields(defaultFields).then((fields) => {
5209
- setResolvedFields(fields || {});
5210
- setFieldsLoading(false);
5211
- });
5212
- } else {
5213
- setResolvedFields(defaultFields);
5603
+ const triggerResolver = useCallback13(() => {
5604
+ var _a2, _b2;
5605
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5606
+ if (hasResolver) {
5607
+ setFieldsLoading(true);
5608
+ resolveFields(defaultFields).then((fields) => {
5609
+ setResolvedFields(fields || {});
5610
+ lastFields.current = fields;
5611
+ setFieldsLoading(false);
5612
+ });
5613
+ return;
5614
+ }
5214
5615
  }
5215
- }, [data, defaultFields, selectedItem, hasResolver]);
5616
+ setResolvedFields(defaultFields);
5617
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5618
+ useOnValueChange(
5619
+ state.ui.itemSelector,
5620
+ () => {
5621
+ lastFields.current = defaultFields;
5622
+ },
5623
+ selectorIs
5624
+ );
5625
+ useOnValueChange(
5626
+ { data, parent, itemSelector: state.ui.itemSelector },
5627
+ () => {
5628
+ triggerResolver();
5629
+ },
5630
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
5631
+ );
5632
+ useEffect17(() => {
5633
+ triggerResolver();
5634
+ }, []);
5216
5635
  return [resolvedFields, fieldsLoading];
5217
5636
  };
5218
- var Fields = () => {
5637
+
5638
+ // components/Puck/components/Fields/index.tsx
5639
+ import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5640
+ var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5641
+ var DefaultFields = ({
5642
+ children
5643
+ }) => {
5644
+ return /* @__PURE__ */ jsx27(Fragment8, { children });
5645
+ };
5646
+ var Fields = ({ wrapFields = true }) => {
5219
5647
  var _a, _b;
5220
5648
  const {
5221
5649
  selectedItem,
@@ -5233,16 +5661,16 @@ var Fields = () => {
5233
5661
  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
5662
  const isLoading = fieldsResolving || componentResolving;
5235
5663
  const rootProps = data.root.props || data.root;
5236
- const Wrapper = useMemo10(() => overrides.fields || DefaultFields, [overrides]);
5664
+ const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
5237
5665
  return /* @__PURE__ */ jsxs14(
5238
5666
  "form",
5239
5667
  {
5240
- className: getClassName21(),
5668
+ className: getClassName21({ wrapFields }),
5241
5669
  onSubmit: (e) => {
5242
5670
  e.preventDefault();
5243
5671
  },
5244
5672
  children: [
5245
- /* @__PURE__ */ jsx26(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5673
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5246
5674
  const field = fields[fieldName];
5247
5675
  if (!(field == null ? void 0 : field.type)) return null;
5248
5676
  const onChange = (value, updatedUi) => {
@@ -5313,7 +5741,7 @@ var Fields = () => {
5313
5741
  item: selectedItem
5314
5742
  });
5315
5743
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5316
- return /* @__PURE__ */ jsx26(
5744
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5317
5745
  AutoFieldPrivate,
5318
5746
  {
5319
5747
  field,
@@ -5322,16 +5750,15 @@ var Fields = () => {
5322
5750
  readOnly: !edit || readOnly[fieldName],
5323
5751
  value: selectedItem.props[fieldName],
5324
5752
  onChange
5325
- },
5326
- id
5327
- );
5753
+ }
5754
+ ) }, id);
5328
5755
  } else {
5329
5756
  const readOnly = data.root.readOnly || {};
5330
5757
  const { edit } = getPermissions({
5331
5758
  root: true
5332
5759
  });
5333
5760
  const id = `root_${field.type}_${fieldName}`;
5334
- return /* @__PURE__ */ jsx26(
5761
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5335
5762
  AutoFieldPrivate,
5336
5763
  {
5337
5764
  field,
@@ -5340,12 +5767,11 @@ var Fields = () => {
5340
5767
  readOnly: !edit || readOnly[fieldName],
5341
5768
  value: rootProps[fieldName],
5342
5769
  onChange
5343
- },
5344
- id
5345
- );
5770
+ }
5771
+ ) }, id);
5346
5772
  }
5347
5773
  }) }),
5348
- isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx26(Loader, { size: 16 }) }) })
5774
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
5349
5775
  ]
5350
5776
  }
5351
5777
  );
@@ -5356,7 +5782,7 @@ init_react_import();
5356
5782
 
5357
5783
  // lib/use-component-list.tsx
5358
5784
  init_react_import();
5359
- import { useEffect as useEffect15, useState as useState19 } from "react";
5785
+ import { useEffect as useEffect18, useState as useState20 } from "react";
5360
5786
 
5361
5787
  // components/ComponentList/index.tsx
5362
5788
  init_react_import();
@@ -5366,7 +5792,7 @@ init_react_import();
5366
5792
  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
5793
 
5368
5794
  // components/ComponentList/index.tsx
5369
- import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
5795
+ import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
5370
5796
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
5371
5797
  var ComponentListItem = ({
5372
5798
  name,
@@ -5376,7 +5802,7 @@ var ComponentListItem = ({
5376
5802
  const canInsert = getPermissions({
5377
5803
  type: name
5378
5804
  }).insert;
5379
- return /* @__PURE__ */ jsx27(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5805
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5380
5806
  };
5381
5807
  var ComponentList = ({
5382
5808
  children,
@@ -5400,14 +5826,14 @@ var ComponentList = ({
5400
5826
  }),
5401
5827
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
5402
5828
  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 }) })
5829
+ /* @__PURE__ */ jsx28("div", { children: title }),
5830
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
5405
5831
  ]
5406
5832
  }
5407
5833
  ),
5408
- /* @__PURE__ */ jsx27("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx27(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5834
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5409
5835
  var _a;
5410
- return /* @__PURE__ */ jsx27(
5836
+ return /* @__PURE__ */ jsx28(
5411
5837
  ComponentListItem,
5412
5838
  {
5413
5839
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -5421,10 +5847,10 @@ var ComponentList = ({
5421
5847
  ComponentList.Item = ComponentListItem;
5422
5848
 
5423
5849
  // lib/use-component-list.tsx
5424
- import { jsx as jsx28 } from "react/jsx-runtime";
5850
+ import { jsx as jsx29 } from "react/jsx-runtime";
5425
5851
  var useComponentList = (config, ui) => {
5426
- const [componentList, setComponentList] = useState19();
5427
- useEffect15(() => {
5852
+ const [componentList, setComponentList] = useState20();
5853
+ useEffect18(() => {
5428
5854
  var _a, _b, _c;
5429
5855
  if (Object.keys(ui.componentList).length > 0) {
5430
5856
  const matchedComponents = [];
@@ -5434,7 +5860,7 @@ var useComponentList = (config, ui) => {
5434
5860
  if (category.visible === false || !category.components) {
5435
5861
  return null;
5436
5862
  }
5437
- return /* @__PURE__ */ jsx28(
5863
+ return /* @__PURE__ */ jsx29(
5438
5864
  ComponentList,
5439
5865
  {
5440
5866
  id: categoryKey,
@@ -5443,7 +5869,7 @@ var useComponentList = (config, ui) => {
5443
5869
  var _a2;
5444
5870
  matchedComponents.push(componentName);
5445
5871
  const componentConf = config.components[componentName] || {};
5446
- return /* @__PURE__ */ jsx28(
5872
+ return /* @__PURE__ */ jsx29(
5447
5873
  ComponentList.Item,
5448
5874
  {
5449
5875
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -5463,7 +5889,7 @@ var useComponentList = (config, ui) => {
5463
5889
  );
5464
5890
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
5465
5891
  _componentList.push(
5466
- /* @__PURE__ */ jsx28(
5892
+ /* @__PURE__ */ jsx29(
5467
5893
  ComponentList,
5468
5894
  {
5469
5895
  id: "other",
@@ -5471,7 +5897,7 @@ var useComponentList = (config, ui) => {
5471
5897
  children: remainingComponents.map((componentName, i) => {
5472
5898
  var _a2;
5473
5899
  const componentConf = config.components[componentName] || {};
5474
- return /* @__PURE__ */ jsx28(
5900
+ return /* @__PURE__ */ jsx29(
5475
5901
  ComponentList.Item,
5476
5902
  {
5477
5903
  name: componentName,
@@ -5493,30 +5919,30 @@ var useComponentList = (config, ui) => {
5493
5919
  };
5494
5920
 
5495
5921
  // components/Puck/components/Components/index.tsx
5496
- import { useMemo as useMemo11 } from "react";
5497
- import { jsx as jsx29 } from "react/jsx-runtime";
5922
+ import { useMemo as useMemo13 } from "react";
5923
+ import { jsx as jsx30 } from "react/jsx-runtime";
5498
5924
  var Components = () => {
5499
5925
  const { config, state, overrides } = useAppContext();
5500
5926
  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" }) });
5927
+ const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
5928
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
5503
5929
  };
5504
5930
 
5505
5931
  // components/Puck/components/Preview/index.tsx
5506
5932
  init_react_import();
5507
- import { useCallback as useCallback11, useEffect as useEffect17, useRef as useRef7, useMemo as useMemo12 } from "react";
5933
+ import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
5508
5934
 
5509
5935
  // components/AutoFrame/index.tsx
5510
5936
  init_react_import();
5511
5937
  import {
5512
- createContext as createContext4,
5513
- useContext as useContext7,
5514
- useEffect as useEffect16,
5515
- useState as useState20
5938
+ createContext as createContext5,
5939
+ useContext as useContext10,
5940
+ useEffect as useEffect19,
5941
+ useState as useState21
5516
5942
  } from "react";
5517
5943
  import hash from "object-hash";
5518
5944
  import { createPortal as createPortal3 } from "react-dom";
5519
- import { Fragment as Fragment9, jsx as jsx30 } from "react/jsx-runtime";
5945
+ import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
5520
5946
  var styleSelector = 'style, link[rel="stylesheet"]';
5521
5947
  var collectStyles = (doc) => {
5522
5948
  const collected = [];
@@ -5559,7 +5985,7 @@ var CopyHostStyles = ({
5559
5985
  onStylesLoaded = () => null
5560
5986
  }) => {
5561
5987
  const { document: doc, window: win } = useFrame();
5562
- useEffect16(() => {
5988
+ useEffect19(() => {
5563
5989
  if (!win || !doc) {
5564
5990
  return () => {
5565
5991
  };
@@ -5716,10 +6142,10 @@ var CopyHostStyles = ({
5716
6142
  observer.disconnect();
5717
6143
  };
5718
6144
  }, []);
5719
- return /* @__PURE__ */ jsx30(Fragment9, { children });
6145
+ return /* @__PURE__ */ jsx31(Fragment9, { children });
5720
6146
  };
5721
- var autoFrameContext = createContext4({});
5722
- var useFrame = () => useContext7(autoFrameContext);
6147
+ var autoFrameContext = createContext5({});
6148
+ var useFrame = () => useContext10(autoFrameContext);
5723
6149
  function AutoFrame(_a) {
5724
6150
  var _b = _a, {
5725
6151
  children,
@@ -5736,10 +6162,10 @@ function AutoFrame(_a) {
5736
6162
  "onStylesLoaded",
5737
6163
  "frameRef"
5738
6164
  ]);
5739
- const [loaded, setLoaded] = useState20(false);
5740
- const [ctx, setCtx] = useState20({});
5741
- const [mountTarget, setMountTarget] = useState20();
5742
- useEffect16(() => {
6165
+ const [loaded, setLoaded] = useState21(false);
6166
+ const [ctx, setCtx] = useState21({});
6167
+ const [mountTarget, setMountTarget] = useState21();
6168
+ useEffect19(() => {
5743
6169
  var _a2;
5744
6170
  if (frameRef.current) {
5745
6171
  setCtx({
@@ -5751,7 +6177,7 @@ function AutoFrame(_a) {
5751
6177
  );
5752
6178
  }
5753
6179
  }, [frameRef, loaded]);
5754
- return /* @__PURE__ */ jsx30(
6180
+ return /* @__PURE__ */ jsx31(
5755
6181
  "iframe",
5756
6182
  __spreadProps(__spreadValues({}, props), {
5757
6183
  className,
@@ -5761,7 +6187,7 @@ function AutoFrame(_a) {
5761
6187
  onLoad: () => {
5762
6188
  setLoaded(true);
5763
6189
  },
5764
- children: /* @__PURE__ */ jsx30(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx30(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
6190
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
5765
6191
  })
5766
6192
  );
5767
6193
  }
@@ -5774,7 +6200,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
5774
6200
 
5775
6201
  // components/Render/index.tsx
5776
6202
  init_react_import();
5777
- import { jsx as jsx31 } from "react/jsx-runtime";
6203
+ import { jsx as jsx32 } from "react/jsx-runtime";
5778
6204
  function Render({
5779
6205
  config,
5780
6206
  data
@@ -5787,7 +6213,7 @@ function Render({
5787
6213
  const rootProps = defaultedData.root.props || defaultedData.root;
5788
6214
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
5789
6215
  if ((_a = config.root) == null ? void 0 : _a.render) {
5790
- return /* @__PURE__ */ jsx31(
6216
+ return /* @__PURE__ */ jsx32(
5791
6217
  DropZoneProvider,
5792
6218
  {
5793
6219
  value: {
@@ -5797,7 +6223,7 @@ function Render({
5797
6223
  depth: 0,
5798
6224
  path: []
5799
6225
  },
5800
- children: /* @__PURE__ */ jsx31(
6226
+ children: /* @__PURE__ */ jsx32(
5801
6227
  config.root.render,
5802
6228
  __spreadProps(__spreadValues({}, rootProps), {
5803
6229
  puck: {
@@ -5807,13 +6233,13 @@ function Render({
5807
6233
  title,
5808
6234
  editMode: false,
5809
6235
  id: "puck-root",
5810
- children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
6236
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
5811
6237
  })
5812
6238
  )
5813
6239
  }
5814
6240
  );
5815
6241
  }
5816
- return /* @__PURE__ */ jsx31(
6242
+ return /* @__PURE__ */ jsx32(
5817
6243
  DropZoneProvider,
5818
6244
  {
5819
6245
  value: {
@@ -5823,17 +6249,17 @@ function Render({
5823
6249
  depth: 0,
5824
6250
  path: []
5825
6251
  },
5826
- children: /* @__PURE__ */ jsx31(DropZone, { zone: rootDroppableId })
6252
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
5827
6253
  }
5828
6254
  );
5829
6255
  }
5830
6256
 
5831
6257
  // components/Puck/components/Preview/index.tsx
5832
- import { Fragment as Fragment10, jsx as jsx32 } from "react/jsx-runtime";
6258
+ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
5833
6259
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
5834
6260
  var useBubbleIframeEvents = (ref) => {
5835
6261
  const { status } = useAppContext();
5836
- useEffect17(() => {
6262
+ useEffect20(() => {
5837
6263
  var _a;
5838
6264
  if (ref.current && status === "READY") {
5839
6265
  const iframe = ref.current;
@@ -5870,22 +6296,22 @@ var useBubbleIframeEvents = (ref) => {
5870
6296
  }
5871
6297
  }, [status]);
5872
6298
  };
5873
- var Preview = ({ id = "puck-preview" }) => {
6299
+ var Preview2 = ({ id = "puck-preview" }) => {
5874
6300
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
5875
- const Page = useCallback11(
6301
+ const Page = useCallback14(
5876
6302
  (pageProps) => {
5877
6303
  var _a, _b;
5878
6304
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
5879
6305
  id: "puck-root"
5880
- }, pageProps)) : /* @__PURE__ */ jsx32(Fragment10, { children: pageProps.children });
6306
+ }, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
5881
6307
  },
5882
6308
  [config.root]
5883
6309
  );
5884
- const Frame = useMemo12(() => overrides.iframe, [overrides]);
6310
+ const Frame = useMemo14(() => overrides.iframe, [overrides]);
5885
6311
  const rootProps = state.data.root.props || state.data.root;
5886
6312
  const ref = useRef7(null);
5887
6313
  useBubbleIframeEvents(ref);
5888
- const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx32(
6314
+ const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
5889
6315
  Page,
5890
6316
  __spreadProps(__spreadValues({}, rootProps), {
5891
6317
  puck: {
@@ -5894,10 +6320,10 @@ var Preview = ({ id = "puck-preview" }) => {
5894
6320
  dragRef: null
5895
6321
  },
5896
6322
  editMode: true,
5897
- children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6323
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
5898
6324
  })
5899
- ) : /* @__PURE__ */ jsx32(Render, { data: state.data, config });
5900
- return /* @__PURE__ */ jsx32(
6325
+ ) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
6326
+ return /* @__PURE__ */ jsx33(
5901
6327
  "div",
5902
6328
  {
5903
6329
  className: getClassName23(),
@@ -5906,7 +6332,7 @@ var Preview = ({ id = "puck-preview" }) => {
5906
6332
  onClick: () => {
5907
6333
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
5908
6334
  },
5909
- children: iframe.enabled ? /* @__PURE__ */ jsx32(
6335
+ children: iframe.enabled ? /* @__PURE__ */ jsx33(
5910
6336
  AutoFrame_default,
5911
6337
  {
5912
6338
  id: "preview-frame",
@@ -5916,14 +6342,14 @@ var Preview = ({ id = "puck-preview" }) => {
5916
6342
  setStatus("READY");
5917
6343
  },
5918
6344
  frameRef: ref,
5919
- children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6345
+ children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
5920
6346
  if (Frame) {
5921
- return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
6347
+ return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
5922
6348
  }
5923
6349
  return inner;
5924
6350
  } })
5925
6351
  }
5926
- ) : /* @__PURE__ */ jsx32(
6352
+ ) : /* @__PURE__ */ jsx33(
5927
6353
  "div",
5928
6354
  {
5929
6355
  id: "preview-frame",
@@ -5980,7 +6406,7 @@ var scrollIntoView = (el) => {
5980
6406
  };
5981
6407
 
5982
6408
  // components/LayerTree/index.tsx
5983
- import { useContext as useContext8 } from "react";
6409
+ import { useContext as useContext11 } from "react";
5984
6410
 
5985
6411
  // lib/is-child-of-zone.ts
5986
6412
  init_react_import();
@@ -6013,7 +6439,7 @@ var onScrollEnd = (frame, cb) => {
6013
6439
  };
6014
6440
 
6015
6441
  // components/LayerTree/index.tsx
6016
- import { Fragment as Fragment11, jsx as jsx33, jsxs as jsxs16 } from "react/jsx-runtime";
6442
+ import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
6017
6443
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
6018
6444
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
6019
6445
  var LayerTree = ({
@@ -6026,15 +6452,15 @@ var LayerTree = ({
6026
6452
  label
6027
6453
  }) => {
6028
6454
  const zones = data.zones || {};
6029
- const ctx = useContext8(dropZoneContext);
6455
+ const ctx = useContext11(dropZoneContext);
6030
6456
  return /* @__PURE__ */ jsxs16(Fragment11, { children: [
6031
6457
  label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
6032
- /* @__PURE__ */ jsx33("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
6458
+ /* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
6033
6459
  " ",
6034
6460
  label
6035
6461
  ] }),
6036
6462
  /* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
6037
- zoneContent.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName24("helper"), children: "No items" }),
6463
+ zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
6038
6464
  zoneContent.map((item, i) => {
6039
6465
  var _a;
6040
6466
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -6057,7 +6483,7 @@ var LayerTree = ({
6057
6483
  childIsSelected
6058
6484
  }),
6059
6485
  children: [
6060
- /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6486
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6061
6487
  "button",
6062
6488
  {
6063
6489
  type: "button",
@@ -6096,22 +6522,22 @@ var LayerTree = ({
6096
6522
  setHoveringComponent(null);
6097
6523
  },
6098
6524
  children: [
6099
- containsZone && /* @__PURE__ */ jsx33(
6525
+ containsZone && /* @__PURE__ */ jsx34(
6100
6526
  "div",
6101
6527
  {
6102
6528
  className: getClassNameLayer("chevron"),
6103
6529
  title: isSelected ? "Collapse" : "Expand",
6104
- children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
6530
+ children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
6105
6531
  }
6106
6532
  ),
6107
6533
  /* @__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 })
6534
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
6535
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
6110
6536
  ] })
6111
6537
  ]
6112
6538
  }
6113
6539
  ) }),
6114
- containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(
6540
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
6115
6541
  LayerTree,
6116
6542
  {
6117
6543
  config,
@@ -6133,13 +6559,13 @@ var LayerTree = ({
6133
6559
  };
6134
6560
 
6135
6561
  // 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";
6562
+ import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
6563
+ import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
6138
6564
  var Outline = () => {
6139
6565
  const { dispatch, state, overrides, config } = useAppContext();
6140
6566
  const { data, ui } = state;
6141
6567
  const { itemSelector } = ui;
6142
- const setItemSelector = useCallback12(
6568
+ const setItemSelector = useCallback15(
6143
6569
  (newItemSelector) => {
6144
6570
  dispatch({
6145
6571
  type: "setUi",
@@ -6148,9 +6574,9 @@ var Outline = () => {
6148
6574
  },
6149
6575
  []
6150
6576
  );
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(
6577
+ const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
6578
+ return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6579
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
6154
6580
  LayerTree,
6155
6581
  {
6156
6582
  config,
@@ -6163,7 +6589,7 @@ var Outline = () => {
6163
6589
  ),
6164
6590
  Object.entries(findZonesForArea(data, "root")).map(
6165
6591
  ([zoneKey, zone]) => {
6166
- return /* @__PURE__ */ jsx34(
6592
+ return /* @__PURE__ */ jsx35(
6167
6593
  LayerTree,
6168
6594
  {
6169
6595
  config,
@@ -6262,19 +6688,19 @@ function usePuckHistory({
6262
6688
 
6263
6689
  // lib/use-history-store.ts
6264
6690
  init_react_import();
6265
- import { useState as useState21 } from "react";
6691
+ import { useState as useState22 } from "react";
6266
6692
  import { useDebouncedCallback as useDebouncedCallback3 } from "use-debounce";
6267
6693
  var EMPTY_HISTORY_INDEX = 0;
6268
6694
  function useHistoryStore(initialHistory) {
6269
6695
  var _a, _b;
6270
- const [histories, setHistories] = useState21(
6696
+ const [histories, setHistories] = useState22(
6271
6697
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
6272
6698
  );
6273
6699
  const updateHistories = (histories2) => {
6274
6700
  setHistories(histories2);
6275
6701
  setIndex(histories2.length - 1);
6276
6702
  };
6277
- const [index, setIndex] = useState21(
6703
+ const [index, setIndex] = useState22(
6278
6704
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
6279
6705
  );
6280
6706
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -6435,27 +6861,27 @@ var getBox = function getBox2(el) {
6435
6861
 
6436
6862
  // components/Puck/components/Canvas/index.tsx
6437
6863
  import {
6438
- useCallback as useCallback13,
6439
- useEffect as useEffect19,
6440
- useMemo as useMemo15,
6864
+ useCallback as useCallback16,
6865
+ useEffect as useEffect22,
6866
+ useMemo as useMemo17,
6441
6867
  useRef as useRef8,
6442
- useState as useState23
6868
+ useState as useState24
6443
6869
  } from "react";
6444
6870
 
6445
6871
  // components/ViewportControls/index.tsx
6446
6872
  init_react_import();
6447
- import { useEffect as useEffect18, useMemo as useMemo14, useState as useState22 } from "react";
6873
+ import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
6448
6874
 
6449
6875
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6450
6876
  init_react_import();
6451
6877
  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
6878
 
6453
6879
  // components/ViewportControls/index.tsx
6454
- import { jsx as jsx35, jsxs as jsxs18 } from "react/jsx-runtime";
6880
+ import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
6455
6881
  var icons = {
6456
- Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
6457
- Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
6458
- Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
6882
+ Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
6883
+ Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
6884
+ Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
6459
6885
  };
6460
6886
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
6461
6887
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -6467,11 +6893,11 @@ var ViewportButton = ({
6467
6893
  onClick
6468
6894
  }) => {
6469
6895
  const { state } = useAppContext();
6470
- const [isActive, setIsActive] = useState22(false);
6471
- useEffect18(() => {
6896
+ const [isActive, setIsActive] = useState23(false);
6897
+ useEffect21(() => {
6472
6898
  setIsActive(width === state.ui.viewports.current.width);
6473
6899
  }, [width, state.ui.viewports.current.width]);
6474
- return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
6900
+ return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
6475
6901
  IconButton,
6476
6902
  {
6477
6903
  title,
@@ -6480,7 +6906,7 @@ var ViewportButton = ({
6480
6906
  e.stopPropagation();
6481
6907
  onClick({ width, height });
6482
6908
  },
6483
- children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
6909
+ children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
6484
6910
  }
6485
6911
  ) });
6486
6912
  };
@@ -6504,7 +6930,7 @@ var ViewportControls = ({
6504
6930
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6505
6931
  (option) => option.value === autoZoom
6506
6932
  );
6507
- const zoomOptions = useMemo14(
6933
+ const zoomOptions = useMemo16(
6508
6934
  () => [
6509
6935
  ...defaultZoomOptions,
6510
6936
  ...defaultsContainAutoZoom ? [] : [
@@ -6517,7 +6943,7 @@ var ViewportControls = ({
6517
6943
  [autoZoom]
6518
6944
  );
6519
6945
  return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
6520
- viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
6946
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
6521
6947
  ViewportButton,
6522
6948
  {
6523
6949
  height: viewport.height,
@@ -6528,8 +6954,8 @@ var ViewportControls = ({
6528
6954
  },
6529
6955
  i
6530
6956
  )),
6531
- /* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
6532
- /* @__PURE__ */ jsx35(
6957
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6958
+ /* @__PURE__ */ jsx36(
6533
6959
  IconButton,
6534
6960
  {
6535
6961
  title: "Zoom viewport out",
@@ -6543,10 +6969,10 @@ var ViewportControls = ({
6543
6969
  )].value
6544
6970
  );
6545
6971
  },
6546
- children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
6972
+ children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
6547
6973
  }
6548
6974
  ),
6549
- /* @__PURE__ */ jsx35(
6975
+ /* @__PURE__ */ jsx36(
6550
6976
  IconButton,
6551
6977
  {
6552
6978
  title: "Zoom viewport in",
@@ -6560,11 +6986,11 @@ var ViewportControls = ({
6560
6986
  )].value
6561
6987
  );
6562
6988
  },
6563
- children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
6989
+ children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
6564
6990
  }
6565
6991
  ),
6566
- /* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
6567
- /* @__PURE__ */ jsx35(
6992
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6993
+ /* @__PURE__ */ jsx36(
6568
6994
  "select",
6569
6995
  {
6570
6996
  className: getClassName25("zoomSelect"),
@@ -6572,7 +6998,7 @@ var ViewportControls = ({
6572
6998
  onChange: (e) => {
6573
6999
  onZoom(parseFloat(e.currentTarget.value));
6574
7000
  },
6575
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
7001
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
6576
7002
  "option",
6577
7003
  {
6578
7004
  value: option.value,
@@ -6620,7 +7046,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
6620
7046
  };
6621
7047
 
6622
7048
  // components/Puck/components/Canvas/index.tsx
6623
- import { Fragment as Fragment13, jsx as jsx36, jsxs as jsxs19 } from "react/jsx-runtime";
7049
+ import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
6624
7050
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
6625
7051
  var ZOOM_ON_CHANGE = true;
6626
7052
  var Canvas = () => {
@@ -6628,16 +7054,16 @@ var Canvas = () => {
6628
7054
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
6629
7055
  const { ui } = state;
6630
7056
  const frameRef = useRef8(null);
6631
- const [showTransition, setShowTransition] = useState23(false);
6632
- const defaultRender = useMemo15(() => {
6633
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment13, { children });
7057
+ const [showTransition, setShowTransition] = useState24(false);
7058
+ const defaultRender = useMemo17(() => {
7059
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
6634
7060
  return PuckDefault;
6635
7061
  }, []);
6636
- const CustomPreview = useMemo15(
7062
+ const CustomPreview = useMemo17(
6637
7063
  () => overrides.preview || defaultRender,
6638
7064
  [overrides]
6639
7065
  );
6640
- const getFrameDimensions = useCallback13(() => {
7066
+ const getFrameDimensions = useCallback16(() => {
6641
7067
  if (frameRef.current) {
6642
7068
  const frame = frameRef.current;
6643
7069
  const box = getBox(frame);
@@ -6645,7 +7071,7 @@ var Canvas = () => {
6645
7071
  }
6646
7072
  return { width: 0, height: 0 };
6647
7073
  }, [frameRef]);
6648
- const resetAutoZoom = useCallback13(
7074
+ const resetAutoZoom = useCallback16(
6649
7075
  (ui2 = state.ui) => {
6650
7076
  if (frameRef.current) {
6651
7077
  setZoomConfig(
@@ -6655,11 +7081,11 @@ var Canvas = () => {
6655
7081
  },
6656
7082
  [frameRef, zoomConfig, state.ui]
6657
7083
  );
6658
- useEffect19(() => {
7084
+ useEffect22(() => {
6659
7085
  setShowTransition(false);
6660
7086
  resetAutoZoom();
6661
7087
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6662
- useEffect19(() => {
7088
+ useEffect22(() => {
6663
7089
  const { height: frameHeight } = getFrameDimensions();
6664
7090
  if (ui.viewports.current.height === "auto") {
6665
7091
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6667,13 +7093,13 @@ var Canvas = () => {
6667
7093
  }));
6668
7094
  }
6669
7095
  }, [zoomConfig.zoom]);
6670
- useEffect19(() => {
7096
+ useEffect22(() => {
6671
7097
  if (ZOOM_ON_CHANGE) {
6672
7098
  setShowTransition(true);
6673
7099
  resetAutoZoom(ui);
6674
7100
  }
6675
7101
  }, [ui.viewports.current.width]);
6676
- useEffect19(() => {
7102
+ useEffect22(() => {
6677
7103
  const cb = () => {
6678
7104
  setShowTransition(false);
6679
7105
  resetAutoZoom();
@@ -6683,8 +7109,8 @@ var Canvas = () => {
6683
7109
  window.removeEventListener("resize", cb);
6684
7110
  };
6685
7111
  }, []);
6686
- const [showLoader, setShowLoader] = useState23(false);
6687
- useEffect19(() => {
7112
+ const [showLoader, setShowLoader] = useState24(false);
7113
+ useEffect22(() => {
6688
7114
  setTimeout(() => {
6689
7115
  setShowLoader(true);
6690
7116
  }, 500);
@@ -6702,7 +7128,7 @@ var Canvas = () => {
6702
7128
  recordHistory: true
6703
7129
  }),
6704
7130
  children: [
6705
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx36(
7131
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
6706
7132
  ViewportControls,
6707
7133
  {
6708
7134
  autoZoom: zoomConfig.autoZoom,
@@ -6729,7 +7155,7 @@ var Canvas = () => {
6729
7155
  }
6730
7156
  ) }),
6731
7157
  /* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
6732
- /* @__PURE__ */ jsx36(
7158
+ /* @__PURE__ */ jsx37(
6733
7159
  "div",
6734
7160
  {
6735
7161
  className: getClassName26("root"),
@@ -6750,10 +7176,10 @@ var Canvas = () => {
6750
7176
  })
6751
7177
  );
6752
7178
  },
6753
- children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview, {}) })
7179
+ children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
6754
7180
  }
6755
7181
  ),
6756
- /* @__PURE__ */ jsx36("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
7182
+ /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
6757
7183
  ] })
6758
7184
  ]
6759
7185
  }
@@ -6762,7 +7188,7 @@ var Canvas = () => {
6762
7188
 
6763
7189
  // lib/use-loaded-overrides.ts
6764
7190
  init_react_import();
6765
- import { useMemo as useMemo16 } from "react";
7191
+ import { useMemo as useMemo18 } from "react";
6766
7192
 
6767
7193
  // lib/load-overrides.ts
6768
7194
  init_react_import();
@@ -6801,26 +7227,26 @@ var useLoadedOverrides = ({
6801
7227
  overrides,
6802
7228
  plugins
6803
7229
  }) => {
6804
- return useMemo16(() => {
7230
+ return useMemo18(() => {
6805
7231
  return loadOverrides({ overrides, plugins });
6806
7232
  }, [plugins, overrides]);
6807
7233
  };
6808
7234
 
6809
7235
  // components/DefaultOverride/index.tsx
6810
7236
  init_react_import();
6811
- import { Fragment as Fragment14, jsx as jsx37 } from "react/jsx-runtime";
6812
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment14, { children });
7237
+ import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
7238
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
6813
7239
 
6814
7240
  // lib/use-inject-css.ts
6815
7241
  init_react_import();
6816
- import { useEffect as useEffect20, useState as useState24 } from "react";
7242
+ import { useEffect as useEffect23, useState as useState25 } from "react";
6817
7243
  var styles = ``;
6818
7244
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
6819
- const [el, setEl] = useState24();
6820
- useEffect20(() => {
7245
+ const [el, setEl] = useState25();
7246
+ useEffect23(() => {
6821
7247
  setEl(document.createElement("style"));
6822
7248
  }, []);
6823
- useEffect20(() => {
7249
+ useEffect23(() => {
6824
7250
  var _a;
6825
7251
  if (!el || typeof window === "undefined") {
6826
7252
  return;
@@ -6840,10 +7266,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
6840
7266
 
6841
7267
  // lib/use-preview-mode-hotkeys.ts
6842
7268
  init_react_import();
6843
- import { useCallback as useCallback14 } from "react";
7269
+ import { useCallback as useCallback17 } from "react";
6844
7270
  import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
6845
7271
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
6846
- const toggleInteractive = useCallback14(() => {
7272
+ const toggleInteractive = useCallback17(() => {
6847
7273
  dispatch({
6848
7274
  type: "setUi",
6849
7275
  ui: (ui) => ({
@@ -6866,7 +7292,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
6866
7292
  };
6867
7293
 
6868
7294
  // components/Puck/index.tsx
6869
- import { Fragment as Fragment15, jsx as jsx38, jsxs as jsxs20 } from "react/jsx-runtime";
7295
+ import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
6870
7296
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
6871
7297
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
6872
7298
  function Puck({
@@ -6895,7 +7321,7 @@ function Puck({
6895
7321
  waitForStyles: true
6896
7322
  }, _iframe);
6897
7323
  useInjectGlobalCss(iframe.enabled);
6898
- const [generatedAppState] = useState25(() => {
7324
+ const [generatedAppState] = useState26(() => {
6899
7325
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
6900
7326
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
6901
7327
  let clientUiState = {};
@@ -6967,7 +7393,7 @@ function Puck({
6967
7393
  histories,
6968
7394
  index: initialHistoryIndex
6969
7395
  });
6970
- const [reducer] = useState25(
7396
+ const [reducer] = useState26(
6971
7397
  () => createReducer({
6972
7398
  config,
6973
7399
  record: historyStore.record,
@@ -6985,14 +7411,14 @@ function Puck({
6985
7411
  historyStore,
6986
7412
  iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
6987
7413
  });
6988
- const [menuOpen, setMenuOpen] = useState25(false);
7414
+ const [menuOpen, setMenuOpen] = useState26(false);
6989
7415
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
6990
7416
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
6991
- useEffect21(() => {
7417
+ useEffect24(() => {
6992
7418
  if (onChange) onChange(data);
6993
7419
  }, [data]);
6994
7420
  const rootProps = data.root.props || data.root;
6995
- const toggleSidebars = useCallback15(
7421
+ const toggleSidebars = useCallback18(
6996
7422
  (sidebar) => {
6997
7423
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
6998
7424
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7006,7 +7432,7 @@ function Puck({
7006
7432
  },
7007
7433
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7008
7434
  );
7009
- useEffect21(() => {
7435
+ useEffect24(() => {
7010
7436
  if (!window.matchMedia("(min-width: 638px)").matches) {
7011
7437
  dispatch({
7012
7438
  type: "setUi",
@@ -7029,7 +7455,7 @@ function Puck({
7029
7455
  window.removeEventListener("resize", handleResize);
7030
7456
  };
7031
7457
  }, []);
7032
- const defaultHeaderRender = useMemo17(() => {
7458
+ const defaultHeaderRender = useMemo19(() => {
7033
7459
  if (renderHeader) {
7034
7460
  console.warn(
7035
7461
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7037,20 +7463,20 @@ function Puck({
7037
7463
  const RenderHeader = (_a2) => {
7038
7464
  var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
7039
7465
  const Comp = renderHeader;
7040
- return /* @__PURE__ */ jsx38(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7466
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7041
7467
  };
7042
7468
  return RenderHeader;
7043
7469
  }
7044
7470
  return DefaultOverride;
7045
7471
  }, [renderHeader]);
7046
- const defaultHeaderActionsRender = useMemo17(() => {
7472
+ const defaultHeaderActionsRender = useMemo19(() => {
7047
7473
  if (renderHeaderActions) {
7048
7474
  console.warn(
7049
7475
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7050
7476
  );
7051
7477
  const RenderHeader = (props) => {
7052
7478
  const Comp = renderHeaderActions;
7053
- return /* @__PURE__ */ jsx38(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7479
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7054
7480
  };
7055
7481
  return RenderHeader;
7056
7482
  }
@@ -7060,27 +7486,27 @@ function Puck({
7060
7486
  overrides,
7061
7487
  plugins
7062
7488
  });
7063
- const CustomPuck = useMemo17(
7489
+ const CustomPuck = useMemo19(
7064
7490
  () => loadedOverrides.puck || DefaultOverride,
7065
7491
  [loadedOverrides]
7066
7492
  );
7067
- const CustomHeader = useMemo17(
7493
+ const CustomHeader = useMemo19(
7068
7494
  () => loadedOverrides.header || defaultHeaderRender,
7069
7495
  [loadedOverrides]
7070
7496
  );
7071
- const CustomHeaderActions = useMemo17(
7497
+ const CustomHeaderActions = useMemo19(
7072
7498
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7073
7499
  [loadedOverrides]
7074
7500
  );
7075
- const [mounted, setMounted] = useState25(false);
7076
- useEffect21(() => {
7501
+ const [mounted, setMounted] = useState26(false);
7502
+ useEffect24(() => {
7077
7503
  setMounted(true);
7078
7504
  }, []);
7079
7505
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
7080
7506
  const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
7081
7507
  usePreviewModeHotkeys(dispatch, iframe.enabled);
7082
7508
  return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
7083
- /* @__PURE__ */ jsx38(
7509
+ /* @__PURE__ */ jsx39(
7084
7510
  AppProvider,
7085
7511
  {
7086
7512
  value: {
@@ -7102,7 +7528,7 @@ function Puck({
7102
7528
  getPermissions: () => ({}),
7103
7529
  refreshPermissions: () => null
7104
7530
  },
7105
- children: /* @__PURE__ */ jsx38(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx38(CustomPuck, { children: children || /* @__PURE__ */ jsx38(
7531
+ children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
7106
7532
  "div",
7107
7533
  {
7108
7534
  className: getLayoutClassName({
@@ -7112,59 +7538,59 @@ function Puck({
7112
7538
  rightSideBarVisible
7113
7539
  }),
7114
7540
  children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
7115
- /* @__PURE__ */ jsx38(
7541
+ /* @__PURE__ */ jsx39(
7116
7542
  CustomHeader,
7117
7543
  {
7118
- actions: /* @__PURE__ */ jsx38(Fragment15, { children: /* @__PURE__ */ jsx38(CustomHeaderActions, { children: /* @__PURE__ */ jsx38(
7544
+ actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7119
7545
  Button,
7120
7546
  {
7121
7547
  onClick: () => {
7122
7548
  onPublish && onPublish(data);
7123
7549
  },
7124
- icon: /* @__PURE__ */ jsx38(Globe, { size: "14px" }),
7550
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7125
7551
  children: "Publish"
7126
7552
  }
7127
7553
  ) }) }),
7128
- children: /* @__PURE__ */ jsx38("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7554
+ children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7129
7555
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
7130
- /* @__PURE__ */ jsx38(
7556
+ /* @__PURE__ */ jsx39(
7131
7557
  "div",
7132
7558
  {
7133
7559
  className: getLayoutClassName("leftSideBarToggle"),
7134
- children: /* @__PURE__ */ jsx38(
7560
+ children: /* @__PURE__ */ jsx39(
7135
7561
  IconButton,
7136
7562
  {
7137
7563
  onClick: () => {
7138
7564
  toggleSidebars("left");
7139
7565
  },
7140
7566
  title: "Toggle left sidebar",
7141
- children: /* @__PURE__ */ jsx38(PanelLeft, { focusable: "false" })
7567
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7142
7568
  }
7143
7569
  )
7144
7570
  }
7145
7571
  ),
7146
- /* @__PURE__ */ jsx38(
7572
+ /* @__PURE__ */ jsx39(
7147
7573
  "div",
7148
7574
  {
7149
7575
  className: getLayoutClassName("rightSideBarToggle"),
7150
- children: /* @__PURE__ */ jsx38(
7576
+ children: /* @__PURE__ */ jsx39(
7151
7577
  IconButton,
7152
7578
  {
7153
7579
  onClick: () => {
7154
7580
  toggleSidebars("right");
7155
7581
  },
7156
7582
  title: "Toggle right sidebar",
7157
- children: /* @__PURE__ */ jsx38(PanelRight, { focusable: "false" })
7583
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7158
7584
  }
7159
7585
  )
7160
7586
  }
7161
7587
  )
7162
7588
  ] }),
7163
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7589
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7164
7590
  headerTitle || rootProps.title || "Page",
7165
7591
  headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
7166
7592
  " ",
7167
- /* @__PURE__ */ jsx38(
7593
+ /* @__PURE__ */ jsx39(
7168
7594
  "code",
7169
7595
  {
7170
7596
  className: getLayoutClassName("headerPath"),
@@ -7174,30 +7600,30 @@ function Puck({
7174
7600
  ] })
7175
7601
  ] }) }),
7176
7602
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
7177
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx38(
7603
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
7178
7604
  IconButton,
7179
7605
  {
7180
7606
  onClick: () => {
7181
7607
  return setMenuOpen(!menuOpen);
7182
7608
  },
7183
7609
  title: "Toggle menu bar",
7184
- children: menuOpen ? /* @__PURE__ */ jsx38(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx38(ChevronDown, { focusable: "false" })
7610
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7185
7611
  }
7186
7612
  ) }),
7187
- /* @__PURE__ */ jsx38(
7613
+ /* @__PURE__ */ jsx39(
7188
7614
  MenuBar,
7189
7615
  {
7190
7616
  appState,
7191
7617
  dispatch,
7192
7618
  onPublish,
7193
7619
  menuOpen,
7194
- renderHeaderActions: () => /* @__PURE__ */ jsx38(CustomHeaderActions, { children: /* @__PURE__ */ jsx38(
7620
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7195
7621
  Button,
7196
7622
  {
7197
7623
  onClick: () => {
7198
7624
  onPublish && onPublish(data);
7199
7625
  },
7200
- icon: /* @__PURE__ */ jsx38(Globe, { size: "14px" }),
7626
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7201
7627
  children: "Publish"
7202
7628
  }
7203
7629
  ) }),
@@ -7209,18 +7635,18 @@ function Puck({
7209
7635
  }
7210
7636
  ),
7211
7637
  /* @__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, {}) })
7638
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
7639
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
7214
7640
  ] }),
7215
- /* @__PURE__ */ jsx38(Canvas, {}),
7216
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx38(
7641
+ /* @__PURE__ */ jsx39(Canvas, {}),
7642
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
7217
7643
  SidebarSection,
7218
7644
  {
7219
7645
  noPadding: true,
7220
7646
  noBorderTop: true,
7221
7647
  showBreadcrumbs: true,
7222
7648
  title: selectedItem ? selectedComponentLabel : "Page",
7223
- children: /* @__PURE__ */ jsx38(Fields, {})
7649
+ children: /* @__PURE__ */ jsx39(Fields, {})
7224
7650
  }
7225
7651
  ) })
7226
7652
  ] })
@@ -7228,13 +7654,13 @@ function Puck({
7228
7654
  ) }) })
7229
7655
  }
7230
7656
  ),
7231
- /* @__PURE__ */ jsx38("div", { id: "puck-portal-root", className: getClassName27("portal") })
7657
+ /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
7232
7658
  ] });
7233
7659
  }
7234
7660
  Puck.Components = Components;
7235
7661
  Puck.Fields = Fields;
7236
7662
  Puck.Outline = Outline;
7237
- Puck.Preview = Preview;
7663
+ Puck.Preview = Preview2;
7238
7664
 
7239
7665
  // lib/migrate.ts
7240
7666
  init_react_import();