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

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