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

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -308,10 +308,10 @@ init_react_import();
308
308
 
309
309
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
310
310
  init_react_import();
311
- 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" };
311
+ 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" };
312
312
 
313
313
  // components/AutoField/index.tsx
314
- var import_react19 = require("react");
314
+ var import_react20 = require("react");
315
315
 
316
316
  // components/AutoField/fields/index.tsx
317
317
  init_react_import();
@@ -771,7 +771,7 @@ var IconButton = ({
771
771
  };
772
772
 
773
773
  // components/AutoField/fields/ArrayField/index.tsx
774
- var import_react11 = require("react");
774
+ var import_react12 = require("react");
775
775
 
776
776
  // components/DragIcon/index.tsx
777
777
  init_react_import();
@@ -988,13 +988,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
988
988
  onResolveStart(item);
989
989
  }
990
990
  const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
991
- const { readOnly: existingReadOnly = {} } = item || {};
992
- const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
993
991
  const resolvedItem = __spreadProps(__spreadValues({}, item), {
994
992
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
995
993
  });
996
- if (Object.keys(newReadOnly).length) {
997
- resolvedItem.readOnly = newReadOnly;
994
+ if (Object.keys(readOnly).length) {
995
+ resolvedItem.readOnly = readOnly;
998
996
  }
999
997
  cache.lastChange[item.props.id] = {
1000
998
  item,
@@ -1161,6 +1159,7 @@ var defaultAppState = {
1161
1159
  itemSelector: null,
1162
1160
  componentList: {},
1163
1161
  isDragging: false,
1162
+ previewMode: "edit",
1164
1163
  viewports: {
1165
1164
  current: {
1166
1165
  width: defaultViewports[0].width,
@@ -1283,7 +1282,7 @@ init_react_import();
1283
1282
  var import_react9 = require("@dnd-kit/react");
1284
1283
  var import_react10 = require("react");
1285
1284
 
1286
- // lib/dnd-kit/safe.ts
1285
+ // lib/dnd/dnd-kit/safe.ts
1287
1286
  init_react_import();
1288
1287
  var import_react8 = require("@dnd-kit/react");
1289
1288
  var import_sortable = require("@dnd-kit/react/sortable");
@@ -1360,8 +1359,53 @@ var Sortable = ({
1360
1359
  return children({ status, ref: sortableRef });
1361
1360
  };
1362
1361
 
1363
- // components/AutoField/fields/ArrayField/index.tsx
1362
+ // components/AutoField/context.tsx
1363
+ init_react_import();
1364
+ var import_react11 = require("react");
1364
1365
  var import_jsx_runtime7 = require("react/jsx-runtime");
1366
+ var NestedFieldContext = (0, import_react11.createContext)({});
1367
+ var useNestedFieldContext = () => {
1368
+ const context = (0, import_react11.useContext)(NestedFieldContext);
1369
+ return __spreadProps(__spreadValues({}, context), {
1370
+ readOnlyFields: context.readOnlyFields || {}
1371
+ });
1372
+ };
1373
+ var NestedFieldProvider = ({
1374
+ children,
1375
+ name,
1376
+ subName,
1377
+ wildcardName = name,
1378
+ readOnlyFields
1379
+ }) => {
1380
+ const subPath = `${name}.${subName}`;
1381
+ const wildcardSubPath = `${wildcardName}.${subName}`;
1382
+ const subReadOnlyFields = (0, import_react11.useMemo)(
1383
+ () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
1384
+ const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
1385
+ if (isLocal) {
1386
+ const subPathPattern = new RegExp(
1387
+ `^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
1388
+ );
1389
+ const localName = readOnlyKey.replace(subPathPattern, "");
1390
+ return __spreadProps(__spreadValues({}, acc), {
1391
+ [localName]: readOnlyFields[readOnlyKey]
1392
+ });
1393
+ }
1394
+ return acc;
1395
+ }, {}),
1396
+ [name, subName, wildcardName, readOnlyFields]
1397
+ );
1398
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1399
+ NestedFieldContext.Provider,
1400
+ {
1401
+ value: { readOnlyFields: subReadOnlyFields, localName: subName },
1402
+ children
1403
+ }
1404
+ );
1405
+ };
1406
+
1407
+ // components/AutoField/fields/ArrayField/index.tsx
1408
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1365
1409
  var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
1366
1410
  var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
1367
1411
  var ArrayField = ({
@@ -1372,10 +1416,10 @@ var ArrayField = ({
1372
1416
  label,
1373
1417
  readOnly,
1374
1418
  id,
1375
- Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", __spreadValues({}, props))
1419
+ Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadValues({}, props))
1376
1420
  }) => {
1377
1421
  const { state, setUi, selectedItem, getPermissions } = useAppContext();
1378
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
1422
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
1379
1423
  const value = _value;
1380
1424
  const arrayState = state.ui.arrayState[id] || {
1381
1425
  items: Array.from(value || []).map((item, idx) => {
@@ -1386,11 +1430,11 @@ var ArrayField = ({
1386
1430
  }),
1387
1431
  openId: ""
1388
1432
  };
1389
- const [localState, setLocalState] = (0, import_react11.useState)({ arrayState, value });
1390
- (0, import_react11.useEffect)(() => {
1433
+ const [localState, setLocalState] = (0, import_react12.useState)({ arrayState, value });
1434
+ (0, import_react12.useEffect)(() => {
1391
1435
  setLocalState({ arrayState, value });
1392
1436
  }, [value, state.ui.arrayState[id]]);
1393
- const mapArrayStateToUi = (0, import_react11.useCallback)(
1437
+ const mapArrayStateToUi = (0, import_react12.useCallback)(
1394
1438
  (partialArrayState) => {
1395
1439
  return {
1396
1440
  arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
@@ -1400,13 +1444,13 @@ var ArrayField = ({
1400
1444
  },
1401
1445
  [arrayState]
1402
1446
  );
1403
- const getHighestIndex = (0, import_react11.useCallback)(() => {
1447
+ const getHighestIndex = (0, import_react12.useCallback)(() => {
1404
1448
  return arrayState.items.reduce(
1405
1449
  (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
1406
1450
  -1
1407
1451
  );
1408
1452
  }, [arrayState]);
1409
- const regenerateArrayState = (0, import_react11.useCallback)(
1453
+ const regenerateArrayState = (0, import_react12.useCallback)(
1410
1454
  (value2) => {
1411
1455
  let highestIndex = getHighestIndex();
1412
1456
  const newItems = Array.from(value2 || []).map((item, idx) => {
@@ -1425,7 +1469,7 @@ var ArrayField = ({
1425
1469
  },
1426
1470
  [arrayState]
1427
1471
  );
1428
- (0, import_react11.useEffect)(() => {
1472
+ (0, import_react12.useEffect)(() => {
1429
1473
  if (arrayState.items.length > 0) {
1430
1474
  setUi(mapArrayStateToUi(arrayState));
1431
1475
  }
@@ -1435,14 +1479,14 @@ var ArrayField = ({
1435
1479
  return null;
1436
1480
  }
1437
1481
  const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
1438
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1482
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1439
1483
  Label2,
1440
1484
  {
1441
1485
  label: label || name,
1442
- icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
1486
+ icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(List, { size: 16 }),
1443
1487
  el: "div",
1444
1488
  readOnly,
1445
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1489
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1446
1490
  SortableProvider,
1447
1491
  {
1448
1492
  onMove: (move) => {
@@ -1464,7 +1508,7 @@ var ArrayField = ({
1464
1508
  arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
1465
1509
  });
1466
1510
  },
1467
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1511
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1468
1512
  "div",
1469
1513
  {
1470
1514
  className: getClassName5({
@@ -1478,13 +1522,13 @@ var ArrayField = ({
1478
1522
  localState.arrayState.items.map((item, i) => {
1479
1523
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
1480
1524
  const data = Array.from(localState.value || [])[i] || {};
1481
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1525
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1482
1526
  Sortable,
1483
1527
  {
1484
1528
  id: _arrayId,
1485
1529
  index: i,
1486
1530
  disabled: readOnly,
1487
- children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1531
+ children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1488
1532
  "div",
1489
1533
  {
1490
1534
  ref,
@@ -1494,7 +1538,7 @@ var ArrayField = ({
1494
1538
  readOnly
1495
1539
  }),
1496
1540
  children: [
1497
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1541
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1498
1542
  "div",
1499
1543
  {
1500
1544
  onClick: (e) => {
@@ -1517,9 +1561,9 @@ var ArrayField = ({
1517
1561
  className: getClassNameItem("summary"),
1518
1562
  children: [
1519
1563
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
1520
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
1521
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
1522
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1564
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
1565
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("actions"), children: [
1566
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1523
1567
  IconButton,
1524
1568
  {
1525
1569
  type: "button",
@@ -1536,10 +1580,10 @@ var ArrayField = ({
1536
1580
  );
1537
1581
  },
1538
1582
  title: "Duplicate",
1539
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
1583
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
1540
1584
  }
1541
1585
  ) }),
1542
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1586
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1543
1587
  IconButton,
1544
1588
  {
1545
1589
  type: "button",
@@ -1560,39 +1604,56 @@ var ArrayField = ({
1560
1604
  );
1561
1605
  },
1562
1606
  title: "Delete",
1563
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
1607
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
1564
1608
  }
1565
1609
  ) })
1566
1610
  ] }),
1567
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
1611
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
1568
1612
  ] })
1569
1613
  ]
1570
1614
  }
1571
1615
  ),
1572
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((fieldName) => {
1573
- const subField = field.arrayFields[fieldName];
1574
- const subFieldName = `${name}[${i}].${fieldName}`;
1575
- const wildcardFieldName = `${name}[*].${fieldName}`;
1576
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
1577
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1578
- AutoFieldPrivate,
1616
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
1617
+ const subField = field.arrayFields[subName];
1618
+ const indexName = `${name}[${i}]`;
1619
+ const subPath = `${indexName}.${subName}`;
1620
+ const localIndexName = `${localName}[${i}]`;
1621
+ const localWildcardName = `${localName}[*]`;
1622
+ const localSubPath = `${localIndexName}.${subName}`;
1623
+ const localWildcardSubPath = `${localWildcardName}.${subName}`;
1624
+ const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
1625
+ const label2 = subField.label || subName;
1626
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1627
+ NestedFieldProvider,
1579
1628
  {
1580
- name: subFieldName,
1581
- label: subField.label || fieldName,
1582
- id: `${_arrayId}_${fieldName}`,
1583
- readOnly: subReadOnly,
1584
- field: subField,
1585
- value: data[fieldName],
1586
- onChange: (val, ui) => {
1587
- onChange(
1588
- replace(value, i, __spreadProps(__spreadValues({}, data), {
1589
- [fieldName]: val
1590
- })),
1591
- ui
1592
- );
1593
- }
1629
+ name: localIndexName,
1630
+ wildcardName: localWildcardName,
1631
+ subName,
1632
+ readOnlyFields,
1633
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1634
+ AutoFieldPrivate,
1635
+ {
1636
+ name: subPath,
1637
+ label: label2,
1638
+ id: `${_arrayId}_${subName}`,
1639
+ readOnly: subReadOnly,
1640
+ field: __spreadProps(__spreadValues({}, subField), {
1641
+ label: label2
1642
+ // May be used by custom fields
1643
+ }),
1644
+ value: data[subName],
1645
+ onChange: (val, ui) => {
1646
+ onChange(
1647
+ replace(value, i, __spreadProps(__spreadValues({}, data), {
1648
+ [subName]: val
1649
+ })),
1650
+ ui
1651
+ );
1652
+ }
1653
+ }
1654
+ )
1594
1655
  },
1595
- subFieldName
1656
+ subPath
1596
1657
  );
1597
1658
  }) }) })
1598
1659
  ]
@@ -1602,7 +1663,7 @@ var ArrayField = ({
1602
1663
  _arrayId
1603
1664
  );
1604
1665
  }),
1605
- !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1666
+ !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1606
1667
  "button",
1607
1668
  {
1608
1669
  type: "button",
@@ -1616,7 +1677,7 @@ var ArrayField = ({
1616
1677
  const newArrayState = regenerateArrayState(newValue);
1617
1678
  onChange(newValue, mapArrayStateToUi(newArrayState));
1618
1679
  },
1619
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
1680
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Plus, { size: 21 })
1620
1681
  }
1621
1682
  )
1622
1683
  ]
@@ -1630,28 +1691,29 @@ var ArrayField = ({
1630
1691
 
1631
1692
  // components/AutoField/fields/DefaultField/index.tsx
1632
1693
  init_react_import();
1633
- var import_jsx_runtime8 = require("react/jsx-runtime");
1694
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1634
1695
  var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
1635
1696
  var DefaultField = ({
1636
1697
  field,
1637
1698
  onChange,
1638
1699
  readOnly,
1639
- value,
1700
+ value: _value,
1640
1701
  name,
1641
1702
  label,
1642
1703
  Label: Label2,
1643
1704
  id
1644
1705
  }) => {
1645
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1706
+ const value = _value;
1707
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1646
1708
  Label2,
1647
1709
  {
1648
1710
  label: label || name,
1649
- icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1650
- field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Type, { size: 16 }),
1651
- field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hash, { size: 16 })
1711
+ icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1712
+ field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Type, { size: 16 }),
1713
+ field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Hash, { size: 16 })
1652
1714
  ] }),
1653
1715
  readOnly,
1654
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1716
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1655
1717
  "input",
1656
1718
  {
1657
1719
  className: getClassName6("input"),
@@ -1659,10 +1721,17 @@ var DefaultField = ({
1659
1721
  type: field.type,
1660
1722
  title: label || name,
1661
1723
  name,
1662
- value: typeof value === "undefined" ? "" : value.toString(),
1724
+ value: (value == null ? void 0 : value.toString) ? value.toString() : "",
1663
1725
  onChange: (e) => {
1664
1726
  if (field.type === "number") {
1665
- onChange(Number(e.currentTarget.value));
1727
+ const numberValue = Number(e.currentTarget.value);
1728
+ if (typeof field.min !== "undefined" && numberValue < field.min) {
1729
+ return;
1730
+ }
1731
+ if (typeof field.max !== "undefined" && numberValue > field.max) {
1732
+ return;
1733
+ }
1734
+ onChange(numberValue);
1666
1735
  } else {
1667
1736
  onChange(e.currentTarget.value);
1668
1737
  }
@@ -1680,11 +1749,11 @@ var DefaultField = ({
1680
1749
 
1681
1750
  // components/AutoField/fields/ExternalField/index.tsx
1682
1751
  init_react_import();
1683
- var import_react15 = require("react");
1752
+ var import_react16 = require("react");
1684
1753
 
1685
1754
  // components/ExternalInput/index.tsx
1686
1755
  init_react_import();
1687
- var import_react14 = require("react");
1756
+ var import_react15 = require("react");
1688
1757
 
1689
1758
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
1690
1759
  init_react_import();
@@ -1692,7 +1761,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
1692
1761
 
1693
1762
  // components/Modal/index.tsx
1694
1763
  init_react_import();
1695
- var import_react12 = require("react");
1764
+ var import_react13 = require("react");
1696
1765
 
1697
1766
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
1698
1767
  init_react_import();
@@ -1700,22 +1769,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
1700
1769
 
1701
1770
  // components/Modal/index.tsx
1702
1771
  var import_react_dom = require("react-dom");
1703
- var import_jsx_runtime9 = require("react/jsx-runtime");
1772
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1704
1773
  var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
1705
1774
  var Modal = ({
1706
1775
  children,
1707
1776
  onClose,
1708
1777
  isOpen
1709
1778
  }) => {
1710
- const [rootEl, setRootEl] = (0, import_react12.useState)(null);
1711
- (0, import_react12.useEffect)(() => {
1779
+ const [rootEl, setRootEl] = (0, import_react13.useState)(null);
1780
+ (0, import_react13.useEffect)(() => {
1712
1781
  setRootEl(document.getElementById("puck-portal-root"));
1713
1782
  }, []);
1714
1783
  if (!rootEl) {
1715
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {});
1784
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
1716
1785
  }
1717
1786
  return (0, import_react_dom.createPortal)(
1718
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1787
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1719
1788
  "div",
1720
1789
  {
1721
1790
  className: getClassName7("inner"),
@@ -1735,11 +1804,11 @@ init_react_import();
1735
1804
  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" };
1736
1805
 
1737
1806
  // components/Heading/index.tsx
1738
- var import_jsx_runtime10 = require("react/jsx-runtime");
1807
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1739
1808
  var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
1740
1809
  var Heading = ({ children, rank, size = "m" }) => {
1741
1810
  const Tag = rank ? `h${rank}` : "span";
1742
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1811
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1743
1812
  Tag,
1744
1813
  {
1745
1814
  className: getClassName8({
@@ -1755,7 +1824,7 @@ init_react_import();
1755
1824
 
1756
1825
  // components/Button/Button.tsx
1757
1826
  init_react_import();
1758
- var import_react13 = require("react");
1827
+ var import_react14 = require("react");
1759
1828
 
1760
1829
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
1761
1830
  init_react_import();
@@ -1775,7 +1844,7 @@ var filterDataAttrs = (props) => {
1775
1844
  };
1776
1845
 
1777
1846
  // components/Button/Button.tsx
1778
- var import_jsx_runtime11 = require("react/jsx-runtime");
1847
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1779
1848
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
1780
1849
  var Button = (_a) => {
1781
1850
  var _b = _a, {
@@ -1805,11 +1874,11 @@ var Button = (_a) => {
1805
1874
  "size",
1806
1875
  "loading"
1807
1876
  ]);
1808
- const [loading, setLoading] = (0, import_react13.useState)(loadingProp);
1809
- (0, import_react13.useEffect)(() => setLoading(loadingProp), [loadingProp]);
1877
+ const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
1878
+ (0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
1810
1879
  const ElementType = href ? "a" : type ? "button" : "span";
1811
1880
  const dataAttrs = filterDataAttrs(props);
1812
- const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1881
+ const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1813
1882
  ElementType,
1814
1883
  __spreadProps(__spreadValues({
1815
1884
  className: getClassName9({
@@ -1834,9 +1903,9 @@ var Button = (_a) => {
1834
1903
  href
1835
1904
  }, dataAttrs), {
1836
1905
  children: [
1837
- icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("icon"), children: icon }),
1906
+ icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("icon"), children: icon }),
1838
1907
  children,
1839
- loading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Loader, { size: 14 }) })
1908
+ loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 14 }) })
1840
1909
  ]
1841
1910
  })
1842
1911
  );
@@ -1844,7 +1913,7 @@ var Button = (_a) => {
1844
1913
  };
1845
1914
 
1846
1915
  // components/ExternalInput/index.tsx
1847
- var import_jsx_runtime12 = require("react/jsx-runtime");
1916
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1848
1917
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
1849
1918
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
1850
1919
  var dataCache = {};
@@ -1861,28 +1930,28 @@ var ExternalInput = ({
1861
1930
  mapRow = (val) => val,
1862
1931
  filterFields
1863
1932
  } = field || {};
1864
- const [data, setData] = (0, import_react14.useState)([]);
1865
- const [isOpen, setOpen] = (0, import_react14.useState)(false);
1866
- const [isLoading, setIsLoading] = (0, import_react14.useState)(true);
1933
+ const [data, setData] = (0, import_react15.useState)([]);
1934
+ const [isOpen, setOpen] = (0, import_react15.useState)(false);
1935
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
1867
1936
  const hasFilterFields = !!filterFields;
1868
- const [filters, setFilters] = (0, import_react14.useState)(field.initialFilters || {});
1869
- const [filtersToggled, setFiltersToggled] = (0, import_react14.useState)(hasFilterFields);
1870
- const mappedData = (0, import_react14.useMemo)(() => {
1937
+ const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
1938
+ const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
1939
+ const mappedData = (0, import_react15.useMemo)(() => {
1871
1940
  return data.map(mapRow);
1872
1941
  }, [data]);
1873
- const keys = (0, import_react14.useMemo)(() => {
1942
+ const keys = (0, import_react15.useMemo)(() => {
1874
1943
  const validKeys = /* @__PURE__ */ new Set();
1875
1944
  for (const item of mappedData) {
1876
1945
  for (const key of Object.keys(item)) {
1877
- if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react14.isValidElement)(item[key])) {
1946
+ if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
1878
1947
  validKeys.add(key);
1879
1948
  }
1880
1949
  }
1881
1950
  }
1882
1951
  return Array.from(validKeys);
1883
1952
  }, [mappedData]);
1884
- const [searchQuery, setSearchQuery] = (0, import_react14.useState)(field.initialQuery || "");
1885
- const search = (0, import_react14.useCallback)(
1953
+ const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
1954
+ const search = (0, import_react15.useCallback)(
1886
1955
  (query, filters2) => __async(void 0, null, function* () {
1887
1956
  setIsLoading(true);
1888
1957
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
@@ -1895,18 +1964,18 @@ var ExternalInput = ({
1895
1964
  }),
1896
1965
  [id, field]
1897
1966
  );
1898
- const Footer = (0, import_react14.useCallback)(
1899
- (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
1967
+ const Footer = (0, import_react15.useCallback)(
1968
+ (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
1900
1969
  props.items.length,
1901
1970
  " result",
1902
1971
  props.items.length === 1 ? "" : "s"
1903
1972
  ] }),
1904
1973
  [field.renderFooter]
1905
1974
  );
1906
- (0, import_react14.useEffect)(() => {
1975
+ (0, import_react15.useEffect)(() => {
1907
1976
  search(searchQuery, filters);
1908
1977
  }, []);
1909
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1978
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1910
1979
  "div",
1911
1980
  {
1912
1981
  className: getClassName10({
@@ -1916,21 +1985,21 @@ var ExternalInput = ({
1916
1985
  }),
1917
1986
  id,
1918
1987
  children: [
1919
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("actions"), children: [
1920
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1988
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("actions"), children: [
1989
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1921
1990
  "button",
1922
1991
  {
1923
1992
  type: "button",
1924
1993
  onClick: () => setOpen(true),
1925
1994
  className: getClassName10("button"),
1926
1995
  disabled: readOnly,
1927
- children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1928
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Link, { size: "16" }),
1929
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: field.placeholder })
1996
+ children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1997
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: "16" }),
1998
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: field.placeholder })
1930
1999
  ] })
1931
2000
  }
1932
2001
  ),
1933
- value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2002
+ value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1934
2003
  "button",
1935
2004
  {
1936
2005
  type: "button",
@@ -1939,11 +2008,11 @@ var ExternalInput = ({
1939
2008
  onChange(null);
1940
2009
  },
1941
2010
  disabled: readOnly,
1942
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LockOpen, { size: 16 })
2011
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LockOpen, { size: 16 })
1943
2012
  }
1944
2013
  )
1945
2014
  ] }),
1946
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2015
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1947
2016
  "form",
1948
2017
  {
1949
2018
  className: getClassNameModal({
@@ -1957,11 +2026,11 @@ var ExternalInput = ({
1957
2026
  search(searchQuery, filters);
1958
2027
  },
1959
2028
  children: [
1960
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
1961
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: getClassNameModal("search"), children: [
1962
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
1963
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Search, { size: "18" }) }),
1964
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2029
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
2030
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: getClassNameModal("search"), children: [
2031
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
2032
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Search, { size: "18" }) }),
2033
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1965
2034
  "input",
1966
2035
  {
1967
2036
  className: getClassNameModal("searchInput"),
@@ -1976,9 +2045,9 @@ var ExternalInput = ({
1976
2045
  }
1977
2046
  )
1978
2047
  ] }),
1979
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
1980
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
1981
- hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2048
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
2049
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
2050
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1982
2051
  IconButton,
1983
2052
  {
1984
2053
  title: "Toggle filters",
@@ -1987,15 +2056,15 @@ var ExternalInput = ({
1987
2056
  e.stopPropagation();
1988
2057
  setFiltersToggled(!filtersToggled);
1989
2058
  },
1990
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SlidersHorizontal, { size: 20 })
2059
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SlidersHorizontal, { size: 20 })
1991
2060
  }
1992
2061
  ) })
1993
2062
  ] })
1994
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
1995
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("grid"), children: [
1996
- hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
2063
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
2064
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("grid"), children: [
2065
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1997
2066
  const filterField = filterFields[fieldName];
1998
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2067
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1999
2068
  AutoFieldPrivate,
2000
2069
  {
2001
2070
  field: filterField,
@@ -2012,9 +2081,9 @@ var ExternalInput = ({
2012
2081
  fieldName
2013
2082
  );
2014
2083
  }) }),
2015
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
2016
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { className: getClassNameModal("table"), children: [
2017
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2084
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
2085
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: getClassNameModal("table"), children: [
2086
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2018
2087
  "th",
2019
2088
  {
2020
2089
  className: getClassNameModal("th"),
@@ -2023,8 +2092,8 @@ var ExternalInput = ({
2023
2092
  },
2024
2093
  key
2025
2094
  )) }) }),
2026
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
2027
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2095
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
2096
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2028
2097
  "tr",
2029
2098
  {
2030
2099
  style: { whiteSpace: "nowrap" },
@@ -2033,16 +2102,16 @@ var ExternalInput = ({
2033
2102
  onChange(mapProp(data[i]));
2034
2103
  setOpen(false);
2035
2104
  },
2036
- children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
2105
+ children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
2037
2106
  },
2038
2107
  i
2039
2108
  );
2040
2109
  }) })
2041
2110
  ] }),
2042
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 24 }) })
2111
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 24 }) })
2043
2112
  ] })
2044
2113
  ] }),
2045
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Footer, { items: mappedData }) })
2114
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footer, { items: mappedData }) })
2046
2115
  ]
2047
2116
  }
2048
2117
  ) })
@@ -2052,7 +2121,7 @@ var ExternalInput = ({
2052
2121
  };
2053
2122
 
2054
2123
  // components/AutoField/fields/ExternalField/index.tsx
2055
- var import_jsx_runtime13 = require("react/jsx-runtime");
2124
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2056
2125
  var ExternalField = ({
2057
2126
  field,
2058
2127
  onChange,
@@ -2066,7 +2135,7 @@ var ExternalField = ({
2066
2135
  var _a, _b, _c;
2067
2136
  const validField = field;
2068
2137
  const deprecatedField = field;
2069
- (0, import_react15.useEffect)(() => {
2138
+ (0, import_react16.useEffect)(() => {
2070
2139
  if (deprecatedField.adaptor) {
2071
2140
  console.error(
2072
2141
  "Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
@@ -2076,7 +2145,7 @@ var ExternalField = ({
2076
2145
  if (field.type !== "external") {
2077
2146
  return null;
2078
2147
  }
2079
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2148
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2080
2149
  ExternalInput,
2081
2150
  {
2082
2151
  name,
@@ -2101,7 +2170,7 @@ var ExternalField = ({
2101
2170
 
2102
2171
  // components/AutoField/fields/RadioField/index.tsx
2103
2172
  init_react_import();
2104
- var import_react16 = require("react");
2173
+ var import_react17 = require("react");
2105
2174
 
2106
2175
  // lib/safe-json-parse.ts
2107
2176
  init_react_import();
@@ -2115,7 +2184,7 @@ var safeJsonParse = (str) => {
2115
2184
  };
2116
2185
 
2117
2186
  // components/AutoField/fields/RadioField/index.tsx
2118
- var import_jsx_runtime14 = require("react/jsx-runtime");
2187
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2119
2188
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
2120
2189
  var RadioField = ({
2121
2190
  field,
@@ -2127,26 +2196,26 @@ var RadioField = ({
2127
2196
  label,
2128
2197
  Label: Label2
2129
2198
  }) => {
2130
- const flatOptions = (0, import_react16.useMemo)(
2199
+ const flatOptions = (0, import_react17.useMemo)(
2131
2200
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
2132
2201
  [field]
2133
2202
  );
2134
2203
  if (field.type !== "radio" || !field.options) {
2135
2204
  return null;
2136
2205
  }
2137
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2206
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2138
2207
  Label2,
2139
2208
  {
2140
- icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
2209
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CircleCheckBig, { size: 16 }),
2141
2210
  label: label || name,
2142
2211
  readOnly,
2143
2212
  el: "div",
2144
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2213
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2145
2214
  "label",
2146
2215
  {
2147
2216
  className: getClassName11("radio"),
2148
2217
  children: [
2149
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2218
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2150
2219
  "input",
2151
2220
  {
2152
2221
  type: "radio",
@@ -2166,7 +2235,7 @@ var RadioField = ({
2166
2235
  checked: value === option.value
2167
2236
  }
2168
2237
  ),
2169
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2238
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2170
2239
  ]
2171
2240
  },
2172
2241
  option.label + option.value
@@ -2177,8 +2246,8 @@ var RadioField = ({
2177
2246
 
2178
2247
  // components/AutoField/fields/SelectField/index.tsx
2179
2248
  init_react_import();
2180
- var import_react17 = require("react");
2181
- var import_jsx_runtime15 = require("react/jsx-runtime");
2249
+ var import_react18 = require("react");
2250
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2182
2251
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
2183
2252
  var SelectField = ({
2184
2253
  field,
@@ -2190,20 +2259,20 @@ var SelectField = ({
2190
2259
  readOnly,
2191
2260
  id
2192
2261
  }) => {
2193
- const flatOptions = (0, import_react17.useMemo)(
2262
+ const flatOptions = (0, import_react18.useMemo)(
2194
2263
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
2195
2264
  [field]
2196
2265
  );
2197
2266
  if (field.type !== "select" || !field.options) {
2198
2267
  return null;
2199
2268
  }
2200
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2269
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2201
2270
  Label2,
2202
2271
  {
2203
2272
  label: label || name,
2204
- icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
2273
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronDown, { size: 16 }),
2205
2274
  readOnly,
2206
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2275
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2207
2276
  "select",
2208
2277
  {
2209
2278
  id,
@@ -2220,7 +2289,7 @@ var SelectField = ({
2220
2289
  }
2221
2290
  },
2222
2291
  value,
2223
- children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2292
+ children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2224
2293
  "option",
2225
2294
  {
2226
2295
  label: option.label,
@@ -2236,7 +2305,7 @@ var SelectField = ({
2236
2305
 
2237
2306
  // components/AutoField/fields/TextareaField/index.tsx
2238
2307
  init_react_import();
2239
- var import_jsx_runtime16 = require("react/jsx-runtime");
2308
+ var import_jsx_runtime17 = require("react/jsx-runtime");
2240
2309
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
2241
2310
  var TextareaField = ({
2242
2311
  onChange,
@@ -2247,7 +2316,7 @@ var TextareaField = ({
2247
2316
  Label: Label2,
2248
2317
  id
2249
2318
  }) => {
2250
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2319
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2251
2320
  "textarea",
2252
2321
  {
2253
2322
  id,
@@ -2274,7 +2343,7 @@ init_react_import();
2274
2343
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
2275
2344
 
2276
2345
  // components/AutoField/fields/ObjectField/index.tsx
2277
- var import_jsx_runtime17 = require("react/jsx-runtime");
2346
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2278
2347
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
2279
2348
  var ObjectField = ({
2280
2349
  field,
@@ -2286,43 +2355,54 @@ var ObjectField = ({
2286
2355
  readOnly,
2287
2356
  id
2288
2357
  }) => {
2289
- const { selectedItem } = useAppContext();
2358
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
2290
2359
  if (field.type !== "object" || !field.objectFields) {
2291
2360
  return null;
2292
2361
  }
2293
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
2294
2362
  const data = value || {};
2295
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2363
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2296
2364
  Label2,
2297
2365
  {
2298
2366
  label: label || name,
2299
- icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
2367
+ icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EllipsisVertical, { size: 16 }),
2300
2368
  el: "div",
2301
2369
  readOnly,
2302
- children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((fieldName) => {
2303
- const subField = field.objectFields[fieldName];
2304
- const subFieldName = `${name}.${fieldName}`;
2305
- const wildcardFieldName = `${name}.${fieldName}`;
2306
- const subReadOnly = readOnly ? readOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
2307
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2308
- AutoFieldPrivate,
2370
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
2371
+ const subField = field.objectFields[subName];
2372
+ const subPath = `${name}.${subName}`;
2373
+ const localSubPath = `${localName || name}.${subName}`;
2374
+ const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
2375
+ const label2 = subField.label || subName;
2376
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2377
+ NestedFieldProvider,
2309
2378
  {
2310
- name: subFieldName,
2311
- label: subField.label || fieldName,
2312
- id: `${id}_${fieldName}`,
2313
- readOnly: subReadOnly,
2314
- field: subField,
2315
- value: data[fieldName],
2316
- onChange: (val, ui) => {
2317
- onChange(
2318
- __spreadProps(__spreadValues({}, data), {
2319
- [fieldName]: val
2379
+ name: localName || id,
2380
+ subName,
2381
+ readOnlyFields,
2382
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2383
+ AutoFieldPrivate,
2384
+ {
2385
+ name: subPath,
2386
+ label: subPath,
2387
+ id: `${id}_${subName}`,
2388
+ readOnly: subReadOnly,
2389
+ field: __spreadProps(__spreadValues({}, subField), {
2390
+ label: label2
2391
+ // May be used by custom fields
2320
2392
  }),
2321
- ui
2322
- );
2323
- }
2393
+ value: data[subName],
2394
+ onChange: (val, ui) => {
2395
+ onChange(
2396
+ __spreadProps(__spreadValues({}, data), {
2397
+ [subName]: val
2398
+ }),
2399
+ ui
2400
+ );
2401
+ }
2402
+ }
2403
+ )
2324
2404
  },
2325
- subFieldName
2405
+ subPath
2326
2406
  );
2327
2407
  }) }) })
2328
2408
  }
@@ -2331,7 +2411,7 @@ var ObjectField = ({
2331
2411
 
2332
2412
  // lib/use-safe-id.ts
2333
2413
  init_react_import();
2334
- var import_react18 = __toESM(require("react"));
2414
+ var import_react19 = __toESM(require("react"));
2335
2415
 
2336
2416
  // lib/generate-id.ts
2337
2417
  init_react_import();
@@ -2340,15 +2420,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
2340
2420
 
2341
2421
  // lib/use-safe-id.ts
2342
2422
  var useSafeId = () => {
2343
- if (typeof import_react18.default.useId !== "undefined") {
2344
- return import_react18.default.useId();
2423
+ if (typeof import_react19.default.useId !== "undefined") {
2424
+ return import_react19.default.useId();
2345
2425
  }
2346
- const [id] = (0, import_react18.useState)(generateId());
2426
+ const [id] = (0, import_react19.useState)(generateId());
2347
2427
  return id;
2348
2428
  };
2349
2429
 
2350
2430
  // components/AutoField/index.tsx
2351
- var import_jsx_runtime18 = require("react/jsx-runtime");
2431
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2352
2432
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2353
2433
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2354
2434
  var FieldLabel = ({
@@ -2360,16 +2440,16 @@ var FieldLabel = ({
2360
2440
  className
2361
2441
  }) => {
2362
2442
  const El = el;
2363
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(El, { className, children: [
2364
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: getClassName15("label"), children: [
2365
- icon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {}),
2443
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(El, { className, children: [
2444
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName15("label"), children: [
2445
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {}),
2366
2446
  label,
2367
- readOnly && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Lock, { size: "12" }) })
2447
+ readOnly && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Lock, { size: "12" }) })
2368
2448
  ] }),
2369
2449
  children
2370
2450
  ] });
2371
2451
  };
2372
- var FieldLabelInternal2 = ({
2452
+ var FieldLabelInternal = ({
2373
2453
  children,
2374
2454
  icon,
2375
2455
  label,
@@ -2377,14 +2457,14 @@ var FieldLabelInternal2 = ({
2377
2457
  readOnly
2378
2458
  }) => {
2379
2459
  const { overrides } = useAppContext();
2380
- const Wrapper = (0, import_react19.useMemo)(
2460
+ const Wrapper = (0, import_react20.useMemo)(
2381
2461
  () => overrides.fieldLabel || FieldLabel,
2382
2462
  [overrides]
2383
2463
  );
2384
2464
  if (!label) {
2385
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
2465
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
2386
2466
  }
2387
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2467
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2388
2468
  Wrapper,
2389
2469
  {
2390
2470
  label,
@@ -2398,8 +2478,9 @@ var FieldLabelInternal2 = ({
2398
2478
  };
2399
2479
  function AutoFieldInternal(props) {
2400
2480
  var _a, _b, _c, _d, _e, _f, _g, _h;
2401
- const { dispatch, overrides } = useAppContext();
2402
- const { id, Label: Label2 = FieldLabelInternal2 } = props;
2481
+ const { dispatch, overrides, selectedItem } = useAppContext();
2482
+ const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
2483
+ const { id, Label: Label2 = FieldLabelInternal } = props;
2403
2484
  const field = props.field;
2404
2485
  const label = field.label;
2405
2486
  const defaultId = useSafeId();
@@ -2430,7 +2511,7 @@ function AutoFieldInternal(props) {
2430
2511
  Label: Label2,
2431
2512
  id: resolvedId
2432
2513
  });
2433
- const onFocus = (0, import_react19.useCallback)(
2514
+ const onFocus = (0, import_react20.useCallback)(
2434
2515
  (e) => {
2435
2516
  if (mergedProps.name && e.target.nodeName === "INPUT") {
2436
2517
  e.stopPropagation();
@@ -2444,7 +2525,7 @@ function AutoFieldInternal(props) {
2444
2525
  },
2445
2526
  [mergedProps.name]
2446
2527
  );
2447
- const onBlur = (0, import_react19.useCallback)((e) => {
2528
+ const onBlur = (0, import_react20.useCallback)((e) => {
2448
2529
  if ("name" in e.target) {
2449
2530
  dispatch({
2450
2531
  type: "setUi",
@@ -2459,27 +2540,36 @@ function AutoFieldInternal(props) {
2459
2540
  return null;
2460
2541
  }
2461
2542
  const CustomField = field.render;
2462
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
2543
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
2463
2544
  }
2464
2545
  const children = defaultFields[field.type](mergedProps);
2465
2546
  const Render2 = render[field.type];
2466
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2467
- "div",
2547
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2548
+ NestedFieldContext.Provider,
2468
2549
  {
2469
- className: getClassNameWrapper(),
2470
- onFocus,
2471
- onBlur,
2472
- onClick: (e) => {
2473
- e.stopPropagation();
2550
+ value: {
2551
+ readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
2552
+ localName: nestedFieldContext.localName
2474
2553
  },
2475
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2554
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2555
+ "div",
2556
+ {
2557
+ className: getClassNameWrapper(),
2558
+ onFocus,
2559
+ onBlur,
2560
+ onClick: (e) => {
2561
+ e.stopPropagation();
2562
+ },
2563
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2564
+ }
2565
+ )
2476
2566
  }
2477
2567
  );
2478
2568
  }
2479
2569
  function AutoFieldPrivate(props) {
2480
2570
  const { state } = useAppContext();
2481
2571
  const { value, onChange } = props;
2482
- const [localValue, setLocalValue] = (0, import_react19.useState)(value);
2572
+ const [localValue, setLocalValue] = (0, import_react20.useState)(value);
2483
2573
  const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
2484
2574
  (val, ui) => {
2485
2575
  onChange(val, ui);
@@ -2487,11 +2577,11 @@ function AutoFieldPrivate(props) {
2487
2577
  50,
2488
2578
  { leading: true }
2489
2579
  );
2490
- const onChangeLocal = (0, import_react19.useCallback)((val, ui) => {
2580
+ const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
2491
2581
  setLocalValue(val);
2492
2582
  onChangeDb(val, ui);
2493
2583
  }, []);
2494
- (0, import_react19.useEffect)(() => {
2584
+ (0, import_react20.useEffect)(() => {
2495
2585
  if (state.ui.field.focus !== props.name) {
2496
2586
  setLocalValue(value);
2497
2587
  }
@@ -2500,11 +2590,11 @@ function AutoFieldPrivate(props) {
2500
2590
  value: localValue,
2501
2591
  onChange: onChangeLocal
2502
2592
  };
2503
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2593
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2504
2594
  }
2505
2595
  function AutoField(props) {
2506
- const DefaultLabel = (0, import_react19.useMemo)(() => {
2507
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2596
+ const DefaultLabel = (0, import_react20.useMemo)(() => {
2597
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2508
2598
  "div",
2509
2599
  __spreadProps(__spreadValues({}, labelProps), {
2510
2600
  className: getClassName15({ readOnly: props.readOnly })
@@ -2512,7 +2602,7 @@ function AutoField(props) {
2512
2602
  );
2513
2603
  return DefaultLabel2;
2514
2604
  }, [props.readOnly]);
2515
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2605
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2516
2606
  }
2517
2607
 
2518
2608
  // components/Drawer/index.tsx
@@ -2523,64 +2613,38 @@ init_react_import();
2523
2613
  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" };
2524
2614
 
2525
2615
  // components/Drawer/index.tsx
2526
- var import_react27 = require("react");
2616
+ var import_react32 = require("react");
2527
2617
 
2528
2618
  // components/DragDropContext/index.tsx
2529
2619
  init_react_import();
2530
- var import_react25 = require("@dnd-kit/react");
2531
- var import_react26 = require("react");
2620
+ var import_react30 = require("@dnd-kit/react");
2621
+ var import_react31 = require("react");
2532
2622
  var import_dom = require("@dnd-kit/dom");
2533
2623
 
2534
2624
  // components/DropZone/index.tsx
2535
2625
  init_react_import();
2536
- var import_react24 = require("react");
2626
+ var import_react29 = require("react");
2537
2627
 
2538
2628
  // components/DraggableComponent/index.tsx
2539
2629
  init_react_import();
2540
- var import_react21 = require("react");
2630
+ var import_react23 = require("react");
2541
2631
 
2542
2632
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
2543
2633
  init_react_import();
2544
2634
  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" };
2545
2635
 
2546
- // lib/use-modifier-held.ts
2547
- init_react_import();
2548
- var import_react20 = require("react");
2549
- var useModifierHeld = (modifier) => {
2550
- const [modifierHeld, setModifierHeld] = (0, import_react20.useState)(false);
2551
- (0, import_react20.useEffect)(() => {
2552
- function downHandler({ key }) {
2553
- if (key === modifier) {
2554
- setModifierHeld(true);
2555
- }
2556
- }
2557
- function upHandler({ key }) {
2558
- if (key === modifier) {
2559
- setModifierHeld(false);
2560
- }
2561
- }
2562
- window.addEventListener("keydown", downHandler);
2563
- window.addEventListener("keyup", upHandler);
2564
- return () => {
2565
- window.removeEventListener("keydown", downHandler);
2566
- window.removeEventListener("keyup", upHandler);
2567
- };
2568
- }, [modifier]);
2569
- return modifierHeld;
2570
- };
2571
-
2572
2636
  // components/DraggableComponent/index.tsx
2573
2637
  var import_react_dom2 = require("react-dom");
2574
2638
 
2575
- // components/DraggableComponent/collision/dynamic/index.ts
2639
+ // lib/dnd/collision/dynamic/index.ts
2576
2640
  init_react_import();
2577
2641
  var import_abstract8 = require("@dnd-kit/abstract");
2578
2642
 
2579
- // components/DraggableComponent/collision/directional/index.ts
2643
+ // lib/dnd/collision/directional/index.ts
2580
2644
  init_react_import();
2581
2645
  var import_abstract = require("@dnd-kit/abstract");
2582
2646
 
2583
- // components/DraggableComponent/collision/collision-debug.ts
2647
+ // lib/dnd/collision/collision-debug.ts
2584
2648
  init_react_import();
2585
2649
  var DEBUG = false;
2586
2650
  var debugElements = {};
@@ -2629,7 +2693,7 @@ var collisionDebug = (a, b, id, color, label) => {
2629
2693
  });
2630
2694
  };
2631
2695
 
2632
- // components/DraggableComponent/collision/directional/index.ts
2696
+ // lib/dnd/collision/directional/index.ts
2633
2697
  var distanceChange = "increasing";
2634
2698
  var directionalCollision = (input, previous) => {
2635
2699
  var _a;
@@ -2662,7 +2726,7 @@ var directionalCollision = (input, previous) => {
2662
2726
  return null;
2663
2727
  };
2664
2728
 
2665
- // components/DraggableComponent/collision/dynamic/get-direction.ts
2729
+ // lib/dnd/collision/dynamic/get-direction.ts
2666
2730
  init_react_import();
2667
2731
  var getDirection = (dragAxis, delta) => {
2668
2732
  if (dragAxis === "dynamic") {
@@ -2677,7 +2741,7 @@ var getDirection = (dragAxis, delta) => {
2677
2741
  return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2678
2742
  };
2679
2743
 
2680
- // components/DraggableComponent/collision/dynamic/get-midpoint-impact.ts
2744
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
2681
2745
  init_react_import();
2682
2746
  var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
2683
2747
  const dragRect = dragShape.boundingRectangle;
@@ -2696,7 +2760,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2696
2760
  return dragRect.right - offset >= dropCenter.x;
2697
2761
  };
2698
2762
 
2699
- // components/DraggableComponent/collision/dynamic/track-movement-interval.ts
2763
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
2700
2764
  init_react_import();
2701
2765
  var import_geometry = require("@dnd-kit/geometry");
2702
2766
  var INTERVAL_SENSITIVITY = 10;
@@ -2800,7 +2864,14 @@ var closestCorners = (input) => {
2800
2864
  };
2801
2865
  };
2802
2866
 
2803
- // components/DraggableComponent/collision/dynamic/index.ts
2867
+ // lib/dnd/collision/dynamic/store.ts
2868
+ init_react_import();
2869
+ var import_vanilla = require("zustand/vanilla");
2870
+ var collisionStore = (0, import_vanilla.createStore)(() => ({
2871
+ fallbackEnabled: false
2872
+ }));
2873
+
2874
+ // lib/dnd/collision/dynamic/index.ts
2804
2875
  var flushNext = "";
2805
2876
  var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2806
2877
  var _a, _b, _c, _d, _e;
@@ -2812,6 +2883,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2812
2883
  return null;
2813
2884
  }
2814
2885
  const { center: dragCenter } = dragShape;
2886
+ const { fallbackEnabled } = collisionStore.getState();
2815
2887
  const interval = trackMovementInterval(position.current, dragAxis);
2816
2888
  dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2817
2889
  direction: interval.direction
@@ -2857,7 +2929,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2857
2929
  flushNext = "";
2858
2930
  return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2859
2931
  }
2860
- if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2932
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2861
2933
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2862
2934
  const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2863
2935
  if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
@@ -2918,8 +2990,102 @@ function getDeepScrollPosition(element) {
2918
2990
  return totalScroll;
2919
2991
  }
2920
2992
 
2993
+ // components/DropZone/context.tsx
2994
+ init_react_import();
2995
+ var import_react21 = require("react");
2996
+ var import_zustand = require("zustand");
2997
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2998
+ var dropZoneContext = (0, import_react21.createContext)(null);
2999
+ var ZoneStoreContext = (0, import_react21.createContext)(
3000
+ (0, import_zustand.createStore)(() => ({
3001
+ zoneDepthIndex: {},
3002
+ nextZoneDepthIndex: {},
3003
+ areaDepthIndex: {},
3004
+ nextAreaDepthIndex: {},
3005
+ draggedItem: null,
3006
+ previewIndex: {}
3007
+ }))
3008
+ );
3009
+ var ZoneStoreProvider = ({
3010
+ children,
3011
+ store
3012
+ }) => {
3013
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ZoneStoreContext.Provider, { value: store, children });
3014
+ };
3015
+ var DropZoneProvider = ({
3016
+ children,
3017
+ value
3018
+ }) => {
3019
+ const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
3020
+ const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
3021
+ {}
3022
+ );
3023
+ const [activeZones, setActiveZones] = (0, import_react21.useState)({});
3024
+ const { dispatch } = useAppContext();
3025
+ const registerZoneArea = (0, import_react21.useCallback)(
3026
+ (area) => {
3027
+ setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
3028
+ },
3029
+ [setAreasWithZones]
3030
+ );
3031
+ const registerZone = (0, import_react21.useCallback)(
3032
+ (zoneCompound) => {
3033
+ if (!dispatch) {
3034
+ return;
3035
+ }
3036
+ dispatch({
3037
+ type: "registerZone",
3038
+ zone: zoneCompound
3039
+ });
3040
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
3041
+ },
3042
+ [setActiveZones, dispatch]
3043
+ );
3044
+ const unregisterZone = (0, import_react21.useCallback)(
3045
+ (zoneCompound) => {
3046
+ if (!dispatch) {
3047
+ return;
3048
+ }
3049
+ dispatch({
3050
+ type: "unregisterZone",
3051
+ zone: zoneCompound
3052
+ });
3053
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
3054
+ [zoneCompound]: false
3055
+ }));
3056
+ },
3057
+ [setActiveZones, dispatch]
3058
+ );
3059
+ const memoValue = (0, import_react21.useMemo)(
3060
+ () => __spreadValues({
3061
+ hoveringComponent,
3062
+ setHoveringComponent,
3063
+ registerZoneArea,
3064
+ areasWithZones,
3065
+ registerZone,
3066
+ unregisterZone,
3067
+ activeZones
3068
+ }, value),
3069
+ [value, hoveringComponent, areasWithZones, activeZones]
3070
+ );
3071
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
3072
+ };
3073
+
3074
+ // lib/use-context-store.ts
3075
+ init_react_import();
3076
+ var import_react22 = require("react");
3077
+ var import_zustand2 = require("zustand");
3078
+ var import_shallow = require("zustand/react/shallow");
3079
+ function useContextStore(context, selector) {
3080
+ const store = (0, import_react22.useContext)(context);
3081
+ if (!store) {
3082
+ throw new Error("useContextStore must be used inside context");
3083
+ }
3084
+ return (0, import_zustand2.useStore)(store, (0, import_shallow.useShallow)(selector));
3085
+ }
3086
+
2921
3087
  // components/DraggableComponent/index.tsx
2922
- var import_jsx_runtime19 = require("react/jsx-runtime");
3088
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2923
3089
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
2924
3090
  var DEBUG2 = false;
2925
3091
  var space = 8;
@@ -2930,12 +3096,12 @@ var DefaultActionBar = ({
2930
3096
  label,
2931
3097
  children,
2932
3098
  parentAction
2933
- }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ActionBar, { children: [
2934
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ActionBar.Group, { children: [
3099
+ }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar, { children: [
3100
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar.Group, { children: [
2935
3101
  parentAction,
2936
- label && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Label, { label })
3102
+ label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Label, { label })
2937
3103
  ] }),
2938
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Group, { children })
3104
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Group, { children })
2939
3105
  ] });
2940
3106
  var convertIdToSelector = (id, zoneCompound, data) => {
2941
3107
  const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
@@ -2970,10 +3136,9 @@ var DraggableComponent = ({
2970
3136
  iframe,
2971
3137
  state
2972
3138
  } = useAppContext();
2973
- const isModifierHeld = useModifierHeld("Alt");
2974
- const ctx = (0, import_react21.useContext)(dropZoneContext);
2975
- const [localZones, setLocalZones] = (0, import_react21.useState)({});
2976
- const registerLocalZone = (0, import_react21.useCallback)(
3139
+ const ctx = (0, import_react23.useContext)(dropZoneContext);
3140
+ const [localZones, setLocalZones] = (0, import_react23.useState)({});
3141
+ const registerLocalZone = (0, import_react23.useCallback)(
2977
3142
  (zoneCompound2, active) => {
2978
3143
  var _a;
2979
3144
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -2983,7 +3148,7 @@ var DraggableComponent = ({
2983
3148
  },
2984
3149
  [setLocalZones]
2985
3150
  );
2986
- const unregisterLocalZone = (0, import_react21.useCallback)(
3151
+ const unregisterLocalZone = (0, import_react23.useCallback)(
2987
3152
  (zoneCompound2) => {
2988
3153
  var _a;
2989
3154
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -2997,8 +3162,8 @@ var DraggableComponent = ({
2997
3162
  );
2998
3163
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
2999
3164
  const { path = [] } = ctx || {};
3000
- const [canDrag, setCanDrag] = (0, import_react21.useState)(false);
3001
- (0, import_react21.useEffect)(() => {
3165
+ const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
3166
+ (0, import_react23.useEffect)(() => {
3002
3167
  var _a;
3003
3168
  const item = getItem({ index, zone: zoneCompound }, state.data);
3004
3169
  if (item) {
@@ -3008,10 +3173,13 @@ var DraggableComponent = ({
3008
3173
  setCanDrag((_a = perms.drag) != null ? _a : true);
3009
3174
  }
3010
3175
  }, [state, index, zoneCompound, getPermissions]);
3011
- const userIsDragging = !!(ctx == null ? void 0 : ctx.draggedItem);
3176
+ const userIsDragging = useContextStore(
3177
+ ZoneStoreContext,
3178
+ (s) => !!s.draggedItem
3179
+ );
3012
3180
  const canCollide = canDrag || userIsDragging;
3013
3181
  const disabled = !isEnabled || !canCollide;
3014
- const [dragAxis, setDragAxis] = (0, import_react21.useState)(userDragAxis || autoDragAxis);
3182
+ const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
3015
3183
  const { ref: sortableRef, status } = useSortableSafe({
3016
3184
  id,
3017
3185
  index,
@@ -3037,8 +3205,8 @@ var DraggableComponent = ({
3037
3205
  }
3038
3206
  });
3039
3207
  const thisIsDragging = status === "dragging";
3040
- const ref = (0, import_react21.useRef)(null);
3041
- const refSetter = (0, import_react21.useCallback)(
3208
+ const ref = (0, import_react23.useRef)(null);
3209
+ const refSetter = (0, import_react23.useCallback)(
3042
3210
  (el) => {
3043
3211
  sortableRef(el);
3044
3212
  if (el) {
@@ -3047,14 +3215,14 @@ var DraggableComponent = ({
3047
3215
  },
3048
3216
  [sortableRef]
3049
3217
  );
3050
- const [portalEl, setPortalEl] = (0, import_react21.useState)();
3051
- (0, import_react21.useEffect)(() => {
3218
+ const [portalEl, setPortalEl] = (0, import_react23.useState)();
3219
+ (0, import_react23.useEffect)(() => {
3052
3220
  var _a, _b, _c;
3053
3221
  setPortalEl(
3054
3222
  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
3055
3223
  );
3056
3224
  }, [iframe.enabled, ref.current]);
3057
- const getStyle = (0, import_react21.useCallback)(() => {
3225
+ const getStyle = (0, import_react23.useCallback)(() => {
3058
3226
  var _a, _b, _c;
3059
3227
  if (!ref.current) return;
3060
3228
  const rect = ref.current.getBoundingClientRect();
@@ -3074,11 +3242,11 @@ var DraggableComponent = ({
3074
3242
  };
3075
3243
  return style2;
3076
3244
  }, [ref.current]);
3077
- const [style, setStyle] = (0, import_react21.useState)();
3078
- const sync = (0, import_react21.useCallback)(() => {
3245
+ const [style, setStyle] = (0, import_react23.useState)();
3246
+ const sync = (0, import_react23.useCallback)(() => {
3079
3247
  setStyle(getStyle());
3080
3248
  }, [ref.current, iframe]);
3081
- (0, import_react21.useEffect)(() => {
3249
+ (0, import_react23.useEffect)(() => {
3082
3250
  if (ref.current) {
3083
3251
  const observer = new ResizeObserver(sync);
3084
3252
  observer.observe(ref.current);
@@ -3087,20 +3255,22 @@ var DraggableComponent = ({
3087
3255
  };
3088
3256
  }
3089
3257
  }, [ref.current]);
3090
- (0, import_react21.useEffect)(() => {
3091
- ctx == null ? void 0 : ctx.registerPath({
3092
- index,
3093
- zone: zoneCompound
3094
- });
3258
+ (0, import_react23.useEffect)(() => {
3259
+ if (isSelected) {
3260
+ ctx == null ? void 0 : ctx.registerPath({
3261
+ index,
3262
+ zone: zoneCompound
3263
+ });
3264
+ }
3095
3265
  }, [isSelected]);
3096
- const CustomActionBar = (0, import_react21.useMemo)(
3266
+ const CustomActionBar = (0, import_react23.useMemo)(
3097
3267
  () => overrides.actionBar || DefaultActionBar,
3098
3268
  [overrides.actionBar]
3099
3269
  );
3100
3270
  const permissions = getPermissions({
3101
3271
  item: selectedItem
3102
3272
  });
3103
- const onClick = (0, import_react21.useCallback)(
3273
+ const onClick = (0, import_react23.useCallback)(
3104
3274
  (e) => {
3105
3275
  e.stopPropagation();
3106
3276
  dispatch({
@@ -3112,7 +3282,7 @@ var DraggableComponent = ({
3112
3282
  },
3113
3283
  [index, zoneCompound, id]
3114
3284
  );
3115
- const onSelectParent = (0, import_react21.useCallback)(() => {
3285
+ const onSelectParent = (0, import_react23.useCallback)(() => {
3116
3286
  if (!(ctx == null ? void 0 : ctx.areaId)) {
3117
3287
  return;
3118
3288
  }
@@ -3130,23 +3300,23 @@ var DraggableComponent = ({
3130
3300
  }
3131
3301
  });
3132
3302
  }, [ctx, path]);
3133
- const onDuplicate = (0, import_react21.useCallback)(() => {
3303
+ const onDuplicate = (0, import_react23.useCallback)(() => {
3134
3304
  dispatch({
3135
3305
  type: "duplicate",
3136
3306
  sourceIndex: index,
3137
3307
  sourceZone: zoneCompound
3138
3308
  });
3139
3309
  }, [index, zoneCompound]);
3140
- const onDelete = (0, import_react21.useCallback)(() => {
3310
+ const onDelete = (0, import_react23.useCallback)(() => {
3141
3311
  dispatch({
3142
3312
  type: "remove",
3143
3313
  index,
3144
3314
  zone: zoneCompound
3145
3315
  });
3146
3316
  }, [index, zoneCompound]);
3147
- const [hover, setHover] = (0, import_react21.useState)(false);
3317
+ const [hover, setHover] = (0, import_react23.useState)(false);
3148
3318
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
3149
- (0, import_react21.useEffect)(() => {
3319
+ (0, import_react23.useEffect)(() => {
3150
3320
  if (!ref.current) {
3151
3321
  return;
3152
3322
  }
@@ -3196,7 +3366,7 @@ var DraggableComponent = ({
3196
3366
  thisIsDragging,
3197
3367
  inDroppableZone
3198
3368
  ]);
3199
- (0, import_react21.useEffect)(() => {
3369
+ (0, import_react23.useEffect)(() => {
3200
3370
  if (ref.current && disabled) {
3201
3371
  ref.current.setAttribute("data-puck-disabled", "");
3202
3372
  return () => {
@@ -3205,8 +3375,8 @@ var DraggableComponent = ({
3205
3375
  };
3206
3376
  }
3207
3377
  }, [disabled, ref]);
3208
- const [isVisible, setIsVisible] = (0, import_react21.useState)(false);
3209
- (0, import_react21.useEffect)(() => {
3378
+ const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
3379
+ (0, import_react23.useEffect)(() => {
3210
3380
  sync();
3211
3381
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
3212
3382
  setIsVisible(true);
@@ -3214,7 +3384,7 @@ var DraggableComponent = ({
3214
3384
  setIsVisible(false);
3215
3385
  }
3216
3386
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3217
- const syncActionsPosition = (0, import_react21.useCallback)(
3387
+ const syncActionsPosition = (0, import_react23.useCallback)(
3218
3388
  (el) => {
3219
3389
  if (el) {
3220
3390
  const view = el.ownerDocument.defaultView;
@@ -3231,7 +3401,7 @@ var DraggableComponent = ({
3231
3401
  },
3232
3402
  [zoomConfig]
3233
3403
  );
3234
- (0, import_react21.useEffect)(() => {
3404
+ (0, import_react23.useEffect)(() => {
3235
3405
  if (userDragAxis) {
3236
3406
  setDragAxis(userDragAxis);
3237
3407
  return;
@@ -3245,8 +3415,8 @@ var DraggableComponent = ({
3245
3415
  }
3246
3416
  setDragAxis(autoDragAxis);
3247
3417
  }, [ref, userDragAxis, autoDragAxis]);
3248
- const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CornerLeftUp, { size: 16 }) });
3249
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3418
+ const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CornerLeftUp, { size: 16 }) });
3419
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3250
3420
  DropZoneProvider,
3251
3421
  {
3252
3422
  value: __spreadProps(__spreadValues({}, ctx), {
@@ -3260,28 +3430,27 @@ var DraggableComponent = ({
3260
3430
  }),
3261
3431
  children: [
3262
3432
  isVisible && (0, import_react_dom2.createPortal)(
3263
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3433
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3264
3434
  "div",
3265
3435
  {
3266
3436
  className: getClassName16({
3267
3437
  isSelected,
3268
3438
  isDragging: thisIsDragging,
3269
- isModifierHeld,
3270
3439
  hover: hover || indicativeHover
3271
3440
  }),
3272
3441
  style: __spreadValues({}, style),
3273
3442
  "data-puck-overlay": true,
3274
3443
  children: [
3275
3444
  debug,
3276
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Loader, {}) }),
3277
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3445
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {}) }),
3446
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3278
3447
  "div",
3279
3448
  {
3280
3449
  className: getClassName16("actionsOverlay"),
3281
3450
  style: {
3282
3451
  top: actionsOverlayTop / zoomConfig.zoom
3283
3452
  },
3284
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3453
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3285
3454
  "div",
3286
3455
  {
3287
3456
  className: getClassName16("actions"),
@@ -3293,14 +3462,14 @@ var DraggableComponent = ({
3293
3462
  paddingRight: actionsSide
3294
3463
  },
3295
3464
  ref: syncActionsPosition,
3296
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3465
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3297
3466
  CustomActionBar,
3298
3467
  {
3299
3468
  parentAction,
3300
3469
  label: DEBUG2 ? id : label,
3301
3470
  children: [
3302
- permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Copy, { size: 16 }) }),
3303
- permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Trash, { size: 16 }) })
3471
+ permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Copy, { size: 16 }) }),
3472
+ permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Trash, { size: 16 }) })
3304
3473
  ]
3305
3474
  }
3306
3475
  )
@@ -3308,7 +3477,7 @@ var DraggableComponent = ({
3308
3477
  )
3309
3478
  }
3310
3479
  ),
3311
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("overlay") })
3480
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("overlay") })
3312
3481
  ]
3313
3482
  }
3314
3483
  ),
@@ -3324,96 +3493,29 @@ var DraggableComponent = ({
3324
3493
  init_react_import();
3325
3494
  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" };
3326
3495
 
3327
- // components/DropZone/context.tsx
3496
+ // components/DropZone/lib/use-min-empty-height.ts
3328
3497
  init_react_import();
3329
- var import_react22 = require("react");
3330
- var import_jsx_runtime20 = require("react/jsx-runtime");
3331
- var dropZoneContext = (0, import_react22.createContext)(null);
3332
- var DropZoneProvider = ({
3333
- children,
3334
- value
3498
+ var import_react24 = require("react");
3499
+ var useMinEmptyHeight = ({
3500
+ zoneCompound,
3501
+ userMinEmptyHeight,
3502
+ ref
3335
3503
  }) => {
3336
- const [hoveringComponent, setHoveringComponent] = (0, import_react22.useState)();
3337
- const [areasWithZones, setAreasWithZones] = (0, import_react22.useState)(
3338
- {}
3339
- );
3340
- const [activeZones, setActiveZones] = (0, import_react22.useState)({});
3341
- const { dispatch = null } = value ? value : {};
3342
- const registerZoneArea = (0, import_react22.useCallback)(
3343
- (area) => {
3344
- setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
3345
- },
3346
- [setAreasWithZones]
3347
- );
3348
- const registerZone = (0, import_react22.useCallback)(
3349
- (zoneCompound) => {
3350
- if (!dispatch) {
3351
- return;
3352
- }
3353
- dispatch({
3354
- type: "registerZone",
3355
- zone: zoneCompound
3356
- });
3357
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
3358
- },
3359
- [setActiveZones, dispatch]
3360
- );
3361
- const unregisterZone = (0, import_react22.useCallback)(
3362
- (zoneCompound) => {
3363
- if (!dispatch) {
3364
- return;
3365
- }
3366
- dispatch({
3367
- type: "unregisterZone",
3368
- zone: zoneCompound
3369
- });
3370
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
3371
- [zoneCompound]: false
3372
- }));
3373
- },
3374
- [setActiveZones, dispatch]
3375
- );
3376
- const memoValue = (0, import_react22.useMemo)(
3377
- () => __spreadValues({
3378
- hoveringComponent,
3379
- setHoveringComponent,
3380
- registerZoneArea,
3381
- areasWithZones,
3382
- registerZone,
3383
- unregisterZone,
3384
- activeZones
3385
- }, value),
3386
- [value, hoveringComponent, areasWithZones, activeZones]
3387
- );
3388
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
3389
- };
3390
-
3391
- // lib/insert.ts
3392
- init_react_import();
3393
- var insert = (list, index, item) => {
3394
- const result = Array.from(list);
3395
- result.splice(index, 0, item);
3396
- return result;
3397
- };
3398
-
3399
- // components/DropZone/use-min-empty-height.ts
3400
- init_react_import();
3401
- var import_react23 = require("react");
3402
- var useMinEmptyHeight = ({
3403
- draggedItem,
3404
- zoneCompound,
3405
- userMinEmptyHeight,
3406
- ref
3407
- }) => {
3408
- const [prevHeight, setPrevHeight] = (0, import_react23.useState)(0);
3409
- const [isAnimating, setIsAnimating] = (0, import_react23.useState)(false);
3410
- (0, import_react23.useEffect)(() => {
3411
- if (draggedItem && ref.current) {
3412
- const componentData = draggedItem.data;
3413
- if (componentData.zone === zoneCompound) {
3414
- const rect = ref.current.getBoundingClientRect();
3415
- setPrevHeight(rect.height);
3416
- setIsAnimating(true);
3504
+ const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
3505
+ const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
3506
+ const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3507
+ var _a, _b;
3508
+ return {
3509
+ draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
3510
+ isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3511
+ };
3512
+ });
3513
+ (0, import_react24.useEffect)(() => {
3514
+ if (draggedItem && ref.current) {
3515
+ if (isZone) {
3516
+ const rect = ref.current.getBoundingClientRect();
3517
+ setPrevHeight(rect.height);
3518
+ setIsAnimating(true);
3417
3519
  return;
3418
3520
  }
3419
3521
  }
@@ -3440,15 +3542,131 @@ function assignRefs(refs, node) {
3440
3542
  });
3441
3543
  }
3442
3544
 
3443
- // components/DropZone/index.tsx
3444
- var import_jsx_runtime21 = require("react/jsx-runtime");
3445
- var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3446
- var DEBUG3 = false;
3545
+ // components/DropZone/lib/use-content-with-preview.ts
3546
+ init_react_import();
3547
+ var import_react27 = require("react");
3548
+
3549
+ // lib/dnd/use-rendered-callback.ts
3550
+ init_react_import();
3551
+ var import_react25 = require("@dnd-kit/react");
3552
+ var import_react26 = require("react");
3553
+ function useRenderedCallback(callback, deps) {
3554
+ const manager = (0, import_react25.useDragDropManager)();
3555
+ return (0, import_react26.useCallback)(
3556
+ (...args) => __async(this, null, function* () {
3557
+ yield manager == null ? void 0 : manager.renderer.rendering;
3558
+ return callback(...args);
3559
+ }),
3560
+ [...deps, manager]
3561
+ );
3562
+ }
3563
+
3564
+ // lib/insert.ts
3565
+ init_react_import();
3566
+ var insert = (list, index, item) => {
3567
+ const result = Array.from(list);
3568
+ result.splice(index, 0, item);
3569
+ return result;
3570
+ };
3571
+
3572
+ // components/DropZone/lib/use-content-with-preview.ts
3573
+ var useContentWithPreview = (content, zoneCompound) => {
3574
+ const { draggedItemId, preview, previewExists } = useContextStore(
3575
+ ZoneStoreContext,
3576
+ (s) => {
3577
+ var _a;
3578
+ return {
3579
+ draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
3580
+ preview: s.previewIndex[zoneCompound],
3581
+ previewExists: Object.keys(s.previewIndex || {}).length > 0
3582
+ };
3583
+ }
3584
+ );
3585
+ const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
3586
+ const updateContent = useRenderedCallback(
3587
+ (content2, preview2) => {
3588
+ if (preview2) {
3589
+ if (preview2.type === "insert") {
3590
+ setContentWithPreview(
3591
+ insert(
3592
+ content2.filter((item) => item.props.id !== preview2.props.id),
3593
+ preview2.index,
3594
+ {
3595
+ type: "preview",
3596
+ props: { id: preview2.props.id }
3597
+ }
3598
+ )
3599
+ );
3600
+ } else {
3601
+ setContentWithPreview(
3602
+ insert(
3603
+ content2.filter((item) => item.props.id !== preview2.props.id),
3604
+ preview2.index,
3605
+ {
3606
+ type: preview2.componentType,
3607
+ props: preview2.props
3608
+ }
3609
+ )
3610
+ );
3611
+ }
3612
+ } else {
3613
+ setContentWithPreview(
3614
+ previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3615
+ );
3616
+ }
3617
+ },
3618
+ [draggedItemId, previewExists]
3619
+ );
3620
+ (0, import_react27.useEffect)(() => {
3621
+ updateContent(content, preview);
3622
+ }, [content, preview]);
3623
+ return contentWithPreview;
3624
+ };
3625
+
3626
+ // components/DropZone/lib/use-drag-axis.ts
3627
+ init_react_import();
3628
+ var import_react28 = require("react");
3447
3629
  var GRID_DRAG_AXIS = "dynamic";
3448
3630
  var FLEX_ROW_DRAG_AXIS = "x";
3449
3631
  var DEFAULT_DRAG_AXIS = "y";
3450
- var DropZoneEdit = (0, import_react24.forwardRef)(
3451
- function DropZoneEdit2({
3632
+ var useDragAxis = (ref, collisionAxis) => {
3633
+ const { status } = useAppContext();
3634
+ const [dragAxis, setDragAxis] = (0, import_react28.useState)(
3635
+ collisionAxis || DEFAULT_DRAG_AXIS
3636
+ );
3637
+ const calculateDragAxis = (0, import_react28.useCallback)(() => {
3638
+ if (ref.current) {
3639
+ const computedStyle = window.getComputedStyle(ref.current);
3640
+ if (computedStyle.display === "grid") {
3641
+ setDragAxis(GRID_DRAG_AXIS);
3642
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3643
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3644
+ } else {
3645
+ setDragAxis(DEFAULT_DRAG_AXIS);
3646
+ }
3647
+ }
3648
+ }, [ref.current]);
3649
+ (0, import_react28.useEffect)(() => {
3650
+ const onViewportChange = () => {
3651
+ calculateDragAxis();
3652
+ };
3653
+ window.addEventListener("viewportchange", onViewportChange);
3654
+ return () => {
3655
+ window.removeEventListener("viewportchange", onViewportChange);
3656
+ };
3657
+ }, []);
3658
+ (0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
3659
+ return [dragAxis, calculateDragAxis];
3660
+ };
3661
+
3662
+ // components/DropZone/index.tsx
3663
+ var import_jsx_runtime22 = require("react/jsx-runtime");
3664
+ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3665
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3666
+ var RENDER_DEBUG = false;
3667
+ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
3668
+ var DropZoneEdit = (0, import_react29.forwardRef)(
3669
+ function DropZoneEditInternal({
3452
3670
  zone,
3453
3671
  allow,
3454
3672
  disallow,
@@ -3458,31 +3676,50 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
3458
3676
  collisionAxis
3459
3677
  }, userRef) {
3460
3678
  const appContext2 = useAppContext();
3461
- const ctx = (0, import_react24.useContext)(dropZoneContext);
3679
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
3462
3680
  const {
3463
3681
  // These all need setting via context
3464
3682
  data,
3465
3683
  config,
3466
3684
  areaId,
3467
- draggedItem,
3468
3685
  registerZoneArea,
3469
3686
  depth,
3470
3687
  registerLocalZone,
3471
3688
  unregisterLocalZone,
3472
- deepestZone = rootDroppableId,
3473
- deepestArea,
3474
- nextDeepestArea,
3475
3689
  path = [],
3476
3690
  activeZones
3477
3691
  } = ctx;
3478
- const { itemSelector } = appContext2.state.ui;
3479
3692
  let zoneCompound = rootDroppableId;
3480
- (0, import_react24.useEffect)(() => {
3693
+ if (areaId) {
3694
+ if (zone !== rootDroppableId) {
3695
+ zoneCompound = `${areaId}:${zone}`;
3696
+ }
3697
+ }
3698
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3699
+ const {
3700
+ isDeepestZone,
3701
+ inNextDeepestArea,
3702
+ draggedComponentType,
3703
+ userIsDragging,
3704
+ preview
3705
+ } = useContextStore(ZoneStoreContext, (s) => {
3706
+ var _a, _b, _c;
3707
+ return {
3708
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3709
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3710
+ draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3711
+ draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3712
+ userIsDragging: !!s.draggedItem,
3713
+ preview: s.previewIndex[zoneCompound]
3714
+ };
3715
+ });
3716
+ const { itemSelector } = appContext2.state.ui;
3717
+ (0, import_react29.useEffect)(() => {
3481
3718
  if (areaId && registerZoneArea) {
3482
3719
  registerZoneArea(areaId);
3483
3720
  }
3484
3721
  }, [areaId]);
3485
- (0, import_react24.useEffect)(() => {
3722
+ (0, import_react29.useEffect)(() => {
3486
3723
  if (ctx == null ? void 0 : ctx.registerZone) {
3487
3724
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3488
3725
  }
@@ -3492,25 +3729,18 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
3492
3729
  }
3493
3730
  };
3494
3731
  }, []);
3495
- if (areaId) {
3496
- if (zone !== rootDroppableId) {
3497
- zoneCompound = `${areaId}:${zone}`;
3498
- }
3499
- }
3500
- const content = (0, import_react24.useMemo)(() => {
3732
+ const content = (0, import_react29.useMemo)(() => {
3501
3733
  if (areaId && zone !== rootDroppableId) {
3502
3734
  return setupZone(data, zoneCompound).zones[zoneCompound];
3503
3735
  }
3504
3736
  return data.content || [];
3505
3737
  }, [data, zoneCompound]);
3506
- const ref = (0, import_react24.useRef)(null);
3507
- const acceptsTarget = (0, import_react24.useCallback)(
3508
- (target) => {
3509
- if (!target) {
3738
+ const ref = (0, import_react29.useRef)(null);
3739
+ const acceptsTarget = (0, import_react29.useCallback)(
3740
+ (componentType) => {
3741
+ if (!componentType) {
3510
3742
  return true;
3511
3743
  }
3512
- const data2 = target.data;
3513
- const { componentType } = data2;
3514
3744
  if (disallow) {
3515
3745
  const defaultedAllow = allow || [];
3516
3746
  const filteredDisallow = (disallow || []).filter(
@@ -3528,49 +3758,26 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
3528
3758
  },
3529
3759
  [allow, disallow]
3530
3760
  );
3531
- (0, import_react24.useEffect)(() => {
3761
+ (0, import_react29.useEffect)(() => {
3532
3762
  if (registerLocalZone) {
3533
- registerLocalZone(zoneCompound, acceptsTarget(draggedItem));
3763
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3534
3764
  }
3535
3765
  return () => {
3536
3766
  if (unregisterLocalZone) {
3537
3767
  unregisterLocalZone(zoneCompound);
3538
3768
  }
3539
3769
  };
3540
- }, [draggedItem, zoneCompound]);
3541
- const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3542
- const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
3543
- const userIsDragging = !!draggedItem;
3770
+ }, [draggedComponentType, zoneCompound]);
3771
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3544
3772
  let isEnabled = true;
3545
- if (draggedItem) {
3546
- isEnabled = deepestZone === zoneCompound;
3773
+ if (userIsDragging) {
3774
+ isEnabled = isDeepestZone;
3547
3775
  }
3548
3776
  if (isEnabled) {
3549
- isEnabled = acceptsTarget(draggedItem);
3550
- }
3551
- const preview = (0, import_react24.useContext)(previewContext);
3552
- const previewInZone = (preview == null ? void 0 : preview.zone) === zoneCompound;
3553
- const contentWithPreview = (0, import_react24.useMemo)(() => {
3554
- let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
3555
- if (previewInZone) {
3556
- contentWithPreview2 = content.filter(
3557
- (item) => item.props.id !== preview.props.id
3558
- );
3559
- if (preview.type === "insert") {
3560
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3561
- type: "preview",
3562
- props: { id: preview.props.id }
3563
- });
3564
- } else {
3565
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3566
- type: preview.componentType,
3567
- props: preview.props
3568
- });
3569
- }
3570
- }
3571
- return contentWithPreview2;
3572
- }, [preview, content]);
3573
- const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3777
+ isEnabled = acceptsTarget(draggedComponentType);
3778
+ }
3779
+ const contentWithPreview = useContentWithPreview(content, zoneCompound);
3780
+ const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3574
3781
  const droppableConfig = {
3575
3782
  id: zoneCompound,
3576
3783
  collisionPriority: isEnabled ? depth : 0,
@@ -3580,45 +3787,20 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
3580
3787
  data: {
3581
3788
  areaId,
3582
3789
  depth,
3583
- isDroppableTarget: acceptsTarget(draggedItem),
3790
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3584
3791
  path
3585
3792
  }
3586
3793
  };
3587
3794
  const { ref: dropRef } = useDroppableSafe(droppableConfig);
3588
3795
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3589
3796
  const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
3590
- const [dragAxis, setDragAxis] = (0, import_react24.useState)(
3591
- collisionAxis || DEFAULT_DRAG_AXIS
3592
- );
3593
- const calculateDragAxis = (0, import_react24.useCallback)(() => {
3594
- if (ref.current) {
3595
- const computedStyle = window.getComputedStyle(ref.current);
3596
- if (computedStyle.display === "grid") {
3597
- setDragAxis(GRID_DRAG_AXIS);
3598
- } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3599
- setDragAxis(FLEX_ROW_DRAG_AXIS);
3600
- } else {
3601
- setDragAxis(DEFAULT_DRAG_AXIS);
3602
- }
3603
- }
3604
- }, [ref.current]);
3605
- (0, import_react24.useEffect)(calculateDragAxis, [appContext2.status, collisionAxis]);
3606
- (0, import_react24.useEffect)(() => {
3607
- const onViewportChange = () => {
3608
- calculateDragAxis();
3609
- };
3610
- window.addEventListener("viewportchange", onViewportChange);
3611
- return () => {
3612
- window.removeEventListener("viewportchange", onViewportChange);
3613
- };
3614
- }, []);
3797
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3615
3798
  const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3616
- draggedItem,
3617
3799
  zoneCompound,
3618
3800
  userMinEmptyHeight,
3619
3801
  ref
3620
3802
  });
3621
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3803
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3622
3804
  "div",
3623
3805
  {
3624
3806
  className: `${getClassName17({
@@ -3638,87 +3820,93 @@ var DropZoneEdit = (0, import_react24.forwardRef)(
3638
3820
  "data-puck-dropzone": zoneCompound,
3639
3821
  "data-puck-dnd": zoneCompound,
3640
3822
  style: __spreadProps(__spreadValues({}, style), {
3641
- "--min-empty-height": `${minEmptyHeight}px`
3823
+ "--min-empty-height": `${minEmptyHeight}px`,
3824
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3642
3825
  }),
3643
- children: [
3644
- isRootZone && DEBUG3 && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { "data-puck-component": true, children: [
3645
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: deepestZone || rootDroppableId }),
3646
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: deepestArea || "No area" })
3647
- ] }),
3648
- contentWithPreview.map((item, i) => {
3649
- var _a, _b, _c, _d, _e;
3650
- const componentId = item.props.id;
3651
- const puckProps = {
3652
- renderDropZone: DropZone,
3653
- isEditing: true,
3654
- dragRef: null
3826
+ children: contentWithPreview.map((item, i) => {
3827
+ var _a, _b, _c, _d, _e, _f, _g;
3828
+ const componentId = item.props.id;
3829
+ const puckProps = {
3830
+ renderDropZone: DropZoneEditPure,
3831
+ isEditing: true,
3832
+ dragRef: null
3833
+ };
3834
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3835
+ puck: puckProps,
3836
+ editMode: true
3837
+ // DEPRECATED
3838
+ });
3839
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3840
+ let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
3841
+ "No configuration for ",
3842
+ item.type
3843
+ ] });
3844
+ const componentConfig = config.components[item.type];
3845
+ let componentType = item.type;
3846
+ let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3847
+ if (item.type === "preview") {
3848
+ let Preview4 = function() {
3849
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3655
3850
  };
3656
- const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3657
- puck: puckProps,
3658
- editMode: true
3659
- // DEPRECATED
3660
- });
3661
- const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3662
- let Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
3663
- "No configuration for ",
3664
- item.type
3665
- ] });
3666
- const componentConfig = config.components[item.type];
3667
- let componentType = item.type;
3668
- let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3669
- if (item.type === "preview") {
3670
- let Preview3 = function() {
3671
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DrawerItemInner, { name: label });
3672
- };
3673
- var Preview2 = Preview3;
3674
- componentType = preview.componentType;
3675
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3676
- Render2 = Preview3;
3677
- }
3678
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3679
- DropZoneProvider,
3680
- {
3681
- value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3682
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3683
- DraggableComponent,
3684
- {
3685
- id: componentId,
3686
- componentType,
3687
- zoneCompound,
3688
- depth: depth + 1,
3689
- index: i,
3690
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3691
- isSelected,
3692
- label,
3693
- isEnabled,
3694
- autoDragAxis: dragAxis,
3695
- userDragAxis: collisionAxis,
3696
- inDroppableZone: acceptsTarget(draggedItem),
3697
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3698
- Render2,
3699
- __spreadProps(__spreadValues({}, defaultedProps), {
3700
- puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3701
- dragRef
3702
- })
3851
+ var Preview3 = Preview4;
3852
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3853
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3854
+ Render2 = Preview4;
3855
+ }
3856
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3857
+ DropZoneProvider,
3858
+ {
3859
+ value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3860
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3861
+ DraggableComponent,
3862
+ {
3863
+ id: componentId,
3864
+ componentType,
3865
+ zoneCompound,
3866
+ depth: depth + 1,
3867
+ index: i,
3868
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3869
+ isSelected,
3870
+ label,
3871
+ isEnabled,
3872
+ autoDragAxis: dragAxis,
3873
+ userDragAxis: collisionAxis,
3874
+ inDroppableZone: acceptsTarget(draggedComponentType),
3875
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3876
+ Render2,
3877
+ __spreadProps(__spreadValues({}, defaultedProps), {
3878
+ puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3879
+ dragRef
3703
3880
  })
3704
- ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Render2, __spreadValues({}, defaultedProps)) })
3705
- }
3706
- )
3707
- },
3708
- componentId
3709
- );
3710
- })
3711
- ]
3881
+ })
3882
+ ) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Render2, __spreadValues({}, defaultedProps)) })
3883
+ }
3884
+ )
3885
+ },
3886
+ componentId
3887
+ );
3888
+ })
3712
3889
  }
