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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  resolveRootData,
17
17
  rootDroppableId,
18
18
  setupZone
19
- } from "./chunk-EXKSBUY5.mjs";
19
+ } from "./chunk-CHWFBYEM.mjs";
20
20
 
21
21
  // ../../node_modules/classnames/index.js
22
22
  var require_classnames = __commonJS({
@@ -205,13 +205,14 @@ init_react_import();
205
205
 
206
206
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
207
207
  init_react_import();
208
- var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
208
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
209
209
 
210
210
  // components/AutoField/index.tsx
211
211
  import {
212
212
  useCallback as useCallback5,
213
+ useContext as useContext3,
213
214
  useEffect as useEffect9,
214
- useMemo as useMemo4,
215
+ useMemo as useMemo5,
215
216
  useState as useState11
216
217
  } from "react";
217
218
 
@@ -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,28 @@ 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
- });
2930
- }, [isSelected]);
2931
- const CustomActionBar = useMemo5(
3101
+ useEffect10(() => {
3102
+ ctx == null ? void 0 : ctx.registerPath(
3103
+ id,
3104
+ {
3105
+ index,
3106
+ zone: zoneCompound
3107
+ },
3108
+ componentType
3109
+ );
3110
+ return () => {
3111
+ var _a;
3112
+ (_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
3113
+ };
3114
+ }, [id, zoneCompound, index, componentType]);
3115
+ const CustomActionBar = useMemo7(
2932
3116
  () => overrides.actionBar || DefaultActionBar,
2933
3117
  [overrides.actionBar]
2934
3118
  );
2935
3119
  const permissions = getPermissions({
2936
3120
  item: selectedItem
2937
3121
  });
2938
- const onClick = useCallback6(
3122
+ const onClick = useCallback7(
2939
3123
  (e) => {
2940
3124
  e.stopPropagation();
2941
3125
  dispatch({
@@ -2947,7 +3131,7 @@ var DraggableComponent = ({
2947
3131
  },
2948
3132
  [index, zoneCompound, id]
2949
3133
  );
2950
- const onSelectParent = useCallback6(() => {
3134
+ const onSelectParent = useCallback7(() => {
2951
3135
  if (!(ctx == null ? void 0 : ctx.areaId)) {
2952
3136
  return;
2953
3137
  }
@@ -2965,14 +3149,14 @@ var DraggableComponent = ({
2965
3149
  }
2966
3150
  });
2967
3151
  }, [ctx, path]);
2968
- const onDuplicate = useCallback6(() => {
3152
+ const onDuplicate = useCallback7(() => {
2969
3153
  dispatch({
2970
3154
  type: "duplicate",
2971
3155
  sourceIndex: index,
2972
3156
  sourceZone: zoneCompound
2973
3157
  });
2974
3158
  }, [index, zoneCompound]);
2975
- const onDelete = useCallback6(() => {
3159
+ const onDelete = useCallback7(() => {
2976
3160
  dispatch({
2977
3161
  type: "remove",
2978
3162
  index,
@@ -2981,7 +3165,7 @@ var DraggableComponent = ({
2981
3165
  }, [index, zoneCompound]);
2982
3166
  const [hover, setHover] = useState13(false);
2983
3167
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
2984
- useEffect11(() => {
3168
+ useEffect10(() => {
2985
3169
  if (!ref.current) {
2986
3170
  return;
2987
3171
  }
@@ -3031,7 +3215,7 @@ var DraggableComponent = ({
3031
3215
  thisIsDragging,
3032
3216
  inDroppableZone
3033
3217
  ]);
3034
- useEffect11(() => {
3218
+ useEffect10(() => {
3035
3219
  if (ref.current && disabled) {
3036
3220
  ref.current.setAttribute("data-puck-disabled", "");
3037
3221
  return () => {
@@ -3041,7 +3225,7 @@ var DraggableComponent = ({
3041
3225
  }
3042
3226
  }, [disabled, ref]);
3043
3227
  const [isVisible, setIsVisible] = useState13(false);
3044
- useEffect11(() => {
3228
+ useEffect10(() => {
3045
3229
  sync();
3046
3230
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
3047
3231
  setIsVisible(true);
@@ -3049,7 +3233,7 @@ var DraggableComponent = ({
3049
3233
  setIsVisible(false);
3050
3234
  }
3051
3235
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3052
- const syncActionsPosition = useCallback6(
3236
+ const syncActionsPosition = useCallback7(
3053
3237
  (el) => {
3054
3238
  if (el) {
3055
3239
  const view = el.ownerDocument.defaultView;
@@ -3066,7 +3250,7 @@ var DraggableComponent = ({
3066
3250
  },
3067
3251
  [zoomConfig]
3068
3252
  );
3069
- useEffect11(() => {
3253
+ useEffect10(() => {
3070
3254
  if (userDragAxis) {
3071
3255
  setDragAxis(userDragAxis);
3072
3256
  return;
@@ -3080,7 +3264,7 @@ var DraggableComponent = ({
3080
3264
  }
3081
3265
  setDragAxis(autoDragAxis);
3082
3266
  }, [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 }) });
3267
+ const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx21(CornerLeftUp, { size: 16 }) });
3084
3268
  return /* @__PURE__ */ jsxs9(
3085
3269
  DropZoneProvider,
3086
3270
  {
@@ -3101,22 +3285,21 @@ var DraggableComponent = ({
3101
3285
  className: getClassName16({
3102
3286
  isSelected,
3103
3287
  isDragging: thisIsDragging,
3104
- isModifierHeld,
3105
3288
  hover: hover || indicativeHover
3106
3289
  }),
3107
3290
  style: __spreadValues({}, style),
3108
3291
  "data-puck-overlay": true,
3109
3292
  children: [
3110
3293
  debug,
3111
- isLoading && /* @__PURE__ */ jsx19("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx19(Loader, {}) }),
3112
- /* @__PURE__ */ jsx19(
3294
+ isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
3295
+ /* @__PURE__ */ jsx21(
3113
3296
  "div",
3114
3297
  {
3115
3298
  className: getClassName16("actionsOverlay"),
3116
3299
  style: {
3117
3300
  top: actionsOverlayTop / zoomConfig.zoom
3118
3301
  },
3119
- children: /* @__PURE__ */ jsx19(
3302
+ children: /* @__PURE__ */ jsx21(
3120
3303
  "div",
3121
3304
  {
3122
3305
  className: getClassName16("actions"),
@@ -3134,8 +3317,8 @@ var DraggableComponent = ({
3134
3317
  parentAction,
3135
3318
  label: DEBUG2 ? id : label,
3136
3319
  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 }) })
3320
+ permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
3321
+ permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
3139
3322
  ]
3140
3323
  }
3141
3324
  )
@@ -3143,7 +3326,7 @@ var DraggableComponent = ({
3143
3326
  )
3144
3327
  }
3145
3328
  ),
3146
- /* @__PURE__ */ jsx19("div", { className: getClassName16("overlay") })
3329
+ /* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
3147
3330
  ]
3148
3331
  }
3149
3332
  ),
@@ -3159,98 +3342,26 @@ var DraggableComponent = ({
3159
3342
  init_react_import();
3160
3343
  var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isActive": "_DropZone--isActive_kmkdc_10", "DropZone--hasChildren": "_DropZone--hasChildren_kmkdc_14", "DropZone--userIsDragging": "_DropZone--userIsDragging_kmkdc_22", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_kmkdc_26", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_kmkdc_27", "DropZone--isRootZone": "_DropZone--isRootZone_kmkdc_27", "DropZone--isDestination": "_DropZone--isDestination_kmkdc_37", "DropZone-item": "_DropZone-item_kmkdc_49", "DropZone-hitbox": "_DropZone-hitbox_kmkdc_53", "DropZone--isEnabled": "_DropZone--isEnabled_kmkdc_61", "DropZone--isAnimating": "_DropZone--isAnimating_kmkdc_70" };
3161
3344
 
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
3345
+ // components/DropZone/lib/use-min-empty-height.ts
3240
3346
  init_react_import();
3241
- import { useEffect as useEffect12, useState as useState15 } from "react";
3347
+ import { useEffect as useEffect11, useState as useState14 } from "react";
3242
3348
  var useMinEmptyHeight = ({
3243
- draggedItem,
3244
3349
  zoneCompound,
3245
3350
  userMinEmptyHeight,
3246
3351
  ref
3247
3352
  }) => {
3248
- const [prevHeight, setPrevHeight] = useState15(0);
3249
- const [isAnimating, setIsAnimating] = useState15(false);
3250
- useEffect12(() => {
3353
+ const [prevHeight, setPrevHeight] = useState14(0);
3354
+ const [isAnimating, setIsAnimating] = useState14(false);
3355
+ const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3356
+ var _a, _b;
3357
+ return {
3358
+ draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
3359
+ isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3360
+ };
3361
+ });
3362
+ useEffect11(() => {
3251
3363
  if (draggedItem && ref.current) {
3252
- const componentData = draggedItem.data;
3253
- if (componentData.zone === zoneCompound) {
3364
+ if (isZone) {
3254
3365
  const rect = ref.current.getBoundingClientRect();
3255
3366
  setPrevHeight(rect.height);
3256
3367
  setIsAnimating(true);
@@ -3280,15 +3391,143 @@ function assignRefs(refs, node) {
3280
3391
  });
3281
3392
  }
3282
3393
 
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;
3394
+ // components/DropZone/lib/use-content-with-preview.ts
3395
+ init_react_import();
3396
+ import { useEffect as useEffect12, useState as useState15 } from "react";
3397
+
3398
+ // lib/dnd/use-rendered-callback.ts
3399
+ init_react_import();
3400
+ import { useDragDropManager } from "@dnd-kit/react";
3401
+ import { useCallback as useCallback8 } from "react";
3402
+ function useRenderedCallback(callback, deps) {
3403
+ const manager = useDragDropManager();
3404
+ return useCallback8(
3405
+ (...args) => __async(this, null, function* () {
3406
+ yield manager == null ? void 0 : manager.renderer.rendering;
3407
+ return callback(...args);
3408
+ }),
3409
+ [...deps, manager]
3410
+ );
3411
+ }
3412
+
3413
+ // lib/insert.ts
3414
+ init_react_import();
3415
+ var insert = (list, index, item) => {
3416
+ const result = Array.from(list);
3417
+ result.splice(index, 0, item);
3418
+ return result;
3419
+ };
3420
+
3421
+ // components/DropZone/lib/use-content-with-preview.ts
3422
+ var useContentWithPreview = (content, zoneCompound) => {
3423
+ const { draggedItemId, preview, previewExists } = useContextStore(
3424
+ ZoneStoreContext,
3425
+ (s) => {
3426
+ var _a;
3427
+ return {
3428
+ draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
3429
+ preview: s.previewIndex[zoneCompound],
3430
+ previewExists: Object.keys(s.previewIndex || {}).length > 0
3431
+ };
3432
+ }
3433
+ );
3434
+ const {
3435
+ state: {
3436
+ ui: { isDragging }
3437
+ }
3438
+ } = useAppContext();
3439
+ const [contentWithPreview, setContentWithPreview] = useState15(content);
3440
+ const [localPreview, setLocalPreview] = useState15(
3441
+ preview
3442
+ );
3443
+ const updateContent = useRenderedCallback(
3444
+ (content2, preview2, isDragging2) => {
3445
+ if (isDragging2 && !previewExists) {
3446
+ return;
3447
+ }
3448
+ if (preview2) {
3449
+ if (preview2.type === "insert") {
3450
+ setContentWithPreview(
3451
+ insert(
3452
+ content2.filter((item) => item.props.id !== preview2.props.id),
3453
+ preview2.index,
3454
+ {
3455
+ type: "preview",
3456
+ props: { id: preview2.props.id }
3457
+ }
3458
+ )
3459
+ );
3460
+ } else {
3461
+ setContentWithPreview(
3462
+ insert(
3463
+ content2.filter((item) => item.props.id !== preview2.props.id),
3464
+ preview2.index,
3465
+ {
3466
+ type: preview2.componentType,
3467
+ props: preview2.props
3468
+ }
3469
+ )
3470
+ );
3471
+ }
3472
+ } else {
3473
+ setContentWithPreview(
3474
+ previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3475
+ );
3476
+ }
3477
+ setLocalPreview(preview2);
3478
+ },
3479
+ [draggedItemId, previewExists]
3480
+ );
3481
+ useEffect12(() => {
3482
+ updateContent(content, preview, isDragging);
3483
+ }, [content, preview, isDragging]);
3484
+ return [contentWithPreview, localPreview];
3485
+ };
3486
+
3487
+ // components/DropZone/lib/use-drag-axis.ts
3488
+ init_react_import();
3489
+ import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
3287
3490
  var GRID_DRAG_AXIS = "dynamic";
3288
3491
  var FLEX_ROW_DRAG_AXIS = "x";
3289
3492
  var DEFAULT_DRAG_AXIS = "y";
3493
+ var useDragAxis = (ref, collisionAxis) => {
3494
+ const { status } = useAppContext();
3495
+ const [dragAxis, setDragAxis] = useState16(
3496
+ collisionAxis || DEFAULT_DRAG_AXIS
3497
+ );
3498
+ const calculateDragAxis = useCallback9(() => {
3499
+ if (ref.current) {
3500
+ const computedStyle = window.getComputedStyle(ref.current);
3501
+ if (computedStyle.display === "grid") {
3502
+ setDragAxis(GRID_DRAG_AXIS);
3503
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3504
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3505
+ } else {
3506
+ setDragAxis(DEFAULT_DRAG_AXIS);
3507
+ }
3508
+ }
3509
+ }, [ref.current]);
3510
+ useEffect13(() => {
3511
+ const onViewportChange = () => {
3512
+ calculateDragAxis();
3513
+ };
3514
+ window.addEventListener("viewportchange", onViewportChange);
3515
+ return () => {
3516
+ window.removeEventListener("viewportchange", onViewportChange);
3517
+ };
3518
+ }, []);
3519
+ useEffect13(calculateDragAxis, [status, collisionAxis]);
3520
+ return [dragAxis, calculateDragAxis];
3521
+ };
3522
+
3523
+ // components/DropZone/index.tsx
3524
+ import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
3525
+ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3526
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3527
+ var RENDER_DEBUG = false;
3528
+ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
3290
3529
  var DropZoneEdit = forwardRef3(
3291
- function DropZoneEdit2({
3530
+ function DropZoneEditInternal({
3292
3531
  zone,
3293
3532
  allow,
3294
3533
  disallow,
@@ -3298,31 +3537,48 @@ var DropZoneEdit = forwardRef3(
3298
3537
  collisionAxis
3299
3538
  }, userRef) {
3300
3539
  const appContext2 = useAppContext();
3301
- const ctx = useContext3(dropZoneContext);
3540
+ const ctx = useContext6(dropZoneContext);
3302
3541
  const {
3303
3542
  // These all need setting via context
3304
3543
  data,
3305
3544
  config,
3306
3545
  areaId,
3307
- draggedItem,
3308
3546
  registerZoneArea,
3309
3547
  depth,
3310
3548
  registerLocalZone,
3311
3549
  unregisterLocalZone,
3312
- deepestZone = rootDroppableId,
3313
- deepestArea,
3314
- nextDeepestArea,
3315
3550
  path = [],
3316
3551
  activeZones
3317
3552
  } = ctx;
3318
- const { itemSelector } = appContext2.state.ui;
3319
3553
  let zoneCompound = rootDroppableId;
3320
- useEffect13(() => {
3554
+ if (areaId) {
3555
+ if (zone !== rootDroppableId) {
3556
+ zoneCompound = `${areaId}:${zone}`;
3557
+ }
3558
+ }
3559
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3560
+ const {
3561
+ isDeepestZone,
3562
+ inNextDeepestArea,
3563
+ draggedComponentType,
3564
+ userIsDragging
3565
+ } = useContextStore(ZoneStoreContext, (s) => {
3566
+ var _a, _b, _c;
3567
+ return {
3568
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3569
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3570
+ draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3571
+ draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3572
+ userIsDragging: !!s.draggedItem
3573
+ };
3574
+ });
3575
+ const { itemSelector } = appContext2.state.ui;
3576
+ useEffect14(() => {
3321
3577
  if (areaId && registerZoneArea) {
3322
3578
  registerZoneArea(areaId);
3323
3579
  }
3324
3580
  }, [areaId]);
3325
- useEffect13(() => {
3581
+ useEffect14(() => {
3326
3582
  if (ctx == null ? void 0 : ctx.registerZone) {
3327
3583
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3328
3584
  }
@@ -3332,25 +3588,18 @@ var DropZoneEdit = forwardRef3(
3332
3588
  }
3333
3589
  };
3334
3590
  }, []);
3335
- if (areaId) {
3336
- if (zone !== rootDroppableId) {
3337
- zoneCompound = `${areaId}:${zone}`;
3338
- }
3339
- }
3340
- const content = useMemo7(() => {
3591
+ const content = useMemo8(() => {
3341
3592
  if (areaId && zone !== rootDroppableId) {
3342
3593
  return setupZone(data, zoneCompound).zones[zoneCompound];
3343
3594
  }
3344
3595
  return data.content || [];
3345
3596
  }, [data, zoneCompound]);
3346
- const ref = useRef4(null);
3347
- const acceptsTarget = useCallback8(
3348
- (target) => {
3349
- if (!target) {
3597
+ const ref = useRef2(null);
3598
+ const acceptsTarget = useCallback10(
3599
+ (componentType) => {
3600
+ if (!componentType) {
3350
3601
  return true;
3351
3602
  }
3352
- const data2 = target.data;
3353
- const { componentType } = data2;
3354
3603
  if (disallow) {
3355
3604
  const defaultedAllow = allow || [];
3356
3605
  const filteredDisallow = (disallow || []).filter(
@@ -3368,49 +3617,29 @@ var DropZoneEdit = forwardRef3(
3368
3617
  },
3369
3618
  [allow, disallow]
3370
3619
  );
3371
- useEffect13(() => {
3620
+ useEffect14(() => {
3372
3621
  if (registerLocalZone) {
3373
- registerLocalZone(zoneCompound, acceptsTarget(draggedItem));
3622
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3374
3623
  }
3375
3624
  return () => {
3376
3625
  if (unregisterLocalZone) {
3377
3626
  unregisterLocalZone(zoneCompound);
3378
3627
  }
3379
3628
  };
3380
- }, [draggedItem, zoneCompound]);
3381
- const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3382
- const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
3383
- const userIsDragging = !!draggedItem;
3629
+ }, [draggedComponentType, zoneCompound]);
3630
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3384
3631
  let isEnabled = true;
3385
- if (draggedItem) {
3386
- isEnabled = deepestZone === zoneCompound;
3632
+ if (userIsDragging) {
3633
+ isEnabled = isDeepestZone;
3387
3634
  }
3388
3635
  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);
3636
+ isEnabled = acceptsTarget(draggedComponentType);
3637
+ }
3638
+ const [contentWithPreview, preview] = useContentWithPreview(
3639
+ content,
3640
+ zoneCompound
3641
+ );
3642
+ const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3414
3643
  const droppableConfig = {
3415
3644
  id: zoneCompound,
3416
3645
  collisionPriority: isEnabled ? depth : 0,
@@ -3420,45 +3649,20 @@ var DropZoneEdit = forwardRef3(
3420
3649
  data: {
3421
3650
  areaId,
3422
3651
  depth,
3423
- isDroppableTarget: acceptsTarget(draggedItem),
3652
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3424
3653
  path
3425
3654
  }
3426
3655
  };
3427
3656
  const { ref: dropRef } = useDroppableSafe(droppableConfig);
3428
3657
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3429
3658
  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
- }, []);
3659
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3455
3660
  const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3456
- draggedItem,
3457
3661
  zoneCompound,
3458
3662
  userMinEmptyHeight,
3459
3663
  ref
3460
3664
  });
3461
- return /* @__PURE__ */ jsxs10(
3665
+ return /* @__PURE__ */ jsx22(
3462
3666
  "div",
3463
3667
  {
3464
3668
  className: `${getClassName17({
@@ -3476,89 +3680,94 @@ var DropZoneEdit = forwardRef3(
3476
3680
  },
3477
3681
  "data-testid": `dropzone:${zoneCompound}`,
3478
3682
  "data-puck-dropzone": zoneCompound,
3479
- "data-puck-dnd": zoneCompound,
3480
3683
  style: __spreadProps(__spreadValues({}, style), {
3481
- "--min-empty-height": `${minEmptyHeight}px`
3684
+ "--min-empty-height": `${minEmptyHeight}px`,
3685
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
3482
3686
  }),
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
3687
+ children: contentWithPreview.map((item, i) => {
3688
+ var _a, _b, _c, _d, _e, _f, _g;
3689
+ const componentId = item.props.id;
3690
+ const puckProps = {
3691
+ renderDropZone: DropZoneEditPure,
3692
+ isEditing: true,
3693
+ dragRef: null
3694
+ };
3695
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3696
+ puck: puckProps,
3697
+ editMode: true
3698
+ // DEPRECATED
3699
+ });
3700
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3701
+ let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
3702
+ "No configuration for ",
3703
+ item.type
3704
+ ] });
3705
+ const componentConfig = config.components[item.type];
3706
+ let componentType = item.type;
3707
+ let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3708
+ if (item.type === "preview") {
3709
+ let Preview4 = function() {
3710
+ return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3495
3711
  };
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
- })
3712
+ var Preview3 = Preview4;
3713
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3714
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3715
+ Render2 = Preview4;
3716
+ }
3717
+ return /* @__PURE__ */ jsx22(
3718
+ DropZoneProvider,
3719
+ {
3720
+ value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3721
+ children: /* @__PURE__ */ jsx22(
3722
+ DraggableComponent,
3723
+ {
3724
+ id: componentId,
3725
+ componentType,
3726
+ zoneCompound,
3727
+ depth: depth + 1,
3728
+ index: i,
3729
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3730
+ isSelected,
3731
+ label,
3732
+ isEnabled,
3733
+ autoDragAxis: dragAxis,
3734
+ userDragAxis: collisionAxis,
3735
+ inDroppableZone: acceptsTarget(draggedComponentType),
3736
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx22(
3737
+ Render2,
3738
+ __spreadProps(__spreadValues({}, defaultedProps), {
3739
+ puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3740
+ dragRef
3543
3741
  })
3544
- ) : /* @__PURE__ */ jsx21("div", { ref: dragRef, children: /* @__PURE__ */ jsx21(Render2, __spreadValues({}, defaultedProps)) })
3545
- }
3546
- )
3547
- },
3548
- componentId
3549
- );
3550
- })
3551
- ]
3742
+ })
3743
+ ) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
3744
+ }
3745
+ )
3746
+ },
3747
+ componentId
3748
+ );
3749
+ })
3552
3750
  }
3553
3751
  );
3554
3752
  }
3555
3753
  );
3754
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
3556
3755
  var DropZoneRender = forwardRef3(
3557
- function DropZoneRender2({ className, style, zone }, ref) {
3558
- const ctx = useContext3(dropZoneContext);
3756
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3757
+ const ctx = useContext6(dropZoneContext);
3559
3758
  const { data, areaId = "root", config } = ctx || {};
3560
3759
  let zoneCompound = rootDroppableId;
3561
3760
  let content = (data == null ? void 0 : data.content) || [];
3761
+ useEffect14(() => {
3762
+ if (ctx == null ? void 0 : ctx.registerZone) {
3763
+ ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3764
+ }
3765
+ return () => {
3766
+ if (ctx == null ? void 0 : ctx.unregisterZone) {
3767
+ ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
3768
+ }
3769
+ };
3770
+ }, []);
3562
3771
  if (!data || !config) {
3563
3772
  return null;
3564
3773
  }
@@ -3566,10 +3775,10 @@ var DropZoneRender = forwardRef3(
3566
3775
  zoneCompound = `${areaId}:${zone}`;
3567
3776
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3568
3777
  }
3569
- return /* @__PURE__ */ jsx21("div", { className, style, ref, children: content.map((item) => {
3778
+ return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
3570
3779
  const Component = config.components[item.type];
3571
3780
  if (Component) {
3572
- return /* @__PURE__ */ jsx21(
3781
+ return /* @__PURE__ */ jsx22(
3573
3782
  DropZoneProvider,
3574
3783
  {
3575
3784
  value: {
@@ -3579,10 +3788,12 @@ var DropZoneRender = forwardRef3(
3579
3788
  depth: 1,
3580
3789
  path: []
3581
3790
  },
3582
- children: /* @__PURE__ */ jsx21(
3791
+ children: /* @__PURE__ */ jsx22(
3583
3792
  Component.render,
3584
3793
  __spreadProps(__spreadValues({}, item.props), {
3585
- puck: { renderDropZone: DropZoneRender2 }
3794
+ puck: {
3795
+ renderDropZone: DropZoneRenderPure
3796
+ }
3586
3797
  })
3587
3798
  )
3588
3799
  },
@@ -3595,11 +3806,11 @@ var DropZoneRender = forwardRef3(
3595
3806
  );
3596
3807
  var DropZone = forwardRef3(
3597
3808
  function DropZone2(props, ref) {
3598
- const ctx = useContext3(dropZoneContext);
3809
+ const ctx = useContext6(dropZoneContext);
3599
3810
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3600
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3811
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3601
3812
  }
3602
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3813
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3603
3814
  }
3604
3815
  );
3605
3816
 
@@ -3615,7 +3826,7 @@ var getZoneId = (zoneCompound) => {
3615
3826
  return [rootDroppableId, zoneCompound];
3616
3827
  };
3617
3828
 
3618
- // components/DragDropContext/NestedDroppablePlugin.ts
3829
+ // lib/dnd/NestedDroppablePlugin.ts
3619
3830
  init_react_import();
3620
3831
  import { Plugin } from "@dnd-kit/abstract";
3621
3832
  import { effects } from "@dnd-kit/state";
@@ -3657,7 +3868,49 @@ var getFrame = () => {
3657
3868
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3658
3869
  };
3659
3870
 
3660
- // components/DragDropContext/NestedDroppablePlugin.ts
3871
+ // lib/global-position.ts
3872
+ init_react_import();
3873
+ var GlobalPosition = class {
3874
+ constructor(target, original) {
3875
+ this.scaleFactor = 1;
3876
+ this.frameEl = null;
3877
+ this.frameRect = null;
3878
+ var _a;
3879
+ this.target = target;
3880
+ this.original = original;
3881
+ this.frameEl = document.querySelector("iframe");
3882
+ if (this.frameEl) {
3883
+ this.frameRect = this.frameEl.getBoundingClientRect();
3884
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3885
+ }
3886
+ }
3887
+ get x() {
3888
+ return this.original.x;
3889
+ }
3890
+ get y() {
3891
+ return this.original.y;
3892
+ }
3893
+ get global() {
3894
+ if (document !== this.target.ownerDocument && this.frameRect) {
3895
+ return {
3896
+ x: this.x * this.scaleFactor + this.frameRect.left,
3897
+ y: this.y * this.scaleFactor + this.frameRect.top
3898
+ };
3899
+ }
3900
+ return this.original;
3901
+ }
3902
+ get frame() {
3903
+ if (document === this.target.ownerDocument && this.frameRect) {
3904
+ return {
3905
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
3906
+ y: (this.y - this.frameRect.top) / this.scaleFactor
3907
+ };
3908
+ }
3909
+ return this.original;
3910
+ }
3911
+ };
3912
+
3913
+ // lib/dnd/NestedDroppablePlugin.ts
3661
3914
  var depthSort = (candidates) => {
3662
3915
  return candidates.sort((a, b) => {
3663
3916
  const aData = a.data;
@@ -3686,10 +3939,12 @@ var getZoneId2 = (candidate) => {
3686
3939
  }
3687
3940
  return id;
3688
3941
  };
3689
- var getPointerCollisions = (position, manager, ownerDocument) => {
3690
- var _a;
3942
+ var getPointerCollisions = (position, manager) => {
3691
3943
  const candidates = [];
3692
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
3944
+ let elements = position.target.ownerDocument.elementsFromPoint(
3945
+ position.x,
3946
+ position.y
3947
+ );
3693
3948
  const previewFrame = elements.find(
3694
3949
  (el) => el.getAttribute("data-puck-preview")
3695
3950
  );
@@ -3698,22 +3953,21 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3698
3953
  elements = [drawer];
3699
3954
  }
3700
3955
  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
- }
3956
+ const frame = getFrame();
3957
+ if (frame) {
3958
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3712
3959
  }
3713
3960
  }
3714
3961
  if (elements) {
3715
3962
  for (let i = 0; i < elements.length; i++) {
3716
3963
  const element = elements[i];
3964
+ const dropzoneId = element.getAttribute("data-puck-dropzone");
3965
+ if (dropzoneId) {
3966
+ const droppable = manager.registry.droppables.get(dropzoneId);
3967
+ if (droppable) {
3968
+ candidates.push(droppable);
3969
+ }
3970
+ }
3717
3971
  const id = element.getAttribute("data-puck-dnd");
3718
3972
  if (id) {
3719
3973
  const droppable = manager.registry.droppables.get(id);
@@ -3725,9 +3979,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3725
3979
  }
3726
3980
  return candidates;
3727
3981
  };
3728
- var findDeepestCandidate = (position, manager, ownerDocument) => {
3982
+ var findDeepestCandidate = (position, manager) => {
3729
3983
  var _a;
3730
- const candidates = getPointerCollisions(position, manager, ownerDocument);
3984
+ const candidates = getPointerCollisions(position, manager);
3731
3985
  if (candidates.length > 0) {
3732
3986
  const sortedCandidates = depthSort(candidates);
3733
3987
  const draggable = manager.dragOperation.source;
@@ -3772,9 +4026,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
3772
4026
  area: null
3773
4027
  };
3774
4028
  };
3775
- var createNestedDroppablePlugin = ({
3776
- onChange
3777
- }) => class NestedDroppablePlugin extends Plugin {
4029
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
3778
4030
  constructor(manager, options) {
3779
4031
  super(manager);
3780
4032
  if (typeof window === "undefined") {
@@ -3782,16 +4034,19 @@ var createNestedDroppablePlugin = ({
3782
4034
  }
3783
4035
  const cleanupEffect = effects(() => {
3784
4036
  const handleMove = (event) => {
3785
- const position = {
4037
+ const target = event.originalTarget || event.target;
4038
+ const position = new GlobalPosition(target, {
3786
4039
  x: event.clientX,
3787
4040
  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
4041
+ });
4042
+ const elements = document.elementsFromPoint(
4043
+ position.global.x,
4044
+ position.global.y
3794
4045
  );
4046
+ const overEl = elements.some((el) => el.id === id);
4047
+ if (overEl) {
4048
+ onChange(findDeepestCandidate(position, manager), manager);
4049
+ }
3795
4050
  };
3796
4051
  const handleMoveThrottled = throttle(handleMove, 50);
3797
4052
  const handlePointerMove = (event) => {
@@ -4121,6 +4376,11 @@ var reduceUi = (ui, action) => {
4121
4376
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4122
4377
  });
4123
4378
  }
4379
+ if (action.type === "remove") {
4380
+ return __spreadProps(__spreadValues({}, ui), {
4381
+ itemSelector: null
4382
+ });
4383
+ }
4124
4384
  return ui;
4125
4385
  };
4126
4386
 
@@ -4208,7 +4468,7 @@ var insertComponent = (componentType, zone, index, {
4208
4468
  import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4209
4469
  import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
4210
4470
 
4211
- // components/DragDropContext/PointerSensor.ts
4471
+ // lib/dnd/PointerSensor.ts
4212
4472
  init_react_import();
4213
4473
  import { batch, effect } from "@dnd-kit/state";
4214
4474
  import { Sensor, configurator } from "@dnd-kit/abstract";
@@ -4380,6 +4640,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
4380
4640
  }
4381
4641
  }
4382
4642
  handlePointerUp(event) {
4643
+ if (!this.source) {
4644
+ return;
4645
+ }
4383
4646
  event.preventDefault();
4384
4647
  event.stopPropagation();
4385
4648
  const { status } = this.manager.dragOperation;
@@ -4479,13 +4742,15 @@ function patchWindow(window2) {
4479
4742
  }
4480
4743
 
4481
4744
  // components/DragDropContext/index.tsx
4482
- import { jsx as jsx22 } from "react/jsx-runtime";
4483
- var dragListenerContext = createContext3({
4745
+ import { createStore as createStore3 } from "zustand";
4746
+ import { jsx as jsx23 } from "react/jsx-runtime";
4747
+ var DEBUG3 = false;
4748
+ var dragListenerContext = createContext4({
4484
4749
  dragListeners: {}
4485
4750
  });
4486
4751
  function useDragListener(type, fn, deps = []) {
4487
- const { setDragListeners } = useContext4(dragListenerContext);
4488
- useEffect14(() => {
4752
+ const { setDragListeners } = useContext7(dragListenerContext);
4753
+ useEffect15(() => {
4489
4754
  if (setDragListeners) {
4490
4755
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
4491
4756
  [type]: [...old[type] || [], fn]
@@ -4493,78 +4758,145 @@ function useDragListener(type, fn, deps = []) {
4493
4758
  }
4494
4759
  }, deps);
4495
4760
  }
4496
- var previewContext = createContext3(null);
4497
4761
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4762
+ var useTempDisableFallback = (timeout3) => {
4763
+ const lastFallbackDisable = useRef3(null);
4764
+ return useCallback11((manager) => {
4765
+ collisionStore.setState({ fallbackEnabled: false });
4766
+ const fallbackId = generateId();
4767
+ lastFallbackDisable.current = fallbackId;
4768
+ setTimeout(() => {
4769
+ if (lastFallbackDisable.current === fallbackId) {
4770
+ collisionStore.setState({ fallbackEnabled: true });
4771
+ manager.collisionObserver.forceUpdate(true);
4772
+ }
4773
+ }, timeout3);
4774
+ }, []);
4775
+ };
4498
4776
  var DragDropContextClient = ({
4499
4777
  children,
4500
4778
  disableAutoScroll
4501
4779
  }) => {
4502
4780
  const { state, config, dispatch, resolveData } = useAppContext();
4503
- const [preview, setPreview] = useState17(null);
4504
- const previewRef = useRef5(null);
4781
+ const id = useId();
4505
4782
  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(
4783
+ const debouncedParamsRef = useRef3(null);
4784
+ const tempDisableFallback = useTempDisableFallback(100);
4785
+ const [zoneStore] = useState17(
4786
+ () => createStore3(() => ({
4787
+ zoneDepthIndex: {},
4788
+ nextZoneDepthIndex: {},
4789
+ areaDepthIndex: {},
4790
+ nextAreaDepthIndex: {},
4791
+ draggedItem: null,
4792
+ previewIndex: {}
4793
+ }))
4794
+ );
4795
+ const getChanged2 = useCallback11(
4796
+ (params, id2) => {
4797
+ const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
4798
+ const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
4799
+ const stateHasArea = Object.keys(areaDepthIndex).length > 0;
4800
+ let zoneChanged = false;
4801
+ let areaChanged = false;
4802
+ if (params.zone && !zoneDepthIndex[params.zone]) {
4803
+ zoneChanged = true;
4804
+ } else if (!params.zone && stateHasZone) {
4805
+ zoneChanged = true;
4806
+ }
4807
+ if (params.area && !areaDepthIndex[params.area]) {
4808
+ areaChanged = true;
4809
+ } else if (!params.area && stateHasArea) {
4810
+ areaChanged = true;
4811
+ }
4812
+ return { zoneChanged, areaChanged };
4813
+ },
4814
+ [zoneStore]
4815
+ );
4816
+ const setDeepestAndCollide = useCallback11(
4511
4817
  (params, manager) => {
4512
- setDeepest(params);
4818
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4819
+ if (!zoneChanged && !areaChanged) return;
4820
+ zoneStore.setState({
4821
+ zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
4822
+ areaDepthIndex: params.area ? { [params.area]: true } : {}
4823
+ });
4824
+ tempDisableFallback(manager);
4513
4825
  setTimeout(() => {
4514
4826
  manager.collisionObserver.forceUpdate(true);
4515
4827
  }, 50);
4516
4828
  debouncedParamsRef.current = null;
4517
4829
  },
4518
- []
4830
+ [zoneStore]
4519
4831
  );
4520
4832
  const setDeepestDb = useDebouncedCallback2(
4521
4833
  setDeepestAndCollide,
4522
4834
  AREA_CHANGE_DEBOUNCE_MS
4523
4835
  );
4524
- useEffect14(() => {
4525
- deepestRef.current = deepest;
4526
- }, [deepest]);
4527
4836
  const cancelDb = () => {
4528
4837
  setDeepestDb.cancel();
4529
4838
  debouncedParamsRef.current = null;
4530
4839
  };
4840
+ useEffect15(() => {
4841
+ if (DEBUG3) {
4842
+ zoneStore.subscribe(
4843
+ (s) => {
4844
+ var _a, _b;
4845
+ return console.log(
4846
+ s.previewIndex,
4847
+ (_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
4848
+ (_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
4849
+ );
4850
+ }
4851
+ );
4852
+ }
4853
+ }, []);
4531
4854
  const [plugins] = useState17(() => [
4532
4855
  ...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) {
4856
+ createNestedDroppablePlugin(
4857
+ {
4858
+ onChange: (params, manager) => {
4859
+ const state2 = zoneStore.getState();
4860
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4861
+ const isDragging = manager.dragOperation.status.dragging;
4862
+ if (areaChanged || zoneChanged) {
4863
+ let nextZoneDepthIndex = {};
4864
+ let nextAreaDepthIndex = {};
4865
+ if (params.zone) {
4866
+ nextZoneDepthIndex = { [params.zone]: true };
4867
+ }
4868
+ if (params.area) {
4869
+ nextAreaDepthIndex = { [params.area]: true };
4870
+ }
4871
+ zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
4872
+ }
4873
+ if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
4874
+ setDeepestAndCollide(params, manager);
4875
+ return;
4876
+ }
4877
+ if (areaChanged) {
4878
+ if (isDragging) {
4879
+ const debouncedParams = debouncedParamsRef.current;
4880
+ const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4881
+ if (!isSameParams) {
4882
+ cancelDb();
4883
+ setDeepestDb(params, manager);
4884
+ debouncedParamsRef.current = params;
4885
+ }
4886
+ } else {
4552
4887
  cancelDb();
4553
- setDeepestDb(params, manager);
4554
- debouncedParamsRef.current = params;
4888
+ setDeepestAndCollide(params, manager);
4555
4889
  }
4556
- } else {
4557
- cancelDb();
4890
+ return;
4891
+ }
4892
+ if (zoneChanged) {
4558
4893
  setDeepestAndCollide(params, manager);
4559
4894
  }
4560
- return;
4561
- }
4562
- if (zoneChanged) {
4563
- setDeepestAndCollide(params, manager);
4895
+ cancelDb();
4564
4896
  }
4565
- cancelDb();
4566
- }
4567
- })
4897
+ },
4898
+ id
4899
+ )
4568
4900
  ]);
4569
4901
  const [sensors] = useState17(() => [
4570
4902
  PointerSensor.configure({
@@ -4585,67 +4917,72 @@ var DragDropContextClient = ({
4585
4917
  }
4586
4918
  })
4587
4919
  ]);
4588
- const [draggedItem, setDraggedItem] = useState17();
4589
4920
  const [dragListeners, setDragListeners] = useState17({});
4590
4921
  const [pathData, setPathData] = useState17();
4591
- const dragMode = useRef5(null);
4592
- const registerPath = useCallback9(
4593
- (selector) => {
4594
- const item = getItem(selector, data);
4595
- if (!item) {
4596
- return;
4597
- }
4922
+ const dragMode = useRef3(null);
4923
+ const registerPath = useCallback11(
4924
+ (id2, selector, label) => {
4598
4925
  const [area] = getZoneId(selector.zone);
4599
4926
  setPathData((latestPathData = {}) => {
4600
4927
  const parentPathData = latestPathData[area] || { path: [] };
4601
4928
  return __spreadProps(__spreadValues({}, latestPathData), {
4602
- [item.props.id]: {
4929
+ [id2]: {
4603
4930
  path: [
4604
4931
  ...parentPathData.path,
4605
4932
  ...selector.zone ? [selector.zone] : []
4606
4933
  ],
4607
- label: item.type
4934
+ label
4608
4935
  }
4609
4936
  });
4610
4937
  });
4611
4938
  },
4612
4939
  [data, setPathData]
4613
4940
  );
4614
- const initialSelector = useRef5(void 0);
4615
- return /* @__PURE__ */ jsx22(
4941
+ const unregisterPath = useCallback11(
4942
+ (id2) => {
4943
+ setPathData((latestPathData = {}) => {
4944
+ const newPathData = __spreadValues({}, latestPathData);
4945
+ delete newPathData[id2];
4946
+ return newPathData;
4947
+ });
4948
+ },
4949
+ [data, setPathData]
4950
+ );
4951
+ const initialSelector = useRef3(void 0);
4952
+ return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
4616
4953
  dragListenerContext.Provider,
4617
4954
  {
4618
4955
  value: {
4619
4956
  dragListeners,
4620
4957
  setDragListeners
4621
4958
  },
4622
- children: /* @__PURE__ */ jsx22(previewContext.Provider, { value: preview, children: /* @__PURE__ */ jsx22(
4959
+ children: /* @__PURE__ */ jsx23(
4623
4960
  DragDropProvider2,
4624
4961
  {
4625
4962
  plugins,
4626
4963
  sensors,
4627
4964
  onDragEnd: (event, manager) => {
4965
+ var _a;
4628
4966
  const { source, target } = event.operation;
4629
- deepestRef.current = null;
4630
4967
  if (!source) {
4631
- setDraggedItem(null);
4968
+ zoneStore.setState({ draggedItem: null });
4632
4969
  return;
4633
4970
  }
4634
4971
  const { zone, index } = source.data;
4635
- const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
4636
- previewRef.current = null;
4972
+ const { previewIndex = {} } = zoneStore.getState() || {};
4973
+ const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
4637
4974
  setTimeout(() => {
4638
- var _a, _b;
4639
- setDraggedItem(null);
4975
+ var _a2, _b;
4976
+ zoneStore.setState({ draggedItem: null });
4640
4977
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4641
- setPreview(null);
4642
- (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
4978
+ zoneStore.setState({ previewIndex: {} });
4979
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
4643
4980
  fn(event, manager);
4644
4981
  });
4645
4982
  return;
4646
4983
  }
4647
4984
  if (thisPreview) {
4648
- setPreview(null);
4985
+ zoneStore.setState({ previewIndex: {} });
4649
4986
  if (thisPreview.type === "insert") {
4650
4987
  insertComponent(
4651
4988
  thisPreview.componentType,
@@ -4680,8 +5017,9 @@ var DragDropContextClient = ({
4680
5017
  }, 250);
4681
5018
  },
4682
5019
  onDragOver: (event, manager) => {
4683
- var _a, _b, _c, _d;
5020
+ var _a, _b, _c, _d, _e;
4684
5021
  event.preventDefault();
5022
+ const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
4685
5023
  if (!draggedItem) return;
4686
5024
  cancelDb();
4687
5025
  const { source, target } = event.operation;
@@ -4697,7 +5035,7 @@ var DragDropContextClient = ({
4697
5035
  const targetData = target.data;
4698
5036
  targetZone = targetData.zone;
4699
5037
  targetIndex = targetData.index;
4700
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
5038
+ const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
4701
5039
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
4702
5040
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
4703
5041
  targetIndex = targetIndex - 1;
@@ -4709,23 +5047,26 @@ var DragDropContextClient = ({
4709
5047
  targetZone = target.id.toString();
4710
5048
  targetIndex = 0;
4711
5049
  }
4712
- if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
5050
+ if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
4713
5051
  const [pathId] = path.split(":");
4714
5052
  return pathId === sourceId;
4715
5053
  }))) {
4716
5054
  return;
4717
5055
  }
4718
5056
  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()
5057
+ zoneStore.setState({
5058
+ previewIndex: {
5059
+ [targetZone]: {
5060
+ componentType: sourceData.componentType,
5061
+ type: "insert",
5062
+ index: targetIndex,
5063
+ zone: targetZone,
5064
+ props: {
5065
+ id: source.id.toString()
5066
+ }
5067
+ }
4726
5068
  }
4727
- };
4728
- setPreview(previewRef.current);
5069
+ });
4729
5070
  } else {
4730
5071
  if (!initialSelector.current) {
4731
5072
  initialSelector.current = {
@@ -4735,17 +5076,20 @@ var DragDropContextClient = ({
4735
5076
  }
4736
5077
  const item = getItem(initialSelector.current, data);
4737
5078
  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);
5079
+ zoneStore.setState({
5080
+ previewIndex: {
5081
+ [targetZone]: {
5082
+ componentType: sourceData.componentType,
5083
+ type: "move",
5084
+ index: targetIndex,
5085
+ zone: targetZone,
5086
+ props: item.props
5087
+ }
5088
+ }
5089
+ });
4746
5090
  }
4747
5091
  }
4748
- (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
5092
+ (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
4749
5093
  fn(event, manager);
4750
5094
  });
4751
5095
  },
@@ -4755,46 +5099,62 @@ var DragDropContextClient = ({
4755
5099
  type: "setUi",
4756
5100
  ui: { itemSelector: null, isDragging: true }
4757
5101
  });
5102
+ const { source } = event.operation;
5103
+ if (source && source.type !== "void") {
5104
+ const sourceData = source.data;
5105
+ const item = getItem(
5106
+ {
5107
+ zone: sourceData.zone,
5108
+ index: sourceData.index
5109
+ },
5110
+ data
5111
+ );
5112
+ if (item) {
5113
+ zoneStore.setState({
5114
+ previewIndex: {
5115
+ [sourceData.zone]: {
5116
+ componentType: sourceData.componentType,
5117
+ type: "move",
5118
+ index: sourceData.index,
5119
+ zone: sourceData.zone,
5120
+ props: item.props
5121
+ }
5122
+ }
5123
+ });
5124
+ }
5125
+ }
4758
5126
  (_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
4759
5127
  fn(event, manager);
4760
5128
  });
4761
5129
  },
4762
5130
  onBeforeDragStart: (event) => {
4763
5131
  var _a;
4764
- if (draggedItem) {
4765
- console.warn("New drag started before previous drag cleaned up");
4766
- }
4767
5132
  const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
4768
5133
  dragMode.current = isNewComponent ? "new" : "existing";
4769
5134
  initialSelector.current = void 0;
4770
- setDraggedItem(event.operation.source);
5135
+ zoneStore.setState({ draggedItem: event.operation.source });
4771
5136
  },
4772
- children: /* @__PURE__ */ jsx22(
5137
+ children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
4773
5138
  DropZoneProvider,
4774
5139
  {
4775
5140
  value: {
4776
5141
  data,
4777
5142
  config,
4778
- dispatch,
4779
- draggedItem,
4780
5143
  mode: "edit",
4781
5144
  areaId: "root",
4782
5145
  depth: 0,
4783
5146
  registerPath,
5147
+ unregisterPath,
4784
5148
  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
5149
  path: []
4790
5150
  },
4791
5151
  children
4792
5152
  }
4793
- )
5153
+ ) })
4794
5154
  }
4795
- ) })
5155
+ )
4796
5156
  }
4797
- );
5157
+ ) });
4798
5158
  };
4799
5159
  var DragDropContext = ({
4800
5160
  children,
@@ -4804,11 +5164,11 @@ var DragDropContext = ({
4804
5164
  if (status === "LOADING") {
4805
5165
  return children;
4806
5166
  }
4807
- return /* @__PURE__ */ jsx22(DragDropContextClient, { disableAutoScroll, children });
5167
+ return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
4808
5168
  };
4809
5169
 
4810
5170
  // components/Drawer/index.tsx
4811
- import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
5171
+ import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
4812
5172
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
4813
5173
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
4814
5174
  var DrawerItemInner = ({
@@ -4818,11 +5178,11 @@ var DrawerItemInner = ({
4818
5178
  dragRef,
4819
5179
  isDragDisabled
4820
5180
  }) => {
4821
- const CustomInner = useMemo8(
4822
- () => children || (({ children: children2 }) => /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("default"), children: children2 })),
5181
+ const CustomInner = useMemo9(
5182
+ () => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
4823
5183
  [children]
4824
5184
  );
4825
- return /* @__PURE__ */ jsx23(
5185
+ return /* @__PURE__ */ jsx24(
4826
5186
  "div",
4827
5187
  {
4828
5188
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -4830,9 +5190,9 @@ var DrawerItemInner = ({
4830
5190
  onMouseDown: (e) => e.preventDefault(),
4831
5191
  "data-testid": dragRef ? `drawer-item:${name}` : "",
4832
5192
  "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, {}) })
5193
+ children: /* @__PURE__ */ jsx24(CustomInner, { name, children: /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
5194
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5195
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx24(DragIcon, {}) })
4836
5196
  ] }) }) })
4837
5197
  }
4838
5198
  );
@@ -4850,8 +5210,8 @@ var DrawerItemDraggable = ({
4850
5210
  disabled: isDragDisabled
4851
5211
  });
4852
5212
  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(
5213
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx24(DrawerItemInner, { name, label, children }) }),
5214
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx24(
4855
5215
  DrawerItemInner,
4856
5216
  {
4857
5217
  name,
@@ -4885,7 +5245,7 @@ var DrawerItem = ({
4885
5245
  },
4886
5246
  [resolvedId]
4887
5247
  );
4888
- return /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
5248
+ return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
4889
5249
  DrawerItemDraggable,
4890
5250
  {
4891
5251
  name,
@@ -4911,14 +5271,14 @@ var Drawer = ({
4911
5271
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
4912
5272
  );
4913
5273
  }
4914
- const [id] = useState18(generateId());
5274
+ const id = useId2();
4915
5275
  const { ref } = useDroppableSafe({
4916
5276
  id,
4917
5277
  type: "void",
4918
5278
  collisionPriority: 0
4919
5279
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
4920
5280
  });
4921
- return /* @__PURE__ */ jsx23(
5281
+ return /* @__PURE__ */ jsx24(
4922
5282
  "div",
4923
5283
  {
4924
5284
  className: getClassName18(),
@@ -4934,9 +5294,9 @@ Drawer.Item = DrawerItem;
4934
5294
  // components/Puck/index.tsx
4935
5295
  init_react_import();
4936
5296
  import {
4937
- useCallback as useCallback14,
4938
- useEffect as useEffect22,
4939
- useMemo as useMemo17,
5297
+ useCallback as useCallback18,
5298
+ useEffect as useEffect24,
5299
+ useMemo as useMemo19,
4940
5300
  useReducer,
4941
5301
  useState as useState26
4942
5302
  } from "react";
@@ -4950,7 +5310,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
4950
5310
 
4951
5311
  // lib/use-breadcrumbs.ts
4952
5312
  init_react_import();
4953
- import { useContext as useContext5, useMemo as useMemo9 } from "react";
5313
+ import { useContext as useContext8, useMemo as useMemo10 } from "react";
4954
5314
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
4955
5315
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
4956
5316
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -5000,8 +5360,8 @@ var useBreadcrumbs = (renderCount) => {
5000
5360
  state: { data },
5001
5361
  selectedItem
5002
5362
  } = useAppContext();
5003
- const dzContext = useContext5(dropZoneContext);
5004
- return useMemo9(() => {
5363
+ const dzContext = useContext8(dropZoneContext);
5364
+ return useMemo10(() => {
5005
5365
  const breadcrumbs = convertPathDataToBreadcrumbs(
5006
5366
  selectedItem,
5007
5367
  dzContext == null ? void 0 : dzContext.pathData,
@@ -5015,7 +5375,7 @@ var useBreadcrumbs = (renderCount) => {
5015
5375
  };
5016
5376
 
5017
5377
  // components/SidebarSection/index.tsx
5018
- import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
5378
+ import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
5019
5379
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5020
5380
  var SidebarSection = ({
5021
5381
  children,
@@ -5034,9 +5394,9 @@ var SidebarSection = ({
5034
5394
  className: getClassName19({ noBorderTop, noPadding }),
5035
5395
  style: { background },
5036
5396
  children: [
5037
- /* @__PURE__ */ jsx24("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5397
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5038
5398
  showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
5039
- /* @__PURE__ */ jsx24(
5399
+ /* @__PURE__ */ jsx25(
5040
5400
  "button",
5041
5401
  {
5042
5402
  type: "button",
@@ -5045,12 +5405,12 @@ var SidebarSection = ({
5045
5405
  children: breadcrumb.label
5046
5406
  }
5047
5407
  ),
5048
- /* @__PURE__ */ jsx24(ChevronRight, { size: 16 })
5408
+ /* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
5049
5409
  ] }, i)) : null,
5050
- /* @__PURE__ */ jsx24("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx24(Heading, { rank: "2", size: "xs", children: title }) })
5410
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
5051
5411
  ] }) }),
5052
- /* @__PURE__ */ jsx24("div", { className: getClassName19("content"), children }),
5053
- isLoading && /* @__PURE__ */ jsx24("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx24(Loader, { size: 32 }) })
5412
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
5413
+ isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
5054
5414
  ]
5055
5415
  }
5056
5416
  );
@@ -5081,7 +5441,7 @@ init_react_import();
5081
5441
  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
5442
 
5083
5443
  // components/MenuBar/index.tsx
5084
- import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
5444
+ import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
5085
5445
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5086
5446
  function MenuBar({
5087
5447
  appState,
@@ -5095,7 +5455,7 @@ function MenuBar({
5095
5455
  history: { back, forward, historyStore }
5096
5456
  } = useAppContext();
5097
5457
  const { hasFuture = false, hasPast = false } = historyStore || {};
5098
- return /* @__PURE__ */ jsx25(
5458
+ return /* @__PURE__ */ jsx26(
5099
5459
  "div",
5100
5460
  {
5101
5461
  className: getClassName20({ menuOpen }),
@@ -5111,10 +5471,10 @@ function MenuBar({
5111
5471
  },
5112
5472
  children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
5113
5473
  /* @__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 }) })
5474
+ /* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
5475
+ /* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
5116
5476
  ] }),
5117
- /* @__PURE__ */ jsx25(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5477
+ /* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5118
5478
  state: appState,
5119
5479
  dispatch
5120
5480
  }) })
@@ -5125,43 +5485,68 @@ function MenuBar({
5125
5485
 
5126
5486
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5127
5487
  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" };
5488
+ 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
5489
 
5130
5490
  // components/Puck/components/Fields/index.tsx
5131
5491
  init_react_import();
5132
5492
 
5133
5493
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5134
5494
  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" };
5495
+ 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
5496
 
5137
5497
  // components/Puck/components/Fields/index.tsx
5138
- import { useCallback as useCallback10, useEffect as useEffect15, useMemo as useMemo10, useState as useState19 } from "react";
5498
+ import { useMemo as useMemo12 } from "react";
5499
+
5500
+ // lib/use-resolved-fields.ts
5501
+ init_react_import();
5502
+ import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
5139
5503
 
5140
5504
  // lib/use-parent.ts
5141
5505
  init_react_import();
5142
- import { useContext as useContext6 } from "react";
5143
- var useParent = (itemSelector) => {
5506
+ import { useCallback as useCallback12, useContext as useContext9 } from "react";
5507
+ var getParent = (itemSelector, pathData, data) => {
5144
5508
  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);
5509
+ if (!itemSelector) return null;
5510
+ const item = getItem(itemSelector, data);
5511
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
5149
5512
  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;
5513
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
5151
5514
  return parent || null;
5152
5515
  };
5516
+ var useGetParent = () => {
5517
+ const { state } = useAppContext();
5518
+ const { pathData } = useContext9(dropZoneContext) || {};
5519
+ return useCallback12(
5520
+ () => getParent(state.ui.itemSelector, pathData, state.data),
5521
+ [state.ui.itemSelector, pathData, state.data]
5522
+ );
5523
+ };
5524
+ var useParent = () => {
5525
+ return useGetParent()();
5526
+ };
5153
5527
 
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);
5528
+ // lib/use-on-value-change.ts
5529
+ init_react_import();
5530
+ import { useRef as useRef4, useEffect as useEffect16 } from "react";
5531
+ function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5532
+ const tracked = useRef4(value);
5533
+ useEffect16(() => {
5534
+ const oldValue = tracked.current;
5535
+ if (!compare(value, oldValue)) {
5536
+ tracked.current = value;
5537
+ onChange(value, oldValue);
5538
+ }
5539
+ }, [onChange, compare, value, ...deps]);
5540
+ }
5541
+
5542
+ // lib/selector-is.ts
5543
+ init_react_import();
5544
+ 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);
5545
+
5546
+ // lib/use-resolved-fields.ts
5157
5547
  var defaultPageFields = {
5158
5548
  title: { type: "text" }
5159
5549
  };
5160
- var DefaultFields = ({
5161
- children
5162
- }) => {
5163
- return /* @__PURE__ */ jsx26(Fragment8, { children });
5164
- };
5165
5550
  var useResolvedFields = () => {
5166
5551
  var _a, _b;
5167
5552
  const { selectedItem, state, config } = useAppContext();
@@ -5169,7 +5554,7 @@ var useResolvedFields = () => {
5169
5554
  const { data } = state;
5170
5555
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5171
5556
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5172
- const defaultFields = useMemo10(
5557
+ const defaultFields = useMemo11(
5173
5558
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5174
5559
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5175
5560
  );
@@ -5177,12 +5562,13 @@ var useResolvedFields = () => {
5177
5562
  const [lastSelectedData, setLastSelectedData] = useState19({});
5178
5563
  const [resolvedFields, setResolvedFields] = useState19(defaultFields);
5179
5564
  const [fieldsLoading, setFieldsLoading] = useState19(false);
5565
+ const lastFields = useRef5(defaultFields);
5180
5566
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5181
5567
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5182
5568
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5183
5569
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5184
5570
  const hasResolver = hasComponentResolver || hasRootResolver;
5185
- const resolveFields = useCallback10(
5571
+ const resolveFields = useCallback13(
5186
5572
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5187
5573
  var _a2;
5188
5574
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5194,7 +5580,7 @@ var useResolvedFields = () => {
5194
5580
  {
5195
5581
  changed,
5196
5582
  fields,
5197
- lastFields: resolvedFields,
5583
+ lastFields: lastFields.current,
5198
5584
  lastData,
5199
5585
  appState: state,
5200
5586
  parent
@@ -5205,7 +5591,7 @@ var useResolvedFields = () => {
5205
5591
  return yield config.root.resolveFields(componentData, {
5206
5592
  changed,
5207
5593
  fields,
5208
- lastFields: resolvedFields,
5594
+ lastFields: lastFields.current,
5209
5595
  lastData,
5210
5596
  appState: state,
5211
5597
  parent
@@ -5214,26 +5600,56 @@ var useResolvedFields = () => {
5214
5600
  return defaultResolveFields(componentData, {
5215
5601
  changed,
5216
5602
  fields,
5217
- lastFields: resolvedFields,
5603
+ lastFields: lastFields.current,
5218
5604
  lastData
5219
5605
  });
5220
5606
  }),
5221
- [data, config, componentData, selectedItem, resolvedFields, state]
5607
+ [data, config, componentData, selectedItem, state, parent]
5222
5608
  );
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);
5609
+ const triggerResolver = useCallback13(() => {
5610
+ var _a2, _b2;
5611
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5612
+ if (hasResolver) {
5613
+ setFieldsLoading(true);
5614
+ resolveFields(defaultFields).then((fields) => {
5615
+ setResolvedFields(fields || {});
5616
+ lastFields.current = fields;
5617
+ setFieldsLoading(false);
5618
+ });
5619
+ return;
5620
+ }
5232
5621
  }
5233
- }, [data, defaultFields, selectedItem, hasResolver]);
5622
+ setResolvedFields(defaultFields);
5623
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5624
+ useOnValueChange(
5625
+ state.ui.itemSelector,
5626
+ () => {
5627
+ lastFields.current = defaultFields;
5628
+ },
5629
+ selectorIs
5630
+ );
5631
+ useOnValueChange(
5632
+ { data, parent, itemSelector: state.ui.itemSelector },
5633
+ () => {
5634
+ triggerResolver();
5635
+ },
5636
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
5637
+ );
5638
+ useEffect17(() => {
5639
+ triggerResolver();
5640
+ }, []);
5234
5641
  return [resolvedFields, fieldsLoading];
5235
5642
  };
5236
- var Fields = () => {
5643
+
5644
+ // components/Puck/components/Fields/index.tsx
5645
+ import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5646
+ var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5647
+ var DefaultFields = ({
5648
+ children
5649
+ }) => {
5650
+ return /* @__PURE__ */ jsx27(Fragment8, { children });
5651
+ };
5652
+ var Fields = ({ wrapFields = true }) => {
5237
5653
  var _a, _b;
5238
5654
  const {
5239
5655
  selectedItem,
@@ -5251,16 +5667,16 @@ var Fields = () => {
5251
5667
  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
5668
  const isLoading = fieldsResolving || componentResolving;
5253
5669
  const rootProps = data.root.props || data.root;
5254
- const Wrapper = useMemo10(() => overrides.fields || DefaultFields, [overrides]);
5670
+ const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
5255
5671
  return /* @__PURE__ */ jsxs14(
5256
5672
  "form",
5257
5673
  {
5258
- className: getClassName21(),
5674
+ className: getClassName21({ wrapFields }),
5259
5675
  onSubmit: (e) => {
5260
5676
  e.preventDefault();
5261
5677
  },
5262
5678
  children: [
5263
- /* @__PURE__ */ jsx26(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5679
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5264
5680
  const field = fields[fieldName];
5265
5681
  if (!(field == null ? void 0 : field.type)) return null;
5266
5682
  const onChange = (value, updatedUi) => {
@@ -5331,7 +5747,7 @@ var Fields = () => {
5331
5747
  item: selectedItem
5332
5748
  });
5333
5749
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5334
- return /* @__PURE__ */ jsx26(
5750
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5335
5751
  AutoFieldPrivate,
5336
5752
  {
5337
5753
  field,
@@ -5340,16 +5756,15 @@ var Fields = () => {
5340
5756
  readOnly: !edit || readOnly[fieldName],
5341
5757
  value: selectedItem.props[fieldName],
5342
5758
  onChange
5343
- },
5344
- id
5345
- );
5759
+ }
5760
+ ) }, id);
5346
5761
  } else {
5347
5762
  const readOnly = data.root.readOnly || {};
5348
5763
  const { edit } = getPermissions({
5349
5764
  root: true
5350
5765
  });
5351
5766
  const id = `root_${field.type}_${fieldName}`;
5352
- return /* @__PURE__ */ jsx26(
5767
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5353
5768
  AutoFieldPrivate,
5354
5769
  {
5355
5770
  field,
@@ -5358,12 +5773,11 @@ var Fields = () => {
5358
5773
  readOnly: !edit || readOnly[fieldName],
5359
5774
  value: rootProps[fieldName],
5360
5775
  onChange
5361
- },
5362
- id
5363
- );
5776
+ }
5777
+ ) }, id);
5364
5778
  }
5365
5779
  }) }),
5366
- isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx26(Loader, { size: 16 }) }) })
5780
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
5367
5781
  ]
5368
5782
  }
5369
5783
  );
@@ -5374,7 +5788,7 @@ init_react_import();
5374
5788
 
5375
5789
  // lib/use-component-list.tsx
5376
5790
  init_react_import();
5377
- import { useEffect as useEffect16, useState as useState20 } from "react";
5791
+ import { useEffect as useEffect18, useState as useState20 } from "react";
5378
5792
 
5379
5793
  // components/ComponentList/index.tsx
5380
5794
  init_react_import();
@@ -5384,7 +5798,7 @@ init_react_import();
5384
5798
  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
5799
 
5386
5800
  // components/ComponentList/index.tsx
5387
- import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
5801
+ import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
5388
5802
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
5389
5803
  var ComponentListItem = ({
5390
5804
  name,
@@ -5394,7 +5808,7 @@ var ComponentListItem = ({
5394
5808
  const canInsert = getPermissions({
5395
5809
  type: name
5396
5810
  }).insert;
5397
- return /* @__PURE__ */ jsx27(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5811
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5398
5812
  };
5399
5813
  var ComponentList = ({
5400
5814
  children,
@@ -5418,14 +5832,14 @@ var ComponentList = ({
5418
5832
  }),
5419
5833
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
5420
5834
  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 }) })
5835
+ /* @__PURE__ */ jsx28("div", { children: title }),
5836
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
5423
5837
  ]
5424
5838
  }
5425
5839
  ),
5426
- /* @__PURE__ */ jsx27("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx27(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5840
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5427
5841
  var _a;
5428
- return /* @__PURE__ */ jsx27(
5842
+ return /* @__PURE__ */ jsx28(
5429
5843
  ComponentListItem,
5430
5844
  {
5431
5845
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -5439,10 +5853,10 @@ var ComponentList = ({
5439
5853
  ComponentList.Item = ComponentListItem;
5440
5854
 
5441
5855
  // lib/use-component-list.tsx
5442
- import { jsx as jsx28 } from "react/jsx-runtime";
5856
+ import { jsx as jsx29 } from "react/jsx-runtime";
5443
5857
  var useComponentList = (config, ui) => {
5444
5858
  const [componentList, setComponentList] = useState20();
5445
- useEffect16(() => {
5859
+ useEffect18(() => {
5446
5860
  var _a, _b, _c;
5447
5861
  if (Object.keys(ui.componentList).length > 0) {
5448
5862
  const matchedComponents = [];
@@ -5452,7 +5866,7 @@ var useComponentList = (config, ui) => {
5452
5866
  if (category.visible === false || !category.components) {
5453
5867
  return null;
5454
5868
  }
5455
- return /* @__PURE__ */ jsx28(
5869
+ return /* @__PURE__ */ jsx29(
5456
5870
  ComponentList,
5457
5871
  {
5458
5872
  id: categoryKey,
@@ -5461,7 +5875,7 @@ var useComponentList = (config, ui) => {
5461
5875
  var _a2;
5462
5876
  matchedComponents.push(componentName);
5463
5877
  const componentConf = config.components[componentName] || {};
5464
- return /* @__PURE__ */ jsx28(
5878
+ return /* @__PURE__ */ jsx29(
5465
5879
  ComponentList.Item,
5466
5880
  {
5467
5881
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -5481,7 +5895,7 @@ var useComponentList = (config, ui) => {
5481
5895
  );
5482
5896
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
5483
5897
  _componentList.push(
5484
- /* @__PURE__ */ jsx28(
5898
+ /* @__PURE__ */ jsx29(
5485
5899
  ComponentList,
5486
5900
  {
5487
5901
  id: "other",
@@ -5489,7 +5903,7 @@ var useComponentList = (config, ui) => {
5489
5903
  children: remainingComponents.map((componentName, i) => {
5490
5904
  var _a2;
5491
5905
  const componentConf = config.components[componentName] || {};
5492
- return /* @__PURE__ */ jsx28(
5906
+ return /* @__PURE__ */ jsx29(
5493
5907
  ComponentList.Item,
5494
5908
  {
5495
5909
  name: componentName,
@@ -5511,30 +5925,30 @@ var useComponentList = (config, ui) => {
5511
5925
  };
5512
5926
 
5513
5927
  // components/Puck/components/Components/index.tsx
5514
- import { useMemo as useMemo11 } from "react";
5515
- import { jsx as jsx29 } from "react/jsx-runtime";
5928
+ import { useMemo as useMemo13 } from "react";
5929
+ import { jsx as jsx30 } from "react/jsx-runtime";
5516
5930
  var Components = () => {
5517
5931
  const { config, state, overrides } = useAppContext();
5518
5932
  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" }) });
5933
+ const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
5934
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
5521
5935
  };
5522
5936
 
5523
5937
  // components/Puck/components/Preview/index.tsx
5524
5938
  init_react_import();
5525
- import { useCallback as useCallback11, useEffect as useEffect18, useRef as useRef7, useMemo as useMemo12 } from "react";
5939
+ import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
5526
5940
 
5527
5941
  // components/AutoFrame/index.tsx
5528
5942
  init_react_import();
5529
5943
  import {
5530
- createContext as createContext4,
5531
- useContext as useContext7,
5532
- useEffect as useEffect17,
5944
+ createContext as createContext5,
5945
+ useContext as useContext10,
5946
+ useEffect as useEffect19,
5533
5947
  useState as useState21
5534
5948
  } from "react";
5535
5949
  import hash from "object-hash";
5536
5950
  import { createPortal as createPortal3 } from "react-dom";
5537
- import { Fragment as Fragment9, jsx as jsx30 } from "react/jsx-runtime";
5951
+ import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
5538
5952
  var styleSelector = 'style, link[rel="stylesheet"]';
5539
5953
  var collectStyles = (doc) => {
5540
5954
  const collected = [];
@@ -5577,7 +5991,7 @@ var CopyHostStyles = ({
5577
5991
  onStylesLoaded = () => null
5578
5992
  }) => {
5579
5993
  const { document: doc, window: win } = useFrame();
5580
- useEffect17(() => {
5994
+ useEffect19(() => {
5581
5995
  if (!win || !doc) {
5582
5996
  return () => {
5583
5997
  };
@@ -5734,10 +6148,10 @@ var CopyHostStyles = ({
5734
6148
  observer.disconnect();
5735
6149
  };
5736
6150
  }, []);
5737
- return /* @__PURE__ */ jsx30(Fragment9, { children });
6151
+ return /* @__PURE__ */ jsx31(Fragment9, { children });
5738
6152
  };
5739
- var autoFrameContext = createContext4({});
5740
- var useFrame = () => useContext7(autoFrameContext);
6153
+ var autoFrameContext = createContext5({});
6154
+ var useFrame = () => useContext10(autoFrameContext);
5741
6155
  function AutoFrame(_a) {
5742
6156
  var _b = _a, {
5743
6157
  children,
@@ -5757,7 +6171,7 @@ function AutoFrame(_a) {
5757
6171
  const [loaded, setLoaded] = useState21(false);
5758
6172
  const [ctx, setCtx] = useState21({});
5759
6173
  const [mountTarget, setMountTarget] = useState21();
5760
- useEffect17(() => {
6174
+ useEffect19(() => {
5761
6175
  var _a2;
5762
6176
  if (frameRef.current) {
5763
6177
  setCtx({
@@ -5769,7 +6183,7 @@ function AutoFrame(_a) {
5769
6183
  );
5770
6184
  }
5771
6185
  }, [frameRef, loaded]);
5772
- return /* @__PURE__ */ jsx30(
6186
+ return /* @__PURE__ */ jsx31(
5773
6187
  "iframe",
5774
6188
  __spreadProps(__spreadValues({}, props), {
5775
6189
  className,
@@ -5779,7 +6193,7 @@ function AutoFrame(_a) {
5779
6193
  onLoad: () => {
5780
6194
  setLoaded(true);
5781
6195
  },
5782
- children: /* @__PURE__ */ jsx30(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx30(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
6196
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
5783
6197
  })
5784
6198
  );
5785
6199
  }
@@ -5790,12 +6204,68 @@ var AutoFrame_default = AutoFrame;
5790
6204
  init_react_import();
5791
6205
  var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
5792
6206
 
6207
+ // components/Render/index.tsx
6208
+ init_react_import();
6209
+ import { jsx as jsx32 } from "react/jsx-runtime";
6210
+ function Render({
6211
+ config,
6212
+ data
6213
+ }) {
6214
+ var _a;
6215
+ const defaultedData = __spreadProps(__spreadValues({}, data), {
6216
+ root: data.root || {},
6217
+ content: data.content || []
6218
+ });
6219
+ const rootProps = defaultedData.root.props || defaultedData.root;
6220
+ const title = (rootProps == null ? void 0 : rootProps.title) || "";
6221
+ if ((_a = config.root) == null ? void 0 : _a.render) {
6222
+ return /* @__PURE__ */ jsx32(
6223
+ DropZoneProvider,
6224
+ {
6225
+ value: {
6226
+ data: defaultedData,
6227
+ config,
6228
+ mode: "render",
6229
+ depth: 0,
6230
+ path: []
6231
+ },
6232
+ children: /* @__PURE__ */ jsx32(
6233
+ config.root.render,
6234
+ __spreadProps(__spreadValues({}, rootProps), {
6235
+ puck: {
6236
+ renderDropZone: DropZone,
6237
+ isEditing: false
6238
+ },
6239
+ title,
6240
+ editMode: false,
6241
+ id: "puck-root",
6242
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6243
+ })
6244
+ )
6245
+ }
6246
+ );
6247
+ }
6248
+ return /* @__PURE__ */ jsx32(
6249
+ DropZoneProvider,
6250
+ {
6251
+ value: {
6252
+ data: defaultedData,
6253
+ config,
6254
+ mode: "render",
6255
+ depth: 0,
6256
+ path: []
6257
+ },
6258
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6259
+ }
6260
+ );
6261
+ }
6262
+
5793
6263
  // components/Puck/components/Preview/index.tsx
5794
- import { Fragment as Fragment10, jsx as jsx31 } from "react/jsx-runtime";
6264
+ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
5795
6265
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
5796
6266
  var useBubbleIframeEvents = (ref) => {
5797
6267
  const { status } = useAppContext();
5798
- useEffect18(() => {
6268
+ useEffect20(() => {
5799
6269
  var _a;
5800
6270
  if (ref.current && status === "READY") {
5801
6271
  const iframe = ref.current;
@@ -5832,22 +6302,34 @@ var useBubbleIframeEvents = (ref) => {
5832
6302
  }
5833
6303
  }, [status]);
5834
6304
  };
5835
- var Preview = ({ id = "puck-preview" }) => {
6305
+ var Preview2 = ({ id = "puck-preview" }) => {
5836
6306
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
5837
- const Page = useCallback11(
6307
+ const Page = useCallback14(
5838
6308
  (pageProps) => {
5839
6309
  var _a, _b;
5840
6310
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
5841
6311
  id: "puck-root"
5842
- }, pageProps)) : /* @__PURE__ */ jsx31(Fragment10, { children: pageProps.children });
6312
+ }, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
5843
6313
  },
5844
6314
  [config.root]
5845
6315
  );
5846
- const Frame = useMemo12(() => overrides.iframe, [overrides]);
6316
+ const Frame = useMemo14(() => overrides.iframe, [overrides]);
5847
6317
  const rootProps = state.data.root.props || state.data.root;
5848
6318
  const ref = useRef7(null);
5849
6319
  useBubbleIframeEvents(ref);
5850
- return /* @__PURE__ */ jsx31(
6320
+ const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
6321
+ Page,
6322
+ __spreadProps(__spreadValues({}, rootProps), {
6323
+ puck: {
6324
+ renderDropZone: DropZone,
6325
+ isEditing: true,
6326
+ dragRef: null
6327
+ },
6328
+ editMode: true,
6329
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
6330
+ })
6331
+ ) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
6332
+ return /* @__PURE__ */ jsx33(
5851
6333
  "div",
5852
6334
  {
5853
6335
  className: getClassName23(),
@@ -5856,7 +6338,7 @@ var Preview = ({ id = "puck-preview" }) => {
5856
6338
  onClick: () => {
5857
6339
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
5858
6340
  },
5859
- children: iframe.enabled ? /* @__PURE__ */ jsx31(
6341
+ children: iframe.enabled ? /* @__PURE__ */ jsx33(
5860
6342
  AutoFrame_default,
5861
6343
  {
5862
6344
  id: "preview-frame",
@@ -5866,40 +6348,21 @@ var Preview = ({ id = "puck-preview" }) => {
5866
6348
  setStatus("READY");
5867
6349
  },
5868
6350
  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
- );
6351
+ children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
5882
6352
  if (Frame) {
5883
- return /* @__PURE__ */ jsx31(Frame, { document: document2, children: inner });
6353
+ return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
5884
6354
  }
5885
6355
  return inner;
5886
6356
  } })
5887
6357
  }
5888
- ) : /* @__PURE__ */ jsx31(
6358
+ ) : /* @__PURE__ */ jsx33(
5889
6359
  "div",
5890
6360
  {
5891
6361
  id: "preview-frame",
5892
6362
  className: getClassName23("frame"),
5893
6363
  ref,
5894
6364
  "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
- )
6365
+ children: inner
5903
6366
  }
5904
6367
  )
5905
6368
  }
@@ -5949,7 +6412,7 @@ var scrollIntoView = (el) => {
5949
6412
  };
5950
6413
 
5951
6414
  // components/LayerTree/index.tsx
5952
- import { useContext as useContext8 } from "react";
6415
+ import { useContext as useContext11 } from "react";
5953
6416
 
5954
6417
  // lib/is-child-of-zone.ts
5955
6418
  init_react_import();
@@ -5982,7 +6445,7 @@ var onScrollEnd = (frame, cb) => {
5982
6445
  };
5983
6446
 
5984
6447
  // components/LayerTree/index.tsx
5985
- import { Fragment as Fragment11, jsx as jsx32, jsxs as jsxs16 } from "react/jsx-runtime";
6448
+ import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
5986
6449
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
5987
6450
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
5988
6451
  var LayerTree = ({
@@ -5995,15 +6458,15 @@ var LayerTree = ({
5995
6458
  label
5996
6459
  }) => {
5997
6460
  const zones = data.zones || {};
5998
- const ctx = useContext8(dropZoneContext);
6461
+ const ctx = useContext11(dropZoneContext);
5999
6462
  return /* @__PURE__ */ jsxs16(Fragment11, { children: [
6000
6463
  label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
6001
- /* @__PURE__ */ jsx32("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx32(Layers, { size: "16" }) }),
6464
+ /* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
6002
6465
  " ",
6003
6466
  label
6004
6467
  ] }),
6005
6468
  /* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
6006
- zoneContent.length === 0 && /* @__PURE__ */ jsx32("div", { className: getClassName24("helper"), children: "No items" }),
6469
+ zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
6007
6470
  zoneContent.map((item, i) => {
6008
6471
  var _a;
6009
6472
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -6026,7 +6489,7 @@ var LayerTree = ({
6026
6489
  childIsSelected
6027
6490
  }),
6028
6491
  children: [
6029
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6492
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6030
6493
  "button",
6031
6494
  {
6032
6495
  type: "button",
@@ -6065,22 +6528,22 @@ var LayerTree = ({
6065
6528
  setHoveringComponent(null);
6066
6529
  },
6067
6530
  children: [
6068
- containsZone && /* @__PURE__ */ jsx32(
6531
+ containsZone && /* @__PURE__ */ jsx34(
6069
6532
  "div",
6070
6533
  {
6071
6534
  className: getClassNameLayer("chevron"),
6072
6535
  title: isSelected ? "Collapse" : "Expand",
6073
- children: /* @__PURE__ */ jsx32(ChevronDown, { size: "12" })
6536
+ children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
6074
6537
  }
6075
6538
  ),
6076
6539
  /* @__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 })
6540
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
6541
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
6079
6542
  ] })
6080
6543
  ]
6081
6544
  }
6082
6545
  ) }),
6083
- containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx32(
6546
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
6084
6547
  LayerTree,
6085
6548
  {
6086
6549
  config,
@@ -6102,13 +6565,13 @@ var LayerTree = ({
6102
6565
  };
6103
6566
 
6104
6567
  // 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";
6568
+ import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
6569
+ import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
6107
6570
  var Outline = () => {
6108
6571
  const { dispatch, state, overrides, config } = useAppContext();
6109
6572
  const { data, ui } = state;
6110
6573
  const { itemSelector } = ui;
6111
- const setItemSelector = useCallback12(
6574
+ const setItemSelector = useCallback15(
6112
6575
  (newItemSelector) => {
6113
6576
  dispatch({
6114
6577
  type: "setUi",
@@ -6117,9 +6580,9 @@ var Outline = () => {
6117
6580
  },
6118
6581
  []
6119
6582
  );
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(
6583
+ const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
6584
+ return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6585
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
6123
6586
  LayerTree,
6124
6587
  {
6125
6588
  config,
@@ -6132,7 +6595,7 @@ var Outline = () => {
6132
6595
  ),
6133
6596
  Object.entries(findZonesForArea(data, "root")).map(
6134
6597
  ([zoneKey, zone]) => {
6135
- return /* @__PURE__ */ jsx33(
6598
+ return /* @__PURE__ */ jsx35(
6136
6599
  LayerTree,
6137
6600
  {
6138
6601
  config,
@@ -6404,27 +6867,27 @@ var getBox = function getBox2(el) {
6404
6867
 
6405
6868
  // components/Puck/components/Canvas/index.tsx
6406
6869
  import {
6407
- useCallback as useCallback13,
6408
- useEffect as useEffect20,
6409
- useMemo as useMemo15,
6870
+ useCallback as useCallback16,
6871
+ useEffect as useEffect22,
6872
+ useMemo as useMemo17,
6410
6873
  useRef as useRef8,
6411
6874
  useState as useState24
6412
6875
  } from "react";
6413
6876
 
6414
6877
  // components/ViewportControls/index.tsx
6415
6878
  init_react_import();
6416
- import { useEffect as useEffect19, useMemo as useMemo14, useState as useState23 } from "react";
6879
+ import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
6417
6880
 
6418
6881
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6419
6882
  init_react_import();
6420
6883
  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
6884
 
6422
6885
  // components/ViewportControls/index.tsx
6423
- import { jsx as jsx34, jsxs as jsxs18 } from "react/jsx-runtime";
6886
+ import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
6424
6887
  var icons = {
6425
- Smartphone: /* @__PURE__ */ jsx34(Smartphone, { size: 16 }),
6426
- Tablet: /* @__PURE__ */ jsx34(Tablet, { size: 16 }),
6427
- Monitor: /* @__PURE__ */ jsx34(Monitor, { size: 16 })
6888
+ Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
6889
+ Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
6890
+ Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
6428
6891
  };
6429
6892
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
6430
6893
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -6437,10 +6900,10 @@ var ViewportButton = ({
6437
6900
  }) => {
6438
6901
  const { state } = useAppContext();
6439
6902
  const [isActive, setIsActive] = useState23(false);
6440
- useEffect19(() => {
6903
+ useEffect21(() => {
6441
6904
  setIsActive(width === state.ui.viewports.current.width);
6442
6905
  }, [width, state.ui.viewports.current.width]);
6443
- return /* @__PURE__ */ jsx34("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx34(
6906
+ return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
6444
6907
  IconButton,
6445
6908
  {
6446
6909
  title,
@@ -6449,7 +6912,7 @@ var ViewportButton = ({
6449
6912
  e.stopPropagation();
6450
6913
  onClick({ width, height });
6451
6914
  },
6452
- children: /* @__PURE__ */ jsx34("span", { className: getClassNameButton("inner"), children })
6915
+ children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
6453
6916
  }
6454
6917
  ) });
6455
6918
  };
@@ -6473,7 +6936,7 @@ var ViewportControls = ({
6473
6936
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6474
6937
  (option) => option.value === autoZoom
6475
6938
  );
6476
- const zoomOptions = useMemo14(
6939
+ const zoomOptions = useMemo16(
6477
6940
  () => [
6478
6941
  ...defaultZoomOptions,
6479
6942
  ...defaultsContainAutoZoom ? [] : [
@@ -6486,7 +6949,7 @@ var ViewportControls = ({
6486
6949
  [autoZoom]
6487
6950
  );
6488
6951
  return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
6489
- viewports.map((viewport, i) => /* @__PURE__ */ jsx34(
6952
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
6490
6953
  ViewportButton,
6491
6954
  {
6492
6955
  height: viewport.height,
@@ -6497,8 +6960,8 @@ var ViewportControls = ({
6497
6960
  },
6498
6961
  i
6499
6962
  )),
6500
- /* @__PURE__ */ jsx34("div", { className: getClassName25("divider") }),
6501
- /* @__PURE__ */ jsx34(
6963
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6964
+ /* @__PURE__ */ jsx36(
6502
6965
  IconButton,
6503
6966
  {
6504
6967
  title: "Zoom viewport out",
@@ -6512,10 +6975,10 @@ var ViewportControls = ({
6512
6975
  )].value
6513
6976
  );
6514
6977
  },
6515
- children: /* @__PURE__ */ jsx34(ZoomOut, { size: 16 })
6978
+ children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
6516
6979
  }
6517
6980
  ),
6518
- /* @__PURE__ */ jsx34(
6981
+ /* @__PURE__ */ jsx36(
6519
6982
  IconButton,
6520
6983
  {
6521
6984
  title: "Zoom viewport in",
@@ -6529,11 +6992,11 @@ var ViewportControls = ({
6529
6992
  )].value
6530
6993
  );
6531
6994
  },
6532
- children: /* @__PURE__ */ jsx34(ZoomIn, { size: 16 })
6995
+ children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
6533
6996
  }
6534
6997
  ),
6535
- /* @__PURE__ */ jsx34("div", { className: getClassName25("divider") }),
6536
- /* @__PURE__ */ jsx34(
6998
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6999
+ /* @__PURE__ */ jsx36(
6537
7000
  "select",
6538
7001
  {
6539
7002
  className: getClassName25("zoomSelect"),
@@ -6541,7 +7004,7 @@ var ViewportControls = ({
6541
7004
  onChange: (e) => {
6542
7005
  onZoom(parseFloat(e.currentTarget.value));
6543
7006
  },
6544
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx34(
7007
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
6545
7008
  "option",
6546
7009
  {
6547
7010
  value: option.value,
@@ -6589,7 +7052,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
6589
7052
  };
6590
7053
 
6591
7054
  // components/Puck/components/Canvas/index.tsx
6592
- import { Fragment as Fragment13, jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
7055
+ import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
6593
7056
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
6594
7057
  var ZOOM_ON_CHANGE = true;
6595
7058
  var Canvas = () => {
@@ -6598,15 +7061,15 @@ var Canvas = () => {
6598
7061
  const { ui } = state;
6599
7062
  const frameRef = useRef8(null);
6600
7063
  const [showTransition, setShowTransition] = useState24(false);
6601
- const defaultRender = useMemo15(() => {
6602
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx35(Fragment13, { children });
7064
+ const defaultRender = useMemo17(() => {
7065
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
6603
7066
  return PuckDefault;
6604
7067
  }, []);
6605
- const CustomPreview = useMemo15(
7068
+ const CustomPreview = useMemo17(
6606
7069
  () => overrides.preview || defaultRender,
6607
7070
  [overrides]
6608
7071
  );
6609
- const getFrameDimensions = useCallback13(() => {
7072
+ const getFrameDimensions = useCallback16(() => {
6610
7073
  if (frameRef.current) {
6611
7074
  const frame = frameRef.current;
6612
7075
  const box = getBox(frame);
@@ -6614,7 +7077,7 @@ var Canvas = () => {
6614
7077
  }
6615
7078
  return { width: 0, height: 0 };
6616
7079
  }, [frameRef]);
6617
- const resetAutoZoom = useCallback13(
7080
+ const resetAutoZoom = useCallback16(
6618
7081
  (ui2 = state.ui) => {
6619
7082
  if (frameRef.current) {
6620
7083
  setZoomConfig(
@@ -6624,11 +7087,11 @@ var Canvas = () => {
6624
7087
  },
6625
7088
  [frameRef, zoomConfig, state.ui]
6626
7089
  );
6627
- useEffect20(() => {
7090
+ useEffect22(() => {
6628
7091
  setShowTransition(false);
6629
7092
  resetAutoZoom();
6630
7093
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6631
- useEffect20(() => {
7094
+ useEffect22(() => {
6632
7095
  const { height: frameHeight } = getFrameDimensions();
6633
7096
  if (ui.viewports.current.height === "auto") {
6634
7097
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6636,13 +7099,13 @@ var Canvas = () => {
6636
7099
  }));
6637
7100
  }
6638
7101
  }, [zoomConfig.zoom]);
6639
- useEffect20(() => {
7102
+ useEffect22(() => {
6640
7103
  if (ZOOM_ON_CHANGE) {
6641
7104
  setShowTransition(true);
6642
7105
  resetAutoZoom(ui);
6643
7106
  }
6644
7107
  }, [ui.viewports.current.width]);
6645
- useEffect20(() => {
7108
+ useEffect22(() => {
6646
7109
  const cb = () => {
6647
7110
  setShowTransition(false);
6648
7111
  resetAutoZoom();
@@ -6653,7 +7116,7 @@ var Canvas = () => {
6653
7116
  };
6654
7117
  }, []);
6655
7118
  const [showLoader, setShowLoader] = useState24(false);
6656
- useEffect20(() => {
7119
+ useEffect22(() => {
6657
7120
  setTimeout(() => {
6658
7121
  setShowLoader(true);
6659
7122
  }, 500);
@@ -6671,7 +7134,7 @@ var Canvas = () => {
6671
7134
  recordHistory: true
6672
7135
  }),
6673
7136
  children: [
6674
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx35("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx35(
7137
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
6675
7138
  ViewportControls,
6676
7139
  {
6677
7140
  autoZoom: zoomConfig.autoZoom,
@@ -6698,7 +7161,7 @@ var Canvas = () => {
6698
7161
  }
6699
7162
  ) }),
6700
7163
  /* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
6701
- /* @__PURE__ */ jsx35(
7164
+ /* @__PURE__ */ jsx37(
6702
7165
  "div",
6703
7166
  {
6704
7167
  className: getClassName26("root"),
@@ -6719,10 +7182,10 @@ var Canvas = () => {
6719
7182
  })
6720
7183
  );
6721
7184
  },
6722
- children: /* @__PURE__ */ jsx35(CustomPreview, { children: /* @__PURE__ */ jsx35(Preview, {}) })
7185
+ children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
6723
7186
  }
6724
7187
  ),
6725
- /* @__PURE__ */ jsx35("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx35(Loader, { size: 24 }) })
7188
+ /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
6726
7189
  ] })
6727
7190
  ]
6728
7191
  }
@@ -6731,7 +7194,7 @@ var Canvas = () => {
6731
7194
 
6732
7195
  // lib/use-loaded-overrides.ts
6733
7196
  init_react_import();
6734
- import { useMemo as useMemo16 } from "react";
7197
+ import { useMemo as useMemo18 } from "react";
6735
7198
 
6736
7199
  // lib/load-overrides.ts
6737
7200
  init_react_import();
@@ -6770,26 +7233,26 @@ var useLoadedOverrides = ({
6770
7233
  overrides,
6771
7234
  plugins
6772
7235
  }) => {
6773
- return useMemo16(() => {
7236
+ return useMemo18(() => {
6774
7237
  return loadOverrides({ overrides, plugins });
6775
7238
  }, [plugins, overrides]);
6776
7239
  };
6777
7240
 
6778
7241
  // components/DefaultOverride/index.tsx
6779
7242
  init_react_import();
6780
- import { Fragment as Fragment14, jsx as jsx36 } from "react/jsx-runtime";
6781
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx36(Fragment14, { children });
7243
+ import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
7244
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
6782
7245
 
6783
7246
  // lib/use-inject-css.ts
6784
7247
  init_react_import();
6785
- import { useEffect as useEffect21, useState as useState25 } from "react";
7248
+ import { useEffect as useEffect23, useState as useState25 } from "react";
6786
7249
  var styles = ``;
6787
7250
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
6788
7251
  const [el, setEl] = useState25();
6789
- useEffect21(() => {
7252
+ useEffect23(() => {
6790
7253
  setEl(document.createElement("style"));
6791
7254
  }, []);
6792
- useEffect21(() => {
7255
+ useEffect23(() => {
6793
7256
  var _a;
6794
7257
  if (!el || typeof window === "undefined") {
6795
7258
  return;
@@ -6807,8 +7270,35 @@ var useInjectGlobalCss = (iframeEnabled) => {
6807
7270
  return useInjectStyleSheet(styles, iframeEnabled);
6808
7271
  };
6809
7272
 
7273
+ // lib/use-preview-mode-hotkeys.ts
7274
+ init_react_import();
7275
+ import { useCallback as useCallback17 } from "react";
7276
+ import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
7277
+ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7278
+ const toggleInteractive = useCallback17(() => {
7279
+ dispatch({
7280
+ type: "setUi",
7281
+ ui: (ui) => ({
7282
+ previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
7283
+ })
7284
+ });
7285
+ }, [dispatch]);
7286
+ const toggleInteractiveIframe = () => {
7287
+ if (iframeEnabled) {
7288
+ toggleInteractive();
7289
+ }
7290
+ };
7291
+ const frame = getFrame();
7292
+ const resolvedFrame = typeof window !== "undefined" && frame !== document ? frame : void 0;
7293
+ useHotkeys2("meta+i", toggleInteractive, { preventDefault: true });
7294
+ useHotkeys2("meta+i", toggleInteractiveIframe, {
7295
+ preventDefault: true,
7296
+ document: resolvedFrame
7297
+ });
7298
+ };
7299
+
6810
7300
  // components/Puck/index.tsx
6811
- import { Fragment as Fragment15, jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
7301
+ import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
6812
7302
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
6813
7303
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
6814
7304
  function Puck({
@@ -6930,11 +7420,11 @@ function Puck({
6930
7420
  const [menuOpen, setMenuOpen] = useState26(false);
6931
7421
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
6932
7422
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
6933
- useEffect22(() => {
7423
+ useEffect24(() => {
6934
7424
  if (onChange) onChange(data);
6935
7425
  }, [data]);
6936
7426
  const rootProps = data.root.props || data.root;
6937
- const toggleSidebars = useCallback14(
7427
+ const toggleSidebars = useCallback18(
6938
7428
  (sidebar) => {
6939
7429
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
6940
7430
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -6948,7 +7438,7 @@ function Puck({
6948
7438
  },
6949
7439
  [dispatch, leftSideBarVisible, rightSideBarVisible]
6950
7440
  );
6951
- useEffect22(() => {
7441
+ useEffect24(() => {
6952
7442
  if (!window.matchMedia("(min-width: 638px)").matches) {
6953
7443
  dispatch({
6954
7444
  type: "setUi",
@@ -6971,7 +7461,7 @@ function Puck({
6971
7461
  window.removeEventListener("resize", handleResize);
6972
7462
  };
6973
7463
  }, []);
6974
- const defaultHeaderRender = useMemo17(() => {
7464
+ const defaultHeaderRender = useMemo19(() => {
6975
7465
  if (renderHeader) {
6976
7466
  console.warn(
6977
7467
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -6979,20 +7469,20 @@ function Puck({
6979
7469
  const RenderHeader = (_a2) => {
6980
7470
  var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
6981
7471
  const Comp = renderHeader;
6982
- return /* @__PURE__ */ jsx37(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7472
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
6983
7473
  };
6984
7474
  return RenderHeader;
6985
7475
  }
6986
7476
  return DefaultOverride;
6987
7477
  }, [renderHeader]);
6988
- const defaultHeaderActionsRender = useMemo17(() => {
7478
+ const defaultHeaderActionsRender = useMemo19(() => {
6989
7479
  if (renderHeaderActions) {
6990
7480
  console.warn(
6991
7481
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
6992
7482
  );
6993
7483
  const RenderHeader = (props) => {
6994
7484
  const Comp = renderHeaderActions;
6995
- return /* @__PURE__ */ jsx37(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7485
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
6996
7486
  };
6997
7487
  return RenderHeader;
6998
7488
  }
@@ -7002,26 +7492,27 @@ function Puck({
7002
7492
  overrides,
7003
7493
  plugins
7004
7494
  });
7005
- const CustomPuck = useMemo17(
7495
+ const CustomPuck = useMemo19(
7006
7496
  () => loadedOverrides.puck || DefaultOverride,
7007
7497
  [loadedOverrides]
7008
7498
  );
7009
- const CustomHeader = useMemo17(
7499
+ const CustomHeader = useMemo19(
7010
7500
  () => loadedOverrides.header || defaultHeaderRender,
7011
7501
  [loadedOverrides]
7012
7502
  );
7013
- const CustomHeaderActions = useMemo17(
7503
+ const CustomHeaderActions = useMemo19(
7014
7504
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7015
7505
  [loadedOverrides]
7016
7506
  );
7017
7507
  const [mounted, setMounted] = useState26(false);
7018
- useEffect22(() => {
7508
+ useEffect24(() => {
7019
7509
  setMounted(true);
7020
7510
  }, []);
7021
7511
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
7022
7512
  const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
7513
+ usePreviewModeHotkeys(dispatch, iframe.enabled);
7023
7514
  return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
7024
- /* @__PURE__ */ jsx37(
7515
+ /* @__PURE__ */ jsx39(
7025
7516
  AppProvider,
7026
7517
  {
7027
7518
  value: {
@@ -7043,7 +7534,7 @@ function Puck({
7043
7534
  getPermissions: () => ({}),
7044
7535
  refreshPermissions: () => null
7045
7536
  },
7046
- children: /* @__PURE__ */ jsx37(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx37(CustomPuck, { children: children || /* @__PURE__ */ jsx37(
7537
+ children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
7047
7538
  "div",
7048
7539
  {
7049
7540
  className: getLayoutClassName({
@@ -7053,59 +7544,59 @@ function Puck({
7053
7544
  rightSideBarVisible
7054
7545
  }),
7055
7546
  children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
7056
- /* @__PURE__ */ jsx37(
7547
+ /* @__PURE__ */ jsx39(
7057
7548
  CustomHeader,
7058
7549
  {
7059
- actions: /* @__PURE__ */ jsx37(Fragment15, { children: /* @__PURE__ */ jsx37(CustomHeaderActions, { children: /* @__PURE__ */ jsx37(
7550
+ actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7060
7551
  Button,
7061
7552
  {
7062
7553
  onClick: () => {
7063
7554
  onPublish && onPublish(data);
7064
7555
  },
7065
- icon: /* @__PURE__ */ jsx37(Globe, { size: "14px" }),
7556
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7066
7557
  children: "Publish"
7067
7558
  }
7068
7559
  ) }) }),
7069
- children: /* @__PURE__ */ jsx37("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7560
+ children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7070
7561
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
7071
- /* @__PURE__ */ jsx37(
7562
+ /* @__PURE__ */ jsx39(
7072
7563
  "div",
7073
7564
  {
7074
7565
  className: getLayoutClassName("leftSideBarToggle"),
7075
- children: /* @__PURE__ */ jsx37(
7566
+ children: /* @__PURE__ */ jsx39(
7076
7567
  IconButton,
7077
7568
  {
7078
7569
  onClick: () => {
7079
7570
  toggleSidebars("left");
7080
7571
  },
7081
7572
  title: "Toggle left sidebar",
7082
- children: /* @__PURE__ */ jsx37(PanelLeft, { focusable: "false" })
7573
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7083
7574
  }
7084
7575
  )
7085
7576
  }
7086
7577
  ),
7087
- /* @__PURE__ */ jsx37(
7578
+ /* @__PURE__ */ jsx39(
7088
7579
  "div",
7089
7580
  {
7090
7581
  className: getLayoutClassName("rightSideBarToggle"),
7091
- children: /* @__PURE__ */ jsx37(
7582
+ children: /* @__PURE__ */ jsx39(
7092
7583
  IconButton,
7093
7584
  {
7094
7585
  onClick: () => {
7095
7586
  toggleSidebars("right");
7096
7587
  },
7097
7588
  title: "Toggle right sidebar",
7098
- children: /* @__PURE__ */ jsx37(PanelRight, { focusable: "false" })
7589
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7099
7590
  }
7100
7591
  )
7101
7592
  }
7102
7593
  )
7103
7594
  ] }),
7104
- /* @__PURE__ */ jsx37("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7595
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7105
7596
  headerTitle || rootProps.title || "Page",
7106
7597
  headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
7107
7598
  " ",
7108
- /* @__PURE__ */ jsx37(
7599
+ /* @__PURE__ */ jsx39(
7109
7600
  "code",
7110
7601
  {
7111
7602
  className: getLayoutClassName("headerPath"),
@@ -7115,30 +7606,30 @@ function Puck({
7115
7606
  ] })
7116
7607
  ] }) }),
7117
7608
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
7118
- /* @__PURE__ */ jsx37("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx37(
7609
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
7119
7610
  IconButton,
7120
7611
  {
7121
7612
  onClick: () => {
7122
7613
  return setMenuOpen(!menuOpen);
7123
7614
  },
7124
7615
  title: "Toggle menu bar",
7125
- children: menuOpen ? /* @__PURE__ */ jsx37(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx37(ChevronDown, { focusable: "false" })
7616
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7126
7617
  }
7127
7618
  ) }),
7128
- /* @__PURE__ */ jsx37(
7619
+ /* @__PURE__ */ jsx39(
7129
7620
  MenuBar,
7130
7621
  {
7131
7622
  appState,
7132
7623
  dispatch,
7133
7624
  onPublish,
7134
7625
  menuOpen,
7135
- renderHeaderActions: () => /* @__PURE__ */ jsx37(CustomHeaderActions, { children: /* @__PURE__ */ jsx37(
7626
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7136
7627
  Button,
7137
7628
  {
7138
7629
  onClick: () => {
7139
7630
  onPublish && onPublish(data);
7140
7631
  },
7141
- icon: /* @__PURE__ */ jsx37(Globe, { size: "14px" }),
7632
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7142
7633
  children: "Publish"
7143
7634
  }
7144
7635
  ) }),
@@ -7150,18 +7641,18 @@ function Puck({
7150
7641
  }
7151
7642
  ),
7152
7643
  /* @__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, {}) })
7644
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
7645
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
7155
7646
  ] }),
7156
- /* @__PURE__ */ jsx37(Canvas, {}),
7157
- /* @__PURE__ */ jsx37("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx37(
7647
+ /* @__PURE__ */ jsx39(Canvas, {}),
7648
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
7158
7649
  SidebarSection,
7159
7650
  {
7160
7651
  noPadding: true,
7161
7652
  noBorderTop: true,
7162
7653
  showBreadcrumbs: true,
7163
7654
  title: selectedItem ? selectedComponentLabel : "Page",
7164
- children: /* @__PURE__ */ jsx37(Fields, {})
7655
+ children: /* @__PURE__ */ jsx39(Fields, {})
7165
7656
  }
7166
7657
  ) })
7167
7658
  ] })
@@ -7169,69 +7660,13 @@ function Puck({
7169
7660
  ) }) })
7170
7661
  }
7171
7662
  ),
7172
- /* @__PURE__ */ jsx37("div", { id: "puck-portal-root", className: getClassName27("portal") })
7663
+ /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
7173
7664
  ] });
7174
7665
  }
7175
7666
  Puck.Components = Components;
7176
7667
  Puck.Fields = Fields;
7177
7668
  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
- }
7669
+ Puck.Preview = Preview2;
7235
7670
 
7236
7671
  // lib/migrate.ts
7237
7672
  init_react_import();