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

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,131 @@ 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 [contentWithPreview, setContentWithPreview] = useState15(content);
3435
+ const updateContent = useRenderedCallback(
3436
+ (content2, preview2) => {
3437
+ if (preview2) {
3438
+ if (preview2.type === "insert") {
3439
+ setContentWithPreview(
3440
+ insert(
3441
+ content2.filter((item) => item.props.id !== preview2.props.id),
3442
+ preview2.index,
3443
+ {
3444
+ type: "preview",
3445
+ props: { id: preview2.props.id }
3446
+ }
3447
+ )
3448
+ );
3449
+ } else {
3450
+ setContentWithPreview(
3451
+ insert(
3452
+ content2.filter((item) => item.props.id !== preview2.props.id),
3453
+ preview2.index,
3454
+ {
3455
+ type: preview2.componentType,
3456
+ props: preview2.props
3457
+ }
3458
+ )
3459
+ );
3460
+ }
3461
+ } else {
3462
+ setContentWithPreview(
3463
+ previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3464
+ );
3465
+ }
3466
+ },
3467
+ [draggedItemId, previewExists]
3468
+ );
3469
+ useEffect12(() => {
3470
+ updateContent(content, preview);
3471
+ }, [content, preview]);
3472
+ return contentWithPreview;
3473
+ };
3474
+
3475
+ // components/DropZone/lib/use-drag-axis.ts
3476
+ init_react_import();
3477
+ import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
3287
3478
  var GRID_DRAG_AXIS = "dynamic";
3288
3479
  var FLEX_ROW_DRAG_AXIS = "x";
3289
3480
  var DEFAULT_DRAG_AXIS = "y";