3713
3890
  );
3714
3891
  }
3715
3892
  );
3716
- var DropZoneRender = (0, import_react24.forwardRef)(
3717
- function DropZoneRender2({ className, style, zone }, ref) {
3718
- const ctx = (0, import_react24.useContext)(dropZoneContext);
3893
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
3894
+ var DropZoneRender = (0, import_react29.forwardRef)(
3895
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3896
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
3719
3897
  const { data, areaId = "root", config } = ctx || {};
3720
3898
  let zoneCompound = rootDroppableId;
3721
3899
  let content = (data == null ? void 0 : data.content) || [];
3900
+ (0, import_react29.useEffect)(() => {
3901
+ if (ctx == null ? void 0 : ctx.registerZone) {
3902
+ ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3903
+ }
3904
+ return () => {
3905
+ if (ctx == null ? void 0 : ctx.unregisterZone) {
3906
+ ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
3907
+ }
3908
+ };
3909
+ }, []);
3722
3910
  if (!data || !config) {
3723
3911
  return null;
3724
3912
  }
@@ -3726,10 +3914,10 @@ var DropZoneRender = (0, import_react24.forwardRef)(
3726
3914
  zoneCompound = `${areaId}:${zone}`;
3727
3915
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3728
3916
  }
3729
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
3917
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
3730
3918
  const Component = config.components[item.type];
3731
3919
  if (Component) {
3732
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3920
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3733
3921
  DropZoneProvider,
3734
3922
  {
3735
3923
  value: {
@@ -3739,10 +3927,12 @@ var DropZoneRender = (0, import_react24.forwardRef)(
3739
3927
  depth: 1,
3740
3928
  path: []
3741
3929
  },
3742
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3930
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3743
3931
  Component.render,
3744
3932
  __spreadProps(__spreadValues({}, item.props), {
3745
- puck: { renderDropZone: DropZoneRender2 }
3933
+ puck: {
3934
+ renderDropZone: DropZoneRenderPure
3935
+ }
3746
3936
  })
3747
3937
  )
3748
3938
  },
@@ -3753,13 +3943,13 @@ var DropZoneRender = (0, import_react24.forwardRef)(
3753
3943
  }) });
3754
3944
  }
3755
3945
  );
3756
- var DropZone = (0, import_react24.forwardRef)(
3946
+ var DropZone = (0, import_react29.forwardRef)(
3757
3947
  function DropZone2(props, ref) {
3758
- const ctx = (0, import_react24.useContext)(dropZoneContext);
3948
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
3759
3949
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3760
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3950
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3761
3951
  }
3762
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3952
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3763
3953
  }
3764
3954
  );
3765
3955
 
@@ -3775,7 +3965,7 @@ var getZoneId = (zoneCompound) => {
3775
3965
  return [rootDroppableId, zoneCompound];
3776
3966
  };
3777
3967
 
3778
- // components/DragDropContext/NestedDroppablePlugin.ts
3968
+ // lib/dnd/NestedDroppablePlugin.ts
3779
3969
  init_react_import();
3780
3970
  var import_abstract9 = require("@dnd-kit/abstract");
3781
3971
  var import_state = require("@dnd-kit/state");
@@ -3817,7 +4007,49 @@ var getFrame = () => {
3817
4007
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3818
4008
  };
3819
4009
 
3820
- // components/DragDropContext/NestedDroppablePlugin.ts
4010
+ // lib/global-position.ts
4011
+ init_react_import();
4012
+ var GlobalPosition = class {
4013
+ constructor(target, original) {
4014
+ this.scaleFactor = 1;
4015
+ this.frameEl = null;
4016
+ this.frameRect = null;
4017
+ var _a;
4018
+ this.target = target;
4019
+ this.original = original;
4020
+ this.frameEl = document.querySelector("iframe");
4021
+ if (this.frameEl) {
4022
+ this.frameRect = this.frameEl.getBoundingClientRect();
4023
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
4024
+ }
4025
+ }
4026
+ get x() {
4027
+ return this.original.x;
4028
+ }
4029
+ get y() {
4030
+ return this.original.y;
4031
+ }
4032
+ get global() {
4033
+ if (document !== this.target.ownerDocument && this.frameRect) {
4034
+ return {
4035
+ x: this.x * this.scaleFactor + this.frameRect.left,
4036
+ y: this.y * this.scaleFactor + this.frameRect.top
4037
+ };
4038
+ }
4039
+ return this.original;
4040
+ }
4041
+ get frame() {
4042
+ if (document === this.target.ownerDocument && this.frameRect) {
4043
+ return {
4044
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
4045
+ y: (this.y - this.frameRect.top) / this.scaleFactor
4046
+ };
4047
+ }
4048
+ return this.original;
4049
+ }
4050
+ };
4051
+
4052
+ // lib/dnd/NestedDroppablePlugin.ts
3821
4053
  var depthSort = (candidates) => {
3822
4054
  return candidates.sort((a, b) => {
3823
4055
  const aData = a.data;
@@ -3846,10 +4078,12 @@ var getZoneId2 = (candidate) => {
3846
4078
  }
3847
4079
  return id;
3848
4080
  };
3849
- var getPointerCollisions = (position, manager, ownerDocument) => {
3850
- var _a;
4081
+ var getPointerCollisions = (position, manager) => {
3851
4082
  const candidates = [];
3852
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
4083
+ let elements = position.target.ownerDocument.elementsFromPoint(
4084
+ position.x,
4085
+ position.y
4086
+ );
3853
4087
  const previewFrame = elements.find(
3854
4088
  (el) => el.getAttribute("data-puck-preview")
3855
4089
  );
@@ -3858,17 +4092,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3858
4092
  elements = [drawer];
3859
4093
  }
3860
4094
  if (previewFrame) {
3861
- const iframe = previewFrame.querySelector("iframe");
3862
- if (iframe) {
3863
- const rect = iframe.getBoundingClientRect();
3864
- const frame = getFrame();
3865
- if (frame) {
3866
- const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3867
- elements = frame.elementsFromPoint(
3868
- (position.x - rect.left) / scaleFactor,
3869
- (position.y - rect.top) / scaleFactor
3870
- );
3871
- }
4095
+ const frame = getFrame();
4096
+ if (frame) {
4097
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3872
4098
  }
3873
4099
  }
3874
4100
  if (elements) {
@@ -3885,9 +4111,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3885
4111
  }
3886
4112
  return candidates;
3887
4113
  };
3888
- var findDeepestCandidate = (position, manager, ownerDocument) => {
4114
+ var findDeepestCandidate = (position, manager) => {
3889
4115
  var _a;
3890
- const candidates = getPointerCollisions(position, manager, ownerDocument);
4116
+ const candidates = getPointerCollisions(position, manager);
3891
4117
  if (candidates.length > 0) {
3892
4118
  const sortedCandidates = depthSort(candidates);
3893
4119
  const draggable = manager.dragOperation.source;
@@ -3932,9 +4158,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
3932
4158
  area: null
3933
4159
  };
3934
4160
  };
3935
- var createNestedDroppablePlugin = ({
3936
- onChange
3937
- }) => class NestedDroppablePlugin extends import_abstract9.Plugin {
4161
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
3938
4162
  constructor(manager, options) {
3939
4163
  super(manager);
3940
4164
  if (typeof window === "undefined") {
@@ -3942,16 +4166,19 @@ var createNestedDroppablePlugin = ({
3942
4166
  }
3943
4167
  const cleanupEffect = (0, import_state.effects)(() => {
3944
4168
  const handleMove = (event) => {
3945
- const position = {
4169
+ const target = event.originalTarget || event.target;
4170
+ const position = new GlobalPosition(target, {
3946
4171
  x: event.clientX,
3947
4172
  y: event.clientY
3948
- };
3949
- const target = event.originalTarget || event.target;
3950
- const ownerDocument = target == null ? void 0 : target.ownerDocument;
3951
- onChange(
3952
- findDeepestCandidate(position, manager, ownerDocument),
3953
- manager
4173
+ });
4174
+ const elements = document.elementsFromPoint(
4175
+ position.global.x,
4176
+ position.global.y
3954
4177
  );
4178
+ const overEl = elements.some((el) => el.id === id);
4179
+ if (overEl) {
4180
+ onChange(findDeepestCandidate(position, manager), manager);
4181
+ }
3955
4182
  };
3956
4183
  const handleMoveThrottled = throttle(handleMove, 50);
3957
4184
  const handlePointerMove = (event) => {
@@ -4281,6 +4508,11 @@ var reduceUi = (ui, action) => {
4281
4508
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4282
4509
  });
4283
4510
  }
4511
+ if (action.type === "remove") {
4512
+ return __spreadProps(__spreadValues({}, ui), {
4513
+ itemSelector: null
4514
+ });
4515
+ }
4284
4516
  return ui;
4285
4517
  };
4286
4518
 
@@ -4368,7 +4600,7 @@ var insertComponent = (componentType, zone, index, {
4368
4600
  var import_use_debounce2 = require("use-debounce");
4369
4601
  var import_utilities2 = require("@dnd-kit/dom/utilities");
4370
4602
 
4371
- // components/DragDropContext/PointerSensor.ts
4603
+ // lib/dnd/PointerSensor.ts
4372
4604
  init_react_import();
4373
4605
  var import_state3 = require("@dnd-kit/state");
4374
4606
  var import_abstract10 = require("@dnd-kit/abstract");
@@ -4531,6 +4763,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
4531
4763
  }
4532
4764
  }
4533
4765
  handlePointerUp(event) {
4766
+ if (!this.source) {
4767
+ return;
4768
+ }
4534
4769
  event.preventDefault();
4535
4770
  event.stopPropagation();
4536
4771
  const { status } = this.manager.dragOperation;
@@ -4630,13 +4865,15 @@ function patchWindow(window2) {
4630
4865
  }
4631
4866
 
4632
4867
  // components/DragDropContext/index.tsx
4633
- var import_jsx_runtime22 = require("react/jsx-runtime");
4634
- var dragListenerContext = (0, import_react26.createContext)({
4868
+ var import_zustand3 = require("zustand");
4869
+ var import_jsx_runtime23 = require("react/jsx-runtime");
4870
+ var DEBUG3 = false;
4871
+ var dragListenerContext = (0, import_react31.createContext)({
4635
4872
  dragListeners: {}
4636
4873
  });
4637
4874
  function useDragListener(type, fn, deps = []) {
4638
- const { setDragListeners } = (0, import_react26.useContext)(dragListenerContext);
4639
- (0, import_react26.useEffect)(() => {
4875
+ const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
4876
+ (0, import_react31.useEffect)(() => {
4640
4877
  if (setDragListeners) {
4641
4878
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
4642
4879
  [type]: [...old[type] || [], fn]
@@ -4644,80 +4881,147 @@ function useDragListener(type, fn, deps = []) {
4644
4881
  }
4645
4882
  }, deps);
4646
4883
  }
4647
- var previewContext = (0, import_react26.createContext)(null);
4648
4884
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4885
+ var useTempDisableFallback = (timeout3) => {
4886
+ const lastFallbackDisable = (0, import_react31.useRef)(null);
4887
+ return (0, import_react31.useCallback)((manager) => {
4888
+ collisionStore.setState({ fallbackEnabled: false });
4889
+ const fallbackId = generateId();
4890
+ lastFallbackDisable.current = fallbackId;
4891
+ setTimeout(() => {
4892
+ if (lastFallbackDisable.current === fallbackId) {
4893
+ collisionStore.setState({ fallbackEnabled: true });
4894
+ manager.collisionObserver.forceUpdate(true);
4895
+ }
4896
+ }, timeout3);
4897
+ }, []);
4898
+ };
4649
4899
  var DragDropContextClient = ({
4650
4900
  children,
4651
4901
  disableAutoScroll
4652
4902
  }) => {
4653
4903
  const { state, config, dispatch, resolveData } = useAppContext();
4654
- const [preview, setPreview] = (0, import_react26.useState)(null);
4655
- const previewRef = (0, import_react26.useRef)(null);
4904
+ const id = (0, import_react31.useId)();
4656
4905
  const { data } = state;
4657
- const [deepest, setDeepest] = (0, import_react26.useState)(null);
4658
- const [nextDeepest, setNextDeepest] = (0, import_react26.useState)(null);
4659
- const deepestRef = (0, import_react26.useRef)(deepest);
4660
- const debouncedParamsRef = (0, import_react26.useRef)(null);
4661
- const setDeepestAndCollide = (0, import_react26.useCallback)(
4906
+ const debouncedParamsRef = (0, import_react31.useRef)(null);
4907
+ const tempDisableFallback = useTempDisableFallback(100);
4908
+ const [zoneStore] = (0, import_react31.useState)(
4909
+ () => (0, import_zustand3.createStore)(() => ({
4910
+ zoneDepthIndex: {},
4911
+ nextZoneDepthIndex: {},
4912
+ areaDepthIndex: {},
4913
+ nextAreaDepthIndex: {},
4914
+ draggedItem: null,
4915
+ previewIndex: {}
4916
+ }))
4917
+ );
4918
+ const getChanged2 = (0, import_react31.useCallback)(
4919
+ (params, id2) => {
4920
+ const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
4921
+ const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
4922
+ const stateHasArea = Object.keys(areaDepthIndex).length > 0;
4923
+ let zoneChanged = false;
4924
+ let areaChanged = false;
4925
+ if (params.zone && !zoneDepthIndex[params.zone]) {
4926
+ zoneChanged = true;
4927
+ } else if (!params.zone && stateHasZone) {
4928
+ zoneChanged = true;
4929
+ }
4930
+ if (params.area && !areaDepthIndex[params.area]) {
4931
+ areaChanged = true;
4932
+ } else if (!params.area && stateHasArea) {
4933
+ areaChanged = true;
4934
+ }
4935
+ return { zoneChanged, areaChanged };
4936
+ },
4937
+ [zoneStore]
4938
+ );
4939
+ const setDeepestAndCollide = (0, import_react31.useCallback)(
4662
4940
  (params, manager) => {
4663
- setDeepest(params);
4941
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4942
+ if (!zoneChanged && !areaChanged) return;
4943
+ zoneStore.setState({
4944
+ zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
4945
+ areaDepthIndex: params.area ? { [params.area]: true } : {}
4946
+ });
4947
+ tempDisableFallback(manager);
4664
4948
  setTimeout(() => {
4665
4949
  manager.collisionObserver.forceUpdate(true);
4666
4950
  }, 50);
4667
4951
  debouncedParamsRef.current = null;
4668
4952
  },
4669
- []
4953
+ [zoneStore]
4670
4954
  );
4671
4955
  const setDeepestDb = (0, import_use_debounce2.useDebouncedCallback)(
4672
4956
  setDeepestAndCollide,
4673
4957
  AREA_CHANGE_DEBOUNCE_MS
4674
4958
  );
4675
- (0, import_react26.useEffect)(() => {
4676
- deepestRef.current = deepest;
4677
- }, [deepest]);
4678
4959
  const cancelDb = () => {
4679
4960
  setDeepestDb.cancel();
4680
4961
  debouncedParamsRef.current = null;
4681
4962
  };
4682
- const [plugins] = (0, import_react26.useState)(() => [
4683
- ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
4684
- createNestedDroppablePlugin({
4685
- onChange: (params, manager) => {
4686
- const lastParams = deepestRef.current;
4687
- const areaChanged = params.area !== (lastParams == null ? void 0 : lastParams.area);
4688
- const zoneChanged = params.zone !== (lastParams == null ? void 0 : lastParams.zone);
4689
- const isDragging = manager.dragOperation.status.dragging;
4690
- if (areaChanged || zoneChanged) {
4691
- setNextDeepest(params);
4692
- }
4693
- if (params.zone !== "void" && (lastParams == null ? void 0 : lastParams.zone) === "void") {
4694
- setDeepest(params);
4695
- manager.collisionObserver.forceUpdate(true);
4696
- return;
4963
+ (0, import_react31.useEffect)(() => {
4964
+ if (DEBUG3) {
4965
+ zoneStore.subscribe(
4966
+ (s) => {
4967
+ var _a, _b;
4968
+ return console.log(
4969
+ s.previewIndex,
4970
+ (_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
4971
+ (_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
4972
+ );
4697
4973
  }
4698
- if (areaChanged) {
4699
- if (isDragging) {
4700
- const debouncedParams = debouncedParamsRef.current;
4701
- const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4702
- if (!isSameParams) {
4974
+ );
4975
+ }
4976
+ }, []);
4977
+ const [plugins] = (0, import_react31.useState)(() => [
4978
+ ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
4979
+ createNestedDroppablePlugin(
4980
+ {
4981
+ onChange: (params, manager) => {
4982
+ const state2 = zoneStore.getState();
4983
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4984
+ const isDragging = manager.dragOperation.status.dragging;
4985
+ if (areaChanged || zoneChanged) {
4986
+ let nextZoneDepthIndex = {};
4987
+ let nextAreaDepthIndex = {};
4988
+ if (params.zone) {
4989
+ nextZoneDepthIndex = { [params.zone]: true };
4990
+ }
4991
+ if (params.area) {
4992
+ nextAreaDepthIndex = { [params.area]: true };
4993
+ }
4994
+ zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
4995
+ }
4996
+ if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
4997
+ setDeepestAndCollide(params, manager);
4998
+ return;
4999
+ }
5000
+ if (areaChanged) {
5001
+ if (isDragging) {
5002
+ const debouncedParams = debouncedParamsRef.current;
5003
+ const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
5004
+ if (!isSameParams) {
5005
+ cancelDb();
5006
+ setDeepestDb(params, manager);
5007
+ debouncedParamsRef.current = params;
5008
+ }
5009
+ } else {
4703
5010
  cancelDb();
4704
- setDeepestDb(params, manager);
4705
- debouncedParamsRef.current = params;
5011
+ setDeepestAndCollide(params, manager);
4706
5012
  }
4707
- } else {
4708
- cancelDb();
5013
+ return;
5014
+ }
5015
+ if (zoneChanged) {
4709
5016
  setDeepestAndCollide(params, manager);
4710
5017
  }
4711
- return;
5018
+ cancelDb();
4712
5019
  }
4713
- if (zoneChanged) {
4714
- setDeepestAndCollide(params, manager);
4715
- }
4716
- cancelDb();
4717
- }
4718
- })
5020
+ },
5021
+ id
5022
+ )
4719
5023
  ]);
4720
- const [sensors] = (0, import_react26.useState)(() => [
5024
+ const [sensors] = (0, import_react31.useState)(() => [
4721
5025
  PointerSensor.configure({
4722
5026
  activationConstraints(event, source) {
4723
5027
  var _a;
@@ -4736,11 +5040,10 @@ var DragDropContextClient = ({
4736
5040
  }
4737
5041
  })
4738
5042
  ]);
4739
- const [draggedItem, setDraggedItem] = (0, import_react26.useState)();
4740
- const [dragListeners, setDragListeners] = (0, import_react26.useState)({});
4741
- const [pathData, setPathData] = (0, import_react26.useState)();
4742
- const dragMode = (0, import_react26.useRef)(null);
4743
- const registerPath = (0, import_react26.useCallback)(
5043
+ const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
5044
+ const [pathData, setPathData] = (0, import_react31.useState)();
5045
+ const dragMode = (0, import_react31.useRef)(null);
5046
+ const registerPath = (0, import_react31.useCallback)(
4744
5047
  (selector) => {
4745
5048
  const item = getItem(selector, data);
4746
5049
  if (!item) {
@@ -4762,41 +5065,41 @@ var DragDropContextClient = ({
4762
5065
  },
4763
5066
  [data, setPathData]
4764
5067
  );
4765
- const initialSelector = (0, import_react26.useRef)(void 0);
4766
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5068
+ const initialSelector = (0, import_react31.useRef)(void 0);
5069
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4767
5070
  dragListenerContext.Provider,
4768
5071
  {
4769
5072
  value: {
4770
5073
  dragListeners,
4771
5074
  setDragListeners
4772
5075
  },
4773
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(previewContext.Provider, { value: preview, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4774
- import_react25.DragDropProvider,
5076
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5077
+ import_react30.DragDropProvider,
4775
5078
  {
4776
5079
  plugins,
4777
5080
  sensors,
4778
5081
  onDragEnd: (event, manager) => {
5082
+ var _a;
4779
5083
  const { source, target } = event.operation;
4780
- deepestRef.current = null;
4781
5084
  if (!source) {
4782
- setDraggedItem(null);
5085
+ zoneStore.setState({ draggedItem: null });
4783
5086
  return;
4784
5087
  }
4785
5088
  const { zone, index } = source.data;
4786
- const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
4787
- previewRef.current = null;
5089
+ const { previewIndex = {} } = zoneStore.getState() || {};
5090
+ const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
4788
5091
  setTimeout(() => {
4789
- var _a, _b;
4790
- setDraggedItem(null);
5092
+ var _a2, _b;
5093
+ zoneStore.setState({ draggedItem: null });
4791
5094
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4792
- setPreview(null);
4793
- (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
5095
+ zoneStore.setState({ previewIndex: {} });
5096
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
4794
5097
  fn(event, manager);
4795
5098
  });
4796
5099
  return;
4797
5100
  }
4798
5101
  if (thisPreview) {
4799
- setPreview(null);
5102
+ zoneStore.setState({ previewIndex: {} });
4800
5103
  if (thisPreview.type === "insert") {
4801
5104
  insertComponent(
4802
5105
  thisPreview.componentType,
@@ -4831,8 +5134,9 @@ var DragDropContextClient = ({
4831
5134
  }, 250);
4832
5135
  },
4833
5136
  onDragOver: (event, manager) => {
4834
- var _a, _b, _c, _d;
5137
+ var _a, _b, _c, _d, _e;
4835
5138
  event.preventDefault();
5139
+ const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
4836
5140
  if (!draggedItem) return;
4837
5141
  cancelDb();
4838
5142
  const { source, target } = event.operation;
@@ -4848,7 +5152,7 @@ var DragDropContextClient = ({
4848
5152
  const targetData = target.data;
4849
5153
  targetZone = targetData.zone;
4850
5154
  targetIndex = targetData.index;
4851
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
5155
+ const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
4852
5156
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
4853
5157
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
4854
5158
  targetIndex = targetIndex - 1;
@@ -4860,23 +5164,26 @@ var DragDropContextClient = ({
4860
5164
  targetZone = target.id.toString();
4861
5165
  targetIndex = 0;
4862
5166
  }
4863
- if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
5167
+ if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
4864
5168
  const [pathId] = path.split(":");
4865
5169
  return pathId === sourceId;
4866
5170
  }))) {
4867
5171
  return;
4868
5172
  }
4869
5173
  if (dragMode.current === "new") {
4870
- previewRef.current = {
4871
- componentType: sourceData.componentType,
4872
- type: "insert",
4873
- index: targetIndex,
4874
- zone: targetZone,
4875
- props: {
4876
- id: source.id.toString()
5174
+ zoneStore.setState({
5175
+ previewIndex: {
5176
+ [targetZone]: {
5177
+ componentType: sourceData.componentType,
5178
+ type: "insert",
5179
+ index: targetIndex,
5180
+ zone: targetZone,
5181
+ props: {
5182
+ id: source.id.toString()
5183
+ }
5184
+ }
4877
5185
  }
4878
- };
4879
- setPreview(previewRef.current);
5186
+ });
4880
5187
  } else {
4881
5188
  if (!initialSelector.current) {
4882
5189
  initialSelector.current = {
@@ -4886,17 +5193,20 @@ var DragDropContextClient = ({
4886
5193
  }
4887
5194
  const item = getItem(initialSelector.current, data);
4888
5195
  if (item) {
4889
- previewRef.current = {
4890
- componentType: sourceData.componentType,
4891
- type: "move",
4892
- index: targetIndex,
4893
- zone: targetZone,
4894
- props: item.props
4895
- };
4896
- setPreview(previewRef.current);
5196
+ zoneStore.setState({
5197
+ previewIndex: {
5198
+ [targetZone]: {
5199
+ componentType: sourceData.componentType,
5200
+ type: "move",
5201
+ index: targetIndex,
5202
+ zone: targetZone,
5203
+ props: item.props
5204
+ }
5205
+ }
5206
+ });
4897
5207
  }
4898
5208
  }
4899
- (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
5209
+ (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
4900
5210
  fn(event, manager);
4901
5211
  });
4902
5212
  },
@@ -4906,46 +5216,61 @@ var DragDropContextClient = ({
4906
5216
  type: "setUi",
4907
5217
  ui: { itemSelector: null, isDragging: true }
4908
5218
  });
5219
+ const { source } = event.operation;
5220
+ if (source && source.type !== "void") {
5221
+ const sourceData = source.data;
5222
+ const item = getItem(
5223
+ {
5224
+ zone: sourceData.zone,
5225
+ index: sourceData.index
5226
+ },
5227
+ data
5228
+ );
5229
+ if (item) {
5230
+ zoneStore.setState({
5231
+ previewIndex: {
5232
+ [sourceData.zone]: {
5233
+ componentType: sourceData.componentType,
5234
+ type: "move",
5235
+ index: sourceData.index,
5236
+ zone: sourceData.zone,
5237
+ props: item.props
5238
+ }
5239
+ }
5240
+ });
5241
+ }
5242
+ }
4909
5243
  (_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
4910
5244
  fn(event, manager);
4911
5245
  });
4912
5246
  },
4913
5247
  onBeforeDragStart: (event) => {
4914
5248
  var _a;
4915
- if (draggedItem) {
4916
- console.warn("New drag started before previous drag cleaned up");
4917
- }
4918
5249
  const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
4919
5250
  dragMode.current = isNewComponent ? "new" : "existing";
4920
5251
  initialSelector.current = void 0;
4921
- setDraggedItem(event.operation.source);
5252
+ zoneStore.setState({ draggedItem: event.operation.source });
4922
5253
  },
4923
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5254
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4924
5255
  DropZoneProvider,
4925
5256
  {
4926
5257
  value: {
4927
5258
  data,
4928
5259
  config,
4929
- dispatch,
4930
- draggedItem,
4931
5260
  mode: "edit",
4932
5261
  areaId: "root",
4933
5262
  depth: 0,
4934
5263
  registerPath,
4935
5264
  pathData,
4936
- deepestZone: deepest == null ? void 0 : deepest.zone,
4937
- deepestArea: deepest == null ? void 0 : deepest.area,
4938
- nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
4939
- nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
4940
5265
  path: []
4941
5266
  },
4942
5267
  children
4943
5268
  }
4944
- )
5269
+ ) })
4945
5270
  }
4946
- ) })
5271
+ )
4947
5272
  }
4948
- );
5273
+ ) });
4949
5274
  };
4950
5275
  var DragDropContext = ({
4951
5276
  children,
@@ -4955,11 +5280,11 @@ var DragDropContext = ({
4955
5280
  if (status === "LOADING") {
4956
5281
  return children;
4957
5282
  }
4958
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DragDropContextClient, { disableAutoScroll, children });
5283
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragDropContextClient, { disableAutoScroll, children });
4959
5284
  };
4960
5285
 
4961
5286
  // components/Drawer/index.tsx
4962
- var import_jsx_runtime23 = require("react/jsx-runtime");
5287
+ var import_jsx_runtime24 = require("react/jsx-runtime");
4963
5288
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
4964
5289
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
4965
5290
  var DrawerItemInner = ({
@@ -4969,11 +5294,11 @@ var DrawerItemInner = ({
4969
5294
  dragRef,
4970
5295
  isDragDisabled
4971
5296
  }) => {
4972
- const CustomInner = (0, import_react27.useMemo)(
4973
- () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
5297
+ const CustomInner = (0, import_react32.useMemo)(
5298
+ () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
4974
5299
  [children]
4975
5300
  );
4976
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5301
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4977
5302
  "div",
4978
5303
  {
4979
5304
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -4981,9 +5306,9 @@ var DrawerItemInner = ({
4981
5306
  onMouseDown: (e) => e.preventDefault(),
4982
5307
  "data-testid": dragRef ? `drawer-item:${name}` : "",
4983
5308
  "data-puck-drawer-item": true,
4984
- children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
4985
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
4986
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragIcon, {}) })
5309
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
5310
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5311
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragIcon, {}) })
4987
5312
  ] }) }) })
4988
5313
  }
4989
5314
  );
@@ -5000,9 +5325,9 @@ var DrawerItemDraggable = ({
5000
5325
  data: { type: "drawer", componentType: name },
5001
5326
  disabled: isDragDisabled
5002
5327
  });
5003
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName18("draggable"), children: [
5004
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DrawerItemInner, { name, label, children }) }),
5005
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5328
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName18("draggable"), children: [
5329
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DrawerItemInner, { name, label, children }) }),
5330
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5006
5331
  DrawerItemInner,
5007
5332
  {
5008
5333
  name,
@@ -5023,7 +5348,7 @@ var DrawerItem = ({
5023
5348
  isDragDisabled
5024
5349
  }) => {
5025
5350
  const resolvedId = id || name;
5026
- const [dynamicId, setDynamicId] = (0, import_react27.useState)(generateId(resolvedId));
5351
+ const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
5027
5352
  if (typeof index !== "undefined") {
5028
5353
  console.error(
5029
5354
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -5036,7 +5361,7 @@ var DrawerItem = ({
5036
5361
  },
5037
5362
  [resolvedId]
5038
5363
  );
5039
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5364
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5040
5365
  DrawerItemDraggable,
5041
5366
  {
5042
5367
  name,
@@ -5062,14 +5387,14 @@ var Drawer = ({
5062
5387
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5063
5388
  );
5064
5389
  }
5065
- const [id] = (0, import_react27.useState)(generateId());
5390
+ const id = (0, import_react32.useId)();
5066
5391
  const { ref } = useDroppableSafe({
5067
5392
  id,
5068
5393
  type: "void",
5069
5394
  collisionPriority: 0
5070
5395
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
5071
5396
  });
5072
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5397
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5073
5398
  "div",
5074
5399
  {
5075
5400
  className: getClassName18(),
@@ -5084,7 +5409,7 @@ Drawer.Item = DrawerItem;
5084
5409
 
5085
5410
  // components/Puck/index.tsx
5086
5411
  init_react_import();
5087
- var import_react42 = require("react");
5412
+ var import_react50 = require("react");
5088
5413
 
5089
5414
  // components/SidebarSection/index.tsx
5090
5415
  init_react_import();
@@ -5095,7 +5420,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
5095
5420
 
5096
5421
  // lib/use-breadcrumbs.ts
5097
5422
  init_react_import();
5098
- var import_react28 = require("react");
5423
+ var import_react33 = require("react");
5099
5424
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
5100
5425
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
5101
5426
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -5145,8 +5470,8 @@ var useBreadcrumbs = (renderCount) => {
5145
5470
  state: { data },
5146
5471
  selectedItem
5147
5472
  } = useAppContext();
5148
- const dzContext = (0, import_react28.useContext)(dropZoneContext);
5149
- return (0, import_react28.useMemo)(() => {
5473
+ const dzContext = (0, import_react33.useContext)(dropZoneContext);
5474
+ return (0, import_react33.useMemo)(() => {
5150
5475
  const breadcrumbs = convertPathDataToBreadcrumbs(
5151
5476
  selectedItem,
5152
5477
  dzContext == null ? void 0 : dzContext.pathData,
@@ -5160,7 +5485,7 @@ var useBreadcrumbs = (renderCount) => {
5160
5485
  };
5161
5486
 
5162
5487
  // components/SidebarSection/index.tsx
5163
- var import_jsx_runtime24 = require("react/jsx-runtime");
5488
+ var import_jsx_runtime25 = require("react/jsx-runtime");
5164
5489
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5165
5490
  var SidebarSection = ({
5166
5491
  children,
@@ -5173,15 +5498,15 @@ var SidebarSection = ({
5173
5498
  }) => {
5174
5499
  const { setUi } = useAppContext();
5175
5500
  const breadcrumbs = useBreadcrumbs(1);
5176
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
5501
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
5177
5502
  "div",
5178
5503
  {
5179
5504
  className: getClassName19({ noBorderTop, noPadding }),
5180
5505
  style: { background },
5181
5506
  children: [
5182
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
5183
- showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
5184
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5507
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
5508
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
5509
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5185
5510
  "button",
5186
5511
  {
5187
5512
  type: "button",
@@ -5190,12 +5515,12 @@ var SidebarSection = ({
5190
5515
  children: breadcrumb.label
5191
5516
  }
5192
5517
  ),
5193
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChevronRight, { size: 16 })
5518
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
5194
5519
  ] }, i)) : null,
5195
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
5520
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
5196
5521
  ] }) }),
5197
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName19("content"), children }),
5198
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Loader, { size: 32 }) })
5522
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
5523
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
5199
5524
  ]
5200
5525
  }
5201
5526
  );
@@ -5226,7 +5551,7 @@ init_react_import();
5226
5551
  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" };
5227
5552
 
5228
5553
  // components/MenuBar/index.tsx
5229
- var import_jsx_runtime25 = require("react/jsx-runtime");
5554
+ var import_jsx_runtime26 = require("react/jsx-runtime");
5230
5555
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5231
5556
  function MenuBar({
5232
5557
  appState,
@@ -5240,7 +5565,7 @@ function MenuBar({
5240
5565
  history: { back, forward, historyStore }
5241
5566
  } = useAppContext();
5242
5567
  const { hasFuture = false, hasPast = false } = historyStore || {};
5243
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5568
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5244
5569
  "div",
5245
5570
  {
5246
5571
  className: getClassName20({ menuOpen }),
@@ -5254,12 +5579,12 @@ function MenuBar({
5254
5579
  setMenuOpen(false);
5255
5580
  }
5256
5581
  },
5257
- children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName20("inner"), children: [
5258
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName20("history"), children: [
5259
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Undo2, { size: 21 }) }),
5260
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Redo2, { size: 21 }) })
5582
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
5583
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
5584
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
5585
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
5261
5586
  ] }),
5262
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: renderHeaderActions && renderHeaderActions({
5587
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
5263
5588
  state: appState,
5264
5589
  dispatch
5265
5590
  }) })
@@ -5270,43 +5595,68 @@ function MenuBar({
5270
5595
 
5271
5596
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5272
5597
  init_react_import();
5273
- 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" };
5598
+ 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" };
5274
5599
 
5275
5600
  // components/Puck/components/Fields/index.tsx
5276
5601
  init_react_import();
5277
5602
 
5278
5603
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5279
5604
  init_react_import();
5280
- 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" };
5605
+ 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" };
5281
5606
 
5282
5607
  // components/Puck/components/Fields/index.tsx
5283
- var import_react30 = require("react");
5608
+ var import_react37 = require("react");
5609
+
5610
+ // lib/use-resolved-fields.ts
5611
+ init_react_import();
5612
+ var import_react36 = require("react");
5284
5613
 
5285
5614
  // lib/use-parent.ts
5286
5615
  init_react_import();
5287
- var import_react29 = require("react");
5288
- var useParent = (itemSelector) => {
5616
+ var import_react34 = require("react");
5617
+ var getParent = (itemSelector, pathData, data) => {
5289
5618
  var _a;
5290
- const { selectedItem, state } = useAppContext();
5291
- const { pathData } = (0, import_react29.useContext)(dropZoneContext) || {};
5292
- const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5293
- const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5619
+ if (!itemSelector) return null;
5620
+ const item = getItem(itemSelector, data);
5621
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
5294
5622
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
5295
- const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
5623
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
5296
5624
  return parent || null;
5297
5625
  };
5626
+ var useGetParent = () => {
5627
+ const { state } = useAppContext();
5628
+ const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
5629
+ return (0, import_react34.useCallback)(
5630
+ () => getParent(state.ui.itemSelector, pathData, state.data),
5631
+ [state.ui.itemSelector, pathData, state.data]
5632
+ );
5633
+ };
5634
+ var useParent = () => {
5635
+ return useGetParent()();
5636
+ };
5298
5637
 
5299
- // components/Puck/components/Fields/index.tsx
5300
- var import_jsx_runtime26 = require("react/jsx-runtime");
5301
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5638
+ // lib/use-on-value-change.ts
5639
+ init_react_import();
5640
+ var import_react35 = require("react");
5641
+ function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5642
+ const tracked = (0, import_react35.useRef)(value);
5643
+ (0, import_react35.useEffect)(() => {
5644
+ const oldValue = tracked.current;
5645
+ if (!compare(value, oldValue)) {
5646
+ tracked.current = value;
5647
+ onChange(value, oldValue);
5648
+ }
5649
+ }, [onChange, compare, value, ...deps]);
5650
+ }
5651
+
5652
+ // lib/selector-is.ts
5653
+ init_react_import();
5654
+ 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);
5655
+
5656
+ // lib/use-resolved-fields.ts
5302
5657
  var defaultPageFields = {
5303
5658
  title: { type: "text" }
5304
5659
  };
5305
- var DefaultFields = ({
5306
- children
5307
- }) => {
5308
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
5309
- };
5310
5660
  var useResolvedFields = () => {
5311
5661
  var _a, _b;
5312
5662
  const { selectedItem, state, config } = useAppContext();
@@ -5314,20 +5664,21 @@ var useResolvedFields = () => {
5314
5664
  const { data } = state;
5315
5665
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5316
5666
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5317
- const defaultFields = (0, import_react30.useMemo)(
5667
+ const defaultFields = (0, import_react36.useMemo)(
5318
5668
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5319
5669
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5320
5670
  );
5321
5671
  const rootProps = data.root.props || data.root;
5322
- const [lastSelectedData, setLastSelectedData] = (0, import_react30.useState)({});
5323
- const [resolvedFields, setResolvedFields] = (0, import_react30.useState)(defaultFields);
5324
- const [fieldsLoading, setFieldsLoading] = (0, import_react30.useState)(false);
5672
+ const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
5673
+ const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
5674
+ const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
5675
+ const lastFields = (0, import_react36.useRef)(defaultFields);
5325
5676
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5326
5677
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5327
5678
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5328
5679
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5329
5680
  const hasResolver = hasComponentResolver || hasRootResolver;
5330
- const resolveFields = (0, import_react30.useCallback)(
5681
+ const resolveFields = (0, import_react36.useCallback)(
5331
5682
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5332
5683
  var _a2;
5333
5684
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5339,7 +5690,7 @@ var useResolvedFields = () => {
5339
5690
  {
5340
5691
  changed,
5341
5692
  fields,
5342
- lastFields: resolvedFields,
5693
+ lastFields: lastFields.current,
5343
5694
  lastData,
5344
5695
  appState: state,
5345
5696
  parent
@@ -5350,7 +5701,7 @@ var useResolvedFields = () => {
5350
5701
  return yield config.root.resolveFields(componentData, {
5351
5702
  changed,
5352
5703
  fields,
5353
- lastFields: resolvedFields,
5704
+ lastFields: lastFields.current,
5354
5705
  lastData,
5355
5706
  appState: state,
5356
5707
  parent
@@ -5359,26 +5710,56 @@ var useResolvedFields = () => {
5359
5710
  return defaultResolveFields(componentData, {
5360
5711
  changed,
5361
5712
  fields,
5362
- lastFields: resolvedFields,
5713
+ lastFields: lastFields.current,
5363
5714
  lastData
5364
5715
  });
5365
5716
  }),
5366
- [data, config, componentData, selectedItem, resolvedFields, state]
5717
+ [data, config, componentData, selectedItem, state, parent]
5367
5718
  );
5368
- (0, import_react30.useEffect)(() => {
5369
- if (hasResolver) {
5370
- setFieldsLoading(true);
5371
- resolveFields(defaultFields).then((fields) => {
5372
- setResolvedFields(fields || {});
5373
- setFieldsLoading(false);
5374
- });
5375
- } else {
5376
- setResolvedFields(defaultFields);
5719
+ const triggerResolver = (0, import_react36.useCallback)(() => {
5720
+ var _a2, _b2;
5721
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5722
+ if (hasResolver) {
5723
+ setFieldsLoading(true);
5724
+ resolveFields(defaultFields).then((fields) => {
5725
+ setResolvedFields(fields || {});
5726
+ lastFields.current = fields;
5727
+ setFieldsLoading(false);
5728
+ });
5729
+ return;
5730
+ }
5377
5731
  }
5378
- }, [data, defaultFields, selectedItem, hasResolver]);
5732
+ setResolvedFields(defaultFields);
5733
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5734
+ useOnValueChange(
5735
+ state.ui.itemSelector,
5736
+ () => {
5737
+ lastFields.current = defaultFields;
5738
+ },
5739
+ selectorIs
5740
+ );
5741
+ useOnValueChange(
5742
+ { data, parent, itemSelector: state.ui.itemSelector },
5743
+ () => {
5744
+ triggerResolver();
5745
+ },
5746
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
5747
+ );
5748
+ (0, import_react36.useEffect)(() => {
5749
+ triggerResolver();
5750
+ }, []);
5379
5751
  return [resolvedFields, fieldsLoading];
5380
5752
  };
5381
- var Fields = () => {
5753
+
5754
+ // components/Puck/components/Fields/index.tsx
5755
+ var import_jsx_runtime27 = require("react/jsx-runtime");
5756
+ var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5757
+ var DefaultFields = ({
5758
+ children
5759
+ }) => {
5760
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
5761
+ };
5762
+ var Fields = ({ wrapFields = true }) => {
5382
5763
  var _a, _b;
5383
5764
  const {
5384
5765
  selectedItem,
@@ -5396,16 +5777,16 @@ var Fields = () => {
5396
5777
  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;
5397
5778
  const isLoading = fieldsResolving || componentResolving;
5398
5779
  const rootProps = data.root.props || data.root;
5399
- const Wrapper = (0, import_react30.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
5400
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
5780
+ const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
5781
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
5401
5782
  "form",
5402
5783
  {
5403
- className: getClassName21(),
5784
+ className: getClassName21({ wrapFields }),
5404
5785
  onSubmit: (e) => {
5405
5786
  e.preventDefault();
5406
5787
  },
5407
5788
  children: [
5408
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5789
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5409
5790
  const field = fields[fieldName];
5410
5791
  if (!(field == null ? void 0 : field.type)) return null;
5411
5792
  const onChange = (value, updatedUi) => {
@@ -5476,7 +5857,7 @@ var Fields = () => {
5476
5857
  item: selectedItem
5477
5858
  });
5478
5859
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5479
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5860
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5480
5861
  AutoFieldPrivate,
5481
5862
  {
5482
5863
  field,
@@ -5485,16 +5866,15 @@ var Fields = () => {
5485
5866
  readOnly: !edit || readOnly[fieldName],
5486
5867
  value: selectedItem.props[fieldName],
5487
5868
  onChange
5488
- },
5489
- id
5490
- );
5869
+ }
5870
+ ) }, id);
5491
5871
  } else {
5492
5872
  const readOnly = data.root.readOnly || {};
5493
5873
  const { edit } = getPermissions({
5494
5874
  root: true
5495
5875
  });
5496
5876
  const id = `root_${field.type}_${fieldName}`;
5497
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5877
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5498
5878
  AutoFieldPrivate,
5499
5879
  {
5500
5880
  field,
@@ -5503,12 +5883,11 @@ var Fields = () => {
5503
5883
  readOnly: !edit || readOnly[fieldName],
5504
5884
  value: rootProps[fieldName],
5505
5885
  onChange
5506
- },
5507
- id
5508
- );
5886
+ }
5887
+ ) }, id);
5509
5888
  }
5510
5889
  }) }),
5511
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Loader, { size: 16 }) }) })
5890
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Loader, { size: 16 }) }) })
5512
5891
  ]
5513
5892
  }