3481
+ var useDragAxis = (ref, collisionAxis) => {
3482
+ const { status } = useAppContext();
3483
+ const [dragAxis, setDragAxis] = useState16(
3484
+ collisionAxis || DEFAULT_DRAG_AXIS
3485
+ );
3486
+ const calculateDragAxis = useCallback9(() => {
3487
+ if (ref.current) {
3488
+ const computedStyle = window.getComputedStyle(ref.current);
3489
+ if (computedStyle.display === "grid") {
3490
+ setDragAxis(GRID_DRAG_AXIS);
3491
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3492
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3493
+ } else {
3494
+ setDragAxis(DEFAULT_DRAG_AXIS);
3495
+ }
3496
+ }
3497
+ }, [ref.current]);
3498
+ useEffect13(() => {
3499
+ const onViewportChange = () => {
3500
+ calculateDragAxis();
3501
+ };
3502
+ window.addEventListener("viewportchange", onViewportChange);
3503
+ return () => {
3504
+ window.removeEventListener("viewportchange", onViewportChange);
3505
+ };
3506
+ }, []);
3507
+ useEffect13(calculateDragAxis, [status, collisionAxis]);
3508
+ return [dragAxis, calculateDragAxis];
3509
+ };
3510
+
3511
+ // components/DropZone/index.tsx
3512
+ import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
3513
+ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3514
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3515
+ var RENDER_DEBUG = false;
3516
+ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
3290
3517
  var DropZoneEdit = forwardRef3(
3291
- function DropZoneEdit2({
3518
+ function DropZoneEditInternal({
3292
3519
  zone,
3293
3520
  allow,
3294
3521
  disallow,
@@ -3298,31 +3525,50 @@ var DropZoneEdit = forwardRef3(
3298
3525
  collisionAxis
3299
3526
  }, userRef) {
3300
3527
  const appContext2 = useAppContext();
3301
- const ctx = useContext3(dropZoneContext);
3528
+ const ctx = useContext6(dropZoneContext);
3302
3529
  const {
3303
3530
  // These all need setting via context
3304
3531
  data,
3305
3532
  config,
3306
3533
  areaId,
3307
- draggedItem,
3308
3534
  registerZoneArea,
3309
3535
  depth,
3310
3536
  registerLocalZone,
3311
3537
  unregisterLocalZone,
3312
- deepestZone = rootDroppableId,
3313
- deepestArea,
3314
- nextDeepestArea,
3315
3538
  path = [],
3316
3539
  activeZones
3317
3540
  } = ctx;
3318
- const { itemSelector } = appContext2.state.ui;
3319
3541
  let zoneCompound = rootDroppableId;
3320
- useEffect13(() => {
3542
+ if (areaId) {
3543
+ if (zone !== rootDroppableId) {
3544
+ zoneCompound = `${areaId}:${zone}`;
3545
+ }
3546
+ }
3547
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3548
+ const {
3549
+ isDeepestZone,
3550
+ inNextDeepestArea,
3551
+ draggedComponentType,
3552
+ userIsDragging,
3553
+ preview
3554
+ } = useContextStore(ZoneStoreContext, (s) => {
3555
+ var _a, _b, _c;
3556
+ return {
3557
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3558
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3559
+ draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3560
+ draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3561
+ userIsDragging: !!s.draggedItem,
3562
+ preview: s.previewIndex[zoneCompound]
3563
+ };
3564
+ });
3565
+ const { itemSelector } = appContext2.state.ui;
3566
+ useEffect14(() => {
3321
3567
  if (areaId && registerZoneArea) {
3322
3568
  registerZoneArea(areaId);
3323
3569
  }
3324
3570
  }, [areaId]);
3325
- useEffect13(() => {
3571
+ useEffect14(() => {
3326
3572
  if (ctx == null ? void 0 : ctx.registerZone) {
3327
3573
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3328
3574
  }
@@ -3332,25 +3578,18 @@ var DropZoneEdit = forwardRef3(
3332
3578
  }
3333
3579
  };
3334
3580
  }, []);
3335
- if (areaId) {
3336
- if (zone !== rootDroppableId) {
3337
- zoneCompound = `${areaId}:${zone}`;
3338
- }
3339
- }
3340
- const content = useMemo7(() => {
3581
+ const content = useMemo8(() => {
3341
3582
  if (areaId && zone !== rootDroppableId) {
3342
3583
  return setupZone(data, zoneCompound).zones[zoneCompound];
3343
3584
  }
3344
3585
  return data.content || [];
3345
3586
  }, [data, zoneCompound]);
3346
- const ref = useRef4(null);
3347
- const acceptsTarget = useCallback8(
3348
- (target) => {
3349
- if (!target) {
3587
+ const ref = useRef2(null);
3588
+ const acceptsTarget = useCallback10(
3589
+ (componentType) => {
3590
+ if (!componentType) {
3350
3591
  return true;
3351
3592
  }
3352
- const data2 = target.data;
3353
- const { componentType } = data2;
3354
3593
  if (disallow) {
3355
3594
  const defaultedAllow = allow || [];
3356
3595
  const filteredDisallow = (disallow || []).filter(
@@ -3368,49 +3607,26 @@ var DropZoneEdit = forwardRef3(
3368
3607
  },
3369
3608
  [allow, disallow]
3370
3609
  );
3371
- useEffect13(() => {
3610
+ useEffect14(() => {
3372
3611
  if (registerLocalZone) {
3373
- registerLocalZone(zoneCompound, acceptsTarget(draggedItem));
3612
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3374
3613
  }
3375
3614
  return () => {
3376
3615
  if (unregisterLocalZone) {
3377
3616
  unregisterLocalZone(zoneCompound);
3378
3617
  }
3379
3618
  };
3380
- }, [draggedItem, zoneCompound]);
3381
- const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3382
- const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
3383
- const userIsDragging = !!draggedItem;
3619
+ }, [draggedComponentType, zoneCompound]);
3620
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3384
3621
  let isEnabled = true;
3385
- if (draggedItem) {
3386
- isEnabled = deepestZone === zoneCompound;
3622
+ if (userIsDragging) {
3623
+ isEnabled = isDeepestZone;
3387
3624
  }
3388
3625
  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);
3626
+ isEnabled = acceptsTarget(draggedComponentType);
3627
+ }
3628
+ const contentWithPreview = useContentWithPreview(content, zoneCompound);
3629
+ const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3414
3630
  const droppableConfig = {
3415
3631
  id: zoneCompound,
3416
3632
  collisionPriority: isEnabled ? depth : 0,
@@ -3420,45 +3636,20 @@ var DropZoneEdit = forwardRef3(
3420
3636
  data: {
3421
3637
  areaId,
3422
3638
  depth,
3423
- isDroppableTarget: acceptsTarget(draggedItem),
3639
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3424
3640
  path
3425
3641
  }
3426
3642
  };
3427
3643
  const { ref: dropRef } = useDroppableSafe(droppableConfig);
3428
3644
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3429
3645
  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
- }, []);
3646
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3455
3647
  const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3456
- draggedItem,
3457
3648
  zoneCompound,
3458
3649
  userMinEmptyHeight,
3459
3650
  ref
3460
3651
  });
3461
- return /* @__PURE__ */ jsxs10(
3652
+ return /* @__PURE__ */ jsx22(
3462
3653
  "div",
3463
3654
  {
3464
3655
  className: `${getClassName17({
@@ -3478,87 +3669,93 @@ var DropZoneEdit = forwardRef3(
3478
3669
  "data-puck-dropzone": zoneCompound,
3479
3670
  "data-puck-dnd": zoneCompound,
3480
3671
  style: __spreadProps(__spreadValues({}, style), {
3481
- "--min-empty-height": `${minEmptyHeight}px`
3672
+ "--min-empty-height": `${minEmptyHeight}px`,
3673
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3482
3674
  }),
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
3675
+ children: contentWithPreview.map((item, i) => {
3676
+ var _a, _b, _c, _d, _e, _f, _g;
3677
+ const componentId = item.props.id;
3678
+ const puckProps = {
3679
+ renderDropZone: DropZoneEditPure,
3680
+ isEditing: true,
3681
+ dragRef: null
3682
+ };
3683
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3684
+ puck: puckProps,
3685
+ editMode: true
3686
+ // DEPRECATED
3687
+ });
3688
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3689
+ let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
3690
+ "No configuration for ",
3691
+ item.type
3692
+ ] });
3693
+ const componentConfig = config.components[item.type];
3694
+ let componentType = item.type;
3695
+ let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3696
+ if (item.type === "preview") {
3697
+ let Preview4 = function() {
3698
+ return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3495
3699
  };
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
- })
3700
+ var Preview3 = Preview4;
3701
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3702
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3703
+ Render2 = Preview4;
3704
+ }
3705
+ return /* @__PURE__ */ jsx22(
3706
+ DropZoneProvider,
3707
+ {
3708
+ value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3709
+ children: /* @__PURE__ */ jsx22(
3710
+ DraggableComponent,
3711
+ {
3712
+ id: componentId,
3713
+ componentType,
3714
+ zoneCompound,
3715
+ depth: depth + 1,
3716
+ index: i,
3717
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3718
+ isSelected,
3719
+ label,
3720
+ isEnabled,
3721
+ autoDragAxis: dragAxis,
3722
+ userDragAxis: collisionAxis,
3723
+ inDroppableZone: acceptsTarget(draggedComponentType),
3724
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx22(
3725
+ Render2,
3726
+ __spreadProps(__spreadValues({}, defaultedProps), {
3727
+ puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3728
+ dragRef
3543
3729
  })
3544
- ) : /* @__PURE__ */ jsx21("div", { ref: dragRef, children: /* @__PURE__ */ jsx21(Render2, __spreadValues({}, defaultedProps)) })
3545
- }
3546
- )
3547
- },
3548
- componentId
3549
- );
3550
- })
3551
- ]
3730
+ })
3731
+ ) : /* @__PURE__ */ jsx22("div", { ref: dragRef, children: /* @__PURE__ */ jsx22(Render2, __spreadValues({}, defaultedProps)) })
3732
+ }
3733
+ )
3734
+ },
3735
+ componentId
3736
+ );
3737
+ })
3552
3738
  }
3553
3739
  );
3554
3740
  }
3555
3741
  );
3742
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
3556
3743
  var DropZoneRender = forwardRef3(
3557
- function DropZoneRender2({ className, style, zone }, ref) {
3558
- const ctx = useContext3(dropZoneContext);
3744
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3745
+ const ctx = useContext6(dropZoneContext);
3559
3746
  const { data, areaId = "root", config } = ctx || {};
3560
3747
  let zoneCompound = rootDroppableId;
3561
3748
  let content = (data == null ? void 0 : data.content) || [];
3749
+ useEffect14(() => {
3750
+ if (ctx == null ? void 0 : ctx.registerZone) {
3751
+ ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3752
+ }
3753
+ return () => {
3754
+ if (ctx == null ? void 0 : ctx.unregisterZone) {
3755
+ ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
3756
+ }
3757
+ };
3758
+ }, []);
3562
3759
  if (!data || !config) {
3563
3760
  return null;
3564
3761
  }
@@ -3566,10 +3763,10 @@ var DropZoneRender = forwardRef3(
3566
3763
  zoneCompound = `${areaId}:${zone}`;
3567
3764
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3568
3765
  }
3569
- return /* @__PURE__ */ jsx21("div", { className, style, ref, children: content.map((item) => {
3766
+ return /* @__PURE__ */ jsx22("div", { className, style, ref, children: content.map((item) => {
3570
3767
  const Component = config.components[item.type];
3571
3768
  if (Component) {
3572
- return /* @__PURE__ */ jsx21(
3769
+ return /* @__PURE__ */ jsx22(
3573
3770
  DropZoneProvider,
3574
3771
  {
3575
3772
  value: {
@@ -3579,10 +3776,12 @@ var DropZoneRender = forwardRef3(
3579
3776
  depth: 1,
3580
3777
  path: []
3581
3778
  },
3582
- children: /* @__PURE__ */ jsx21(
3779
+ children: /* @__PURE__ */ jsx22(
3583
3780
  Component.render,
3584
3781
  __spreadProps(__spreadValues({}, item.props), {
3585
- puck: { renderDropZone: DropZoneRender2 }
3782
+ puck: {
3783
+ renderDropZone: DropZoneRenderPure
3784
+ }
3586
3785
  })
3587
3786
  )
3588
3787
  },
@@ -3595,11 +3794,11 @@ var DropZoneRender = forwardRef3(
3595
3794
  );
3596
3795
  var DropZone = forwardRef3(
3597
3796
  function DropZone2(props, ref) {
3598
- const ctx = useContext3(dropZoneContext);
3797
+ const ctx = useContext6(dropZoneContext);
3599
3798
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3600
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3799
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3601
3800
  }
3602
- return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3801
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3603
3802
  }
3604
3803
  );
3605
3804
 
@@ -3615,7 +3814,7 @@ var getZoneId = (zoneCompound) => {
3615
3814
  return [rootDroppableId, zoneCompound];
3616
3815
  };
3617
3816
 
3618
- // components/DragDropContext/NestedDroppablePlugin.ts
3817
+ // lib/dnd/NestedDroppablePlugin.ts
3619
3818
  init_react_import();
3620
3819
  import { Plugin } from "@dnd-kit/abstract";
3621
3820
  import { effects } from "@dnd-kit/state";
@@ -3657,7 +3856,49 @@ var getFrame = () => {
3657
3856
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3658
3857
  };
3659
3858
 
3660
- // components/DragDropContext/NestedDroppablePlugin.ts
3859
+ // lib/global-position.ts
3860
+ init_react_import();
3861
+ var GlobalPosition = class {
3862
+ constructor(target, original) {
3863
+ this.scaleFactor = 1;
3864
+ this.frameEl = null;
3865
+ this.frameRect = null;
3866
+ var _a;
3867
+ this.target = target;
3868
+ this.original = original;
3869
+ this.frameEl = document.querySelector("iframe");
3870
+ if (this.frameEl) {
3871
+ this.frameRect = this.frameEl.getBoundingClientRect();
3872
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3873
+ }
3874
+ }
3875
+ get x() {
3876
+ return this.original.x;
3877
+ }
3878
+ get y() {
3879
+ return this.original.y;
3880
+ }
3881
+ get global() {
3882
+ if (document !== this.target.ownerDocument && this.frameRect) {
3883
+ return {
3884
+ x: this.x * this.scaleFactor + this.frameRect.left,
3885
+ y: this.y * this.scaleFactor + this.frameRect.top
3886
+ };
3887
+ }
3888
+ return this.original;
3889
+ }
3890
+ get frame() {
3891
+ if (document === this.target.ownerDocument && this.frameRect) {
3892
+ return {
3893
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
3894
+ y: (this.y - this.frameRect.top) / this.scaleFactor
3895
+ };
3896
+ }
3897
+ return this.original;
3898
+ }
3899
+ };
3900
+
3901
+ // lib/dnd/NestedDroppablePlugin.ts
3661
3902
  var depthSort = (candidates) => {
3662
3903
  return candidates.sort((a, b) => {
3663
3904
  const aData = a.data;
@@ -3686,10 +3927,12 @@ var getZoneId2 = (candidate) => {
3686
3927
  }
3687
3928
  return id;
3688
3929
  };
3689
- var getPointerCollisions = (position, manager, ownerDocument) => {
3690
- var _a;
3930
+ var getPointerCollisions = (position, manager) => {
3691
3931
  const candidates = [];
3692
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
3932
+ let elements = position.target.ownerDocument.elementsFromPoint(
3933
+ position.x,
3934
+ position.y
3935
+ );
3693
3936
  const previewFrame = elements.find(
3694
3937
  (el) => el.getAttribute("data-puck-preview")
3695
3938
  );
@@ -3698,17 +3941,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3698
3941
  elements = [drawer];
3699
3942
  }
3700
3943
  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
- }
3944
+ const frame = getFrame();
3945
+ if (frame) {
3946
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3712
3947
  }
3713
3948
  }
3714
3949
  if (elements) {
@@ -3725,9 +3960,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3725
3960
  }
3726
3961
  return candidates;
3727
3962
  };
3728
- var findDeepestCandidate = (position, manager, ownerDocument) => {
3963
+ var findDeepestCandidate = (position, manager) => {
3729
3964
  var _a;
3730
- const candidates = getPointerCollisions(position, manager, ownerDocument);
3965
+ const candidates = getPointerCollisions(position, manager);
3731
3966
  if (candidates.length > 0) {
3732
3967
  const sortedCandidates = depthSort(candidates);
3733
3968
  const draggable = manager.dragOperation.source;
@@ -3772,9 +4007,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
3772
4007
  area: null
3773
4008
  };
3774
4009
  };
3775
- var createNestedDroppablePlugin = ({
3776
- onChange
3777
- }) => class NestedDroppablePlugin extends Plugin {
4010
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
3778
4011
  constructor(manager, options) {
3779
4012
  super(manager);
3780
4013
  if (typeof window === "undefined") {
@@ -3782,16 +4015,19 @@ var createNestedDroppablePlugin = ({
3782
4015
  }
3783
4016
  const cleanupEffect = effects(() => {
3784
4017
  const handleMove = (event) => {
3785
- const position = {
4018
+ const target = event.originalTarget || event.target;
4019
+ const position = new GlobalPosition(target, {
3786
4020
  x: event.clientX,
3787
4021
  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
4022
+ });
4023
+ const elements = document.elementsFromPoint(
4024
+ position.global.x,
4025
+ position.global.y
3794
4026
  );
4027
+ const overEl = elements.some((el) => el.id === id);
4028
+ if (overEl) {
4029
+ onChange(findDeepestCandidate(position, manager), manager);
4030
+ }
3795
4031
  };
3796
4032
  const handleMoveThrottled = throttle(handleMove, 50);
3797
4033
  const handlePointerMove = (event) => {
@@ -4121,6 +4357,11 @@ var reduceUi = (ui, action) => {
4121
4357
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4122
4358
  });
4123
4359
  }
4360
+ if (action.type === "remove") {
4361
+ return __spreadProps(__spreadValues({}, ui), {
4362
+ itemSelector: null
4363
+ });
4364
+ }
4124
4365
  return ui;
4125
4366
  };
4126
4367
 
@@ -4208,7 +4449,7 @@ var insertComponent = (componentType, zone, index, {
4208
4449
  import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4209
4450
  import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
4210
4451
 
4211
- // components/DragDropContext/PointerSensor.ts
4452
+ // lib/dnd/PointerSensor.ts
4212
4453
  init_react_import();
4213
4454
  import { batch, effect } from "@dnd-kit/state";
4214
4455
  import { Sensor, configurator } from "@dnd-kit/abstract";
@@ -4380,6 +4621,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
4380
4621
  }
4381
4622
  }
4382
4623
  handlePointerUp(event) {
4624
+ if (!this.source) {
4625
+ return;
4626
+ }
4383
4627
  event.preventDefault();
4384
4628
  event.stopPropagation();
4385
4629
  const { status } = this.manager.dragOperation;
@@ -4479,13 +4723,15 @@ function patchWindow(window2) {
4479
4723
  }
4480
4724
 
4481
4725
  // components/DragDropContext/index.tsx
4482
- import { jsx as jsx22 } from "react/jsx-runtime";
4483
- var dragListenerContext = createContext3({
4726
+ import { createStore as createStore3 } from "zustand";
4727
+ import { jsx as jsx23 } from "react/jsx-runtime";
4728
+ var DEBUG3 = false;
4729
+ var dragListenerContext = createContext4({
4484
4730
  dragListeners: {}
4485
4731
  });
4486
4732
  function useDragListener(type, fn, deps = []) {
4487
- const { setDragListeners } = useContext4(dragListenerContext);
4488
- useEffect14(() => {
4733
+ const { setDragListeners } = useContext7(dragListenerContext);
4734
+ useEffect15(() => {
4489
4735
  if (setDragListeners) {
4490
4736
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
4491
4737
  [type]: [...old[type] || [], fn]
@@ -4493,78 +4739,145 @@ function useDragListener(type, fn, deps = []) {
4493
4739
  }
4494
4740
  }, deps);
4495
4741
  }
4496
- var previewContext = createContext3(null);
4497
4742
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4743
+ var useTempDisableFallback = (timeout3) => {
4744
+ const lastFallbackDisable = useRef3(null);
4745
+ return useCallback11((manager) => {
4746
+ collisionStore.setState({ fallbackEnabled: false });
4747
+ const fallbackId = generateId();
4748
+ lastFallbackDisable.current = fallbackId;
4749
+ setTimeout(() => {
4750
+ if (lastFallbackDisable.current === fallbackId) {
4751
+ collisionStore.setState({ fallbackEnabled: true });
4752
+ manager.collisionObserver.forceUpdate(true);
4753
+ }
4754
+ }, timeout3);
4755
+ }, []);
4756
+ };
4498
4757
  var DragDropContextClient = ({
4499
4758
  children,
4500
4759
  disableAutoScroll
4501
4760
  }) => {
4502
4761
  const { state, config, dispatch, resolveData } = useAppContext();
4503
- const [preview, setPreview] = useState17(null);
4504
- const previewRef = useRef5(null);
4762
+ const id = useId();
4505
4763
  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(
4764
+ const debouncedParamsRef = useRef3(null);
4765
+ const tempDisableFallback = useTempDisableFallback(100);
4766
+ const [zoneStore] = useState17(
4767
+ () => createStore3(() => ({
4768
+ zoneDepthIndex: {},
4769
+ nextZoneDepthIndex: {},
4770
+ areaDepthIndex: {},
4771
+ nextAreaDepthIndex: {},
4772
+ draggedItem: null,
4773
+ previewIndex: {}
4774
+ }))
4775
+ );
4776
+ const getChanged2 = useCallback11(
4777
+ (params, id2) => {
4778
+ const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
4779
+ const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
4780
+ const stateHasArea = Object.keys(areaDepthIndex).length > 0;
4781
+ let zoneChanged = false;
4782
+ let areaChanged = false;
4783
+ if (params.zone && !zoneDepthIndex[params.zone]) {
4784
+ zoneChanged = true;
4785
+ } else if (!params.zone && stateHasZone) {
4786
+ zoneChanged = true;
4787
+ }
4788
+ if (params.area && !areaDepthIndex[params.area]) {
4789
+ areaChanged = true;
4790
+ } else if (!params.area && stateHasArea) {
4791
+ areaChanged = true;
4792
+ }
4793
+ return { zoneChanged, areaChanged };
4794
+ },
4795
+ [zoneStore]
4796
+ );
4797
+ const setDeepestAndCollide = useCallback11(
4511
4798
  (params, manager) => {
4512
- setDeepest(params);
4799
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4800
+ if (!zoneChanged && !areaChanged) return;
4801
+ zoneStore.setState({
4802
+ zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
4803
+ areaDepthIndex: params.area ? { [params.area]: true } : {}
4804
+ });
4805
+ tempDisableFallback(manager);
4513
4806
  setTimeout(() => {
4514
4807
  manager.collisionObserver.forceUpdate(true);
4515
4808
  }, 50);
4516
4809
  debouncedParamsRef.current = null;
4517
4810
  },
4518
- []
4811
+ [zoneStore]
4519
4812
  );
4520
4813
  const setDeepestDb = useDebouncedCallback2(
4521
4814
  setDeepestAndCollide,
4522
4815
  AREA_CHANGE_DEBOUNCE_MS
4523
4816
  );
4524
- useEffect14(() => {
4525
- deepestRef.current = deepest;
4526
- }, [deepest]);
4527
4817
  const cancelDb = () => {
4528
4818
  setDeepestDb.cancel();
4529
4819
  debouncedParamsRef.current = null;
4530
4820
  };
4821
+ useEffect15(() => {
4822
+ if (DEBUG3) {
4823
+ zoneStore.subscribe(
4824
+ (s) => {
4825
+ var _a, _b;
4826
+ return console.log(
4827
+ s.previewIndex,
4828
+ (_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
4829
+ (_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
4830
+ );
4831
+ }
4832
+ );
4833
+ }
4834
+ }, []);
4531
4835
  const [plugins] = useState17(() => [
4532
4836
  ...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) {
4837
+ createNestedDroppablePlugin(
4838
+ {
4839
+ onChange: (params, manager) => {
4840
+ const state2 = zoneStore.getState();
4841
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4842
+ const isDragging = manager.dragOperation.status.dragging;
4843
+ if (areaChanged || zoneChanged) {
4844
+ let nextZoneDepthIndex = {};
4845
+ let nextAreaDepthIndex = {};
4846
+ if (params.zone) {
4847
+ nextZoneDepthIndex = { [params.zone]: true };
4848
+ }
4849
+ if (params.area) {
4850
+ nextAreaDepthIndex = { [params.area]: true };
4851
+ }
4852
+ zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
4853
+ }
4854
+ if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
4855
+ setDeepestAndCollide(params, manager);
4856
+ return;
4857
+ }
4858
+ if (areaChanged) {
4859
+ if (isDragging) {
4860
+ const debouncedParams = debouncedParamsRef.current;
4861
+ const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4862
+ if (!isSameParams) {
4863
+ cancelDb();
4864
+ setDeepestDb(params, manager);
4865
+ debouncedParamsRef.current = params;
4866
+ }
4867
+ } else {
4552
4868
  cancelDb();
4553
- setDeepestDb(params, manager);
4554
- debouncedParamsRef.current = params;
4869
+ setDeepestAndCollide(params, manager);
4555
4870
  }
4556
- } else {
4557
- cancelDb();
4871
+ return;
4872
+ }
4873
+ if (zoneChanged) {
4558
4874
  setDeepestAndCollide(params, manager);
4559
4875
  }
4560
- return;
4876
+ cancelDb();
4561
4877
  }
4562
- if (zoneChanged) {
4563
- setDeepestAndCollide(params, manager);
4564
- }
4565
- cancelDb();
4566
- }
4567
- })
4878
+ },
4879
+ id
4880
+ )
4568
4881
  ]);
4569
4882
  const [sensors] = useState17(() => [
4570
4883
  PointerSensor.configure({
@@ -4585,67 +4898,72 @@ var DragDropContextClient = ({
4585
4898
  }
4586
4899
  })
4587
4900
  ]);
4588
- const [draggedItem, setDraggedItem] = useState17();
4589
4901
  const [dragListeners, setDragListeners] = useState17({});
4590
4902
  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
- }
4903
+ const dragMode = useRef3(null);
4904
+ const registerPath = useCallback11(
4905
+ (id2, selector, label) => {
4598
4906
  const [area] = getZoneId(selector.zone);
4599
4907
  setPathData((latestPathData = {}) => {
4600
4908
  const parentPathData = latestPathData[area] || { path: [] };
4601
4909
  return __spreadProps(__spreadValues({}, latestPathData), {
4602
- [item.props.id]: {
4910
+ [id2]: {
4603
4911
  path: [
4604
4912
  ...parentPathData.path,
4605
4913
  ...selector.zone ? [selector.zone] : []
4606
4914
  ],
4607
- label: item.type
4915
+ label
4608
4916
  }
4609
4917
  });
4610
4918
  });
4611
4919
  },
4612
4920
  [data, setPathData]
4613
4921
  );
4614
- const initialSelector = useRef5(void 0);
4615
- return /* @__PURE__ */ jsx22(
4922
+ const unregisterPath = useCallback11(
4923
+ (id2) => {
4924
+ setPathData((latestPathData = {}) => {
4925
+ const newPathData = __spreadValues({}, latestPathData);
4926
+ delete newPathData[id2];
4927
+ return newPathData;
4928
+ });
4929
+ },
4930
+ [data, setPathData]
4931
+ );
4932
+ const initialSelector = useRef3(void 0);
4933
+ return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
4616
4934
  dragListenerContext.Provider,
4617
4935
  {
4618
4936
  value: {
4619
4937
  dragListeners,
4620
4938
  setDragListeners
4621
4939
  },
4622
- children: /* @__PURE__ */ jsx22(previewContext.Provider, { value: preview, children: /* @__PURE__ */ jsx22(
4940
+ children: /* @__PURE__ */ jsx23(
4623
4941
  DragDropProvider2,
4624
4942
  {
4625
4943
  plugins,
4626
4944
  sensors,
4627
4945
  onDragEnd: (event, manager) => {
4946
+ var _a;
4628
4947
  const { source, target } = event.operation;
4629
- deepestRef.current = null;
4630
4948
  if (!source) {
4631
- setDraggedItem(null);
4949
+ zoneStore.setState({ draggedItem: null });
4632
4950
  return;
4633
4951
  }
4634
4952
  const { zone, index } = source.data;
4635
- const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
4636
- previewRef.current = null;
4953
+ const { previewIndex = {} } = zoneStore.getState() || {};
4954
+ const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
4637
4955
  setTimeout(() => {
4638
- var _a, _b;
4639
- setDraggedItem(null);
4956
+ var _a2, _b;
4957
+ zoneStore.setState({ draggedItem: null });
4640
4958
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4641
- setPreview(null);
4642
- (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
4959
+ zoneStore.setState({ previewIndex: {} });
4960
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
4643
4961
  fn(event, manager);
4644
4962
  });
4645
4963
  return;
4646
4964
  }
4647
4965
  if (thisPreview) {
4648
- setPreview(null);
4966
+ zoneStore.setState({ previewIndex: {} });
4649
4967
  if (thisPreview.type === "insert") {
4650
4968
  insertComponent(
4651
4969
  thisPreview.componentType,
@@ -4680,8 +4998,9 @@ var DragDropContextClient = ({
4680
4998
  }, 250);
4681
4999
  },
4682
5000
  onDragOver: (event, manager) => {
4683
- var _a, _b, _c, _d;
5001
+ var _a, _b, _c, _d, _e;
4684
5002
  event.preventDefault();
5003
+ const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
4685
5004
  if (!draggedItem) return;
4686
5005
  cancelDb();
4687
5006
  const { source, target } = event.operation;
@@ -4697,7 +5016,7 @@ var DragDropContextClient = ({
4697
5016
  const targetData = target.data;
4698
5017
  targetZone = targetData.zone;
4699
5018
  targetIndex = targetData.index;
4700
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
5019
+ const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
4701
5020
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
4702
5021
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
4703
5022
  targetIndex = targetIndex - 1;
@@ -4709,23 +5028,26 @@ var DragDropContextClient = ({
4709
5028
  targetZone = target.id.toString();
4710
5029
  targetIndex = 0;
4711
5030
  }
4712
- if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
5031
+ if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
4713
5032
  const [pathId] = path.split(":");
4714
5033
  return pathId === sourceId;
4715
5034
  }))) {
4716
5035
  return;
4717
5036
  }
4718
5037
  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()
5038
+ zoneStore.setState({
5039
+ previewIndex: {
5040
+ [targetZone]: {
5041
+ componentType: sourceData.componentType,
5042
+ type: "insert",
5043
+ index: targetIndex,
5044
+ zone: targetZone,
5045
+ props: {
5046
+ id: source.id.toString()
5047
+ }
5048
+ }
4726
5049
  }
4727
- };
4728
- setPreview(previewRef.current);
5050
+ });
4729
5051
  } else {
4730
5052
  if (!initialSelector.current) {
4731
5053
  initialSelector.current = {
@@ -4735,17 +5057,20 @@ var DragDropContextClient = ({
4735
5057
  }
4736
5058
  const item = getItem(initialSelector.current, data);
4737
5059
  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);
5060
+ zoneStore.setState({
5061
+ previewIndex: {
5062
+ [targetZone]: {
5063
+ componentType: sourceData.componentType,
5064
+ type: "move",
5065
+ index: targetIndex,
5066
+ zone: targetZone,
5067
+ props: item.props
5068
+ }
5069
+ }
5070
+ });
4746
5071
  }
4747
5072
  }
4748
- (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
5073
+ (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
4749
5074
  fn(event, manager);
4750
5075
  });
4751
5076
  },
@@ -4755,46 +5080,62 @@ var DragDropContextClient = ({
4755
5080
  type: "setUi",
4756
5081
  ui: { itemSelector: null, isDragging: true }
4757
5082
  });
5083
+ const { source } = event.operation;
5084
+ if (source && source.type !== "void") {
5085
+ const sourceData = source.data;
5086
+ const item = getItem(
5087
+ {
5088
+ zone: sourceData.zone,
5089
+ index: sourceData.index
5090
+ },
5091
+ data
5092
+ );
5093
+ if (item) {
5094
+ zoneStore.setState({
5095
+ previewIndex: {
5096
+ [sourceData.zone]: {
5097
+ componentType: sourceData.componentType,
5098
+ type: "move",
5099
+ index: sourceData.index,
5100
+ zone: sourceData.zone,
5101
+ props: item.props
5102
+ }
5103
+ }
5104
+ });
5105
+ }
5106
+ }
4758
5107
  (_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
4759
5108
  fn(event, manager);
4760
5109
  });
4761
5110
  },
4762
5111
  onBeforeDragStart: (event) => {
4763
5112
  var _a;
4764
- if (draggedItem) {
4765
- console.warn("New drag started before previous drag cleaned up");
4766
- }
4767
5113
  const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
4768
5114
  dragMode.current = isNewComponent ? "new" : "existing";
4769
5115
  initialSelector.current = void 0;
4770
- setDraggedItem(event.operation.source);
5116
+ zoneStore.setState({ draggedItem: event.operation.source });
4771
5117
  },
4772
- children: /* @__PURE__ */ jsx22(
5118
+ children: /* @__PURE__ */ jsx23(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx23(
4773
5119
  DropZoneProvider,
4774
5120
  {
4775
5121
  value: {
4776
5122
  data,
4777
5123
  config,
4778
- dispatch,
4779
- draggedItem,
4780
5124
  mode: "edit",
4781
5125
  areaId: "root",
4782
5126
  depth: 0,
4783
5127
  registerPath,
5128
+ unregisterPath,
4784
5129
  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
5130
  path: []
4790
5131
  },
4791
5132
  children
4792
5133
  }
4793
- )
5134
+ ) })
4794
5135
  }
4795
- ) })
5136
+ )
4796
5137
  }
4797
- );
5138
+ ) });
4798
5139
  };
4799
5140
  var DragDropContext = ({
4800
5141
  children,
@@ -4804,11 +5145,11 @@ var DragDropContext = ({
4804
5145
  if (status === "LOADING") {
4805
5146
  return children;
4806
5147
  }
4807
- return /* @__PURE__ */ jsx22(DragDropContextClient, { disableAutoScroll, children });
5148
+ return /* @__PURE__ */ jsx23(DragDropContextClient, { disableAutoScroll, children });
4808
5149
  };
4809
5150
 
4810
5151
  // components/Drawer/index.tsx
4811
- import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
5152
+ import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
4812
5153
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
4813
5154
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
4814
5155
  var DrawerItemInner = ({
@@ -4818,11 +5159,11 @@ var DrawerItemInner = ({
4818
5159
  dragRef,
4819
5160
  isDragDisabled
4820
5161
  }) => {
4821
- const CustomInner = useMemo8(
4822
- () => children || (({ children: children2 }) => /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("default"), children: children2 })),
5162
+ const CustomInner = useMemo9(
5163
+ () => children || (({ children: children2 }) => /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("default"), children: children2 })),
4823
5164
  [children]
4824
5165
  );
4825
- return /* @__PURE__ */ jsx23(
5166
+ return /* @__PURE__ */ jsx24(
4826
5167
  "div",
4827
5168
  {
4828
5169
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -4830,9 +5171,9 @@ var DrawerItemInner = ({
4830
5171
  onMouseDown: (e) => e.preventDefault(),
4831
5172
  "data-testid": dragRef ? `drawer-item:${name}` : "",
4832
5173
  "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, {}) })
5174
+ children: /* @__PURE__ */ jsx24(CustomInner, { name, children: /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
5175
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5176
+ /* @__PURE__ */ jsx24("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx24(DragIcon, {}) })
4836
5177
  ] }) }) })
4837
5178
  }
4838
5179
  );
@@ -4850,8 +5191,8 @@ var DrawerItemDraggable = ({
4850
5191
  disabled: isDragDisabled
4851
5192
  });
4852
5193
  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(
5194
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx24(DrawerItemInner, { name, label, children }) }),
5195
+ /* @__PURE__ */ jsx24("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx24(
4855
5196
  DrawerItemInner,
4856
5197
  {
4857
5198
  name,
@@ -4885,7 +5226,7 @@ var DrawerItem = ({
4885
5226
  },
4886
5227
  [resolvedId]
4887
5228
  );
4888
- return /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
5229
+ return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(
4889
5230
  DrawerItemDraggable,
4890
5231
  {
4891
5232
  name,
@@ -4911,14 +5252,14 @@ var Drawer = ({
4911
5252
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
4912
5253
  );
4913
5254
  }
4914
- const [id] = useState18(generateId());
5255
+ const id = useId2();
4915
5256
  const { ref } = useDroppableSafe({
4916
5257
  id,
4917
5258
  type: "void",
4918
5259
  collisionPriority: 0
4919
5260
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
4920
5261
  });
4921
- return /* @__PURE__ */ jsx23(
5262
+ return /* @__PURE__ */ jsx24(
4922
5263
  "div",
4923
5264
  {
4924
5265
  className: getClassName18(),
@@ -4934,9 +5275,9 @@ Drawer.Item = DrawerItem;
4934
5275
  // components/Puck/index.tsx
4935
5276
  init_react_import();
4936
5277
  import {
4937
- useCallback as useCallback14,
4938
- useEffect as useEffect22,
4939
- useMemo as useMemo17,
5278
+ useCallback as useCallback18,
5279
+ useEffect as useEffect24,
5280
+ useMemo as useMemo19,
4940
5281
  useReducer,
4941
5282
  useState as useState26
4942
5283
  } from "react";
@@ -4950,7 +5291,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
4950
5291
 
4951
5292
  // lib/use-breadcrumbs.ts
4952
5293
  init_react_import();
4953
- import { useContext as useContext5, useMemo as useMemo9 } from "react";
5294
+ import { useContext as useContext8, useMemo as useMemo10 } from "react";
4954
5295
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
4955
5296
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
4956
5297
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -5000,8 +5341,8 @@ var useBreadcrumbs = (renderCount) => {
5000
5341
  state: { data },
5001
5342
  selectedItem
5002
5343
  } = useAppContext();
5003
- const dzContext = useContext5(dropZoneContext);
5004
- return useMemo9(() => {
5344
+ const dzContext = useContext8(dropZoneContext);
5345
+ return useMemo10(() => {
5005
5346
  const breadcrumbs = convertPathDataToBreadcrumbs(
5006
5347
  selectedItem,
5007
5348
  dzContext == null ? void 0 : dzContext.pathData,
@@ -5015,7 +5356,7 @@ var useBreadcrumbs = (renderCount) => {
5015
5356
  };
5016
5357
 
5017
5358
  // components/SidebarSection/index.tsx
5018
- import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
5359
+ import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
5019
5360
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5020
5361
  var SidebarSection = ({
5021
5362
  children,
@@ -5034,9 +5375,9 @@ var SidebarSection = ({
5034
5375
  className: getClassName19({ noBorderTop, noPadding }),
5035
5376
  style: { background },
5036
5377
  children: [
5037
- /* @__PURE__ */ jsx24("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5378
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
5038
5379
  showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
5039
- /* @__PURE__ */ jsx24(
5380
+ /* @__PURE__ */ jsx25(
5040
5381
  "button",
5041
5382
  {
5042
5383
  type: "button",
@@ -5045,12 +5386,12 @@ var SidebarSection = ({
5045
5386
  children: breadcrumb.label
5046
5387
  }
5047
5388
  ),
5048
- /* @__PURE__ */ jsx24(ChevronRight, { size: 16 })
5389
+ /* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
5049
5390
  ] }, i)) : null,
5050
- /* @__PURE__ */ jsx24("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx24(Heading, { rank: "2", size: "xs", children: title }) })
5391
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
5051
5392
  ] }) }),
5052
- /* @__PURE__ */ jsx24("div", { className: getClassName19("content"), children }),
5053
- isLoading && /* @__PURE__ */ jsx24("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx24(Loader, { size: 32 }) })
5393
+ /* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
5394
+ isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
5054
5395
  ]
5055
5396
  }
5056
5397
  );
@@ -5081,7 +5422,7 @@ init_react_import();
5081
5422
  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
5423
 
5083
5424
  // components/MenuBar/index.tsx
5084
- import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
5425
+ import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
5085
5426
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5086
5427
  function MenuBar({
5087
5428
  appState,
@@ -5095,7 +5436,7 @@ function MenuBar({
5095
5436
  history: { back, forward, historyStore }
5096
5437
  } = useAppContext();
5097
5438
  const { hasFuture = false, hasPast = false } = historyStore || {};
5098
- return /* @__PURE__ */ jsx25(
5439
+ return /* @__PURE__ */ jsx26(
5099
5440
  "div",
5100
5441
  {
5101
5442
  className: getClassName20({ menuOpen }),
@@ -5111,10 +5452,10 @@ function MenuBar({
5111
5452
  },
5112
5453
  children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
5113
5454
  /* @__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 }) })
5455
+ /* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
5456
+ /* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
5116
5457
  ] }),
5117
- /* @__PURE__ */ jsx25(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5458
+ /* @__PURE__ */ jsx26(Fragment7, { children: renderHeaderActions && renderHeaderActions({
5118
5459
  state: appState,
5119
5460
  dispatch
5120
5461
  }) })
@@ -5125,43 +5466,68 @@ function MenuBar({
5125
5466
 
5126
5467
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5127
5468
  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" };
5469
+ 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
5470
 
5130
5471
  // components/Puck/components/Fields/index.tsx
5131
5472
  init_react_import();
5132
5473
 
5133
5474
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5134
5475
  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" };
5476
+ 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
5477
 
5137
5478
  // components/Puck/components/Fields/index.tsx
5138
- import { useCallback as useCallback10, useEffect as useEffect15, useMemo as useMemo10, useState as useState19 } from "react";
5479
+ import { useMemo as useMemo12 } from "react";
5480
+
5481
+ // lib/use-resolved-fields.ts
5482
+ init_react_import();
5483
+ import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
5139
5484
 
5140
5485
  // lib/use-parent.ts
5141
5486
  init_react_import();
5142
- import { useContext as useContext6 } from "react";
5143
- var useParent = (itemSelector) => {
5487
+ import { useCallback as useCallback12, useContext as useContext9 } from "react";
5488
+ var getParent = (itemSelector, pathData, data) => {
5144
5489
  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);
5490
+ if (!itemSelector) return null;
5491
+ const item = getItem(itemSelector, data);
5492
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
5149
5493
  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;
5494
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
5151
5495
  return parent || null;
5152
5496
  };
5497
+ var useGetParent = () => {
5498
+ const { state } = useAppContext();
5499
+ const { pathData } = useContext9(dropZoneContext) || {};
5500
+ return useCallback12(
5501
+ () => getParent(state.ui.itemSelector, pathData, state.data),
5502
+ [state.ui.itemSelector, pathData, state.data]
5503
+ );
5504
+ };
5505
+ var useParent = () => {
5506
+ return useGetParent()();
5507
+ };
5153
5508
 
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);
5509
+ // lib/use-on-value-change.ts
5510
+ init_react_import();
5511
+ import { useRef as useRef4, useEffect as useEffect16 } from "react";
5512
+ function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5513
+ const tracked = useRef4(value);
5514
+ useEffect16(() => {
5515
+ const oldValue = tracked.current;
5516
+ if (!compare(value, oldValue)) {
5517
+ tracked.current = value;
5518
+ onChange(value, oldValue);
5519
+ }
5520
+ }, [onChange, compare, value, ...deps]);
5521
+ }
5522
+
5523
+ // lib/selector-is.ts
5524
+ init_react_import();
5525
+ 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);
5526
+
5527
+ // lib/use-resolved-fields.ts
5157
5528
  var defaultPageFields = {
5158
5529
  title: { type: "text" }
5159
5530
  };
5160
- var DefaultFields = ({
5161
- children
5162
- }) => {
5163
- return /* @__PURE__ */ jsx26(Fragment8, { children });
5164
- };
5165
5531
  var useResolvedFields = () => {
5166
5532
  var _a, _b;
5167
5533
  const { selectedItem, state, config } = useAppContext();
@@ -5169,7 +5535,7 @@ var useResolvedFields = () => {
5169
5535
  const { data } = state;
5170
5536
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5171
5537
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5172
- const defaultFields = useMemo10(
5538
+ const defaultFields = useMemo11(
5173
5539
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5174
5540
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5175
5541
  );
@@ -5177,12 +5543,13 @@ var useResolvedFields = () => {
5177
5543
  const [lastSelectedData, setLastSelectedData] = useState19({});
5178
5544
  const [resolvedFields, setResolvedFields] = useState19(defaultFields);
5179
5545
  const [fieldsLoading, setFieldsLoading] = useState19(false);
5546
+ const lastFields = useRef5(defaultFields);
5180
5547
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5181
5548
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5182
5549
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5183
5550
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5184
5551
  const hasResolver = hasComponentResolver || hasRootResolver;
5185
- const resolveFields = useCallback10(
5552
+ const resolveFields = useCallback13(
5186
5553
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5187
5554
  var _a2;
5188
5555
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5194,7 +5561,7 @@ var useResolvedFields = () => {
5194
5561
  {
5195
5562
  changed,
5196
5563
  fields,
5197
- lastFields: resolvedFields,
5564
+ lastFields: lastFields.current,
5198
5565
  lastData,
5199
5566
  appState: state,
5200
5567
  parent
@@ -5205,7 +5572,7 @@ var useResolvedFields = () => {
5205
5572
  return yield config.root.resolveFields(componentData, {
5206
5573
  changed,
5207
5574
  fields,
5208
- lastFields: resolvedFields,
5575
+ lastFields: lastFields.current,
5209
5576
  lastData,
5210
5577
  appState: state,
5211
5578
  parent
@@ -5214,26 +5581,56 @@ var useResolvedFields = () => {
5214
5581
  return defaultResolveFields(componentData, {
5215
5582
  changed,
5216
5583
  fields,
5217
- lastFields: resolvedFields,
5584
+ lastFields: lastFields.current,
5218
5585
  lastData
5219
5586
  });
5220
5587
  }),
5221
- [data, config, componentData, selectedItem, resolvedFields, state]
5588
+ [data, config, componentData, selectedItem, state, parent]
5222
5589
  );
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);
5590
+ const triggerResolver = useCallback13(() => {
5591
+ var _a2, _b2;
5592
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5593
+ if (hasResolver) {
5594
+ setFieldsLoading(true);
5595
+ resolveFields(defaultFields).then((fields) => {
5596
+ setResolvedFields(fields || {});
5597
+ lastFields.current = fields;
5598
+ setFieldsLoading(false);
5599
+ });
5600
+ return;
5601
+ }
5232
5602
  }
5233
- }, [data, defaultFields, selectedItem, hasResolver]);
5603
+ setResolvedFields(defaultFields);
5604
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5605
+ useOnValueChange(
5606
+ state.ui.itemSelector,
5607
+ () => {
5608
+ lastFields.current = defaultFields;
5609
+ },
5610
+ selectorIs
5611
+ );
5612
+ useOnValueChange(
5613
+ { data, parent, itemSelector: state.ui.itemSelector },
5614
+ () => {
5615
+ triggerResolver();
5616
+ },
5617
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
5618
+ );
5619
+ useEffect17(() => {
5620
+ triggerResolver();
5621
+ }, []);
5234
5622
  return [resolvedFields, fieldsLoading];
5235
5623
  };
5236
- var Fields = () => {
5624
+
5625
+ // components/Puck/components/Fields/index.tsx
5626
+ import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5627
+ var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5628
+ var DefaultFields = ({
5629
+ children
5630
+ }) => {
5631
+ return /* @__PURE__ */ jsx27(Fragment8, { children });
5632
+ };
5633
+ var Fields = ({ wrapFields = true }) => {
5237
5634
  var _a, _b;
5238
5635
  const {
5239
5636
  selectedItem,
@@ -5251,16 +5648,16 @@ var Fields = () => {
5251
5648
  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
5649
  const isLoading = fieldsResolving || componentResolving;
5253
5650
  const rootProps = data.root.props || data.root;
5254
- const Wrapper = useMemo10(() => overrides.fields || DefaultFields, [overrides]);
5651
+ const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
5255
5652
  return /* @__PURE__ */ jsxs14(
5256
5653
  "form",
5257
5654
  {
5258
- className: getClassName21(),
5655
+ className: getClassName21({ wrapFields }),
5259
5656
  onSubmit: (e) => {
5260
5657
  e.preventDefault();
5261
5658
  },
5262
5659
  children: [
5263
- /* @__PURE__ */ jsx26(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5660
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5264
5661
  const field = fields[fieldName];
5265
5662
  if (!(field == null ? void 0 : field.type)) return null;
5266
5663
  const onChange = (value, updatedUi) => {
@@ -5331,7 +5728,7 @@ var Fields = () => {
5331
5728
  item: selectedItem
5332
5729
  });
5333
5730
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5334
- return /* @__PURE__ */ jsx26(
5731
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5335
5732
  AutoFieldPrivate,
5336
5733
  {
5337
5734
  field,
@@ -5340,16 +5737,15 @@ var Fields = () => {
5340
5737
  readOnly: !edit || readOnly[fieldName],
5341
5738
  value: selectedItem.props[fieldName],
5342
5739
  onChange
5343
- },
5344
- id
5345
- );
5740
+ }
5741
+ ) }, id);
5346
5742
  } else {
5347
5743
  const readOnly = data.root.readOnly || {};
5348
5744
  const { edit } = getPermissions({
5349
5745
  root: true
5350
5746
  });
5351
5747
  const id = `root_${field.type}_${fieldName}`;
5352
- return /* @__PURE__ */ jsx26(
5748
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5353
5749
  AutoFieldPrivate,
5354
5750
  {
5355
5751
  field,
@@ -5358,12 +5754,11 @@ var Fields = () => {
5358
5754
  readOnly: !edit || readOnly[fieldName],
5359
5755
  value: rootProps[fieldName],
5360
5756
  onChange
5361
- },
5362
- id
5363
- );
5757
+ }
5758
+ ) }, id);
5364
5759
  }
5365
5760
  }) }),
5366
- isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx26("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx26(Loader, { size: 16 }) }) })
5761
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
5367
5762
  ]
5368
5763
  }
5369
5764
  );
@@ -5374,7 +5769,7 @@ init_react_import();
5374
5769
 
5375
5770
  // lib/use-component-list.tsx
5376
5771
  init_react_import();
5377
- import { useEffect as useEffect16, useState as useState20 } from "react";
5772
+ import { useEffect as useEffect18, useState as useState20 } from "react";
5378
5773
 
5379
5774
  // components/ComponentList/index.tsx
5380
5775
  init_react_import();
@@ -5384,7 +5779,7 @@ init_react_import();
5384
5779
  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
5780
 
5386
5781
  // components/ComponentList/index.tsx
5387
- import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
5782
+ import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
5388
5783
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
5389
5784
  var ComponentListItem = ({
5390
5785
  name,
@@ -5394,7 +5789,7 @@ var ComponentListItem = ({
5394
5789
  const canInsert = getPermissions({
5395
5790
  type: name
5396
5791
  }).insert;
5397
- return /* @__PURE__ */ jsx27(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5792
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5398
5793
  };
5399
5794
  var ComponentList = ({
5400
5795
  children,
@@ -5418,14 +5813,14 @@ var ComponentList = ({
5418
5813
  }),
5419
5814
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
5420
5815
  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 }) })
5816
+ /* @__PURE__ */ jsx28("div", { children: title }),
5817
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
5423
5818
  ]
5424
5819
  }
5425
5820
  ),
5426
- /* @__PURE__ */ jsx27("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx27(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5821
+ /* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5427
5822
  var _a;
5428
- return /* @__PURE__ */ jsx27(
5823
+ return /* @__PURE__ */ jsx28(
5429
5824
  ComponentListItem,
5430
5825
  {
5431
5826
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -5439,10 +5834,10 @@ var ComponentList = ({
5439
5834
  ComponentList.Item = ComponentListItem;
5440
5835
 
5441
5836
  // lib/use-component-list.tsx
5442
- import { jsx as jsx28 } from "react/jsx-runtime";
5837
+ import { jsx as jsx29 } from "react/jsx-runtime";
5443
5838
  var useComponentList = (config, ui) => {
5444
5839
  const [componentList, setComponentList] = useState20();
5445
- useEffect16(() => {
5840
+ useEffect18(() => {
5446
5841
  var _a, _b, _c;
5447
5842
  if (Object.keys(ui.componentList).length > 0) {
5448
5843
  const matchedComponents = [];
@@ -5452,7 +5847,7 @@ var useComponentList = (config, ui) => {
5452
5847
  if (category.visible === false || !category.components) {
5453
5848
  return null;
5454
5849
  }
5455
- return /* @__PURE__ */ jsx28(
5850
+ return /* @__PURE__ */ jsx29(
5456
5851
  ComponentList,
5457
5852
  {
5458
5853
  id: categoryKey,
@@ -5461,7 +5856,7 @@ var useComponentList = (config, ui) => {
5461
5856
  var _a2;
5462
5857
  matchedComponents.push(componentName);
5463
5858
  const componentConf = config.components[componentName] || {};
5464
- return /* @__PURE__ */ jsx28(
5859
+ return /* @__PURE__ */ jsx29(
5465
5860
  ComponentList.Item,
5466
5861
  {
5467
5862
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -5481,7 +5876,7 @@ var useComponentList = (config, ui) => {
5481
5876
  );
5482
5877
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
5483
5878
  _componentList.push(
5484
- /* @__PURE__ */ jsx28(
5879
+ /* @__PURE__ */ jsx29(
5485
5880
  ComponentList,
5486
5881
  {
5487
5882
  id: "other",
@@ -5489,7 +5884,7 @@ var useComponentList = (config, ui) => {
5489
5884
  children: remainingComponents.map((componentName, i) => {
5490
5885
  var _a2;
5491
5886
  const componentConf = config.components[componentName] || {};
5492
- return /* @__PURE__ */ jsx28(
5887
+ return /* @__PURE__ */ jsx29(
5493
5888
  ComponentList.Item,
5494
5889
  {
5495
5890
  name: componentName,
@@ -5511,30 +5906,30 @@ var useComponentList = (config, ui) => {
5511
5906
  };
5512
5907
 
5513
5908
  // components/Puck/components/Components/index.tsx
5514
- import { useMemo as useMemo11 } from "react";
5515
- import { jsx as jsx29 } from "react/jsx-runtime";
5909
+ import { useMemo as useMemo13 } from "react";
5910
+ import { jsx as jsx30 } from "react/jsx-runtime";
5516
5911
  var Components = () => {
5517
5912
  const { config, state, overrides } = useAppContext();
5518
5913
  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" }) });
5914
+ const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
5915
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
5521
5916
  };
5522
5917
 
5523
5918
  // components/Puck/components/Preview/index.tsx
5524
5919
  init_react_import();
5525
- import { useCallback as useCallback11, useEffect as useEffect18, useRef as useRef7, useMemo as useMemo12 } from "react";
5920
+ import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
5526
5921
 
5527
5922
  // components/AutoFrame/index.tsx
5528
5923
  init_react_import();
5529
5924
  import {
5530
- createContext as createContext4,
5531
- useContext as useContext7,
5532
- useEffect as useEffect17,
5925
+ createContext as createContext5,
5926
+ useContext as useContext10,
5927
+ useEffect as useEffect19,
5533
5928
  useState as useState21
5534
5929
  } from "react";
5535
5930
  import hash from "object-hash";
5536
5931
  import { createPortal as createPortal3 } from "react-dom";
5537
- import { Fragment as Fragment9, jsx as jsx30 } from "react/jsx-runtime";
5932
+ import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
5538
5933
  var styleSelector = 'style, link[rel="stylesheet"]';
5539
5934
  var collectStyles = (doc) => {
5540
5935
  const collected = [];
@@ -5577,7 +5972,7 @@ var CopyHostStyles = ({
5577
5972
  onStylesLoaded = () => null
5578
5973
  }) => {
5579
5974
  const { document: doc, window: win } = useFrame();
5580
- useEffect17(() => {
5975
+ useEffect19(() => {
5581
5976
  if (!win || !doc) {
5582
5977
  return () => {
5583
5978
  };
@@ -5734,10 +6129,10 @@ var CopyHostStyles = ({
5734
6129
  observer.disconnect();
5735
6130
  };
5736
6131
  }, []);
5737
- return /* @__PURE__ */ jsx30(Fragment9, { children });
6132
+ return /* @__PURE__ */ jsx31(Fragment9, { children });
5738
6133
  };
5739
- var autoFrameContext = createContext4({});
5740
- var useFrame = () => useContext7(autoFrameContext);
6134
+ var autoFrameContext = createContext5({});
6135
+ var useFrame = () => useContext10(autoFrameContext);
5741
6136
  function AutoFrame(_a) {
5742
6137
  var _b = _a, {
5743
6138
  children,
@@ -5757,7 +6152,7 @@ function AutoFrame(_a) {
5757
6152
  const [loaded, setLoaded] = useState21(false);
5758
6153
  const [ctx, setCtx] = useState21({});
5759
6154
  const [mountTarget, setMountTarget] = useState21();
5760
- useEffect17(() => {
6155
+ useEffect19(() => {
5761
6156
  var _a2;
5762
6157
  if (frameRef.current) {
5763
6158
  setCtx({
@@ -5769,7 +6164,7 @@ function AutoFrame(_a) {
5769
6164
  );
5770
6165
  }
5771
6166
  }, [frameRef, loaded]);
5772
- return /* @__PURE__ */ jsx30(
6167
+ return /* @__PURE__ */ jsx31(
5773
6168
  "iframe",
5774
6169
  __spreadProps(__spreadValues({}, props), {
5775
6170
  className,
@@ -5779,7 +6174,7 @@ function AutoFrame(_a) {
5779
6174
  onLoad: () => {
5780
6175
  setLoaded(true);
5781
6176
  },
5782
- children: /* @__PURE__ */ jsx30(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx30(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
6177
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
5783
6178
  })
5784
6179
  );
5785
6180
  }
@@ -5790,12 +6185,68 @@ var AutoFrame_default = AutoFrame;
5790
6185
  init_react_import();
5791
6186
  var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
5792
6187
 
6188
+ // components/Render/index.tsx
6189
+ init_react_import();
6190
+ import { jsx as jsx32 } from "react/jsx-runtime";
6191
+ function Render({
6192
+ config,
6193
+ data
6194
+ }) {
6195
+ var _a;
6196
+ const defaultedData = __spreadProps(__spreadValues({}, data), {
6197
+ root: data.root || {},
6198
+ content: data.content || []
6199
+ });
6200
+ const rootProps = defaultedData.root.props || defaultedData.root;
6201
+ const title = (rootProps == null ? void 0 : rootProps.title) || "";
6202
+ if ((_a = config.root) == null ? void 0 : _a.render) {
6203
+ return /* @__PURE__ */ jsx32(
6204
+ DropZoneProvider,
6205
+ {
6206
+ value: {
6207
+ data: defaultedData,
6208
+ config,
6209
+ mode: "render",
6210
+ depth: 0,
6211
+ path: []
6212
+ },
6213
+ children: /* @__PURE__ */ jsx32(
6214
+ config.root.render,
6215
+ __spreadProps(__spreadValues({}, rootProps), {
6216
+ puck: {
6217
+ renderDropZone: DropZone,
6218
+ isEditing: false
6219
+ },
6220
+ title,
6221
+ editMode: false,
6222
+ id: "puck-root",
6223
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6224
+ })
6225
+ )
6226
+ }
6227
+ );
6228
+ }
6229
+ return /* @__PURE__ */ jsx32(
6230
+ DropZoneProvider,
6231
+ {
6232
+ value: {
6233
+ data: defaultedData,
6234
+ config,
6235
+ mode: "render",
6236
+ depth: 0,
6237
+ path: []
6238
+ },
6239
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6240
+ }
6241
+ );
6242
+ }
6243
+
5793
6244
  // components/Puck/components/Preview/index.tsx
5794
- import { Fragment as Fragment10, jsx as jsx31 } from "react/jsx-runtime";
6245
+ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
5795
6246
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
5796
6247
  var useBubbleIframeEvents = (ref) => {
5797
6248
  const { status } = useAppContext();
5798
- useEffect18(() => {
6249
+ useEffect20(() => {
5799
6250
  var _a;
5800
6251
  if (ref.current && status === "READY") {
5801
6252
  const iframe = ref.current;
@@ -5832,22 +6283,34 @@ var useBubbleIframeEvents = (ref) => {
5832
6283
  }
5833
6284
  }, [status]);
5834
6285
  };
5835
- var Preview = ({ id = "puck-preview" }) => {
6286
+ var Preview2 = ({ id = "puck-preview" }) => {
5836
6287
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
5837
- const Page = useCallback11(
6288
+ const Page = useCallback14(
5838
6289
  (pageProps) => {
5839
6290
  var _a, _b;
5840
6291
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
5841
6292
  id: "puck-root"
5842
- }, pageProps)) : /* @__PURE__ */ jsx31(Fragment10, { children: pageProps.children });
6293
+ }, pageProps)) : /* @__PURE__ */ jsx33(Fragment10, { children: pageProps.children });
5843
6294
  },
5844
6295
  [config.root]
5845
6296
  );
5846
- const Frame = useMemo12(() => overrides.iframe, [overrides]);
6297
+ const Frame = useMemo14(() => overrides.iframe, [overrides]);
5847
6298
  const rootProps = state.data.root.props || state.data.root;
5848
6299
  const ref = useRef7(null);
5849
6300
  useBubbleIframeEvents(ref);
5850
- return /* @__PURE__ */ jsx31(
6301
+ const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
6302
+ Page,
6303
+ __spreadProps(__spreadValues({}, rootProps), {
6304
+ puck: {
6305
+ renderDropZone: DropZone,
6306
+ isEditing: true,
6307
+ dragRef: null
6308
+ },
6309
+ editMode: true,
6310
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
6311
+ })
6312
+ ) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
6313
+ return /* @__PURE__ */ jsx33(
5851
6314
  "div",
5852
6315
  {
5853
6316
  className: getClassName23(),
@@ -5856,7 +6319,7 @@ var Preview = ({ id = "puck-preview" }) => {
5856
6319
  onClick: () => {
5857
6320
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
5858
6321
  },
5859
- children: iframe.enabled ? /* @__PURE__ */ jsx31(
6322
+ children: iframe.enabled ? /* @__PURE__ */ jsx33(
5860
6323
  AutoFrame_default,
5861
6324
  {
5862
6325
  id: "preview-frame",
@@ -5866,40 +6329,21 @@ var Preview = ({ id = "puck-preview" }) => {
5866
6329
  setStatus("READY");
5867
6330
  },
5868
6331
  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
- );
6332
+ children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
5882
6333
  if (Frame) {
5883
- return /* @__PURE__ */ jsx31(Frame, { document: document2, children: inner });
6334
+ return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
5884
6335
  }
5885
6336
  return inner;
5886
6337
  } })
5887
6338
  }
5888
- ) : /* @__PURE__ */ jsx31(
6339
+ ) : /* @__PURE__ */ jsx33(
5889
6340
  "div",
5890
6341
  {
5891
6342
  id: "preview-frame",
5892
6343
  className: getClassName23("frame"),
5893
6344
  ref,
5894
6345
  "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
- )
6346
+ children: inner
5903
6347
  }
5904
6348
  )
5905
6349
  }
@@ -5949,7 +6393,7 @@ var scrollIntoView = (el) => {
5949
6393
  };
5950
6394
 
5951
6395
  // components/LayerTree/index.tsx
5952
- import { useContext as useContext8 } from "react";
6396
+ import { useContext as useContext11 } from "react";
5953
6397
 
5954
6398
  // lib/is-child-of-zone.ts
5955
6399
  init_react_import();
@@ -5982,7 +6426,7 @@ var onScrollEnd = (frame, cb) => {
5982
6426
  };
5983
6427
 
5984
6428
  // components/LayerTree/index.tsx
5985
- import { Fragment as Fragment11, jsx as jsx32, jsxs as jsxs16 } from "react/jsx-runtime";
6429
+ import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
5986
6430
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
5987
6431
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
5988
6432
  var LayerTree = ({
@@ -5995,15 +6439,15 @@ var LayerTree = ({
5995
6439
  label
5996
6440
  }) => {
5997
6441
  const zones = data.zones || {};
5998
- const ctx = useContext8(dropZoneContext);
6442
+ const ctx = useContext11(dropZoneContext);
5999
6443
  return /* @__PURE__ */ jsxs16(Fragment11, { children: [
6000
6444
  label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
6001
- /* @__PURE__ */ jsx32("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx32(Layers, { size: "16" }) }),
6445
+ /* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
6002
6446
  " ",
6003
6447
  label
6004
6448
  ] }),
6005
6449
  /* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
6006
- zoneContent.length === 0 && /* @__PURE__ */ jsx32("div", { className: getClassName24("helper"), children: "No items" }),
6450
+ zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
6007
6451
  zoneContent.map((item, i) => {
6008
6452
  var _a;
6009
6453
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -6026,7 +6470,7 @@ var LayerTree = ({
6026
6470
  childIsSelected
6027
6471
  }),
6028
6472
  children: [
6029
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6473
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6030
6474
  "button",
6031
6475
  {
6032
6476
  type: "button",
@@ -6065,22 +6509,22 @@ var LayerTree = ({
6065
6509
  setHoveringComponent(null);
6066
6510
  },
6067
6511
  children: [
6068
- containsZone && /* @__PURE__ */ jsx32(
6512
+ containsZone && /* @__PURE__ */ jsx34(
6069
6513
  "div",
6070
6514
  {
6071
6515
  className: getClassNameLayer("chevron"),
6072
6516
  title: isSelected ? "Collapse" : "Expand",
6073
- children: /* @__PURE__ */ jsx32(ChevronDown, { size: "12" })
6517
+ children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
6074
6518
  }
6075
6519
  ),
6076
6520
  /* @__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 })
6521
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
6522
+ /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
6079
6523
  ] })
6080
6524
  ]
6081
6525
  }
6082
6526
  ) }),
6083
- containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx32(
6527
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
6084
6528
  LayerTree,
6085
6529
  {
6086
6530
  config,
@@ -6102,13 +6546,13 @@ var LayerTree = ({
6102
6546
  };
6103
6547
 
6104
6548
  // 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";
6549
+ import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
6550
+ import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
6107
6551
  var Outline = () => {
6108
6552
  const { dispatch, state, overrides, config } = useAppContext();
6109
6553
  const { data, ui } = state;
6110
6554
  const { itemSelector } = ui;
6111
- const setItemSelector = useCallback12(
6555
+ const setItemSelector = useCallback15(
6112
6556
  (newItemSelector) => {
6113
6557
  dispatch({
6114
6558
  type: "setUi",
@@ -6117,9 +6561,9 @@ var Outline = () => {
6117
6561
  },
6118
6562
  []
6119
6563
  );
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(
6564
+ const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
6565
+ return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6566
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
6123
6567
  LayerTree,
6124
6568
  {
6125
6569
  config,
@@ -6132,7 +6576,7 @@ var Outline = () => {
6132
6576
  ),
6133
6577
  Object.entries(findZonesForArea(data, "root")).map(
6134
6578
  ([zoneKey, zone]) => {
6135
- return /* @__PURE__ */ jsx33(
6579
+ return /* @__PURE__ */ jsx35(
6136
6580
  LayerTree,
6137
6581
  {
6138
6582
  config,
@@ -6404,27 +6848,27 @@ var getBox = function getBox2(el) {
6404
6848
 
6405
6849
  // components/Puck/components/Canvas/index.tsx
6406
6850
  import {
6407
- useCallback as useCallback13,
6408
- useEffect as useEffect20,
6409
- useMemo as useMemo15,
6851
+ useCallback as useCallback16,
6852
+ useEffect as useEffect22,
6853
+ useMemo as useMemo17,
6410
6854
  useRef as useRef8,
6411
6855
  useState as useState24
6412
6856
  } from "react";
6413
6857
 
6414
6858
  // components/ViewportControls/index.tsx
6415
6859
  init_react_import();
6416
- import { useEffect as useEffect19, useMemo as useMemo14, useState as useState23 } from "react";
6860
+ import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
6417
6861
 
6418
6862
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6419
6863
  init_react_import();
6420
6864
  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
6865
 
6422
6866
  // components/ViewportControls/index.tsx
6423
- import { jsx as jsx34, jsxs as jsxs18 } from "react/jsx-runtime";
6867
+ import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
6424
6868
  var icons = {
6425
- Smartphone: /* @__PURE__ */ jsx34(Smartphone, { size: 16 }),
6426
- Tablet: /* @__PURE__ */ jsx34(Tablet, { size: 16 }),
6427
- Monitor: /* @__PURE__ */ jsx34(Monitor, { size: 16 })
6869
+ Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
6870
+ Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
6871
+ Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
6428
6872
  };
6429
6873
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
6430
6874
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -6437,10 +6881,10 @@ var ViewportButton = ({
6437
6881
  }) => {
6438
6882
  const { state } = useAppContext();
6439
6883
  const [isActive, setIsActive] = useState23(false);
6440
- useEffect19(() => {
6884
+ useEffect21(() => {
6441
6885
  setIsActive(width === state.ui.viewports.current.width);
6442
6886
  }, [width, state.ui.viewports.current.width]);
6443
- return /* @__PURE__ */ jsx34("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx34(
6887
+ return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
6444
6888
  IconButton,
6445
6889
  {
6446
6890
  title,
@@ -6449,7 +6893,7 @@ var ViewportButton = ({
6449
6893
  e.stopPropagation();
6450
6894
  onClick({ width, height });
6451
6895
  },
6452
- children: /* @__PURE__ */ jsx34("span", { className: getClassNameButton("inner"), children })
6896
+ children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
6453
6897
  }
6454
6898
  ) });
6455
6899
  };
@@ -6473,7 +6917,7 @@ var ViewportControls = ({
6473
6917
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6474
6918
  (option) => option.value === autoZoom
6475
6919
  );
6476
- const zoomOptions = useMemo14(
6920
+ const zoomOptions = useMemo16(
6477
6921
  () => [
6478
6922
  ...defaultZoomOptions,
6479
6923
  ...defaultsContainAutoZoom ? [] : [
@@ -6486,7 +6930,7 @@ var ViewportControls = ({
6486
6930
  [autoZoom]
6487
6931
  );
6488
6932
  return /* @__PURE__ */ jsxs18("div", { className: getClassName25(), children: [
6489
- viewports.map((viewport, i) => /* @__PURE__ */ jsx34(
6933
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
6490
6934
  ViewportButton,
6491
6935
  {
6492
6936
  height: viewport.height,
@@ -6497,8 +6941,8 @@ var ViewportControls = ({
6497
6941
  },
6498
6942
  i
6499
6943
  )),
6500
- /* @__PURE__ */ jsx34("div", { className: getClassName25("divider") }),
6501
- /* @__PURE__ */ jsx34(
6944
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6945
+ /* @__PURE__ */ jsx36(
6502
6946
  IconButton,
6503
6947
  {
6504
6948
  title: "Zoom viewport out",
@@ -6512,10 +6956,10 @@ var ViewportControls = ({
6512
6956
  )].value
6513
6957
  );
6514
6958
  },
6515
- children: /* @__PURE__ */ jsx34(ZoomOut, { size: 16 })
6959
+ children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
6516
6960
  }
6517
6961
  ),
6518
- /* @__PURE__ */ jsx34(
6962
+ /* @__PURE__ */ jsx36(
6519
6963
  IconButton,
6520
6964
  {
6521
6965
  title: "Zoom viewport in",
@@ -6529,11 +6973,11 @@ var ViewportControls = ({
6529
6973
  )].value
6530
6974
  );
6531
6975
  },
6532
- children: /* @__PURE__ */ jsx34(ZoomIn, { size: 16 })
6976
+ children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
6533
6977
  }
6534
6978
  ),
6535
- /* @__PURE__ */ jsx34("div", { className: getClassName25("divider") }),
6536
- /* @__PURE__ */ jsx34(
6979
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
6980
+ /* @__PURE__ */ jsx36(
6537
6981
  "select",
6538
6982
  {
6539
6983
  className: getClassName25("zoomSelect"),
@@ -6541,7 +6985,7 @@ var ViewportControls = ({
6541
6985
  onChange: (e) => {
6542
6986
  onZoom(parseFloat(e.currentTarget.value));
6543
6987
  },
6544
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx34(
6988
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
6545
6989
  "option",
6546
6990
  {
6547
6991
  value: option.value,
@@ -6589,7 +7033,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
6589
7033
  };
6590
7034
 
6591
7035
  // components/Puck/components/Canvas/index.tsx
6592
- import { Fragment as Fragment13, jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
7036
+ import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
6593
7037
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
6594
7038
  var ZOOM_ON_CHANGE = true;
6595
7039
  var Canvas = () => {
@@ -6598,15 +7042,15 @@ var Canvas = () => {
6598
7042
  const { ui } = state;
6599
7043
  const frameRef = useRef8(null);
6600
7044
  const [showTransition, setShowTransition] = useState24(false);
6601
- const defaultRender = useMemo15(() => {
6602
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx35(Fragment13, { children });
7045
+ const defaultRender = useMemo17(() => {
7046
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
6603
7047
  return PuckDefault;
6604
7048
  }, []);
6605
- const CustomPreview = useMemo15(
7049
+ const CustomPreview = useMemo17(
6606
7050
  () => overrides.preview || defaultRender,
6607
7051
  [overrides]
6608
7052
  );
6609
- const getFrameDimensions = useCallback13(() => {
7053
+ const getFrameDimensions = useCallback16(() => {
6610
7054
  if (frameRef.current) {
6611
7055
  const frame = frameRef.current;
6612
7056
  const box = getBox(frame);
@@ -6614,7 +7058,7 @@ var Canvas = () => {
6614
7058
  }
6615
7059
  return { width: 0, height: 0 };
6616
7060
  }, [frameRef]);
6617
- const resetAutoZoom = useCallback13(
7061
+ const resetAutoZoom = useCallback16(
6618
7062
  (ui2 = state.ui) => {
6619
7063
  if (frameRef.current) {
6620
7064
  setZoomConfig(
@@ -6624,11 +7068,11 @@ var Canvas = () => {
6624
7068
  },
6625
7069
  [frameRef, zoomConfig, state.ui]
6626
7070
  );
6627
- useEffect20(() => {
7071
+ useEffect22(() => {
6628
7072
  setShowTransition(false);
6629
7073
  resetAutoZoom();
6630
7074
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6631
- useEffect20(() => {
7075
+ useEffect22(() => {
6632
7076
  const { height: frameHeight } = getFrameDimensions();
6633
7077
  if (ui.viewports.current.height === "auto") {
6634
7078
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6636,13 +7080,13 @@ var Canvas = () => {
6636
7080
  }));
6637
7081
  }
6638
7082
  }, [zoomConfig.zoom]);
6639
- useEffect20(() => {
7083
+ useEffect22(() => {
6640
7084
  if (ZOOM_ON_CHANGE) {
6641
7085
  setShowTransition(true);
6642
7086
  resetAutoZoom(ui);
6643
7087
  }
6644
7088
  }, [ui.viewports.current.width]);
6645
- useEffect20(() => {
7089
+ useEffect22(() => {
6646
7090
  const cb = () => {
6647
7091
  setShowTransition(false);
6648
7092
  resetAutoZoom();
@@ -6653,7 +7097,7 @@ var Canvas = () => {
6653
7097
  };
6654
7098
  }, []);
6655
7099
  const [showLoader, setShowLoader] = useState24(false);
6656
- useEffect20(() => {
7100
+ useEffect22(() => {
6657
7101
  setTimeout(() => {
6658
7102
  setShowLoader(true);
6659
7103
  }, 500);
@@ -6671,7 +7115,7 @@ var Canvas = () => {
6671
7115
  recordHistory: true
6672
7116
  }),
6673
7117
  children: [
6674
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx35("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx35(
7118
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
6675
7119
  ViewportControls,
6676
7120
  {
6677
7121
  autoZoom: zoomConfig.autoZoom,
@@ -6698,7 +7142,7 @@ var Canvas = () => {
6698
7142
  }
6699
7143
  ) }),
6700
7144
  /* @__PURE__ */ jsxs19("div", { className: getClassName26("inner"), ref: frameRef, children: [
6701
- /* @__PURE__ */ jsx35(
7145
+ /* @__PURE__ */ jsx37(
6702
7146
  "div",
6703
7147
  {
6704
7148
  className: getClassName26("root"),
@@ -6719,10 +7163,10 @@ var Canvas = () => {
6719
7163
  })
6720
7164
  );
6721
7165
  },
6722
- children: /* @__PURE__ */ jsx35(CustomPreview, { children: /* @__PURE__ */ jsx35(Preview, {}) })
7166
+ children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
6723
7167
  }
6724
7168
  ),
6725
- /* @__PURE__ */ jsx35("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx35(Loader, { size: 24 }) })
7169
+ /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
6726
7170
  ] })
6727
7171
  ]
6728
7172
  }
@@ -6731,7 +7175,7 @@ var Canvas = () => {
6731
7175
 
6732
7176
  // lib/use-loaded-overrides.ts
6733
7177
  init_react_import();
6734
- import { useMemo as useMemo16 } from "react";
7178
+ import { useMemo as useMemo18 } from "react";
6735
7179
 
6736
7180
  // lib/load-overrides.ts
6737
7181
  init_react_import();
@@ -6770,26 +7214,26 @@ var useLoadedOverrides = ({
6770
7214
  overrides,
6771
7215
  plugins
6772
7216
  }) => {
6773
- return useMemo16(() => {
7217
+ return useMemo18(() => {
6774
7218
  return loadOverrides({ overrides, plugins });
6775
7219
  }, [plugins, overrides]);
6776
7220
  };
6777
7221
 
6778
7222
  // components/DefaultOverride/index.tsx
6779
7223
  init_react_import();
6780
- import { Fragment as Fragment14, jsx as jsx36 } from "react/jsx-runtime";
6781
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx36(Fragment14, { children });
7224
+ import { Fragment as Fragment14, jsx as jsx38 } from "react/jsx-runtime";
7225
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { children });
6782
7226
 
6783
7227
  // lib/use-inject-css.ts
6784
7228
  init_react_import();
6785
- import { useEffect as useEffect21, useState as useState25 } from "react";
7229
+ import { useEffect as useEffect23, useState as useState25 } from "react";
6786
7230
  var styles = ``;
6787
7231
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
6788
7232
  const [el, setEl] = useState25();
6789
- useEffect21(() => {
7233
+ useEffect23(() => {
6790
7234
  setEl(document.createElement("style"));
6791
7235
  }, []);
6792
- useEffect21(() => {
7236
+ useEffect23(() => {
6793
7237
  var _a;
6794
7238
  if (!el || typeof window === "undefined") {
6795
7239
  return;
@@ -6807,8 +7251,35 @@ var useInjectGlobalCss = (iframeEnabled) => {
6807
7251
  return useInjectStyleSheet(styles, iframeEnabled);
6808
7252
  };
6809
7253
 
7254
+ // lib/use-preview-mode-hotkeys.ts
7255
+ init_react_import();
7256
+ import { useCallback as useCallback17 } from "react";
7257
+ import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
7258
+ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7259
+ const toggleInteractive = useCallback17(() => {
7260
+ dispatch({
7261
+ type: "setUi",
7262
+ ui: (ui) => ({
7263
+ previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
7264
+ })
7265
+ });
7266
+ }, [dispatch]);
7267
+ const toggleInteractiveIframe = () => {
7268
+ if (iframeEnabled) {
7269
+ toggleInteractive();
7270
+ }
7271
+ };
7272
+ const frame = getFrame();
7273
+ const resolvedFrame = typeof window !== "undefined" && frame !== document ? frame : void 0;
7274
+ useHotkeys2("meta+i", toggleInteractive, { preventDefault: true });
7275
+ useHotkeys2("meta+i", toggleInteractiveIframe, {
7276
+ preventDefault: true,
7277
+ document: resolvedFrame
7278
+ });
7279
+ };
7280
+
6810
7281
  // components/Puck/index.tsx
6811
- import { Fragment as Fragment15, jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
7282
+ import { Fragment as Fragment15, jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
6812
7283
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
6813
7284
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
6814
7285
  function Puck({
@@ -6930,11 +7401,11 @@ function Puck({
6930
7401
  const [menuOpen, setMenuOpen] = useState26(false);
6931
7402
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
6932
7403
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
6933
- useEffect22(() => {
7404
+ useEffect24(() => {
6934
7405
  if (onChange) onChange(data);
6935
7406
  }, [data]);
6936
7407
  const rootProps = data.root.props || data.root;
6937
- const toggleSidebars = useCallback14(
7408
+ const toggleSidebars = useCallback18(
6938
7409
  (sidebar) => {
6939
7410
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
6940
7411
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -6948,7 +7419,7 @@ function Puck({
6948
7419
  },
6949
7420
  [dispatch, leftSideBarVisible, rightSideBarVisible]
6950
7421
  );
6951
- useEffect22(() => {
7422
+ useEffect24(() => {
6952
7423
  if (!window.matchMedia("(min-width: 638px)").matches) {
6953
7424
  dispatch({
6954
7425
  type: "setUi",
@@ -6971,7 +7442,7 @@ function Puck({
6971
7442
  window.removeEventListener("resize", handleResize);
6972
7443
  };
6973
7444
  }, []);
6974
- const defaultHeaderRender = useMemo17(() => {
7445
+ const defaultHeaderRender = useMemo19(() => {
6975
7446
  if (renderHeader) {
6976
7447
  console.warn(
6977
7448
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -6979,20 +7450,20 @@ function Puck({
6979
7450
  const RenderHeader = (_a2) => {
6980
7451
  var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
6981
7452
  const Comp = renderHeader;
6982
- return /* @__PURE__ */ jsx37(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7453
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
6983
7454
  };
6984
7455
  return RenderHeader;
6985
7456
  }
6986
7457
  return DefaultOverride;
6987
7458
  }, [renderHeader]);
6988
- const defaultHeaderActionsRender = useMemo17(() => {
7459
+ const defaultHeaderActionsRender = useMemo19(() => {
6989
7460
  if (renderHeaderActions) {
6990
7461
  console.warn(
6991
7462
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
6992
7463
  );
6993
7464
  const RenderHeader = (props) => {
6994
7465
  const Comp = renderHeaderActions;
6995
- return /* @__PURE__ */ jsx37(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7466
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
6996
7467
  };
6997
7468
  return RenderHeader;
6998
7469
  }
@@ -7002,26 +7473,27 @@ function Puck({
7002
7473
  overrides,
7003
7474
  plugins
7004
7475
  });
7005
- const CustomPuck = useMemo17(
7476
+ const CustomPuck = useMemo19(
7006
7477
  () => loadedOverrides.puck || DefaultOverride,
7007
7478
  [loadedOverrides]
7008
7479
  );
7009
- const CustomHeader = useMemo17(
7480
+ const CustomHeader = useMemo19(
7010
7481
  () => loadedOverrides.header || defaultHeaderRender,
7011
7482
  [loadedOverrides]
7012
7483
  );
7013
- const CustomHeaderActions = useMemo17(
7484
+ const CustomHeaderActions = useMemo19(
7014
7485
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7015
7486
  [loadedOverrides]
7016
7487
  );
7017
7488
  const [mounted, setMounted] = useState26(false);
7018
- useEffect22(() => {
7489
+ useEffect24(() => {
7019
7490
  setMounted(true);
7020
7491
  }, []);
7021
7492
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
7022
7493
  const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
7494
+ usePreviewModeHotkeys(dispatch, iframe.enabled);
7023
7495
  return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName27()}`, children: [
7024
- /* @__PURE__ */ jsx37(
7496
+ /* @__PURE__ */ jsx39(
7025
7497
  AppProvider,
7026
7498
  {
7027
7499
  value: {
@@ -7043,7 +7515,7 @@ function Puck({
7043
7515
  getPermissions: () => ({}),
7044
7516
  refreshPermissions: () => null
7045
7517
  },
7046
- children: /* @__PURE__ */ jsx37(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx37(CustomPuck, { children: children || /* @__PURE__ */ jsx37(
7518
+ children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
7047
7519
  "div",
7048
7520
  {
7049
7521
  className: getLayoutClassName({
@@ -7053,59 +7525,59 @@ function Puck({
7053
7525
  rightSideBarVisible
7054
7526
  }),
7055
7527
  children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
7056
- /* @__PURE__ */ jsx37(
7528
+ /* @__PURE__ */ jsx39(
7057
7529
  CustomHeader,
7058
7530
  {
7059
- actions: /* @__PURE__ */ jsx37(Fragment15, { children: /* @__PURE__ */ jsx37(CustomHeaderActions, { children: /* @__PURE__ */ jsx37(
7531
+ actions: /* @__PURE__ */ jsx39(Fragment15, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7060
7532
  Button,
7061
7533
  {
7062
7534
  onClick: () => {
7063
7535
  onPublish && onPublish(data);
7064
7536
  },
7065
- icon: /* @__PURE__ */ jsx37(Globe, { size: "14px" }),
7537
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7066
7538
  children: "Publish"
7067
7539
  }
7068
7540
  ) }) }),
7069
- children: /* @__PURE__ */ jsx37("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7541
+ children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerInner"), children: [
7070
7542
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerToggle"), children: [
7071
- /* @__PURE__ */ jsx37(
7543
+ /* @__PURE__ */ jsx39(
7072
7544
  "div",
7073
7545
  {
7074
7546
  className: getLayoutClassName("leftSideBarToggle"),
7075
- children: /* @__PURE__ */ jsx37(
7547
+ children: /* @__PURE__ */ jsx39(
7076
7548
  IconButton,
7077
7549
  {
7078
7550
  onClick: () => {
7079
7551
  toggleSidebars("left");
7080
7552
  },
7081
7553
  title: "Toggle left sidebar",
7082
- children: /* @__PURE__ */ jsx37(PanelLeft, { focusable: "false" })
7554
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7083
7555
  }
7084
7556
  )
7085
7557
  }
7086
7558
  ),
7087
- /* @__PURE__ */ jsx37(
7559
+ /* @__PURE__ */ jsx39(
7088
7560
  "div",
7089
7561
  {
7090
7562
  className: getLayoutClassName("rightSideBarToggle"),
7091
- children: /* @__PURE__ */ jsx37(
7563
+ children: /* @__PURE__ */ jsx39(
7092
7564
  IconButton,
7093
7565
  {
7094
7566
  onClick: () => {
7095
7567
  toggleSidebars("right");
7096
7568
  },
7097
7569
  title: "Toggle right sidebar",
7098
- children: /* @__PURE__ */ jsx37(PanelRight, { focusable: "false" })
7570
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7099
7571
  }
7100
7572
  )
7101
7573
  }
7102
7574
  )
7103
7575
  ] }),
7104
- /* @__PURE__ */ jsx37("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7576
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs20(Heading, { rank: "2", size: "xs", children: [
7105
7577
  headerTitle || rootProps.title || "Page",
7106
7578
  headerPath && /* @__PURE__ */ jsxs20(Fragment15, { children: [
7107
7579
  " ",
7108
- /* @__PURE__ */ jsx37(
7580
+ /* @__PURE__ */ jsx39(
7109
7581
  "code",
7110
7582
  {
7111
7583
  className: getLayoutClassName("headerPath"),
@@ -7115,30 +7587,30 @@ function Puck({
7115
7587
  ] })
7116
7588
  ] }) }),
7117
7589
  /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("headerTools"), children: [
7118
- /* @__PURE__ */ jsx37("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx37(
7590
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
7119
7591
  IconButton,
7120
7592
  {
7121
7593
  onClick: () => {
7122
7594
  return setMenuOpen(!menuOpen);
7123
7595
  },
7124
7596
  title: "Toggle menu bar",
7125
- children: menuOpen ? /* @__PURE__ */ jsx37(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx37(ChevronDown, { focusable: "false" })
7597
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7126
7598
  }
7127
7599
  ) }),
7128
- /* @__PURE__ */ jsx37(
7600
+ /* @__PURE__ */ jsx39(
7129
7601
  MenuBar,
7130
7602
  {
7131
7603
  appState,
7132
7604
  dispatch,
7133
7605
  onPublish,
7134
7606
  menuOpen,
7135
- renderHeaderActions: () => /* @__PURE__ */ jsx37(CustomHeaderActions, { children: /* @__PURE__ */ jsx37(
7607
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7136
7608
  Button,
7137
7609
  {
7138
7610
  onClick: () => {
7139
7611
  onPublish && onPublish(data);
7140
7612
  },
7141
- icon: /* @__PURE__ */ jsx37(Globe, { size: "14px" }),
7613
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7142
7614
  children: "Publish"
7143
7615
  }
7144
7616
  ) }),
@@ -7150,18 +7622,18 @@ function Puck({
7150
7622
  }
7151
7623
  ),
7152
7624
  /* @__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, {}) })
7625
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
7626
+ /* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
7155
7627
  ] }),
7156
- /* @__PURE__ */ jsx37(Canvas, {}),
7157
- /* @__PURE__ */ jsx37("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx37(
7628
+ /* @__PURE__ */ jsx39(Canvas, {}),
7629
+ /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
7158
7630
  SidebarSection,
7159
7631
  {
7160
7632
  noPadding: true,
7161
7633
  noBorderTop: true,
7162
7634
  showBreadcrumbs: true,
7163
7635
  title: selectedItem ? selectedComponentLabel : "Page",
7164
- children: /* @__PURE__ */ jsx37(Fields, {})
7636
+ children: /* @__PURE__ */ jsx39(Fields, {})
7165
7637
  }
7166
7638
  ) })
7167
7639
  ] })
@@ -7169,69 +7641,13 @@ function Puck({
7169
7641
  ) }) })
7170
7642
  }
7171
7643
  ),
7172
- /* @__PURE__ */ jsx37("div", { id: "puck-portal-root", className: getClassName27("portal") })
7644
+ /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
7173
7645
  ] });
7174
7646
  }
7175
7647
  Puck.Components = Components;
7176
7648
  Puck.Fields = Fields;
7177
7649
  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
- }
7650
+ Puck.Preview = Preview2;
7235
7651
 
7236
7652
  // lib/migrate.ts
7237
7653
  init_react_import();