5514
5893
  );
@@ -5519,7 +5898,7 @@ init_react_import();
5519
5898
 
5520
5899
  // lib/use-component-list.tsx
5521
5900
  init_react_import();
5522
- var import_react31 = require("react");
5901
+ var import_react38 = require("react");
5523
5902
 
5524
5903
  // components/ComponentList/index.tsx
5525
5904
  init_react_import();
@@ -5529,7 +5908,7 @@ init_react_import();
5529
5908
  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" };
5530
5909
 
5531
5910
  // components/ComponentList/index.tsx
5532
- var import_jsx_runtime27 = require("react/jsx-runtime");
5911
+ var import_jsx_runtime28 = require("react/jsx-runtime");
5533
5912
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
5534
5913
  var ComponentListItem = ({
5535
5914
  name,
@@ -5539,7 +5918,7 @@ var ComponentListItem = ({
5539
5918
  const canInsert = getPermissions({
5540
5919
  type: name
5541
5920
  }).insert;
5542
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5921
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5543
5922
  };
5544
5923
  var ComponentList = ({
5545
5924
  children,
@@ -5548,8 +5927,8 @@ var ComponentList = ({
5548
5927
  }) => {
5549
5928
  const { config, state, setUi } = useAppContext();
5550
5929
  const { expanded = true } = state.ui.componentList[id] || {};
5551
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
5552
- title && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
5930
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
5931
+ title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
5553
5932
  "button",
5554
5933
  {
5555
5934
  type: "button",
@@ -5563,14 +5942,14 @@ var ComponentList = ({
5563
5942
  }),
5564
5943
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
5565
5944
  children: [
5566
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: title }),
5567
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ChevronDown, { size: 12 }) })
5945
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
5946
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronDown, { size: 12 }) })
5568
5947
  ]
5569
5948
  }
5570
5949
  ),
5571
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5950
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
5572
5951
  var _a;
5573
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5952
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
5574
5953
  ComponentListItem,
5575
5954
  {
5576
5955
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -5584,10 +5963,10 @@ var ComponentList = ({
5584
5963
  ComponentList.Item = ComponentListItem;
5585
5964
 
5586
5965
  // lib/use-component-list.tsx
5587
- var import_jsx_runtime28 = require("react/jsx-runtime");
5966
+ var import_jsx_runtime29 = require("react/jsx-runtime");
5588
5967
  var useComponentList = (config, ui) => {
5589
- const [componentList, setComponentList] = (0, import_react31.useState)();
5590
- (0, import_react31.useEffect)(() => {
5968
+ const [componentList, setComponentList] = (0, import_react38.useState)();
5969
+ (0, import_react38.useEffect)(() => {
5591
5970
  var _a, _b, _c;
5592
5971
  if (Object.keys(ui.componentList).length > 0) {
5593
5972
  const matchedComponents = [];
@@ -5597,7 +5976,7 @@ var useComponentList = (config, ui) => {
5597
5976
  if (category.visible === false || !category.components) {
5598
5977
  return null;
5599
5978
  }
5600
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
5979
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5601
5980
  ComponentList,
5602
5981
  {
5603
5982
  id: categoryKey,
@@ -5606,7 +5985,7 @@ var useComponentList = (config, ui) => {
5606
5985
  var _a2;
5607
5986
  matchedComponents.push(componentName);
5608
5987
  const componentConf = config.components[componentName] || {};
5609
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
5988
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5610
5989
  ComponentList.Item,
5611
5990
  {
5612
5991
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -5626,7 +6005,7 @@ var useComponentList = (config, ui) => {
5626
6005
  );
5627
6006
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
5628
6007
  _componentList.push(
5629
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6008
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5630
6009
  ComponentList,
5631
6010
  {
5632
6011
  id: "other",
@@ -5634,7 +6013,7 @@ var useComponentList = (config, ui) => {
5634
6013
  children: remainingComponents.map((componentName, i) => {
5635
6014
  var _a2;
5636
6015
  const componentConf = config.components[componentName] || {};
5637
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6016
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5638
6017
  ComponentList.Item,
5639
6018
  {
5640
6019
  name: componentName,
@@ -5656,25 +6035,25 @@ var useComponentList = (config, ui) => {
5656
6035
  };
5657
6036
 
5658
6037
  // components/Puck/components/Components/index.tsx
5659
- var import_react32 = require("react");
5660
- var import_jsx_runtime29 = require("react/jsx-runtime");
6038
+ var import_react39 = require("react");
6039
+ var import_jsx_runtime30 = require("react/jsx-runtime");
5661
6040
  var Components = () => {
5662
6041
  const { config, state, overrides } = useAppContext();
5663
6042
  const componentList = useComponentList(config, state.ui);
5664
- const Wrapper = (0, import_react32.useMemo)(() => overrides.components || "div", [overrides]);
5665
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ComponentList, { id: "all" }) });
6043
+ const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
6044
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
5666
6045
  };
5667
6046
 
5668
6047
  // components/Puck/components/Preview/index.tsx
5669
6048
  init_react_import();
5670
- var import_react34 = require("react");
6049
+ var import_react41 = require("react");
5671
6050
 
5672
6051
  // components/AutoFrame/index.tsx
5673
6052
  init_react_import();
5674
- var import_react33 = require("react");
6053
+ var import_react40 = require("react");
5675
6054
  var import_object_hash = __toESM(require("object-hash"));
5676
6055
  var import_react_dom3 = require("react-dom");
5677
- var import_jsx_runtime30 = require("react/jsx-runtime");
6056
+ var import_jsx_runtime31 = require("react/jsx-runtime");
5678
6057
  var styleSelector = 'style, link[rel="stylesheet"]';
5679
6058
  var collectStyles = (doc) => {
5680
6059
  const collected = [];
@@ -5717,7 +6096,7 @@ var CopyHostStyles = ({
5717
6096
  onStylesLoaded = () => null
5718
6097
  }) => {
5719
6098
  const { document: doc, window: win } = useFrame();
5720
- (0, import_react33.useEffect)(() => {
6099
+ (0, import_react40.useEffect)(() => {
5721
6100
  if (!win || !doc) {
5722
6101
  return () => {
5723
6102
  };
@@ -5874,10 +6253,10 @@ var CopyHostStyles = ({
5874
6253
  observer.disconnect();
5875
6254
  };
5876
6255
  }, []);
5877
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
6256
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
5878
6257
  };
5879
- var autoFrameContext = (0, import_react33.createContext)({});
5880
- var useFrame = () => (0, import_react33.useContext)(autoFrameContext);
6258
+ var autoFrameContext = (0, import_react40.createContext)({});
6259
+ var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
5881
6260
  function AutoFrame(_a) {
5882
6261
  var _b = _a, {
5883
6262
  children,
@@ -5894,10 +6273,10 @@ function AutoFrame(_a) {
5894
6273
  "onStylesLoaded",
5895
6274
  "frameRef"
5896
6275
  ]);
5897
- const [loaded, setLoaded] = (0, import_react33.useState)(false);
5898
- const [ctx, setCtx] = (0, import_react33.useState)({});
5899
- const [mountTarget, setMountTarget] = (0, import_react33.useState)();
5900
- (0, import_react33.useEffect)(() => {
6276
+ const [loaded, setLoaded] = (0, import_react40.useState)(false);
6277
+ const [ctx, setCtx] = (0, import_react40.useState)({});
6278
+ const [mountTarget, setMountTarget] = (0, import_react40.useState)();
6279
+ (0, import_react40.useEffect)(() => {
5901
6280
  var _a2;
5902
6281
  if (frameRef.current) {
5903
6282
  setCtx({
@@ -5909,7 +6288,7 @@ function AutoFrame(_a) {
5909
6288
  );
5910
6289
  }
5911
6290
  }, [frameRef, loaded]);
5912
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6291
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
5913
6292
  "iframe",
5914
6293
  __spreadProps(__spreadValues({}, props), {
5915
6294
  className,
@@ -5919,7 +6298,7 @@ function AutoFrame(_a) {
5919
6298
  onLoad: () => {
5920
6299
  setLoaded(true);
5921
6300
  },
5922
- children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(CopyHostStyles, { debug, onStylesLoaded, children: (0, import_react_dom3.createPortal)(children, mountTarget) }) })
6301
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CopyHostStyles, { debug, onStylesLoaded, children: (0, import_react_dom3.createPortal)(children, mountTarget) }) })
5923
6302
  })
5924
6303
  );
5925
6304
  }
@@ -5930,12 +6309,68 @@ var AutoFrame_default = AutoFrame;
5930
6309
  init_react_import();
5931
6310
  var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
5932
6311
 
6312
+ // components/Render/index.tsx
6313
+ init_react_import();
6314
+ var import_jsx_runtime32 = require("react/jsx-runtime");
6315
+ function Render({
6316
+ config,
6317
+ data
6318
+ }) {
6319
+ var _a;
6320
+ const defaultedData = __spreadProps(__spreadValues({}, data), {
6321
+ root: data.root || {},
6322
+ content: data.content || []
6323
+ });
6324
+ const rootProps = defaultedData.root.props || defaultedData.root;
6325
+ const title = (rootProps == null ? void 0 : rootProps.title) || "";
6326
+ if ((_a = config.root) == null ? void 0 : _a.render) {
6327
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6328
+ DropZoneProvider,
6329
+ {
6330
+ value: {
6331
+ data: defaultedData,
6332
+ config,
6333
+ mode: "render",
6334
+ depth: 0,
6335
+ path: []
6336
+ },
6337
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6338
+ config.root.render,
6339
+ __spreadProps(__spreadValues({}, rootProps), {
6340
+ puck: {
6341
+ renderDropZone: DropZone,
6342
+ isEditing: false
6343
+ },
6344
+ title,
6345
+ editMode: false,
6346
+ id: "puck-root",
6347
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
6348
+ })
6349
+ )
6350
+ }
6351
+ );
6352
+ }
6353
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6354
+ DropZoneProvider,
6355
+ {
6356
+ value: {
6357
+ data: defaultedData,
6358
+ config,
6359
+ mode: "render",
6360
+ depth: 0,
6361
+ path: []
6362
+ },
6363
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
6364
+ }
6365
+ );
6366
+ }
6367
+
5933
6368
  // components/Puck/components/Preview/index.tsx
5934
- var import_jsx_runtime31 = require("react/jsx-runtime");
6369
+ var import_jsx_runtime33 = require("react/jsx-runtime");
5935
6370
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
5936
6371
  var useBubbleIframeEvents = (ref) => {
5937
6372
  const { status } = useAppContext();
5938
- (0, import_react34.useEffect)(() => {
6373
+ (0, import_react41.useEffect)(() => {
5939
6374
  var _a;
5940
6375
  if (ref.current && status === "READY") {
5941
6376
  const iframe = ref.current;
@@ -5972,22 +6407,34 @@ var useBubbleIframeEvents = (ref) => {
5972
6407
  }
5973
6408
  }, [status]);
5974
6409
  };
5975
- var Preview = ({ id = "puck-preview" }) => {
6410
+ var Preview2 = ({ id = "puck-preview" }) => {
5976
6411
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
5977
- const Page = (0, import_react34.useCallback)(
6412
+ const Page = (0, import_react41.useCallback)(
5978
6413
  (pageProps) => {
5979
6414
  var _a, _b;
5980
6415
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
5981
6416
  id: "puck-root"
5982
- }, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: pageProps.children });
6417
+ }, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
5983
6418
  },
5984
6419
  [config.root]
5985
6420
  );
5986
- const Frame = (0, import_react34.useMemo)(() => overrides.iframe, [overrides]);
6421
+ const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
5987
6422
  const rootProps = state.data.root.props || state.data.root;
5988
- const ref = (0, import_react34.useRef)(null);
6423
+ const ref = (0, import_react41.useRef)(null);
5989
6424
  useBubbleIframeEvents(ref);
5990
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6425
+ const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6426
+ Page,
6427
+ __spreadProps(__spreadValues({}, rootProps), {
6428
+ puck: {
6429
+ renderDropZone: DropZone,
6430
+ isEditing: true,
6431
+ dragRef: null
6432
+ },
6433
+ editMode: true,
6434
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
6435
+ })
6436
+ ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
6437
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
5991
6438
  "div",
5992
6439
  {
5993
6440
  className: getClassName23(),
@@ -5996,7 +6443,7 @@ var Preview = ({ id = "puck-preview" }) => {
5996
6443
  onClick: () => {
5997
6444
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
5998
6445
  },
5999
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6446
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6000
6447
  AutoFrame_default,
6001
6448
  {
6002
6449
  id: "preview-frame",
@@ -6006,40 +6453,21 @@ var Preview = ({ id = "puck-preview" }) => {
6006
6453
  setStatus("READY");
6007
6454
  },
6008
6455
  frameRef: ref,
6009
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6010
- const inner = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6011
- Page,
6012
- __spreadProps(__spreadValues({}, rootProps), {
6013
- puck: {
6014
- renderDropZone: DropZone,
6015
- isEditing: true,
6016
- dragRef: null
6017
- },
6018
- editMode: true,
6019
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DropZone, { zone: rootDroppableId })
6020
- })
6021
- );
6456
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6022
6457
  if (Frame) {
6023
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Frame, { document: document2, children: inner });
6458
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
6024
6459
  }
6025
6460
  return inner;
6026
6461
  } })
6027
6462
  }
6028
- ) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6463
+ ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6029
6464
  "div",
6030
6465
  {
6031
6466
  id: "preview-frame",
6032
6467
  className: getClassName23("frame"),
6033
6468
  ref,
6034
6469
  "data-puck-entry": true,
6035
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6036
- Page,
6037
- __spreadProps(__spreadValues({}, rootProps), {
6038
- puck: { renderDropZone: DropZone, isEditing: true, dragRef: null },
6039
- editMode: true,
6040
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DropZone, { zone: rootDroppableId })
6041
- })
6042
- )
6470
+ children: inner
6043
6471
  }
6044
6472
  )
6045
6473
  }
@@ -6089,7 +6517,7 @@ var scrollIntoView = (el) => {
6089
6517
  };
6090
6518
 
6091
6519
  // components/LayerTree/index.tsx
6092
- var import_react35 = require("react");
6520
+ var import_react42 = require("react");
6093
6521
 
6094
6522
  // lib/is-child-of-zone.ts
6095
6523
  init_react_import();
@@ -6122,7 +6550,7 @@ var onScrollEnd = (frame, cb) => {
6122
6550
  };
6123
6551
 
6124
6552
  // components/LayerTree/index.tsx
6125
- var import_jsx_runtime32 = require("react/jsx-runtime");
6553
+ var import_jsx_runtime34 = require("react/jsx-runtime");
6126
6554
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
6127
6555
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
6128
6556
  var LayerTree = ({
@@ -6135,15 +6563,15 @@ var LayerTree = ({
6135
6563
  label
6136
6564
  }) => {
6137
6565
  const zones = data.zones || {};
6138
- const ctx = (0, import_react35.useContext)(dropZoneContext);
6139
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
6140
- label && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
6141
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Layers, { size: "16" }) }),
6566
+ const ctx = (0, import_react42.useContext)(dropZoneContext);
6567
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
6568
+ label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
6569
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
6142
6570
  " ",
6143
6571
  label
6144
6572
  ] }),
6145
- /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("ul", { className: getClassName24(), children: [
6146
- zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
6573
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
6574
+ zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
6147
6575
  zoneContent.map((item, i) => {
6148
6576
  var _a;
6149
6577
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -6156,7 +6584,7 @@ var LayerTree = ({
6156
6584
  const childIsSelected = isChildOfZone(item, selectedItem, ctx);
6157
6585
  const componentConfig = config.components[item.type];
6158
6586
  const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
6159
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
6587
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
6160
6588
  "li",
6161
6589
  {
6162
6590
  className: getClassNameLayer({
@@ -6166,7 +6594,7 @@ var LayerTree = ({
6166
6594
  childIsSelected
6167
6595
  }),
6168
6596
  children: [
6169
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
6597
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
6170
6598
  "button",
6171
6599
  {
6172
6600
  type: "button",
@@ -6205,22 +6633,22 @@ var LayerTree = ({
6205
6633
  setHoveringComponent(null);
6206
6634
  },
6207
6635
  children: [
6208
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6636
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
6209
6637
  "div",
6210
6638
  {
6211
6639
  className: getClassNameLayer("chevron"),
6212
6640
  title: isSelected ? "Collapse" : "Expand",
6213
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ChevronDown, { size: "12" })
6641
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
6214
6642
  }
6215
6643
  ),
6216
- /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: getClassNameLayer("title"), children: [
6217
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(LayoutGrid, { size: "16" }) }),
6218
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
6644
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
6645
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(LayoutGrid, { size: "16" }) }),
6646
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
6219
6647
  ] })
6220
6648
  ]
6221
6649
  }
6222
6650
  ) }),
6223
- containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6651
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
6224
6652
  LayerTree,
6225
6653
  {
6226
6654
  config,
@@ -6242,13 +6670,13 @@ var LayerTree = ({
6242
6670
  };
6243
6671
 
6244
6672
  // components/Puck/components/Outline/index.tsx
6245
- var import_react36 = require("react");
6246
- var import_jsx_runtime33 = require("react/jsx-runtime");
6673
+ var import_react43 = require("react");
6674
+ var import_jsx_runtime35 = require("react/jsx-runtime");
6247
6675
  var Outline = () => {
6248
6676
  const { dispatch, state, overrides, config } = useAppContext();
6249
6677
  const { data, ui } = state;
6250
6678
  const { itemSelector } = ui;
6251
- const setItemSelector = (0, import_react36.useCallback)(
6679
+ const setItemSelector = (0, import_react43.useCallback)(
6252
6680
  (newItemSelector) => {
6253
6681
  dispatch({
6254
6682
  type: "setUi",
@@ -6257,9 +6685,9 @@ var Outline = () => {
6257
6685
  },
6258
6686
  []
6259
6687
  );
6260
- const Wrapper = (0, import_react36.useMemo)(() => overrides.outline || "div", [overrides]);
6261
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
6262
- (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6688
+ const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
6689
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
6690
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
6263
6691
  LayerTree,
6264
6692
  {
6265
6693
  config,
@@ -6272,7 +6700,7 @@ var Outline = () => {
6272
6700
  ),
6273
6701
  Object.entries(findZonesForArea(data, "root")).map(
6274
6702
  ([zoneKey, zone]) => {
6275
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6703
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
6276
6704
  LayerTree,
6277
6705
  {
6278
6706
  config,
@@ -6371,19 +6799,19 @@ function usePuckHistory({
6371
6799
 
6372
6800
  // lib/use-history-store.ts
6373
6801
  init_react_import();
6374
- var import_react37 = require("react");
6802
+ var import_react44 = require("react");
6375
6803
  var import_use_debounce3 = require("use-debounce");
6376
6804
  var EMPTY_HISTORY_INDEX = 0;
6377
6805
  function useHistoryStore(initialHistory) {
6378
6806
  var _a, _b;
6379
- const [histories, setHistories] = (0, import_react37.useState)(
6807
+ const [histories, setHistories] = (0, import_react44.useState)(
6380
6808
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
6381
6809
  );
6382
6810
  const updateHistories = (histories2) => {
6383
6811
  setHistories(histories2);
6384
6812
  setIndex(histories2.length - 1);
6385
6813
  };
6386
- const [index, setIndex] = (0, import_react37.useState)(
6814
+ const [index, setIndex] = (0, import_react44.useState)(
6387
6815
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
6388
6816
  );
6389
6817
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -6543,22 +6971,22 @@ var getBox = function getBox2(el) {
6543
6971
  };
6544
6972
 
6545
6973
  // components/Puck/components/Canvas/index.tsx
6546
- var import_react39 = require("react");
6974
+ var import_react46 = require("react");
6547
6975
 
6548
6976
  // components/ViewportControls/index.tsx
6549
6977
  init_react_import();
6550
- var import_react38 = require("react");
6978
+ var import_react45 = require("react");
6551
6979
 
6552
6980
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6553
6981
  init_react_import();
6554
6982
  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" };
6555
6983
 
6556
6984
  // components/ViewportControls/index.tsx
6557
- var import_jsx_runtime34 = require("react/jsx-runtime");
6985
+ var import_jsx_runtime36 = require("react/jsx-runtime");
6558
6986
  var icons = {
6559
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Smartphone, { size: 16 }),
6560
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Tablet, { size: 16 }),
6561
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Monitor, { size: 16 })
6987
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
6988
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
6989
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
6562
6990
  };
6563
6991
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
6564
6992
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -6570,11 +6998,11 @@ var ViewportButton = ({
6570
6998
  onClick
6571
6999
  }) => {
6572
7000
  const { state } = useAppContext();
6573
- const [isActive, setIsActive] = (0, import_react38.useState)(false);
6574
- (0, import_react38.useEffect)(() => {
7001
+ const [isActive, setIsActive] = (0, import_react45.useState)(false);
7002
+ (0, import_react45.useEffect)(() => {
6575
7003
  setIsActive(width === state.ui.viewports.current.width);
6576
7004
  }, [width, state.ui.viewports.current.width]);
6577
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7005
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6578
7006
  IconButton,
6579
7007
  {
6580
7008
  title,
@@ -6583,7 +7011,7 @@ var ViewportButton = ({
6583
7011
  e.stopPropagation();
6584
7012
  onClick({ width, height });
6585
7013
  },
6586
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: getClassNameButton("inner"), children })
7014
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
6587
7015
  }
6588
7016
  ) });
6589
7017
  };
@@ -6607,7 +7035,7 @@ var ViewportControls = ({
6607
7035
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6608
7036
  (option) => option.value === autoZoom
6609
7037
  );
6610
- const zoomOptions = (0, import_react38.useMemo)(
7038
+ const zoomOptions = (0, import_react45.useMemo)(
6611
7039
  () => [
6612
7040
  ...defaultZoomOptions,
6613
7041
  ...defaultsContainAutoZoom ? [] : [
@@ -6619,8 +7047,8 @@ var ViewportControls = ({
6619
7047
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
6620
7048
  [autoZoom]
6621
7049
  );
6622
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25(), children: [
6623
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7050
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
7051
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6624
7052
  ViewportButton,
6625
7053
  {
6626
7054
  height: viewport.height,
@@ -6631,8 +7059,8 @@ var ViewportControls = ({
6631
7059
  },
6632
7060
  i
6633
7061
  )),
6634
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("divider") }),
6635
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7062
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7063
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6636
7064
  IconButton,
6637
7065
  {
6638
7066
  title: "Zoom viewport out",
@@ -6646,10 +7074,10 @@ var ViewportControls = ({
6646
7074
  )].value
6647
7075
  );
6648
7076
  },
6649
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ZoomOut, { size: 16 })
7077
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
6650
7078
  }
6651
7079
  ),
6652
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7080
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6653
7081
  IconButton,
6654
7082
  {
6655
7083
  title: "Zoom viewport in",
@@ -6663,11 +7091,11 @@ var ViewportControls = ({
6663
7091
  )].value
6664
7092
  );
6665
7093
  },
6666
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ZoomIn, { size: 16 })
7094
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
6667
7095
  }
6668
7096
  ),
6669
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("divider") }),
6670
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7097
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7098
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6671
7099
  "select",
6672
7100
  {
6673
7101
  className: getClassName25("zoomSelect"),
@@ -6675,7 +7103,7 @@ var ViewportControls = ({
6675
7103
  onChange: (e) => {
6676
7104
  onZoom(parseFloat(e.currentTarget.value));
6677
7105
  },
6678
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7106
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6679
7107
  "option",
6680
7108
  {
6681
7109
  value: option.value,
@@ -6723,24 +7151,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
6723
7151
  };
6724
7152
 
6725
7153
  // components/Puck/components/Canvas/index.tsx
6726
- var import_jsx_runtime35 = require("react/jsx-runtime");
7154
+ var import_jsx_runtime37 = require("react/jsx-runtime");
6727
7155
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
6728
7156
  var ZOOM_ON_CHANGE = true;
6729
7157
  var Canvas = () => {
6730
7158
  const { status, iframe } = useAppContext();
6731
7159
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
6732
7160
  const { ui } = state;
6733
- const frameRef = (0, import_react39.useRef)(null);
6734
- const [showTransition, setShowTransition] = (0, import_react39.useState)(false);
6735
- const defaultRender = (0, import_react39.useMemo)(() => {
6736
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children });
7161
+ const frameRef = (0, import_react46.useRef)(null);
7162
+ const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
7163
+ const defaultRender = (0, import_react46.useMemo)(() => {
7164
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
6737
7165
  return PuckDefault;
6738
7166
  }, []);
6739
- const CustomPreview = (0, import_react39.useMemo)(
7167
+ const CustomPreview = (0, import_react46.useMemo)(
6740
7168
  () => overrides.preview || defaultRender,
6741
7169
  [overrides]
6742
7170
  );
6743
- const getFrameDimensions = (0, import_react39.useCallback)(() => {
7171
+ const getFrameDimensions = (0, import_react46.useCallback)(() => {
6744
7172
  if (frameRef.current) {
6745
7173
  const frame = frameRef.current;
6746
7174
  const box = getBox(frame);
@@ -6748,7 +7176,7 @@ var Canvas = () => {
6748
7176
  }
6749
7177
  return { width: 0, height: 0 };
6750
7178
  }, [frameRef]);
6751
- const resetAutoZoom = (0, import_react39.useCallback)(
7179
+ const resetAutoZoom = (0, import_react46.useCallback)(
6752
7180
  (ui2 = state.ui) => {
6753
7181
  if (frameRef.current) {
6754
7182
  setZoomConfig(
@@ -6758,11 +7186,11 @@ var Canvas = () => {
6758
7186
  },
6759
7187
  [frameRef, zoomConfig, state.ui]
6760
7188
  );
6761
- (0, import_react39.useEffect)(() => {
7189
+ (0, import_react46.useEffect)(() => {
6762
7190
  setShowTransition(false);
6763
7191
  resetAutoZoom();
6764
7192
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6765
- (0, import_react39.useEffect)(() => {
7193
+ (0, import_react46.useEffect)(() => {
6766
7194
  const { height: frameHeight } = getFrameDimensions();
6767
7195
  if (ui.viewports.current.height === "auto") {
6768
7196
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6770,13 +7198,13 @@ var Canvas = () => {
6770
7198
  }));
6771
7199
  }
6772
7200
  }, [zoomConfig.zoom]);
6773
- (0, import_react39.useEffect)(() => {
7201
+ (0, import_react46.useEffect)(() => {
6774
7202
  if (ZOOM_ON_CHANGE) {
6775
7203
  setShowTransition(true);
6776
7204
  resetAutoZoom(ui);
6777
7205
  }
6778
7206
  }, [ui.viewports.current.width]);
6779
- (0, import_react39.useEffect)(() => {
7207
+ (0, import_react46.useEffect)(() => {
6780
7208
  const cb = () => {
6781
7209
  setShowTransition(false);
6782
7210
  resetAutoZoom();
@@ -6786,13 +7214,13 @@ var Canvas = () => {
6786
7214
  window.removeEventListener("resize", cb);
6787
7215
  };
6788
7216
  }, []);
6789
- const [showLoader, setShowLoader] = (0, import_react39.useState)(false);
6790
- (0, import_react39.useEffect)(() => {
7217
+ const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
7218
+ (0, import_react46.useEffect)(() => {
6791
7219
  setTimeout(() => {
6792
7220
  setShowLoader(true);
6793
7221
  }, 500);
6794
7222
  }, []);
6795
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7223
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
6796
7224
  "div",
6797
7225
  {
6798
7226
  className: getClassName26({
@@ -6805,7 +7233,7 @@ var Canvas = () => {
6805
7233
  recordHistory: true
6806
7234
  }),
6807
7235
  children: [
6808
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7236
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
6809
7237
  ViewportControls,
6810
7238
  {
6811
7239
  autoZoom: zoomConfig.autoZoom,
@@ -6831,8 +7259,8 @@ var Canvas = () => {
6831
7259
  }
6832
7260
  }
6833
7261
  ) }),
6834
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
6835
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7262
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
7263
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
6836
7264
  "div",
6837
7265
  {
6838
7266
  className: getClassName26("root"),
@@ -6853,10 +7281,10 @@ var Canvas = () => {
6853
7281
  })
6854
7282
  );
6855
7283
  },
6856
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Preview, {}) })
7284
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview2, {}) })
6857
7285
  }
6858
7286
  ),
6859
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Loader, { size: 24 }) })
7287
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
6860
7288
  ] })
6861
7289
  ]
6862
7290
  }
@@ -6865,7 +7293,7 @@ var Canvas = () => {
6865
7293
 
6866
7294
  // lib/use-loaded-overrides.ts
6867
7295
  init_react_import();
6868
- var import_react40 = require("react");
7296
+ var import_react47 = require("react");
6869
7297
 
6870
7298
  // lib/load-overrides.ts
6871
7299
  init_react_import();
@@ -6904,26 +7332,26 @@ var useLoadedOverrides = ({
6904
7332
  overrides,
6905
7333
  plugins
6906
7334
  }) => {
6907
- return (0, import_react40.useMemo)(() => {
7335
+ return (0, import_react47.useMemo)(() => {
6908
7336
  return loadOverrides({ overrides, plugins });
6909
7337
  }, [plugins, overrides]);
6910
7338
  };
6911
7339
 
6912
7340
  // components/DefaultOverride/index.tsx
6913
7341
  init_react_import();
6914
- var import_jsx_runtime36 = require("react/jsx-runtime");
6915
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
7342
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7343
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
6916
7344
 
6917
7345
  // lib/use-inject-css.ts
6918
7346
  init_react_import();
6919
- var import_react41 = require("react");
7347
+ var import_react48 = require("react");
6920
7348
  var styles = ``;
6921
7349
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
6922
- const [el, setEl] = (0, import_react41.useState)();
6923
- (0, import_react41.useEffect)(() => {
7350
+ const [el, setEl] = (0, import_react48.useState)();
7351
+ (0, import_react48.useEffect)(() => {
6924
7352
  setEl(document.createElement("style"));
6925
7353
  }, []);
6926
- (0, import_react41.useEffect)(() => {
7354
+ (0, import_react48.useEffect)(() => {
6927
7355
  var _a;
6928
7356
  if (!el || typeof window === "undefined") {
6929
7357
  return;
@@ -6941,8 +7369,35 @@ var useInjectGlobalCss = (iframeEnabled) => {
6941
7369
  return useInjectStyleSheet(styles, iframeEnabled);
6942
7370
  };
6943
7371
 
7372
+ // lib/use-preview-mode-hotkeys.ts
7373
+ init_react_import();
7374
+ var import_react49 = require("react");
7375
+ var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
7376
+ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7377
+ const toggleInteractive = (0, import_react49.useCallback)(() => {
7378
+ dispatch({
7379
+ type: "setUi",
7380
+ ui: (ui) => ({
7381
+ previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
7382
+ })
7383
+ });
7384
+ }, [dispatch]);
7385
+ const toggleInteractiveIframe = () => {
7386
+ if (iframeEnabled) {
7387
+ toggleInteractive();
7388
+ }
7389
+ };
7390
+ const frame = getFrame();
7391
+ const resolvedFrame = typeof window !== "undefined" && frame !== document ? frame : void 0;
7392
+ (0, import_react_hotkeys_hook2.useHotkeys)("meta+i", toggleInteractive, { preventDefault: true });
7393
+ (0, import_react_hotkeys_hook2.useHotkeys)("meta+i", toggleInteractiveIframe, {
7394
+ preventDefault: true,
7395
+ document: resolvedFrame
7396
+ });
7397
+ };
7398
+
6944
7399
  // components/Puck/index.tsx
6945
- var import_jsx_runtime37 = require("react/jsx-runtime");
7400
+ var import_jsx_runtime39 = require("react/jsx-runtime");
6946
7401
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
6947
7402
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
6948
7403
  function Puck({
@@ -6971,7 +7426,7 @@ function Puck({
6971
7426
  waitForStyles: true
6972
7427
  }, _iframe);
6973
7428
  useInjectGlobalCss(iframe.enabled);
6974
- const [generatedAppState] = (0, import_react42.useState)(() => {
7429
+ const [generatedAppState] = (0, import_react50.useState)(() => {
6975
7430
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
6976
7431
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
6977
7432
  let clientUiState = {};
@@ -7043,14 +7498,14 @@ function Puck({
7043
7498
  histories,
7044
7499
  index: initialHistoryIndex
7045
7500
  });
7046
- const [reducer] = (0, import_react42.useState)(
7501
+ const [reducer] = (0, import_react50.useState)(
7047
7502
  () => createReducer({
7048
7503
  config,
7049
7504
  record: historyStore.record,
7050
7505
  onAction
7051
7506
  })
7052
7507
  );
7053
- const [appState, dispatch] = (0, import_react42.useReducer)(
7508
+ const [appState, dispatch] = (0, import_react50.useReducer)(
7054
7509
  reducer,
7055
7510
  flushZones(initialAppState)
7056
7511
  );
@@ -7061,14 +7516,14 @@ function Puck({
7061
7516
  historyStore,
7062
7517
  iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
7063
7518
  });
7064
- const [menuOpen, setMenuOpen] = (0, import_react42.useState)(false);
7519
+ const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
7065
7520
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
7066
7521
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
7067
- (0, import_react42.useEffect)(() => {
7522
+ (0, import_react50.useEffect)(() => {
7068
7523
  if (onChange) onChange(data);
7069
7524
  }, [data]);
7070
7525
  const rootProps = data.root.props || data.root;
7071
- const toggleSidebars = (0, import_react42.useCallback)(
7526
+ const toggleSidebars = (0, import_react50.useCallback)(
7072
7527
  (sidebar) => {
7073
7528
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7074
7529
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7082,7 +7537,7 @@ function Puck({
7082
7537
  },
7083
7538
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7084
7539
  );
7085
- (0, import_react42.useEffect)(() => {
7540
+ (0, import_react50.useEffect)(() => {
7086
7541
  if (!window.matchMedia("(min-width: 638px)").matches) {
7087
7542
  dispatch({
7088
7543
  type: "setUi",
@@ -7105,7 +7560,7 @@ function Puck({
7105
7560
  window.removeEventListener("resize", handleResize);
7106
7561
  };
7107
7562
  }, []);
7108
- const defaultHeaderRender = (0, import_react42.useMemo)(() => {
7563
+ const defaultHeaderRender = (0, import_react50.useMemo)(() => {
7109
7564
  if (renderHeader) {
7110
7565
  console.warn(
7111
7566
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7113,20 +7568,20 @@ function Puck({
7113
7568
  const RenderHeader = (_a2) => {
7114
7569
  var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
7115
7570
  const Comp = renderHeader;
7116
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7571
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7117
7572
  };
7118
7573
  return RenderHeader;
7119
7574
  }
7120
7575
  return DefaultOverride;
7121
7576
  }, [renderHeader]);
7122
- const defaultHeaderActionsRender = (0, import_react42.useMemo)(() => {
7577
+ const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
7123
7578
  if (renderHeaderActions) {
7124
7579
  console.warn(
7125
7580
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7126
7581
  );
7127
7582
  const RenderHeader = (props) => {
7128
7583
  const Comp = renderHeaderActions;
7129
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7584
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7130
7585
  };
7131
7586
  return RenderHeader;
7132
7587
  }
@@ -7136,26 +7591,27 @@ function Puck({
7136
7591
  overrides,
7137
7592
  plugins
7138
7593
  });
7139
- const CustomPuck = (0, import_react42.useMemo)(
7594
+ const CustomPuck = (0, import_react50.useMemo)(
7140
7595
  () => loadedOverrides.puck || DefaultOverride,
7141
7596
  [loadedOverrides]
7142
7597
  );
7143
- const CustomHeader = (0, import_react42.useMemo)(
7598
+ const CustomHeader = (0, import_react50.useMemo)(
7144
7599
  () => loadedOverrides.header || defaultHeaderRender,
7145
7600
  [loadedOverrides]
7146
7601
  );
7147
- const CustomHeaderActions = (0, import_react42.useMemo)(
7602
+ const CustomHeaderActions = (0, import_react50.useMemo)(
7148
7603
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7149
7604
  [loadedOverrides]
7150
7605
  );
7151
- const [mounted, setMounted] = (0, import_react42.useState)(false);
7152
- (0, import_react42.useEffect)(() => {
7606
+ const [mounted, setMounted] = (0, import_react50.useState)(false);
7607
+ (0, import_react50.useEffect)(() => {
7153
7608
  setMounted(true);
7154
7609
  }, []);
7155
7610
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
7156
7611
  const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
7157
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
7158
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7612
+ usePreviewModeHotkeys(dispatch, iframe.enabled);
7613
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
7614
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7159
7615
  AppProvider,
7160
7616
  {
7161
7617
  value: {
@@ -7177,7 +7633,7 @@ function Puck({
7177
7633
  getPermissions: () => ({}),
7178
7634
  refreshPermissions: () => null
7179
7635
  },
7180
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7636
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7181
7637
  "div",
7182
7638
  {
7183
7639
  className: getLayoutClassName({
@@ -7186,60 +7642,60 @@ function Puck({
7186
7642
  mounted,
7187
7643
  rightSideBarVisible
7188
7644
  }),
7189
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getLayoutClassName("inner"), children: [
7190
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7645
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
7646
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7191
7647
  CustomHeader,
7192
7648
  {
7193
- actions: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7649
+ actions: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7194
7650
  Button,
7195
7651
  {
7196
7652
  onClick: () => {
7197
7653
  onPublish && onPublish(data);
7198
7654
  },
7199
- icon: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Globe, { size: "14px" }),
7655
+ icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
7200
7656
  children: "Publish"
7201
7657
  }
7202
7658
  ) }) }),
7203
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
7204
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
7205
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7659
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
7660
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
7661
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7206
7662
  "div",
7207
7663
  {
7208
7664
  className: getLayoutClassName("leftSideBarToggle"),
7209
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7665
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7210
7666
  IconButton,
7211
7667
  {
7212
7668
  onClick: () => {
7213
7669
  toggleSidebars("left");
7214
7670
  },
7215
7671
  title: "Toggle left sidebar",
7216
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(PanelLeft, { focusable: "false" })
7672
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
7217
7673
  }
7218
7674
  )
7219
7675
  }
7220
7676
  ),
7221
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7677
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7222
7678
  "div",
7223
7679
  {
7224
7680
  className: getLayoutClassName("rightSideBarToggle"),
7225
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7681
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7226
7682
  IconButton,
7227
7683
  {
7228
7684
  onClick: () => {
7229
7685
  toggleSidebars("right");
7230
7686
  },
7231
7687
  title: "Toggle right sidebar",
7232
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(PanelRight, { focusable: "false" })
7688
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
7233
7689
  }
7234
7690
  )
7235
7691
  }
7236
7692
  )
7237
7693
  ] }),
7238
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(Heading, { rank: "2", size: "xs", children: [
7694
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
7239
7695
  headerTitle || rootProps.title || "Page",
7240
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
7696
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
7241
7697
  " ",
7242
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7698
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7243
7699
  "code",
7244
7700
  {
7245
7701
  className: getLayoutClassName("headerPath"),
@@ -7248,31 +7704,31 @@ function Puck({
7248
7704
  )
7249
7705
  ] })
7250
7706
  ] }) }),
7251
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
7252
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7707
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
7708
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7253
7709
  IconButton,
7254
7710
  {
7255
7711
  onClick: () => {
7256
7712
  return setMenuOpen(!menuOpen);
7257
7713
  },
7258
7714
  title: "Toggle menu bar",
7259
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChevronDown, { focusable: "false" })
7715
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
7260
7716
  }
7261
7717
  ) }),
7262
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7718
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7263
7719
  MenuBar,
7264
7720
  {
7265
7721
  appState,
7266
7722
  dispatch,
7267
7723
  onPublish,
7268
7724
  menuOpen,
7269
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7725
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7270
7726
  Button,
7271
7727
  {
7272
7728
  onClick: () => {
7273
7729
  onPublish && onPublish(data);
7274
7730
  },
7275
- icon: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Globe, { size: "14px" }),
7731
+ icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
7276
7732
  children: "Publish"
7277
7733
  }
7278
7734
  ) }),
@@ -7283,19 +7739,19 @@ function Puck({
7283
7739
  ] }) })
7284
7740
  }
7285
7741
  ),
7286
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
7287
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Components, {}) }),
7288
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Outline, {}) })
7742
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
7743
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
7744
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
7289
7745
  ] }),
7290
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Canvas, {}),
7291
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7746
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
7747
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7292
7748
  SidebarSection,
7293
7749
  {
7294
7750
  noPadding: true,
7295
7751
  noBorderTop: true,
7296
7752
  showBreadcrumbs: true,
7297
7753
  title: selectedItem ? selectedComponentLabel : "Page",
7298
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Fields, {})
7754
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
7299
7755
  }
7300
7756
  ) })
7301
7757
  ] })
@@ -7303,69 +7759,13 @@ function Puck({
7303
7759
  ) }) })
7304
7760
  }
7305
7761
  ),
7306
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
7762
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
7307
7763
  ] });
7308
7764
  }
7309
7765
  Puck.Components = Components;
7310
7766
  Puck.Fields = Fields;
7311
7767
  Puck.Outline = Outline;
7312
- Puck.Preview = Preview;
7313
-
7314
- // components/Render/index.tsx
7315
- init_react_import();
7316
- var import_jsx_runtime38 = require("react/jsx-runtime");
7317
- function Render({
7318
- config,
7319
- data
7320
- }) {
7321
- var _a;
7322
- const defaultedData = __spreadProps(__spreadValues({}, data), {
7323
- root: data.root || {},
7324
- content: data.content || []
7325
- });
7326
- const rootProps = defaultedData.root.props || defaultedData.root;
7327
- const title = (rootProps == null ? void 0 : rootProps.title) || "";
7328
- if ((_a = config.root) == null ? void 0 : _a.render) {
7329
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7330
- DropZoneProvider,
7331
- {
7332
- value: {
7333
- data: defaultedData,
7334
- config,
7335
- mode: "render",
7336
- depth: 0,
7337
- path: []
7338
- },
7339
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7340
- config.root.render,
7341
- __spreadProps(__spreadValues({}, rootProps), {
7342
- puck: {
7343
- renderDropZone: DropZone,
7344
- isEditing: false
7345
- },
7346
- title,
7347
- editMode: false,
7348
- id: "puck-root",
7349
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DropZone, { zone: rootDroppableId })
7350
- })
7351
- )
7352
- }
7353
- );
7354
- }
7355
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7356
- DropZoneProvider,
7357
- {
7358
- value: {
7359
- data: defaultedData,
7360
- config,
7361
- mode: "render",
7362
- depth: 0,
7363
- path: []
7364
- },
7365
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DropZone, { zone: rootDroppableId })
7366
- }
7367
- );
7368
- }
7768
+ Puck.Preview = Preview2;
7369
7769
 
7370
7770
  // lib/migrate.ts
7371
7771
  init_react_import();