@measured/puck 0.18.0-canary.beb05b5 → 0.18.0-canary.cfe4ca8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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,
@@ -1284,7 +1282,7 @@ init_react_import();
1284
1282
  var import_react9 = require("@dnd-kit/react");
1285
1283
  var import_react10 = require("react");
1286
1284
 
1287
- // lib/dnd-kit/safe.ts
1285
+ // lib/dnd/dnd-kit/safe.ts
1288
1286
  init_react_import();
1289
1287
  var import_react8 = require("@dnd-kit/react");
1290
1288
  var import_sortable = require("@dnd-kit/react/sortable");
@@ -1361,8 +1359,53 @@ var Sortable = ({
1361
1359
  return children({ status, ref: sortableRef });
1362
1360
  };
1363
1361
 
1364
- // components/AutoField/fields/ArrayField/index.tsx
1362
+ // components/AutoField/context.tsx
1363
+ init_react_import();
1364
+ var import_react11 = require("react");
1365
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");
1366
1409
  var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
1367
1410
  var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
1368
1411
  var ArrayField = ({
@@ -1373,10 +1416,10 @@ var ArrayField = ({
1373
1416
  label,
1374
1417
  readOnly,
1375
1418
  id,
1376
- 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))
1377
1420
  }) => {
1378
1421
  const { state, setUi, selectedItem, getPermissions } = useAppContext();
1379
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
1422
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
1380
1423
  const value = _value;
1381
1424
  const arrayState = state.ui.arrayState[id] || {
1382
1425
  items: Array.from(value || []).map((item, idx) => {
@@ -1387,11 +1430,11 @@ var ArrayField = ({
1387
1430
  }),
1388
1431
  openId: ""
1389
1432
  };
1390
- const [localState, setLocalState] = (0, import_react11.useState)({ arrayState, value });
1391
- (0, import_react11.useEffect)(() => {
1433
+ const [localState, setLocalState] = (0, import_react12.useState)({ arrayState, value });
1434
+ (0, import_react12.useEffect)(() => {
1392
1435
  setLocalState({ arrayState, value });
1393
1436
  }, [value, state.ui.arrayState[id]]);
1394
- const mapArrayStateToUi = (0, import_react11.useCallback)(
1437
+ const mapArrayStateToUi = (0, import_react12.useCallback)(
1395
1438
  (partialArrayState) => {
1396
1439
  return {
1397
1440
  arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
@@ -1401,13 +1444,13 @@ var ArrayField = ({
1401
1444
  },
1402
1445
  [arrayState]
1403
1446
  );
1404
- const getHighestIndex = (0, import_react11.useCallback)(() => {
1447
+ const getHighestIndex = (0, import_react12.useCallback)(() => {
1405
1448
  return arrayState.items.reduce(
1406
1449
  (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
1407
1450
  -1
1408
1451
  );
1409
1452
  }, [arrayState]);
1410
- const regenerateArrayState = (0, import_react11.useCallback)(
1453
+ const regenerateArrayState = (0, import_react12.useCallback)(
1411
1454
  (value2) => {
1412
1455
  let highestIndex = getHighestIndex();
1413
1456
  const newItems = Array.from(value2 || []).map((item, idx) => {
@@ -1426,7 +1469,7 @@ var ArrayField = ({
1426
1469
  },
1427
1470
  [arrayState]
1428
1471
  );
1429
- (0, import_react11.useEffect)(() => {
1472
+ (0, import_react12.useEffect)(() => {
1430
1473
  if (arrayState.items.length > 0) {
1431
1474
  setUi(mapArrayStateToUi(arrayState));
1432
1475
  }
@@ -1436,14 +1479,14 @@ var ArrayField = ({
1436
1479
  return null;
1437
1480
  }
1438
1481
  const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
1439
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1482
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1440
1483
  Label2,
1441
1484
  {
1442
1485
  label: label || name,
1443
- icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
1486
+ icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(List, { size: 16 }),
1444
1487
  el: "div",
1445
1488
  readOnly,
1446
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1489
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1447
1490
  SortableProvider,
1448
1491
  {
1449
1492
  onMove: (move) => {
@@ -1465,7 +1508,7 @@ var ArrayField = ({
1465
1508
  arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
1466
1509
  });
1467
1510
  },
1468
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1511
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1469
1512
  "div",
1470
1513
  {
1471
1514
  className: getClassName5({
@@ -1479,13 +1522,13 @@ var ArrayField = ({
1479
1522
  localState.arrayState.items.map((item, i) => {
1480
1523
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
1481
1524
  const data = Array.from(localState.value || [])[i] || {};
1482
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1525
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1483
1526
  Sortable,
1484
1527
  {
1485
1528
  id: _arrayId,
1486
1529
  index: i,
1487
1530
  disabled: readOnly,
1488
- children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1531
+ children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1489
1532
  "div",
1490
1533
  {
1491
1534
  ref,
@@ -1495,7 +1538,7 @@ var ArrayField = ({
1495
1538
  readOnly
1496
1539
  }),
1497
1540
  children: [
1498
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1541
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1499
1542
  "div",
1500
1543
  {
1501
1544
  onClick: (e) => {
@@ -1518,9 +1561,9 @@ var ArrayField = ({
1518
1561
  className: getClassNameItem("summary"),
1519
1562
  children: [
1520
1563
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
1521
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
1522
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
1523
- /* @__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)(
1524
1567
  IconButton,
1525
1568
  {
1526
1569
  type: "button",
@@ -1537,10 +1580,10 @@ var ArrayField = ({
1537
1580
  );
1538
1581
  },
1539
1582
  title: "Duplicate",
1540
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
1583
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
1541
1584
  }
1542
1585
  ) }),
1543
- /* @__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)(
1544
1587
  IconButton,
1545
1588
  {
1546
1589
  type: "button",
@@ -1561,39 +1604,56 @@ var ArrayField = ({
1561
1604
  );
1562
1605
  },
1563
1606
  title: "Delete",
1564
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
1607
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
1565
1608
  }
1566
1609
  ) })
1567
1610
  ] }),
1568
- /* @__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, {}) })
1569
1612
  ] })
1570
1613
  ]
1571
1614
  }
1572
1615
  ),
1573
- /* @__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) => {
1574
- const subField = field.arrayFields[fieldName];
1575
- const subFieldName = `${name}[${i}].${fieldName}`;
1576
- const wildcardFieldName = `${name}[*].${fieldName}`;
1577
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
1578
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1579
- 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,
1580
1628
  {
1581
- name: subFieldName,
1582
- label: subField.label || fieldName,
1583
- id: `${_arrayId}_${fieldName}`,
1584
- readOnly: subReadOnly,
1585
- field: subField,
1586
- value: data[fieldName],
1587
- onChange: (val, ui) => {
1588
- onChange(
1589
- replace(value, i, __spreadProps(__spreadValues({}, data), {
1590
- [fieldName]: val
1591
- })),
1592
- ui
1593
- );
1594
- }
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
+ )
1595
1655
  },
1596
- subFieldName
1656
+ subPath
1597
1657
  );
1598
1658
  }) }) })
1599
1659
  ]
@@ -1603,7 +1663,7 @@ var ArrayField = ({
1603
1663
  _arrayId
1604
1664
  );
1605
1665
  }),
1606
- !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1666
+ !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1607
1667
  "button",
1608
1668
  {
1609
1669
  type: "button",
@@ -1617,7 +1677,7 @@ var ArrayField = ({
1617
1677
  const newArrayState = regenerateArrayState(newValue);
1618
1678
  onChange(newValue, mapArrayStateToUi(newArrayState));
1619
1679
  },
1620
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
1680
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Plus, { size: 21 })
1621
1681
  }
1622
1682
  )
1623
1683
  ]
@@ -1631,7 +1691,7 @@ var ArrayField = ({
1631
1691
 
1632
1692
  // components/AutoField/fields/DefaultField/index.tsx
1633
1693
  init_react_import();
1634
- var import_jsx_runtime8 = require("react/jsx-runtime");
1694
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1635
1695
  var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
1636
1696
  var DefaultField = ({
1637
1697
  field,
@@ -1643,16 +1703,16 @@ var DefaultField = ({
1643
1703
  Label: Label2,
1644
1704
  id
1645
1705
  }) => {
1646
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1706
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1647
1707
  Label2,
1648
1708
  {
1649
1709
  label: label || name,
1650
- icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1651
- field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Type, { size: 16 }),
1652
- field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hash, { size: 16 })
1710
+ icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1711
+ field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Type, { size: 16 }),
1712
+ field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Hash, { size: 16 })
1653
1713
  ] }),
1654
1714
  readOnly,
1655
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1715
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1656
1716
  "input",
1657
1717
  {
1658
1718
  className: getClassName6("input"),
@@ -1663,7 +1723,14 @@ var DefaultField = ({
1663
1723
  value: typeof value === "undefined" ? "" : value.toString(),
1664
1724
  onChange: (e) => {
1665
1725
  if (field.type === "number") {
1666
- onChange(Number(e.currentTarget.value));
1726
+ const numberValue = Number(e.currentTarget.value);
1727
+ if (typeof field.min !== "undefined" && numberValue < field.min) {
1728
+ return;
1729
+ }
1730
+ if (typeof field.max !== "undefined" && numberValue > field.max) {
1731
+ return;
1732
+ }
1733
+ onChange(numberValue);
1667
1734
  } else {
1668
1735
  onChange(e.currentTarget.value);
1669
1736
  }
@@ -1681,11 +1748,11 @@ var DefaultField = ({
1681
1748
 
1682
1749
  // components/AutoField/fields/ExternalField/index.tsx
1683
1750
  init_react_import();
1684
- var import_react15 = require("react");
1751
+ var import_react16 = require("react");
1685
1752
 
1686
1753
  // components/ExternalInput/index.tsx
1687
1754
  init_react_import();
1688
- var import_react14 = require("react");
1755
+ var import_react15 = require("react");
1689
1756
 
1690
1757
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
1691
1758
  init_react_import();
@@ -1693,7 +1760,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
1693
1760
 
1694
1761
  // components/Modal/index.tsx
1695
1762
  init_react_import();
1696
- var import_react12 = require("react");
1763
+ var import_react13 = require("react");
1697
1764
 
1698
1765
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
1699
1766
  init_react_import();
@@ -1701,22 +1768,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
1701
1768
 
1702
1769
  // components/Modal/index.tsx
1703
1770
  var import_react_dom = require("react-dom");
1704
- var import_jsx_runtime9 = require("react/jsx-runtime");
1771
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1705
1772
  var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
1706
1773
  var Modal = ({
1707
1774
  children,
1708
1775
  onClose,
1709
1776
  isOpen
1710
1777
  }) => {
1711
- const [rootEl, setRootEl] = (0, import_react12.useState)(null);
1712
- (0, import_react12.useEffect)(() => {
1778
+ const [rootEl, setRootEl] = (0, import_react13.useState)(null);
1779
+ (0, import_react13.useEffect)(() => {
1713
1780
  setRootEl(document.getElementById("puck-portal-root"));
1714
1781
  }, []);
1715
1782
  if (!rootEl) {
1716
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {});
1783
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
1717
1784
  }
1718
1785
  return (0, import_react_dom.createPortal)(
1719
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1786
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1720
1787
  "div",
1721
1788
  {
1722
1789
  className: getClassName7("inner"),
@@ -1736,11 +1803,11 @@ init_react_import();
1736
1803
  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" };
1737
1804
 
1738
1805
  // components/Heading/index.tsx
1739
- var import_jsx_runtime10 = require("react/jsx-runtime");
1806
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1740
1807
  var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
1741
1808
  var Heading = ({ children, rank, size = "m" }) => {
1742
1809
  const Tag = rank ? `h${rank}` : "span";
1743
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1810
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1744
1811
  Tag,
1745
1812
  {
1746
1813
  className: getClassName8({
@@ -1756,7 +1823,7 @@ init_react_import();
1756
1823
 
1757
1824
  // components/Button/Button.tsx
1758
1825
  init_react_import();
1759
- var import_react13 = require("react");
1826
+ var import_react14 = require("react");
1760
1827
 
1761
1828
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
1762
1829
  init_react_import();
@@ -1776,7 +1843,7 @@ var filterDataAttrs = (props) => {
1776
1843
  };
1777
1844
 
1778
1845
  // components/Button/Button.tsx
1779
- var import_jsx_runtime11 = require("react/jsx-runtime");
1846
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1780
1847
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
1781
1848
  var Button = (_a) => {
1782
1849
  var _b = _a, {
@@ -1806,11 +1873,11 @@ var Button = (_a) => {
1806
1873
  "size",
1807
1874
  "loading"
1808
1875
  ]);
1809
- const [loading, setLoading] = (0, import_react13.useState)(loadingProp);
1810
- (0, import_react13.useEffect)(() => setLoading(loadingProp), [loadingProp]);
1876
+ const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
1877
+ (0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
1811
1878
  const ElementType = href ? "a" : type ? "button" : "span";
1812
1879
  const dataAttrs = filterDataAttrs(props);
1813
- const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1880
+ const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1814
1881
  ElementType,
1815
1882
  __spreadProps(__spreadValues({
1816
1883
  className: getClassName9({
@@ -1835,9 +1902,9 @@ var Button = (_a) => {
1835
1902
  href
1836
1903
  }, dataAttrs), {
1837
1904
  children: [
1838
- icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("icon"), children: icon }),
1905
+ icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("icon"), children: icon }),
1839
1906
  children,
1840
- loading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Loader, { size: 14 }) })
1907
+ loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 14 }) })
1841
1908
  ]
1842
1909
  })
1843
1910
  );
@@ -1845,7 +1912,7 @@ var Button = (_a) => {
1845
1912
  };
1846
1913
 
1847
1914
  // components/ExternalInput/index.tsx
1848
- var import_jsx_runtime12 = require("react/jsx-runtime");
1915
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1849
1916
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
1850
1917
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
1851
1918
  var dataCache = {};
@@ -1862,28 +1929,28 @@ var ExternalInput = ({
1862
1929
  mapRow = (val) => val,
1863
1930
  filterFields
1864
1931
  } = field || {};
1865
- const [data, setData] = (0, import_react14.useState)([]);
1866
- const [isOpen, setOpen] = (0, import_react14.useState)(false);
1867
- const [isLoading, setIsLoading] = (0, import_react14.useState)(true);
1932
+ const [data, setData] = (0, import_react15.useState)([]);
1933
+ const [isOpen, setOpen] = (0, import_react15.useState)(false);
1934
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
1868
1935
  const hasFilterFields = !!filterFields;
1869
- const [filters, setFilters] = (0, import_react14.useState)(field.initialFilters || {});
1870
- const [filtersToggled, setFiltersToggled] = (0, import_react14.useState)(hasFilterFields);
1871
- const mappedData = (0, import_react14.useMemo)(() => {
1936
+ const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
1937
+ const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
1938
+ const mappedData = (0, import_react15.useMemo)(() => {
1872
1939
  return data.map(mapRow);
1873
1940
  }, [data]);
1874
- const keys = (0, import_react14.useMemo)(() => {
1941
+ const keys = (0, import_react15.useMemo)(() => {
1875
1942
  const validKeys = /* @__PURE__ */ new Set();
1876
1943
  for (const item of mappedData) {
1877
1944
  for (const key of Object.keys(item)) {
1878
- if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react14.isValidElement)(item[key])) {
1945
+ if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
1879
1946
  validKeys.add(key);
1880
1947
  }
1881
1948
  }
1882
1949
  }
1883
1950
  return Array.from(validKeys);
1884
1951
  }, [mappedData]);
1885
- const [searchQuery, setSearchQuery] = (0, import_react14.useState)(field.initialQuery || "");
1886
- const search = (0, import_react14.useCallback)(
1952
+ const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
1953
+ const search = (0, import_react15.useCallback)(
1887
1954
  (query, filters2) => __async(void 0, null, function* () {
1888
1955
  setIsLoading(true);
1889
1956
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
@@ -1896,18 +1963,18 @@ var ExternalInput = ({
1896
1963
  }),
1897
1964
  [id, field]
1898
1965
  );
1899
- const Footer = (0, import_react14.useCallback)(
1900
- (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
1966
+ const Footer = (0, import_react15.useCallback)(
1967
+ (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
1901
1968
  props.items.length,
1902
1969
  " result",
1903
1970
  props.items.length === 1 ? "" : "s"
1904
1971
  ] }),
1905
1972
  [field.renderFooter]
1906
1973
  );
1907
- (0, import_react14.useEffect)(() => {
1974
+ (0, import_react15.useEffect)(() => {
1908
1975
  search(searchQuery, filters);
1909
1976
  }, []);
1910
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1977
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1911
1978
  "div",
1912
1979
  {
1913
1980
  className: getClassName10({
@@ -1917,21 +1984,21 @@ var ExternalInput = ({
1917
1984
  }),
1918
1985
  id,
1919
1986
  children: [
1920
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("actions"), children: [
1921
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1987
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("actions"), children: [
1988
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1922
1989
  "button",
1923
1990
  {
1924
1991
  type: "button",
1925
1992
  onClick: () => setOpen(true),
1926
1993
  className: getClassName10("button"),
1927
1994
  disabled: readOnly,
1928
- children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1929
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Link, { size: "16" }),
1930
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: field.placeholder })
1995
+ children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1996
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: "16" }),
1997
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: field.placeholder })
1931
1998
  ] })
1932
1999
  }
1933
2000
  ),
1934
- value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2001
+ value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1935
2002
  "button",
1936
2003
  {
1937
2004
  type: "button",
@@ -1940,11 +2007,11 @@ var ExternalInput = ({
1940
2007
  onChange(null);
1941
2008
  },
1942
2009
  disabled: readOnly,
1943
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LockOpen, { size: 16 })
2010
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LockOpen, { size: 16 })
1944
2011
  }
1945
2012
  )
1946
2013
  ] }),
1947
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2014
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1948
2015
  "form",
1949
2016
  {
1950
2017
  className: getClassNameModal({
@@ -1958,11 +2025,11 @@ var ExternalInput = ({
1958
2025
  search(searchQuery, filters);
1959
2026
  },
1960
2027
  children: [
1961
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
1962
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: getClassNameModal("search"), children: [
1963
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
1964
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Search, { size: "18" }) }),
1965
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2028
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
2029
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: getClassNameModal("search"), children: [
2030
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
2031
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Search, { size: "18" }) }),
2032
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1966
2033
  "input",
1967
2034
  {
1968
2035
  className: getClassNameModal("searchInput"),
@@ -1977,9 +2044,9 @@ var ExternalInput = ({
1977
2044
  }
1978
2045
  )
1979
2046
  ] }),
1980
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
1981
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
1982
- hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2047
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
2048
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
2049
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1983
2050
  IconButton,
1984
2051
  {
1985
2052
  title: "Toggle filters",
@@ -1988,15 +2055,15 @@ var ExternalInput = ({
1988
2055
  e.stopPropagation();
1989
2056
  setFiltersToggled(!filtersToggled);
1990
2057
  },
1991
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SlidersHorizontal, { size: 20 })
2058
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SlidersHorizontal, { size: 20 })
1992
2059
  }
1993
2060
  ) })
1994
2061
  ] })
1995
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
1996
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("grid"), children: [
1997
- hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
2062
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
2063
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("grid"), children: [
2064
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1998
2065
  const filterField = filterFields[fieldName];
1999
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2066
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2000
2067
  AutoFieldPrivate,
2001
2068
  {
2002
2069
  field: filterField,
@@ -2013,9 +2080,9 @@ var ExternalInput = ({
2013
2080
  fieldName
2014
2081
  );
2015
2082
  }) }),
2016
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
2017
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { className: getClassNameModal("table"), children: [
2018
- /* @__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)(
2083
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
2084
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: getClassNameModal("table"), children: [
2085
+ /* @__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)(
2019
2086
  "th",
2020
2087
  {
2021
2088
  className: getClassNameModal("th"),
@@ -2024,8 +2091,8 @@ var ExternalInput = ({
2024
2091
  },
2025
2092
  key
2026
2093
  )) }) }),
2027
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
2028
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2094
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
2095
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2029
2096
  "tr",
2030
2097
  {
2031
2098
  style: { whiteSpace: "nowrap" },
@@ -2034,16 +2101,16 @@ var ExternalInput = ({
2034
2101
  onChange(mapProp(data[i]));
2035
2102
  setOpen(false);
2036
2103
  },
2037
- children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
2104
+ children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
2038
2105
  },
2039
2106
  i
2040
2107
  );
2041
2108
  }) })
2042
2109
  ] }),
2043
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 24 }) })
2110
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 24 }) })
2044
2111
  ] })
2045
2112
  ] }),
2046
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Footer, { items: mappedData }) })
2113
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footer, { items: mappedData }) })
2047
2114
  ]
2048
2115
  }
2049
2116
  ) })
@@ -2053,7 +2120,7 @@ var ExternalInput = ({
2053
2120
  };
2054
2121
 
2055
2122
  // components/AutoField/fields/ExternalField/index.tsx
2056
- var import_jsx_runtime13 = require("react/jsx-runtime");
2123
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2057
2124
  var ExternalField = ({
2058
2125
  field,
2059
2126
  onChange,
@@ -2067,7 +2134,7 @@ var ExternalField = ({
2067
2134
  var _a, _b, _c;
2068
2135
  const validField = field;
2069
2136
  const deprecatedField = field;
2070
- (0, import_react15.useEffect)(() => {
2137
+ (0, import_react16.useEffect)(() => {
2071
2138
  if (deprecatedField.adaptor) {
2072
2139
  console.error(
2073
2140
  "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."
@@ -2077,7 +2144,7 @@ var ExternalField = ({
2077
2144
  if (field.type !== "external") {
2078
2145
  return null;
2079
2146
  }
2080
- 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)(
2147
+ 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)(
2081
2148
  ExternalInput,
2082
2149
  {
2083
2150
  name,
@@ -2102,7 +2169,7 @@ var ExternalField = ({
2102
2169
 
2103
2170
  // components/AutoField/fields/RadioField/index.tsx
2104
2171
  init_react_import();
2105
- var import_react16 = require("react");
2172
+ var import_react17 = require("react");
2106
2173
 
2107
2174
  // lib/safe-json-parse.ts
2108
2175
  init_react_import();
@@ -2116,7 +2183,7 @@ var safeJsonParse = (str) => {
2116
2183
  };
2117
2184
 
2118
2185
  // components/AutoField/fields/RadioField/index.tsx
2119
- var import_jsx_runtime14 = require("react/jsx-runtime");
2186
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2120
2187
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
2121
2188
  var RadioField = ({
2122
2189
  field,
@@ -2128,26 +2195,26 @@ var RadioField = ({
2128
2195
  label,
2129
2196
  Label: Label2
2130
2197
  }) => {
2131
- const flatOptions = (0, import_react16.useMemo)(
2198
+ const flatOptions = (0, import_react17.useMemo)(
2132
2199
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
2133
2200
  [field]
2134
2201
  );
2135
2202
  if (field.type !== "radio" || !field.options) {
2136
2203
  return null;
2137
2204
  }
2138
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2205
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2139
2206
  Label2,
2140
2207
  {
2141
- icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
2208
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CircleCheckBig, { size: 16 }),
2142
2209
  label: label || name,
2143
2210
  readOnly,
2144
2211
  el: "div",
2145
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2212
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2146
2213
  "label",
2147
2214
  {
2148
2215
  className: getClassName11("radio"),
2149
2216
  children: [
2150
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2217
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2151
2218
  "input",
2152
2219
  {
2153
2220
  type: "radio",
@@ -2167,7 +2234,7 @@ var RadioField = ({
2167
2234
  checked: value === option.value
2168
2235
  }
2169
2236
  ),
2170
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2237
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2171
2238
  ]
2172
2239
  },
2173
2240
  option.label + option.value
@@ -2178,8 +2245,8 @@ var RadioField = ({
2178
2245
 
2179
2246
  // components/AutoField/fields/SelectField/index.tsx
2180
2247
  init_react_import();
2181
- var import_react17 = require("react");
2182
- var import_jsx_runtime15 = require("react/jsx-runtime");
2248
+ var import_react18 = require("react");
2249
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2183
2250
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
2184
2251
  var SelectField = ({
2185
2252
  field,
@@ -2191,20 +2258,20 @@ var SelectField = ({
2191
2258
  readOnly,
2192
2259
  id
2193
2260
  }) => {
2194
- const flatOptions = (0, import_react17.useMemo)(
2261
+ const flatOptions = (0, import_react18.useMemo)(
2195
2262
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
2196
2263
  [field]
2197
2264
  );
2198
2265
  if (field.type !== "select" || !field.options) {
2199
2266
  return null;
2200
2267
  }
2201
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2268
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2202
2269
  Label2,
2203
2270
  {
2204
2271
  label: label || name,
2205
- icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
2272
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronDown, { size: 16 }),
2206
2273
  readOnly,
2207
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2274
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2208
2275
  "select",
2209
2276
  {
2210
2277
  id,
@@ -2221,7 +2288,7 @@ var SelectField = ({
2221
2288
  }
2222
2289
  },
2223
2290
  value,
2224
- children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2291
+ children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2225
2292
  "option",
2226
2293
  {
2227
2294
  label: option.label,
@@ -2237,7 +2304,7 @@ var SelectField = ({
2237
2304
 
2238
2305
  // components/AutoField/fields/TextareaField/index.tsx
2239
2306
  init_react_import();
2240
- var import_jsx_runtime16 = require("react/jsx-runtime");
2307
+ var import_jsx_runtime17 = require("react/jsx-runtime");
2241
2308
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
2242
2309
  var TextareaField = ({
2243
2310
  onChange,
@@ -2248,7 +2315,7 @@ var TextareaField = ({
2248
2315
  Label: Label2,
2249
2316
  id
2250
2317
  }) => {
2251
- 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)(
2318
+ 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)(
2252
2319
  "textarea",
2253
2320
  {
2254
2321
  id,
@@ -2275,7 +2342,7 @@ init_react_import();
2275
2342
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
2276
2343
 
2277
2344
  // components/AutoField/fields/ObjectField/index.tsx
2278
- var import_jsx_runtime17 = require("react/jsx-runtime");
2345
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2279
2346
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
2280
2347
  var ObjectField = ({
2281
2348
  field,
@@ -2287,43 +2354,54 @@ var ObjectField = ({
2287
2354
  readOnly,
2288
2355
  id
2289
2356
  }) => {
2290
- const { selectedItem } = useAppContext();
2357
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
2291
2358
  if (field.type !== "object" || !field.objectFields) {
2292
2359
  return null;
2293
2360
  }
2294
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
2295
2361
  const data = value || {};
2296
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2362
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2297
2363
  Label2,
2298
2364
  {
2299
2365
  label: label || name,
2300
- icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
2366
+ icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EllipsisVertical, { size: 16 }),
2301
2367
  el: "div",
2302
2368
  readOnly,
2303
- 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) => {
2304
- const subField = field.objectFields[fieldName];
2305
- const subFieldName = `${name}.${fieldName}`;
2306
- const wildcardFieldName = `${name}.${fieldName}`;
2307
- const subReadOnly = readOnly ? readOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
2308
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2309
- AutoFieldPrivate,
2369
+ 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) => {
2370
+ const subField = field.objectFields[subName];
2371
+ const subPath = `${name}.${subName}`;
2372
+ const localSubPath = `${localName || name}.${subName}`;
2373
+ const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
2374
+ const label2 = subField.label || subName;
2375
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2376
+ NestedFieldProvider,
2310
2377
  {
2311
- name: subFieldName,
2312
- label: subField.label || fieldName,
2313
- id: `${id}_${fieldName}`,
2314
- readOnly: subReadOnly,
2315
- field: subField,
2316
- value: data[fieldName],
2317
- onChange: (val, ui) => {
2318
- onChange(
2319
- __spreadProps(__spreadValues({}, data), {
2320
- [fieldName]: val
2378
+ name: localName || id,
2379
+ subName,
2380
+ readOnlyFields,
2381
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2382
+ AutoFieldPrivate,
2383
+ {
2384
+ name: subPath,
2385
+ label: subPath,
2386
+ id: `${id}_${subName}`,
2387
+ readOnly: subReadOnly,
2388
+ field: __spreadProps(__spreadValues({}, subField), {
2389
+ label: label2
2390
+ // May be used by custom fields
2321
2391
  }),
2322
- ui
2323
- );
2324
- }
2392
+ value: data[subName],
2393
+ onChange: (val, ui) => {
2394
+ onChange(
2395
+ __spreadProps(__spreadValues({}, data), {
2396
+ [subName]: val
2397
+ }),
2398
+ ui
2399
+ );
2400
+ }
2401
+ }
2402
+ )
2325
2403
  },
2326
- subFieldName
2404
+ subPath
2327
2405
  );
2328
2406
  }) }) })
2329
2407
  }
@@ -2332,7 +2410,7 @@ var ObjectField = ({
2332
2410
 
2333
2411
  // lib/use-safe-id.ts
2334
2412
  init_react_import();
2335
- var import_react18 = __toESM(require("react"));
2413
+ var import_react19 = __toESM(require("react"));
2336
2414
 
2337
2415
  // lib/generate-id.ts
2338
2416
  init_react_import();
@@ -2341,15 +2419,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
2341
2419
 
2342
2420
  // lib/use-safe-id.ts
2343
2421
  var useSafeId = () => {
2344
- if (typeof import_react18.default.useId !== "undefined") {
2345
- return import_react18.default.useId();
2422
+ if (typeof import_react19.default.useId !== "undefined") {
2423
+ return import_react19.default.useId();
2346
2424
  }
2347
- const [id] = (0, import_react18.useState)(generateId());
2425
+ const [id] = (0, import_react19.useState)(generateId());
2348
2426
  return id;
2349
2427
  };
2350
2428
 
2351
2429
  // components/AutoField/index.tsx
2352
- var import_jsx_runtime18 = require("react/jsx-runtime");
2430
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2353
2431
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2354
2432
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2355
2433
  var FieldLabel = ({
@@ -2361,16 +2439,16 @@ var FieldLabel = ({
2361
2439
  className
2362
2440
  }) => {
2363
2441
  const El = el;
2364
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(El, { className, children: [
2365
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: getClassName15("label"), children: [
2366
- icon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {}),
2442
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(El, { className, children: [
2443
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName15("label"), children: [
2444
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {}),
2367
2445
  label,
2368
- readOnly && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Lock, { size: "12" }) })
2446
+ readOnly && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Lock, { size: "12" }) })
2369
2447
  ] }),
2370
2448
  children
2371
2449
  ] });
2372
2450
  };
2373
- var FieldLabelInternal2 = ({
2451
+ var FieldLabelInternal = ({
2374
2452
  children,
2375
2453
  icon,
2376
2454
  label,
@@ -2378,14 +2456,14 @@ var FieldLabelInternal2 = ({
2378
2456
  readOnly
2379
2457
  }) => {
2380
2458
  const { overrides } = useAppContext();
2381
- const Wrapper = (0, import_react19.useMemo)(
2459
+ const Wrapper = (0, import_react20.useMemo)(
2382
2460
  () => overrides.fieldLabel || FieldLabel,
2383
2461
  [overrides]
2384
2462
  );
2385
2463
  if (!label) {
2386
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
2464
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
2387
2465
  }
2388
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2466
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2389
2467
  Wrapper,
2390
2468
  {
2391
2469
  label,
@@ -2399,8 +2477,9 @@ var FieldLabelInternal2 = ({
2399
2477
  };
2400
2478
  function AutoFieldInternal(props) {
2401
2479
  var _a, _b, _c, _d, _e, _f, _g, _h;
2402
- const { dispatch, overrides } = useAppContext();
2403
- const { id, Label: Label2 = FieldLabelInternal2 } = props;
2480
+ const { dispatch, overrides, selectedItem } = useAppContext();
2481
+ const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
2482
+ const { id, Label: Label2 = FieldLabelInternal } = props;
2404
2483
  const field = props.field;
2405
2484
  const label = field.label;
2406
2485
  const defaultId = useSafeId();
@@ -2431,7 +2510,7 @@ function AutoFieldInternal(props) {
2431
2510
  Label: Label2,
2432
2511
  id: resolvedId
2433
2512
  });
2434
- const onFocus = (0, import_react19.useCallback)(
2513
+ const onFocus = (0, import_react20.useCallback)(
2435
2514
  (e) => {
2436
2515
  if (mergedProps.name && e.target.nodeName === "INPUT") {
2437
2516
  e.stopPropagation();
@@ -2445,7 +2524,7 @@ function AutoFieldInternal(props) {
2445
2524
  },
2446
2525
  [mergedProps.name]
2447
2526
  );
2448
- const onBlur = (0, import_react19.useCallback)((e) => {
2527
+ const onBlur = (0, import_react20.useCallback)((e) => {
2449
2528
  if ("name" in e.target) {
2450
2529
  dispatch({
2451
2530
  type: "setUi",
@@ -2460,27 +2539,36 @@ function AutoFieldInternal(props) {
2460
2539
  return null;
2461
2540
  }
2462
2541
  const CustomField = field.render;
2463
- 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)) }) });
2542
+ 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)) }) });
2464
2543
  }
2465
2544
  const children = defaultFields[field.type](mergedProps);
2466
2545
  const Render2 = render[field.type];
2467
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2468
- "div",
2546
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2547
+ NestedFieldContext.Provider,
2469
2548
  {
2470
- className: getClassNameWrapper(),
2471
- onFocus,
2472
- onBlur,
2473
- onClick: (e) => {
2474
- e.stopPropagation();
2549
+ value: {
2550
+ readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
2551
+ localName: nestedFieldContext.localName
2475
2552
  },
2476
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2553
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2554
+ "div",
2555
+ {
2556
+ className: getClassNameWrapper(),
2557
+ onFocus,
2558
+ onBlur,
2559
+ onClick: (e) => {
2560
+ e.stopPropagation();
2561
+ },
2562
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2563
+ }
2564
+ )
2477
2565
  }
2478
2566
  );
2479
2567
  }
2480
2568
  function AutoFieldPrivate(props) {
2481
2569
  const { state } = useAppContext();
2482
2570
  const { value, onChange } = props;
2483
- const [localValue, setLocalValue] = (0, import_react19.useState)(value);
2571
+ const [localValue, setLocalValue] = (0, import_react20.useState)(value);
2484
2572
  const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
2485
2573
  (val, ui) => {
2486
2574
  onChange(val, ui);
@@ -2488,11 +2576,11 @@ function AutoFieldPrivate(props) {
2488
2576
  50,
2489
2577
  { leading: true }
2490
2578
  );
2491
- const onChangeLocal = (0, import_react19.useCallback)((val, ui) => {
2579
+ const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
2492
2580
  setLocalValue(val);
2493
2581
  onChangeDb(val, ui);
2494
2582
  }, []);
2495
- (0, import_react19.useEffect)(() => {
2583
+ (0, import_react20.useEffect)(() => {
2496
2584
  if (state.ui.field.focus !== props.name) {
2497
2585
  setLocalValue(value);
2498
2586
  }
@@ -2501,11 +2589,11 @@ function AutoFieldPrivate(props) {
2501
2589
  value: localValue,
2502
2590
  onChange: onChangeLocal
2503
2591
  };
2504
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2592
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2505
2593
  }
2506
2594
  function AutoField(props) {
2507
- const DefaultLabel = (0, import_react19.useMemo)(() => {
2508
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2595
+ const DefaultLabel = (0, import_react20.useMemo)(() => {
2596
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2509
2597
  "div",
2510
2598
  __spreadProps(__spreadValues({}, labelProps), {
2511
2599
  className: getClassName15({ readOnly: props.readOnly })
@@ -2513,7 +2601,7 @@ function AutoField(props) {
2513
2601
  );
2514
2602
  return DefaultLabel2;
2515
2603
  }, [props.readOnly]);
2516
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2604
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2517
2605
  }
2518
2606
 
2519
2607
  // components/Drawer/index.tsx
@@ -2524,21 +2612,21 @@ init_react_import();
2524
2612
  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" };
2525
2613
 
2526
2614
  // components/Drawer/index.tsx
2527
- var import_react26 = require("react");
2615
+ var import_react32 = require("react");
2528
2616
 
2529
2617
  // components/DragDropContext/index.tsx
2530
2618
  init_react_import();
2531
- var import_react24 = require("@dnd-kit/react");
2532
- var import_react25 = require("react");
2619
+ var import_react30 = require("@dnd-kit/react");
2620
+ var import_react31 = require("react");
2533
2621
  var import_dom = require("@dnd-kit/dom");
2534
2622
 
2535
2623
  // components/DropZone/index.tsx
2536
2624
  init_react_import();
2537
- var import_react23 = require("react");
2625
+ var import_react29 = require("react");
2538
2626
 
2539
2627
  // components/DraggableComponent/index.tsx
2540
2628
  init_react_import();
2541
- var import_react20 = require("react");
2629
+ var import_react23 = require("react");
2542
2630
 
2543
2631
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
2544
2632
  init_react_import();
@@ -2547,15 +2635,15 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
2547
2635
  // components/DraggableComponent/index.tsx
2548
2636
  var import_react_dom2 = require("react-dom");
2549
2637
 
2550
- // components/DraggableComponent/collision/dynamic/index.ts
2638
+ // lib/dnd/collision/dynamic/index.ts
2551
2639
  init_react_import();
2552
2640
  var import_abstract8 = require("@dnd-kit/abstract");
2553
2641
 
2554
- // components/DraggableComponent/collision/directional/index.ts
2642
+ // lib/dnd/collision/directional/index.ts
2555
2643
  init_react_import();
2556
2644
  var import_abstract = require("@dnd-kit/abstract");
2557
2645
 
2558
- // components/DraggableComponent/collision/collision-debug.ts
2646
+ // lib/dnd/collision/collision-debug.ts
2559
2647
  init_react_import();
2560
2648
  var DEBUG = false;
2561
2649
  var debugElements = {};
@@ -2604,7 +2692,7 @@ var collisionDebug = (a, b, id, color, label) => {
2604
2692
  });
2605
2693
  };
2606
2694
 
2607
- // components/DraggableComponent/collision/directional/index.ts
2695
+ // lib/dnd/collision/directional/index.ts
2608
2696
  var distanceChange = "increasing";
2609
2697
  var directionalCollision = (input, previous) => {
2610
2698
  var _a;
@@ -2637,7 +2725,7 @@ var directionalCollision = (input, previous) => {
2637
2725
  return null;
2638
2726
  };
2639
2727
 
2640
- // components/DraggableComponent/collision/dynamic/get-direction.ts
2728
+ // lib/dnd/collision/dynamic/get-direction.ts
2641
2729
  init_react_import();
2642
2730
  var getDirection = (dragAxis, delta) => {
2643
2731
  if (dragAxis === "dynamic") {
@@ -2652,7 +2740,7 @@ var getDirection = (dragAxis, delta) => {
2652
2740
  return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2653
2741
  };
2654
2742
 
2655
- // components/DraggableComponent/collision/dynamic/get-midpoint-impact.ts
2743
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
2656
2744
  init_react_import();
2657
2745
  var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
2658
2746
  const dragRect = dragShape.boundingRectangle;
@@ -2671,7 +2759,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2671
2759
  return dragRect.right - offset >= dropCenter.x;
2672
2760
  };
2673
2761
 
2674
- // components/DraggableComponent/collision/dynamic/track-movement-interval.ts
2762
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
2675
2763
  init_react_import();
2676
2764
  var import_geometry = require("@dnd-kit/geometry");
2677
2765
  var INTERVAL_SENSITIVITY = 10;
@@ -2775,7 +2863,14 @@ var closestCorners = (input) => {
2775
2863
  };
2776
2864
  };
2777
2865
 
2778
- // components/DraggableComponent/collision/dynamic/index.ts
2866
+ // lib/dnd/collision/dynamic/store.ts
2867
+ init_react_import();
2868
+ var import_vanilla = require("zustand/vanilla");
2869
+ var collisionStore = (0, import_vanilla.createStore)(() => ({
2870
+ fallbackEnabled: false
2871
+ }));
2872
+
2873
+ // lib/dnd/collision/dynamic/index.ts
2779
2874
  var flushNext = "";
2780
2875
  var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2781
2876
  var _a, _b, _c, _d, _e;
@@ -2787,6 +2882,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2787
2882
  return null;
2788
2883
  }
2789
2884
  const { center: dragCenter } = dragShape;
2885
+ const { fallbackEnabled } = collisionStore.getState();
2790
2886
  const interval = trackMovementInterval(position.current, dragAxis);
2791
2887
  dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2792
2888
  direction: interval.direction
@@ -2832,7 +2928,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2832
2928
  flushNext = "";
2833
2929
  return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2834
2930
  }
2835
- if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2931
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2836
2932
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2837
2933
  const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2838
2934
  if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
@@ -2893,8 +2989,102 @@ function getDeepScrollPosition(element) {
2893
2989
  return totalScroll;
2894
2990
  }
2895
2991
 
2992
+ // components/DropZone/context.tsx
2993
+ init_react_import();
2994
+ var import_react21 = require("react");
2995
+ var import_zustand = require("zustand");
2996
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2997
+ var dropZoneContext = (0, import_react21.createContext)(null);
2998
+ var ZoneStoreContext = (0, import_react21.createContext)(
2999
+ (0, import_zustand.createStore)(() => ({
3000
+ zoneDepthIndex: {},
3001
+ nextZoneDepthIndex: {},
3002
+ areaDepthIndex: {},
3003
+ nextAreaDepthIndex: {},
3004
+ draggedItem: null,
3005
+ previewIndex: {}
3006
+ }))
3007
+ );
3008
+ var ZoneStoreProvider = ({
3009
+ children,
3010
+ store
3011
+ }) => {
3012
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ZoneStoreContext.Provider, { value: store, children });
3013
+ };
3014
+ var DropZoneProvider = ({
3015
+ children,
3016
+ value
3017
+ }) => {
3018
+ const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
3019
+ const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
3020
+ {}
3021
+ );
3022
+ const [activeZones, setActiveZones] = (0, import_react21.useState)({});
3023
+ const { dispatch } = useAppContext();
3024
+ const registerZoneArea = (0, import_react21.useCallback)(
3025
+ (area) => {
3026
+ setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
3027
+ },
3028
+ [setAreasWithZones]
3029
+ );
3030
+ const registerZone = (0, import_react21.useCallback)(
3031
+ (zoneCompound) => {
3032
+ if (!dispatch) {
3033
+ return;
3034
+ }
3035
+ dispatch({
3036
+ type: "registerZone",
3037
+ zone: zoneCompound
3038
+ });
3039
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
3040
+ },
3041
+ [setActiveZones, dispatch]
3042
+ );
3043
+ const unregisterZone = (0, import_react21.useCallback)(
3044
+ (zoneCompound) => {
3045
+ if (!dispatch) {
3046
+ return;
3047
+ }
3048
+ dispatch({
3049
+ type: "unregisterZone",
3050
+ zone: zoneCompound
3051
+ });
3052
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
3053
+ [zoneCompound]: false
3054
+ }));
3055
+ },
3056
+ [setActiveZones, dispatch]
3057
+ );
3058
+ const memoValue = (0, import_react21.useMemo)(
3059
+ () => __spreadValues({
3060
+ hoveringComponent,
3061
+ setHoveringComponent,
3062
+ registerZoneArea,
3063
+ areasWithZones,
3064
+ registerZone,
3065
+ unregisterZone,
3066
+ activeZones
3067
+ }, value),
3068
+ [value, hoveringComponent, areasWithZones, activeZones]
3069
+ );
3070
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
3071
+ };
3072
+
3073
+ // lib/use-context-store.ts
3074
+ init_react_import();
3075
+ var import_react22 = require("react");
3076
+ var import_zustand2 = require("zustand");
3077
+ var import_shallow = require("zustand/react/shallow");
3078
+ function useContextStore(context, selector) {
3079
+ const store = (0, import_react22.useContext)(context);
3080
+ if (!store) {
3081
+ throw new Error("useContextStore must be used inside context");
3082
+ }
3083
+ return (0, import_zustand2.useStore)(store, (0, import_shallow.useShallow)(selector));
3084
+ }
3085
+
2896
3086
  // components/DraggableComponent/index.tsx
2897
- var import_jsx_runtime19 = require("react/jsx-runtime");
3087
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2898
3088
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
2899
3089
  var DEBUG2 = false;
2900
3090
  var space = 8;
@@ -2905,12 +3095,12 @@ var DefaultActionBar = ({
2905
3095
  label,
2906
3096
  children,
2907
3097
  parentAction
2908
- }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ActionBar, { children: [
2909
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ActionBar.Group, { children: [
3098
+ }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar, { children: [
3099
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar.Group, { children: [
2910
3100
  parentAction,
2911
- label && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Label, { label })
3101
+ label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Label, { label })
2912
3102
  ] }),
2913
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Group, { children })
3103
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Group, { children })
2914
3104
  ] });
2915
3105
  var convertIdToSelector = (id, zoneCompound, data) => {
2916
3106
  const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
@@ -2945,9 +3135,9 @@ var DraggableComponent = ({
2945
3135
  iframe,
2946
3136
  state
2947
3137
  } = useAppContext();
2948
- const ctx = (0, import_react20.useContext)(dropZoneContext);
2949
- const [localZones, setLocalZones] = (0, import_react20.useState)({});
2950
- const registerLocalZone = (0, import_react20.useCallback)(
3138
+ const ctx = (0, import_react23.useContext)(dropZoneContext);
3139
+ const [localZones, setLocalZones] = (0, import_react23.useState)({});
3140
+ const registerLocalZone = (0, import_react23.useCallback)(
2951
3141
  (zoneCompound2, active) => {
2952
3142
  var _a;
2953
3143
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -2957,7 +3147,7 @@ var DraggableComponent = ({
2957
3147
  },
2958
3148
  [setLocalZones]
2959
3149
  );
2960
- const unregisterLocalZone = (0, import_react20.useCallback)(
3150
+ const unregisterLocalZone = (0, import_react23.useCallback)(
2961
3151
  (zoneCompound2) => {
2962
3152
  var _a;
2963
3153
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -2971,8 +3161,8 @@ var DraggableComponent = ({
2971
3161
  );
2972
3162
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
2973
3163
  const { path = [] } = ctx || {};
2974
- const [canDrag, setCanDrag] = (0, import_react20.useState)(false);
2975
- (0, import_react20.useEffect)(() => {
3164
+ const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
3165
+ (0, import_react23.useEffect)(() => {
2976
3166
  var _a;
2977
3167
  const item = getItem({ index, zone: zoneCompound }, state.data);
2978
3168
  if (item) {
@@ -2982,10 +3172,13 @@ var DraggableComponent = ({
2982
3172
  setCanDrag((_a = perms.drag) != null ? _a : true);
2983
3173
  }
2984
3174
  }, [state, index, zoneCompound, getPermissions]);
2985
- const userIsDragging = !!(ctx == null ? void 0 : ctx.draggedItem);
3175
+ const userIsDragging = useContextStore(
3176
+ ZoneStoreContext,
3177
+ (s) => !!s.draggedItem
3178
+ );
2986
3179
  const canCollide = canDrag || userIsDragging;
2987
3180
  const disabled = !isEnabled || !canCollide;
2988
- const [dragAxis, setDragAxis] = (0, import_react20.useState)(userDragAxis || autoDragAxis);
3181
+ const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
2989
3182
  const { ref: sortableRef, status } = useSortableSafe({
2990
3183
  id,
2991
3184
  index,
@@ -3011,8 +3204,8 @@ var DraggableComponent = ({
3011
3204
  }
3012
3205
  });
3013
3206
  const thisIsDragging = status === "dragging";
3014
- const ref = (0, import_react20.useRef)(null);
3015
- const refSetter = (0, import_react20.useCallback)(
3207
+ const ref = (0, import_react23.useRef)(null);
3208
+ const refSetter = (0, import_react23.useCallback)(
3016
3209
  (el) => {
3017
3210
  sortableRef(el);
3018
3211
  if (el) {
@@ -3021,14 +3214,14 @@ var DraggableComponent = ({
3021
3214
  },
3022
3215
  [sortableRef]
3023
3216
  );
3024
- const [portalEl, setPortalEl] = (0, import_react20.useState)();
3025
- (0, import_react20.useEffect)(() => {
3217
+ const [portalEl, setPortalEl] = (0, import_react23.useState)();
3218
+ (0, import_react23.useEffect)(() => {
3026
3219
  var _a, _b, _c;
3027
3220
  setPortalEl(
3028
3221
  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
3029
3222
  );
3030
3223
  }, [iframe.enabled, ref.current]);
3031
- const getStyle = (0, import_react20.useCallback)(() => {
3224
+ const getStyle = (0, import_react23.useCallback)(() => {
3032
3225
  var _a, _b, _c;
3033
3226
  if (!ref.current) return;
3034
3227
  const rect = ref.current.getBoundingClientRect();
@@ -3048,11 +3241,11 @@ var DraggableComponent = ({
3048
3241
  };
3049
3242
  return style2;
3050
3243
  }, [ref.current]);
3051
- const [style, setStyle] = (0, import_react20.useState)();
3052
- const sync = (0, import_react20.useCallback)(() => {
3244
+ const [style, setStyle] = (0, import_react23.useState)();
3245
+ const sync = (0, import_react23.useCallback)(() => {
3053
3246
  setStyle(getStyle());
3054
3247
  }, [ref.current, iframe]);
3055
- (0, import_react20.useEffect)(() => {
3248
+ (0, import_react23.useEffect)(() => {
3056
3249
  if (ref.current) {
3057
3250
  const observer = new ResizeObserver(sync);
3058
3251
  observer.observe(ref.current);
@@ -3061,20 +3254,22 @@ var DraggableComponent = ({
3061
3254
  };
3062
3255
  }
3063
3256
  }, [ref.current]);
3064
- (0, import_react20.useEffect)(() => {
3065
- ctx == null ? void 0 : ctx.registerPath({
3066
- index,
3067
- zone: zoneCompound
3068
- });
3257
+ (0, import_react23.useEffect)(() => {
3258
+ if (isSelected) {
3259
+ ctx == null ? void 0 : ctx.registerPath({
3260
+ index,
3261
+ zone: zoneCompound
3262
+ });
3263
+ }
3069
3264
  }, [isSelected]);
3070
- const CustomActionBar = (0, import_react20.useMemo)(
3265
+ const CustomActionBar = (0, import_react23.useMemo)(
3071
3266
  () => overrides.actionBar || DefaultActionBar,
3072
3267
  [overrides.actionBar]
3073
3268
  );
3074
3269
  const permissions = getPermissions({
3075
3270
  item: selectedItem
3076
3271
  });
3077
- const onClick = (0, import_react20.useCallback)(
3272
+ const onClick = (0, import_react23.useCallback)(
3078
3273
  (e) => {
3079
3274
  e.stopPropagation();
3080
3275
  dispatch({
@@ -3086,7 +3281,7 @@ var DraggableComponent = ({
3086
3281
  },
3087
3282
  [index, zoneCompound, id]
3088
3283
  );
3089
- const onSelectParent = (0, import_react20.useCallback)(() => {
3284
+ const onSelectParent = (0, import_react23.useCallback)(() => {
3090
3285
  if (!(ctx == null ? void 0 : ctx.areaId)) {
3091
3286
  return;
3092
3287
  }
@@ -3104,23 +3299,23 @@ var DraggableComponent = ({
3104
3299
  }
3105
3300
  });
3106
3301
  }, [ctx, path]);
3107
- const onDuplicate = (0, import_react20.useCallback)(() => {
3302
+ const onDuplicate = (0, import_react23.useCallback)(() => {
3108
3303
  dispatch({
3109
3304
  type: "duplicate",
3110
3305
  sourceIndex: index,
3111
3306
  sourceZone: zoneCompound
3112
3307
  });
3113
3308
  }, [index, zoneCompound]);
3114
- const onDelete = (0, import_react20.useCallback)(() => {
3309
+ const onDelete = (0, import_react23.useCallback)(() => {
3115
3310
  dispatch({
3116
3311
  type: "remove",
3117
3312
  index,
3118
3313
  zone: zoneCompound
3119
3314
  });
3120
3315
  }, [index, zoneCompound]);
3121
- const [hover, setHover] = (0, import_react20.useState)(false);
3316
+ const [hover, setHover] = (0, import_react23.useState)(false);
3122
3317
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
3123
- (0, import_react20.useEffect)(() => {
3318
+ (0, import_react23.useEffect)(() => {
3124
3319
  if (!ref.current) {
3125
3320
  return;
3126
3321
  }
@@ -3170,7 +3365,7 @@ var DraggableComponent = ({
3170
3365
  thisIsDragging,
3171
3366
  inDroppableZone
3172
3367
  ]);
3173
- (0, import_react20.useEffect)(() => {
3368
+ (0, import_react23.useEffect)(() => {
3174
3369
  if (ref.current && disabled) {
3175
3370
  ref.current.setAttribute("data-puck-disabled", "");
3176
3371
  return () => {
@@ -3179,8 +3374,8 @@ var DraggableComponent = ({
3179
3374
  };
3180
3375
  }
3181
3376
  }, [disabled, ref]);
3182
- const [isVisible, setIsVisible] = (0, import_react20.useState)(false);
3183
- (0, import_react20.useEffect)(() => {
3377
+ const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
3378
+ (0, import_react23.useEffect)(() => {
3184
3379
  sync();
3185
3380
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
3186
3381
  setIsVisible(true);
@@ -3188,7 +3383,7 @@ var DraggableComponent = ({
3188
3383
  setIsVisible(false);
3189
3384
  }
3190
3385
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3191
- const syncActionsPosition = (0, import_react20.useCallback)(
3386
+ const syncActionsPosition = (0, import_react23.useCallback)(
3192
3387
  (el) => {
3193
3388
  if (el) {
3194
3389
  const view = el.ownerDocument.defaultView;
@@ -3205,7 +3400,7 @@ var DraggableComponent = ({
3205
3400
  },
3206
3401
  [zoomConfig]
3207
3402
  );
3208
- (0, import_react20.useEffect)(() => {
3403
+ (0, import_react23.useEffect)(() => {
3209
3404
  if (userDragAxis) {
3210
3405
  setDragAxis(userDragAxis);
3211
3406
  return;
@@ -3219,8 +3414,8 @@ var DraggableComponent = ({
3219
3414
  }
3220
3415
  setDragAxis(autoDragAxis);
3221
3416
  }, [ref, userDragAxis, autoDragAxis]);
3222
- 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 }) });
3223
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3417
+ 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 }) });
3418
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3224
3419
  DropZoneProvider,
3225
3420
  {
3226
3421
  value: __spreadProps(__spreadValues({}, ctx), {
@@ -3234,7 +3429,7 @@ var DraggableComponent = ({
3234
3429
  }),
3235
3430
  children: [
3236
3431
  isVisible && (0, import_react_dom2.createPortal)(
3237
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3432
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3238
3433
  "div",
3239
3434
  {
3240
3435
  className: getClassName16({
@@ -3246,15 +3441,15 @@ var DraggableComponent = ({
3246
3441
  "data-puck-overlay": true,
3247
3442
  children: [
3248
3443
  debug,
3249
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Loader, {}) }),
3250
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3444
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {}) }),
3445
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3251
3446
  "div",
3252
3447
  {
3253
3448
  className: getClassName16("actionsOverlay"),
3254
3449
  style: {
3255
3450
  top: actionsOverlayTop / zoomConfig.zoom
3256
3451
  },
3257
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3452
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3258
3453
  "div",
3259
3454
  {
3260
3455
  className: getClassName16("actions"),
@@ -3266,14 +3461,14 @@ var DraggableComponent = ({
3266
3461
  paddingRight: actionsSide
3267
3462
  },
3268
3463
  ref: syncActionsPosition,
3269
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3464
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3270
3465
  CustomActionBar,
3271
3466
  {
3272
3467
  parentAction,
3273
3468
  label: DEBUG2 ? id : label,
3274
3469
  children: [
3275
- permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Copy, { size: 16 }) }),
3276
- permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Trash, { size: 16 }) })
3470
+ permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Copy, { size: 16 }) }),
3471
+ permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Trash, { size: 16 }) })
3277
3472
  ]
3278
3473
  }
3279
3474
  )
@@ -3281,7 +3476,7 @@ var DraggableComponent = ({
3281
3476
  )
3282
3477
  }
3283
3478
  ),
3284
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("overlay") })
3479
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("overlay") })
3285
3480
  ]
3286
3481
  }
3287
3482
  ),
@@ -3297,93 +3492,26 @@ var DraggableComponent = ({
3297
3492
  init_react_import();
3298
3493
  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" };
3299
3494
 
3300
- // components/DropZone/context.tsx
3301
- init_react_import();
3302
- var import_react21 = require("react");
3303
- var import_jsx_runtime20 = require("react/jsx-runtime");
3304
- var dropZoneContext = (0, import_react21.createContext)(null);
3305
- var DropZoneProvider = ({
3306
- children,
3307
- value
3308
- }) => {
3309
- const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
3310
- const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
3311
- {}
3312
- );
3313
- const [activeZones, setActiveZones] = (0, import_react21.useState)({});
3314
- const { dispatch } = useAppContext();
3315
- const registerZoneArea = (0, import_react21.useCallback)(
3316
- (area) => {
3317
- setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
3318
- },
3319
- [setAreasWithZones]
3320
- );
3321
- const registerZone = (0, import_react21.useCallback)(
3322
- (zoneCompound) => {
3323
- if (!dispatch) {
3324
- return;
3325
- }
3326
- dispatch({
3327
- type: "registerZone",
3328
- zone: zoneCompound
3329
- });
3330
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
3331
- },
3332
- [setActiveZones, dispatch]
3333
- );
3334
- const unregisterZone = (0, import_react21.useCallback)(
3335
- (zoneCompound) => {
3336
- if (!dispatch) {
3337
- return;
3338
- }
3339
- dispatch({
3340
- type: "unregisterZone",
3341
- zone: zoneCompound
3342
- });
3343
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
3344
- [zoneCompound]: false
3345
- }));
3346
- },
3347
- [setActiveZones, dispatch]
3348
- );
3349
- const memoValue = (0, import_react21.useMemo)(
3350
- () => __spreadValues({
3351
- hoveringComponent,
3352
- setHoveringComponent,
3353
- registerZoneArea,
3354
- areasWithZones,
3355
- registerZone,
3356
- unregisterZone,
3357
- activeZones
3358
- }, value),
3359
- [value, hoveringComponent, areasWithZones, activeZones]
3360
- );
3361
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
3362
- };
3363
-
3364
- // lib/insert.ts
3495
+ // components/DropZone/lib/use-min-empty-height.ts
3365
3496
  init_react_import();
3366
- var insert = (list, index, item) => {
3367
- const result = Array.from(list);
3368
- result.splice(index, 0, item);
3369
- return result;
3370
- };
3371
-
3372
- // components/DropZone/use-min-empty-height.ts
3373
- init_react_import();
3374
- var import_react22 = require("react");
3497
+ var import_react24 = require("react");
3375
3498
  var useMinEmptyHeight = ({
3376
- draggedItem,
3377
3499
  zoneCompound,
3378
3500
  userMinEmptyHeight,
3379
3501
  ref
3380
3502
  }) => {
3381
- const [prevHeight, setPrevHeight] = (0, import_react22.useState)(0);
3382
- const [isAnimating, setIsAnimating] = (0, import_react22.useState)(false);
3383
- (0, import_react22.useEffect)(() => {
3503
+ const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
3504
+ const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
3505
+ const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3506
+ var _a, _b;
3507
+ return {
3508
+ draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
3509
+ isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3510
+ };
3511
+ });
3512
+ (0, import_react24.useEffect)(() => {
3384
3513
  if (draggedItem && ref.current) {
3385
- const componentData = draggedItem.data;
3386
- if (componentData.zone === zoneCompound) {
3514
+ if (isZone) {
3387
3515
  const rect = ref.current.getBoundingClientRect();
3388
3516
  setPrevHeight(rect.height);
3389
3517
  setIsAnimating(true);
@@ -3413,15 +3541,131 @@ function assignRefs(refs, node) {
3413
3541
  });
3414
3542
  }
3415
3543
 
3544
+ // components/DropZone/lib/use-content-with-preview.ts
3545
+ init_react_import();
3546
+ var import_react27 = require("react");
3547
+
3548
+ // lib/dnd/use-rendered-callback.ts
3549
+ init_react_import();
3550
+ var import_react25 = require("@dnd-kit/react");
3551
+ var import_react26 = require("react");
3552
+ function useRenderedCallback(callback, deps) {
3553
+ const manager = (0, import_react25.useDragDropManager)();
3554
+ return (0, import_react26.useCallback)(
3555
+ (...args) => __async(this, null, function* () {
3556
+ yield manager == null ? void 0 : manager.renderer.rendering;
3557
+ return callback(...args);
3558
+ }),
3559
+ [...deps, manager]
3560
+ );
3561
+ }
3562
+
3563
+ // lib/insert.ts
3564
+ init_react_import();
3565
+ var insert = (list, index, item) => {
3566
+ const result = Array.from(list);
3567
+ result.splice(index, 0, item);
3568
+ return result;
3569
+ };
3570
+
3571
+ // components/DropZone/lib/use-content-with-preview.ts
3572
+ var useContentWithPreview = (content, zoneCompound) => {
3573
+ const { draggedItemId, preview, previewExists } = useContextStore(
3574
+ ZoneStoreContext,
3575
+ (s) => {
3576
+ var _a;
3577
+ return {
3578
+ draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
3579
+ preview: s.previewIndex[zoneCompound],
3580
+ previewExists: Object.keys(s.previewIndex || {}).length > 0
3581
+ };
3582
+ }
3583
+ );
3584
+ const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
3585
+ const updateContent = useRenderedCallback(
3586
+ (content2, preview2) => {
3587
+ if (preview2) {
3588
+ if (preview2.type === "insert") {
3589
+ setContentWithPreview(
3590
+ insert(
3591
+ content2.filter((item) => item.props.id !== preview2.props.id),
3592
+ preview2.index,
3593
+ {
3594
+ type: "preview",
3595
+ props: { id: preview2.props.id }
3596
+ }
3597
+ )
3598
+ );
3599
+ } else {
3600
+ setContentWithPreview(
3601
+ insert(
3602
+ content2.filter((item) => item.props.id !== preview2.props.id),
3603
+ preview2.index,
3604
+ {
3605
+ type: preview2.componentType,
3606
+ props: preview2.props
3607
+ }
3608
+ )
3609
+ );
3610
+ }
3611
+ } else {
3612
+ setContentWithPreview(
3613
+ previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3614
+ );
3615
+ }
3616
+ },
3617
+ [draggedItemId, previewExists]
3618
+ );
3619
+ (0, import_react27.useEffect)(() => {
3620
+ updateContent(content, preview);
3621
+ }, [content, preview]);
3622
+ return contentWithPreview;
3623
+ };
3624
+
3625
+ // components/DropZone/lib/use-drag-axis.ts
3626
+ init_react_import();
3627
+ var import_react28 = require("react");
3628
+ var GRID_DRAG_AXIS = "dynamic";
3629
+ var FLEX_ROW_DRAG_AXIS = "x";
3630
+ var DEFAULT_DRAG_AXIS = "y";
3631
+ var useDragAxis = (ref, collisionAxis) => {
3632
+ const { status } = useAppContext();
3633
+ const [dragAxis, setDragAxis] = (0, import_react28.useState)(
3634
+ collisionAxis || DEFAULT_DRAG_AXIS
3635
+ );
3636
+ const calculateDragAxis = (0, import_react28.useCallback)(() => {
3637
+ if (ref.current) {
3638
+ const computedStyle = window.getComputedStyle(ref.current);
3639
+ if (computedStyle.display === "grid") {
3640
+ setDragAxis(GRID_DRAG_AXIS);
3641
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3642
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3643
+ } else {
3644
+ setDragAxis(DEFAULT_DRAG_AXIS);
3645
+ }
3646
+ }
3647
+ }, [ref.current]);
3648
+ (0, import_react28.useEffect)(() => {
3649
+ const onViewportChange = () => {
3650
+ calculateDragAxis();
3651
+ };
3652
+ window.addEventListener("viewportchange", onViewportChange);
3653
+ return () => {
3654
+ window.removeEventListener("viewportchange", onViewportChange);
3655
+ };
3656
+ }, []);
3657
+ (0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
3658
+ return [dragAxis, calculateDragAxis];
3659
+ };
3660
+
3416
3661
  // components/DropZone/index.tsx
3417
- var import_jsx_runtime21 = require("react/jsx-runtime");
3662
+ var import_jsx_runtime22 = require("react/jsx-runtime");
3418
3663
  var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3419
- var DEBUG3 = false;
3420
- var GRID_DRAG_AXIS = "dynamic";
3421
- var FLEX_ROW_DRAG_AXIS = "x";
3422
- var DEFAULT_DRAG_AXIS = "y";
3423
- var DropZoneEdit = (0, import_react23.forwardRef)(
3424
- function DropZoneEdit2({
3664
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3665
+ var RENDER_DEBUG = false;
3666
+ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
3667
+ var DropZoneEdit = (0, import_react29.forwardRef)(
3668
+ function DropZoneEditInternal({
3425
3669
  zone,
3426
3670
  allow,
3427
3671
  disallow,
@@ -3431,31 +3675,50 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3431
3675
  collisionAxis
3432
3676
  }, userRef) {
3433
3677
  const appContext2 = useAppContext();
3434
- const ctx = (0, import_react23.useContext)(dropZoneContext);
3678
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
3435
3679
  const {
3436
3680
  // These all need setting via context
3437
3681
  data,
3438
3682
  config,
3439
3683
  areaId,
3440
- draggedItem,
3441
3684
  registerZoneArea,
3442
3685
  depth,
3443
3686
  registerLocalZone,
3444
3687
  unregisterLocalZone,
3445
- deepestZone = rootDroppableId,
3446
- deepestArea,
3447
- nextDeepestArea,
3448
3688
  path = [],
3449
3689
  activeZones
3450
3690
  } = ctx;
3451
- const { itemSelector } = appContext2.state.ui;
3452
3691
  let zoneCompound = rootDroppableId;
3453
- (0, import_react23.useEffect)(() => {
3692
+ if (areaId) {
3693
+ if (zone !== rootDroppableId) {
3694
+ zoneCompound = `${areaId}:${zone}`;
3695
+ }
3696
+ }
3697
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3698
+ const {
3699
+ isDeepestZone,
3700
+ inNextDeepestArea,
3701
+ draggedComponentType,
3702
+ userIsDragging,
3703
+ preview
3704
+ } = useContextStore(ZoneStoreContext, (s) => {
3705
+ var _a, _b, _c;
3706
+ return {
3707
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3708
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3709
+ draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3710
+ draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3711
+ userIsDragging: !!s.draggedItem,
3712
+ preview: s.previewIndex[zoneCompound]
3713
+ };
3714
+ });
3715
+ const { itemSelector } = appContext2.state.ui;
3716
+ (0, import_react29.useEffect)(() => {
3454
3717
  if (areaId && registerZoneArea) {
3455
3718
  registerZoneArea(areaId);
3456
3719
  }
3457
3720
  }, [areaId]);
3458
- (0, import_react23.useEffect)(() => {
3721
+ (0, import_react29.useEffect)(() => {
3459
3722
  if (ctx == null ? void 0 : ctx.registerZone) {
3460
3723
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3461
3724
  }
@@ -3465,25 +3728,18 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3465
3728
  }
3466
3729
  };
3467
3730
  }, []);
3468
- if (areaId) {
3469
- if (zone !== rootDroppableId) {
3470
- zoneCompound = `${areaId}:${zone}`;
3471
- }
3472
- }
3473
- const content = (0, import_react23.useMemo)(() => {
3731
+ const content = (0, import_react29.useMemo)(() => {
3474
3732
  if (areaId && zone !== rootDroppableId) {
3475
3733
  return setupZone(data, zoneCompound).zones[zoneCompound];
3476
3734
  }
3477
3735
  return data.content || [];
3478
3736
  }, [data, zoneCompound]);
3479
- const ref = (0, import_react23.useRef)(null);
3480
- const acceptsTarget = (0, import_react23.useCallback)(
3481
- (target) => {
3482
- if (!target) {
3737
+ const ref = (0, import_react29.useRef)(null);
3738
+ const acceptsTarget = (0, import_react29.useCallback)(
3739
+ (componentType) => {
3740
+ if (!componentType) {
3483
3741
  return true;
3484
3742
  }
3485
- const data2 = target.data;
3486
- const { componentType } = data2;
3487
3743
  if (disallow) {
3488
3744
  const defaultedAllow = allow || [];
3489
3745
  const filteredDisallow = (disallow || []).filter(
@@ -3501,49 +3757,26 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3501
3757
  },
3502
3758
  [allow, disallow]
3503
3759
  );
3504
- (0, import_react23.useEffect)(() => {
3760
+ (0, import_react29.useEffect)(() => {
3505
3761
  if (registerLocalZone) {
3506
- registerLocalZone(zoneCompound, acceptsTarget(draggedItem));
3762
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3507
3763
  }
3508
3764
  return () => {
3509
3765
  if (unregisterLocalZone) {
3510
3766
  unregisterLocalZone(zoneCompound);
3511
3767
  }
3512
3768
  };
3513
- }, [draggedItem, zoneCompound]);
3514
- const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3515
- const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
3516
- const userIsDragging = !!draggedItem;
3769
+ }, [draggedComponentType, zoneCompound]);
3770
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3517
3771
  let isEnabled = true;
3518
- if (draggedItem) {
3519
- isEnabled = deepestZone === zoneCompound;
3772
+ if (userIsDragging) {
3773
+ isEnabled = isDeepestZone;
3520
3774
  }
3521
3775
  if (isEnabled) {
3522
- isEnabled = acceptsTarget(draggedItem);
3523
- }
3524
- const preview = (0, import_react23.useContext)(previewContext);
3525
- const previewInZone = (preview == null ? void 0 : preview.zone) === zoneCompound;
3526
- const contentWithPreview = (0, import_react23.useMemo)(() => {
3527
- let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
3528
- if (previewInZone) {
3529
- contentWithPreview2 = content.filter(
3530
- (item) => item.props.id !== preview.props.id
3531
- );
3532
- if (preview.type === "insert") {
3533
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3534
- type: "preview",
3535
- props: { id: preview.props.id }
3536
- });
3537
- } else {
3538
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3539
- type: preview.componentType,
3540
- props: preview.props
3541
- });
3542
- }
3543
- }
3544
- return contentWithPreview2;
3545
- }, [preview, content]);
3546
- const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3776
+ isEnabled = acceptsTarget(draggedComponentType);
3777
+ }
3778
+ const contentWithPreview = useContentWithPreview(content, zoneCompound);
3779
+ const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3547
3780
  const droppableConfig = {
3548
3781
  id: zoneCompound,
3549
3782
  collisionPriority: isEnabled ? depth : 0,
@@ -3553,45 +3786,20 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3553
3786
  data: {
3554
3787
  areaId,
3555
3788
  depth,
3556
- isDroppableTarget: acceptsTarget(draggedItem),
3789
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3557
3790
  path
3558
3791
  }
3559
3792
  };
3560
3793
  const { ref: dropRef } = useDroppableSafe(droppableConfig);
3561
3794
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3562
3795
  const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
3563
- const [dragAxis, setDragAxis] = (0, import_react23.useState)(
3564
- collisionAxis || DEFAULT_DRAG_AXIS
3565
- );
3566
- const calculateDragAxis = (0, import_react23.useCallback)(() => {
3567
- if (ref.current) {
3568
- const computedStyle = window.getComputedStyle(ref.current);
3569
- if (computedStyle.display === "grid") {
3570
- setDragAxis(GRID_DRAG_AXIS);
3571
- } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3572
- setDragAxis(FLEX_ROW_DRAG_AXIS);
3573
- } else {
3574
- setDragAxis(DEFAULT_DRAG_AXIS);
3575
- }
3576
- }
3577
- }, [ref.current]);
3578
- (0, import_react23.useEffect)(calculateDragAxis, [appContext2.status, collisionAxis]);
3579
- (0, import_react23.useEffect)(() => {
3580
- const onViewportChange = () => {
3581
- calculateDragAxis();
3582
- };
3583
- window.addEventListener("viewportchange", onViewportChange);
3584
- return () => {
3585
- window.removeEventListener("viewportchange", onViewportChange);
3586
- };
3587
- }, []);
3796
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3588
3797
  const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3589
- draggedItem,
3590
3798
  zoneCompound,
3591
3799
  userMinEmptyHeight,
3592
3800
  ref
3593
3801
  });
3594
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3802
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3595
3803
  "div",
3596
3804
  {
3597
3805
  className: `${getClassName17({
@@ -3611,88 +3819,84 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3611
3819
  "data-puck-dropzone": zoneCompound,
3612
3820
  "data-puck-dnd": zoneCompound,
3613
3821
  style: __spreadProps(__spreadValues({}, style), {
3614
- "--min-empty-height": `${minEmptyHeight}px`
3822
+ "--min-empty-height": `${minEmptyHeight}px`,
3823
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3615
3824
  }),
3616
- children: [
3617
- isRootZone && DEBUG3 && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { "data-puck-component": true, children: [
3618
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: deepestZone || rootDroppableId }),
3619
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: deepestArea || "No area" })
3620
- ] }),
3621
- contentWithPreview.map((item, i) => {
3622
- var _a, _b, _c, _d, _e;
3623
- const componentId = item.props.id;
3624
- const puckProps = {
3625
- renderDropZone: DropZone,
3626
- isEditing: true,
3627
- dragRef: null
3825
+ children: contentWithPreview.map((item, i) => {
3826
+ var _a, _b, _c, _d, _e, _f, _g;
3827
+ const componentId = item.props.id;
3828
+ const puckProps = {
3829
+ renderDropZone: DropZoneEditPure,
3830
+ isEditing: true,
3831
+ dragRef: null
3832
+ };
3833
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3834
+ puck: puckProps,
3835
+ editMode: true
3836
+ // DEPRECATED
3837
+ });
3838
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3839
+ 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: [
3840
+ "No configuration for ",
3841
+ item.type
3842
+ ] });
3843
+ const componentConfig = config.components[item.type];
3844
+ let componentType = item.type;
3845
+ let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3846
+ if (item.type === "preview") {
3847
+ let Preview4 = function() {
3848
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3628
3849
  };
3629
- const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3630
- puck: puckProps,
3631
- editMode: true
3632
- // DEPRECATED
3633
- });
3634
- const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3635
- let Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
3636
- "No configuration for ",
3637
- item.type
3638
- ] });
3639
- const componentConfig = config.components[item.type];
3640
- let componentType = item.type;
3641
- let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3642
- if (item.type === "preview") {
3643
- let Preview3 = function() {
3644
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DrawerItemInner, { name: label });
3645
- };
3646
- var Preview2 = Preview3;
3647
- componentType = preview.componentType;
3648
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3649
- Render2 = Preview3;
3650
- }
3651
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3652
- DropZoneProvider,
3653
- {
3654
- value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3655
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3656
- DraggableComponent,
3657
- {
3658
- id: componentId,
3659
- componentType,
3660
- zoneCompound,
3661
- depth: depth + 1,
3662
- index: i,
3663
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3664
- isSelected,
3665
- label,
3666
- isEnabled,
3667
- autoDragAxis: dragAxis,
3668
- userDragAxis: collisionAxis,
3669
- inDroppableZone: acceptsTarget(draggedItem),
3670
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3671
- Render2,
3672
- __spreadProps(__spreadValues({}, defaultedProps), {
3673
- puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3674
- dragRef
3675
- })
3850
+ var Preview3 = Preview4;
3851
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3852
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3853
+ Render2 = Preview4;
3854
+ }
3855
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3856
+ DropZoneProvider,
3857
+ {
3858
+ value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3859
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3860
+ DraggableComponent,
3861
+ {
3862
+ id: componentId,
3863
+ componentType,
3864
+ zoneCompound,
3865
+ depth: depth + 1,
3866
+ index: i,
3867
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3868
+ isSelected,
3869
+ label,
3870
+ isEnabled,
3871
+ autoDragAxis: dragAxis,
3872
+ userDragAxis: collisionAxis,
3873
+ inDroppableZone: acceptsTarget(draggedComponentType),
3874
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3875
+ Render2,
3876
+ __spreadProps(__spreadValues({}, defaultedProps), {
3877
+ puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3878
+ dragRef
3676
3879
  })
3677
- ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Render2, __spreadValues({}, defaultedProps)) })
3678
- }
3679
- )
3680
- },
3681
- componentId
3682
- );
3683
- })
3684
- ]
3880
+ })
3881
+ ) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Render2, __spreadValues({}, defaultedProps)) })
3882
+ }
3883
+ )
3884
+ },
3885
+ componentId
3886
+ );
3887
+ })
3685
3888
  }
3686
3889
  );
3687
3890
  }
3688
3891
  );
3689
- var DropZoneRender = (0, import_react23.forwardRef)(
3690
- function DropZoneRender2({ className, style, zone }, ref) {
3691
- const ctx = (0, import_react23.useContext)(dropZoneContext);
3892
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
3893
+ var DropZoneRender = (0, import_react29.forwardRef)(
3894
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3895
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
3692
3896
  const { data, areaId = "root", config } = ctx || {};
3693
3897
  let zoneCompound = rootDroppableId;
3694
3898
  let content = (data == null ? void 0 : data.content) || [];
3695
- (0, import_react23.useEffect)(() => {
3899
+ (0, import_react29.useEffect)(() => {
3696
3900
  if (ctx == null ? void 0 : ctx.registerZone) {
3697
3901
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3698
3902
  }
@@ -3709,10 +3913,10 @@ var DropZoneRender = (0, import_react23.forwardRef)(
3709
3913
  zoneCompound = `${areaId}:${zone}`;
3710
3914
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3711
3915
  }
3712
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
3916
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
3713
3917
  const Component = config.components[item.type];
3714
3918
  if (Component) {
3715
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3919
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3716
3920
  DropZoneProvider,
3717
3921
  {
3718
3922
  value: {
@@ -3722,10 +3926,12 @@ var DropZoneRender = (0, import_react23.forwardRef)(
3722
3926
  depth: 1,
3723
3927
  path: []
3724
3928
  },
3725
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3929
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3726
3930
  Component.render,
3727
3931
  __spreadProps(__spreadValues({}, item.props), {
3728
- puck: { renderDropZone: DropZoneRender2 }
3932
+ puck: {
3933
+ renderDropZone: DropZoneRenderPure
3934
+ }
3729
3935
  })
3730
3936
  )
3731
3937
  },
@@ -3736,13 +3942,13 @@ var DropZoneRender = (0, import_react23.forwardRef)(
3736
3942
  }) });
3737
3943
  }
3738
3944
  );
3739
- var DropZone = (0, import_react23.forwardRef)(
3945
+ var DropZone = (0, import_react29.forwardRef)(
3740
3946
  function DropZone2(props, ref) {
3741
- const ctx = (0, import_react23.useContext)(dropZoneContext);
3947
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
3742
3948
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3743
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3949
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3744
3950
  }
3745
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3951
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3746
3952
  }
3747
3953
  );
3748
3954
 
@@ -3758,7 +3964,7 @@ var getZoneId = (zoneCompound) => {
3758
3964
  return [rootDroppableId, zoneCompound];
3759
3965
  };
3760
3966
 
3761
- // components/DragDropContext/NestedDroppablePlugin.ts
3967
+ // lib/dnd/NestedDroppablePlugin.ts
3762
3968
  init_react_import();
3763
3969
  var import_abstract9 = require("@dnd-kit/abstract");
3764
3970
  var import_state = require("@dnd-kit/state");
@@ -3800,7 +4006,49 @@ var getFrame = () => {
3800
4006
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3801
4007
  };
3802
4008
 
3803
- // components/DragDropContext/NestedDroppablePlugin.ts
4009
+ // lib/global-position.ts
4010
+ init_react_import();
4011
+ var GlobalPosition = class {
4012
+ constructor(target, original) {
4013
+ this.scaleFactor = 1;
4014
+ this.frameEl = null;
4015
+ this.frameRect = null;
4016
+ var _a;
4017
+ this.target = target;
4018
+ this.original = original;
4019
+ this.frameEl = document.querySelector("iframe");
4020
+ if (this.frameEl) {
4021
+ this.frameRect = this.frameEl.getBoundingClientRect();
4022
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
4023
+ }
4024
+ }
4025
+ get x() {
4026
+ return this.original.x;
4027
+ }
4028
+ get y() {
4029
+ return this.original.y;
4030
+ }
4031
+ get global() {
4032
+ if (document !== this.target.ownerDocument && this.frameRect) {
4033
+ return {
4034
+ x: this.x * this.scaleFactor + this.frameRect.left,
4035
+ y: this.y * this.scaleFactor + this.frameRect.top
4036
+ };
4037
+ }
4038
+ return this.original;
4039
+ }
4040
+ get frame() {
4041
+ if (document === this.target.ownerDocument && this.frameRect) {
4042
+ return {
4043
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
4044
+ y: (this.y - this.frameRect.top) / this.scaleFactor
4045
+ };
4046
+ }
4047
+ return this.original;
4048
+ }
4049
+ };
4050
+
4051
+ // lib/dnd/NestedDroppablePlugin.ts
3804
4052
  var depthSort = (candidates) => {
3805
4053
  return candidates.sort((a, b) => {
3806
4054
  const aData = a.data;
@@ -3829,10 +4077,12 @@ var getZoneId2 = (candidate) => {
3829
4077
  }
3830
4078
  return id;
3831
4079
  };
3832
- var getPointerCollisions = (position, manager, ownerDocument) => {
3833
- var _a;
4080
+ var getPointerCollisions = (position, manager) => {
3834
4081
  const candidates = [];
3835
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
4082
+ let elements = position.target.ownerDocument.elementsFromPoint(
4083
+ position.x,
4084
+ position.y
4085
+ );
3836
4086
  const previewFrame = elements.find(
3837
4087
  (el) => el.getAttribute("data-puck-preview")
3838
4088
  );
@@ -3841,17 +4091,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3841
4091
  elements = [drawer];
3842
4092
  }
3843
4093
  if (previewFrame) {
3844
- const iframe = previewFrame.querySelector("iframe");
3845
- if (iframe) {
3846
- const rect = iframe.getBoundingClientRect();
3847
- const frame = getFrame();
3848
- if (frame) {
3849
- const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3850
- elements = frame.elementsFromPoint(
3851
- (position.x - rect.left) / scaleFactor,
3852
- (position.y - rect.top) / scaleFactor
3853
- );
3854
- }
4094
+ const frame = getFrame();
4095
+ if (frame) {
4096
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3855
4097
  }
3856
4098
  }
3857
4099
  if (elements) {
@@ -3868,9 +4110,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3868
4110
  }
3869
4111
  return candidates;
3870
4112
  };
3871
- var findDeepestCandidate = (position, manager, ownerDocument) => {
4113
+ var findDeepestCandidate = (position, manager) => {
3872
4114
  var _a;
3873
- const candidates = getPointerCollisions(position, manager, ownerDocument);
4115
+ const candidates = getPointerCollisions(position, manager);
3874
4116
  if (candidates.length > 0) {
3875
4117
  const sortedCandidates = depthSort(candidates);
3876
4118
  const draggable = manager.dragOperation.source;
@@ -3915,9 +4157,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
3915
4157
  area: null
3916
4158
  };
3917
4159
  };
3918
- var createNestedDroppablePlugin = ({
3919
- onChange
3920
- }) => class NestedDroppablePlugin extends import_abstract9.Plugin {
4160
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
3921
4161
  constructor(manager, options) {
3922
4162
  super(manager);
3923
4163
  if (typeof window === "undefined") {
@@ -3925,16 +4165,19 @@ var createNestedDroppablePlugin = ({
3925
4165
  }
3926
4166
  const cleanupEffect = (0, import_state.effects)(() => {
3927
4167
  const handleMove = (event) => {
3928
- const position = {
4168
+ const target = event.originalTarget || event.target;
4169
+ const position = new GlobalPosition(target, {
3929
4170
  x: event.clientX,
3930
4171
  y: event.clientY
3931
- };
3932
- const target = event.originalTarget || event.target;
3933
- const ownerDocument = target == null ? void 0 : target.ownerDocument;
3934
- onChange(
3935
- findDeepestCandidate(position, manager, ownerDocument),
3936
- manager
4172
+ });
4173
+ const elements = document.elementsFromPoint(
4174
+ position.global.x,
4175
+ position.global.y
3937
4176
  );
4177
+ const overEl = elements.some((el) => el.id === id);
4178
+ if (overEl) {
4179
+ onChange(findDeepestCandidate(position, manager), manager);
4180
+ }
3938
4181
  };
3939
4182
  const handleMoveThrottled = throttle(handleMove, 50);
3940
4183
  const handlePointerMove = (event) => {
@@ -4264,6 +4507,11 @@ var reduceUi = (ui, action) => {
4264
4507
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4265
4508
  });
4266
4509
  }
4510
+ if (action.type === "remove") {
4511
+ return __spreadProps(__spreadValues({}, ui), {
4512
+ itemSelector: null
4513
+ });
4514
+ }
4267
4515
  return ui;
4268
4516
  };
4269
4517
 
@@ -4351,7 +4599,7 @@ var insertComponent = (componentType, zone, index, {
4351
4599
  var import_use_debounce2 = require("use-debounce");
4352
4600
  var import_utilities2 = require("@dnd-kit/dom/utilities");
4353
4601
 
4354
- // components/DragDropContext/PointerSensor.ts
4602
+ // lib/dnd/PointerSensor.ts
4355
4603
  init_react_import();
4356
4604
  var import_state3 = require("@dnd-kit/state");
4357
4605
  var import_abstract10 = require("@dnd-kit/abstract");
@@ -4514,6 +4762,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
4514
4762
  }
4515
4763
  }
4516
4764
  handlePointerUp(event) {
4765
+ if (!this.source) {
4766
+ return;
4767
+ }
4517
4768
  event.preventDefault();
4518
4769
  event.stopPropagation();
4519
4770
  const { status } = this.manager.dragOperation;
@@ -4613,13 +4864,15 @@ function patchWindow(window2) {
4613
4864
  }
4614
4865
 
4615
4866
  // components/DragDropContext/index.tsx
4616
- var import_jsx_runtime22 = require("react/jsx-runtime");
4617
- var dragListenerContext = (0, import_react25.createContext)({
4867
+ var import_zustand3 = require("zustand");
4868
+ var import_jsx_runtime23 = require("react/jsx-runtime");
4869
+ var DEBUG3 = false;
4870
+ var dragListenerContext = (0, import_react31.createContext)({
4618
4871
  dragListeners: {}
4619
4872
  });
4620
4873
  function useDragListener(type, fn, deps = []) {
4621
- const { setDragListeners } = (0, import_react25.useContext)(dragListenerContext);
4622
- (0, import_react25.useEffect)(() => {
4874
+ const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
4875
+ (0, import_react31.useEffect)(() => {
4623
4876
  if (setDragListeners) {
4624
4877
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
4625
4878
  [type]: [...old[type] || [], fn]
@@ -4627,80 +4880,147 @@ function useDragListener(type, fn, deps = []) {
4627
4880
  }
4628
4881
  }, deps);
4629
4882
  }
4630
- var previewContext = (0, import_react25.createContext)(null);
4631
4883
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4884
+ var useTempDisableFallback = (timeout3) => {
4885
+ const lastFallbackDisable = (0, import_react31.useRef)(null);
4886
+ return (0, import_react31.useCallback)((manager) => {
4887
+ collisionStore.setState({ fallbackEnabled: false });
4888
+ const fallbackId = generateId();
4889
+ lastFallbackDisable.current = fallbackId;
4890
+ setTimeout(() => {
4891
+ if (lastFallbackDisable.current === fallbackId) {
4892
+ collisionStore.setState({ fallbackEnabled: true });
4893
+ manager.collisionObserver.forceUpdate(true);
4894
+ }
4895
+ }, timeout3);
4896
+ }, []);
4897
+ };
4632
4898
  var DragDropContextClient = ({
4633
4899
  children,
4634
4900
  disableAutoScroll
4635
4901
  }) => {
4636
4902
  const { state, config, dispatch, resolveData } = useAppContext();
4637
- const [preview, setPreview] = (0, import_react25.useState)(null);
4638
- const previewRef = (0, import_react25.useRef)(null);
4903
+ const id = (0, import_react31.useId)();
4639
4904
  const { data } = state;
4640
- const [deepest, setDeepest] = (0, import_react25.useState)(null);
4641
- const [nextDeepest, setNextDeepest] = (0, import_react25.useState)(null);
4642
- const deepestRef = (0, import_react25.useRef)(deepest);
4643
- const debouncedParamsRef = (0, import_react25.useRef)(null);
4644
- const setDeepestAndCollide = (0, import_react25.useCallback)(
4905
+ const debouncedParamsRef = (0, import_react31.useRef)(null);
4906
+ const tempDisableFallback = useTempDisableFallback(100);
4907
+ const [zoneStore] = (0, import_react31.useState)(
4908
+ () => (0, import_zustand3.createStore)(() => ({
4909
+ zoneDepthIndex: {},
4910
+ nextZoneDepthIndex: {},
4911
+ areaDepthIndex: {},
4912
+ nextAreaDepthIndex: {},
4913
+ draggedItem: null,
4914
+ previewIndex: {}
4915
+ }))
4916
+ );
4917
+ const getChanged2 = (0, import_react31.useCallback)(
4918
+ (params, id2) => {
4919
+ const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
4920
+ const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
4921
+ const stateHasArea = Object.keys(areaDepthIndex).length > 0;
4922
+ let zoneChanged = false;
4923
+ let areaChanged = false;
4924
+ if (params.zone && !zoneDepthIndex[params.zone]) {
4925
+ zoneChanged = true;
4926
+ } else if (!params.zone && stateHasZone) {
4927
+ zoneChanged = true;
4928
+ }
4929
+ if (params.area && !areaDepthIndex[params.area]) {
4930
+ areaChanged = true;
4931
+ } else if (!params.area && stateHasArea) {
4932
+ areaChanged = true;
4933
+ }
4934
+ return { zoneChanged, areaChanged };
4935
+ },
4936
+ [zoneStore]
4937
+ );
4938
+ const setDeepestAndCollide = (0, import_react31.useCallback)(
4645
4939
  (params, manager) => {
4646
- setDeepest(params);
4940
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4941
+ if (!zoneChanged && !areaChanged) return;
4942
+ zoneStore.setState({
4943
+ zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
4944
+ areaDepthIndex: params.area ? { [params.area]: true } : {}
4945
+ });
4946
+ tempDisableFallback(manager);
4647
4947
  setTimeout(() => {
4648
4948
  manager.collisionObserver.forceUpdate(true);
4649
4949
  }, 50);
4650
4950
  debouncedParamsRef.current = null;
4651
4951
  },
4652
- []
4952
+ [zoneStore]
4653
4953
  );
4654
4954
  const setDeepestDb = (0, import_use_debounce2.useDebouncedCallback)(
4655
4955
  setDeepestAndCollide,
4656
4956
  AREA_CHANGE_DEBOUNCE_MS
4657
4957
  );
4658
- (0, import_react25.useEffect)(() => {
4659
- deepestRef.current = deepest;
4660
- }, [deepest]);
4661
4958
  const cancelDb = () => {
4662
4959
  setDeepestDb.cancel();
4663
4960
  debouncedParamsRef.current = null;
4664
4961
  };
4665
- const [plugins] = (0, import_react25.useState)(() => [
4666
- ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
4667
- createNestedDroppablePlugin({
4668
- onChange: (params, manager) => {
4669
- const lastParams = deepestRef.current;
4670
- const areaChanged = params.area !== (lastParams == null ? void 0 : lastParams.area);
4671
- const zoneChanged = params.zone !== (lastParams == null ? void 0 : lastParams.zone);
4672
- const isDragging = manager.dragOperation.status.dragging;
4673
- if (areaChanged || zoneChanged) {
4674
- setNextDeepest(params);
4675
- }
4676
- if (params.zone !== "void" && (lastParams == null ? void 0 : lastParams.zone) === "void") {
4677
- setDeepest(params);
4678
- manager.collisionObserver.forceUpdate(true);
4679
- return;
4962
+ (0, import_react31.useEffect)(() => {
4963
+ if (DEBUG3) {
4964
+ zoneStore.subscribe(
4965
+ (s) => {
4966
+ var _a, _b;
4967
+ return console.log(
4968
+ s.previewIndex,
4969
+ (_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
4970
+ (_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
4971
+ );
4680
4972
  }
4681
- if (areaChanged) {
4682
- if (isDragging) {
4683
- const debouncedParams = debouncedParamsRef.current;
4684
- const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4685
- if (!isSameParams) {
4973
+ );
4974
+ }
4975
+ }, []);
4976
+ const [plugins] = (0, import_react31.useState)(() => [
4977
+ ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
4978
+ createNestedDroppablePlugin(
4979
+ {
4980
+ onChange: (params, manager) => {
4981
+ const state2 = zoneStore.getState();
4982
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4983
+ const isDragging = manager.dragOperation.status.dragging;
4984
+ if (areaChanged || zoneChanged) {
4985
+ let nextZoneDepthIndex = {};
4986
+ let nextAreaDepthIndex = {};
4987
+ if (params.zone) {
4988
+ nextZoneDepthIndex = { [params.zone]: true };
4989
+ }
4990
+ if (params.area) {
4991
+ nextAreaDepthIndex = { [params.area]: true };
4992
+ }
4993
+ zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
4994
+ }
4995
+ if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
4996
+ setDeepestAndCollide(params, manager);
4997
+ return;
4998
+ }
4999
+ if (areaChanged) {
5000
+ if (isDragging) {
5001
+ const debouncedParams = debouncedParamsRef.current;
5002
+ const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
5003
+ if (!isSameParams) {
5004
+ cancelDb();
5005
+ setDeepestDb(params, manager);
5006
+ debouncedParamsRef.current = params;
5007
+ }
5008
+ } else {
4686
5009
  cancelDb();
4687
- setDeepestDb(params, manager);
4688
- debouncedParamsRef.current = params;
5010
+ setDeepestAndCollide(params, manager);
4689
5011
  }
4690
- } else {
4691
- cancelDb();
5012
+ return;
5013
+ }
5014
+ if (zoneChanged) {
4692
5015
  setDeepestAndCollide(params, manager);
4693
5016
  }
4694
- return;
5017
+ cancelDb();
4695
5018
  }
4696
- if (zoneChanged) {
4697
- setDeepestAndCollide(params, manager);
4698
- }
4699
- cancelDb();
4700
- }
4701
- })
5019
+ },
5020
+ id
5021
+ )
4702
5022
  ]);
4703
- const [sensors] = (0, import_react25.useState)(() => [
5023
+ const [sensors] = (0, import_react31.useState)(() => [
4704
5024
  PointerSensor.configure({
4705
5025
  activationConstraints(event, source) {
4706
5026
  var _a;
@@ -4719,11 +5039,10 @@ var DragDropContextClient = ({
4719
5039
  }
4720
5040
  })
4721
5041
  ]);
4722
- const [draggedItem, setDraggedItem] = (0, import_react25.useState)();
4723
- const [dragListeners, setDragListeners] = (0, import_react25.useState)({});
4724
- const [pathData, setPathData] = (0, import_react25.useState)();
4725
- const dragMode = (0, import_react25.useRef)(null);
4726
- const registerPath = (0, import_react25.useCallback)(
5042
+ const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
5043
+ const [pathData, setPathData] = (0, import_react31.useState)();
5044
+ const dragMode = (0, import_react31.useRef)(null);
5045
+ const registerPath = (0, import_react31.useCallback)(
4727
5046
  (selector) => {
4728
5047
  const item = getItem(selector, data);
4729
5048
  if (!item) {
@@ -4745,41 +5064,41 @@ var DragDropContextClient = ({
4745
5064
  },
4746
5065
  [data, setPathData]
4747
5066
  );
4748
- const initialSelector = (0, import_react25.useRef)(void 0);
4749
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5067
+ const initialSelector = (0, import_react31.useRef)(void 0);
5068
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4750
5069
  dragListenerContext.Provider,
4751
5070
  {
4752
5071
  value: {
4753
5072
  dragListeners,
4754
5073
  setDragListeners
4755
5074
  },
4756
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(previewContext.Provider, { value: preview, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4757
- import_react24.DragDropProvider,
5075
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5076
+ import_react30.DragDropProvider,
4758
5077
  {
4759
5078
  plugins,
4760
5079
  sensors,
4761
5080
  onDragEnd: (event, manager) => {
5081
+ var _a;
4762
5082
  const { source, target } = event.operation;
4763
- deepestRef.current = null;
4764
5083
  if (!source) {
4765
- setDraggedItem(null);
5084
+ zoneStore.setState({ draggedItem: null });
4766
5085
  return;
4767
5086
  }
4768
5087
  const { zone, index } = source.data;
4769
- const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
4770
- previewRef.current = null;
5088
+ const { previewIndex = {} } = zoneStore.getState() || {};
5089
+ const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
4771
5090
  setTimeout(() => {
4772
- var _a, _b;
4773
- setDraggedItem(null);
5091
+ var _a2, _b;
5092
+ zoneStore.setState({ draggedItem: null });
4774
5093
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4775
- setPreview(null);
4776
- (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
5094
+ zoneStore.setState({ previewIndex: {} });
5095
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
4777
5096
  fn(event, manager);
4778
5097
  });
4779
5098
  return;
4780
5099
  }
4781
5100
  if (thisPreview) {
4782
- setPreview(null);
5101
+ zoneStore.setState({ previewIndex: {} });
4783
5102
  if (thisPreview.type === "insert") {
4784
5103
  insertComponent(
4785
5104
  thisPreview.componentType,
@@ -4814,8 +5133,9 @@ var DragDropContextClient = ({
4814
5133
  }, 250);
4815
5134
  },
4816
5135
  onDragOver: (event, manager) => {
4817
- var _a, _b, _c, _d;
5136
+ var _a, _b, _c, _d, _e;
4818
5137
  event.preventDefault();
5138
+ const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
4819
5139
  if (!draggedItem) return;
4820
5140
  cancelDb();
4821
5141
  const { source, target } = event.operation;
@@ -4831,7 +5151,7 @@ var DragDropContextClient = ({
4831
5151
  const targetData = target.data;
4832
5152
  targetZone = targetData.zone;
4833
5153
  targetIndex = targetData.index;
4834
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
5154
+ const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
4835
5155
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
4836
5156
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
4837
5157
  targetIndex = targetIndex - 1;
@@ -4843,23 +5163,26 @@ var DragDropContextClient = ({
4843
5163
  targetZone = target.id.toString();
4844
5164
  targetIndex = 0;
4845
5165
  }
4846
- if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
5166
+ if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
4847
5167
  const [pathId] = path.split(":");
4848
5168
  return pathId === sourceId;
4849
5169
  }))) {
4850
5170
  return;
4851
5171
  }
4852
5172
  if (dragMode.current === "new") {
4853
- previewRef.current = {
4854
- componentType: sourceData.componentType,
4855
- type: "insert",
4856
- index: targetIndex,
4857
- zone: targetZone,
4858
- props: {
4859
- id: source.id.toString()
5173
+ zoneStore.setState({
5174
+ previewIndex: {
5175
+ [targetZone]: {
5176
+ componentType: sourceData.componentType,
5177
+ type: "insert",
5178
+ index: targetIndex,
5179
+ zone: targetZone,
5180
+ props: {
5181
+ id: source.id.toString()
5182
+ }
5183
+ }
4860
5184
  }
4861
- };
4862
- setPreview(previewRef.current);
5185
+ });
4863
5186
  } else {
4864
5187
  if (!initialSelector.current) {
4865
5188
  initialSelector.current = {
@@ -4869,17 +5192,20 @@ var DragDropContextClient = ({
4869
5192
  }
4870
5193
  const item = getItem(initialSelector.current, data);
4871
5194
  if (item) {
4872
- previewRef.current = {
4873
- componentType: sourceData.componentType,
4874
- type: "move",
4875
- index: targetIndex,
4876
- zone: targetZone,
4877
- props: item.props
4878
- };
4879
- setPreview(previewRef.current);
5195
+ zoneStore.setState({
5196
+ previewIndex: {
5197
+ [targetZone]: {
5198
+ componentType: sourceData.componentType,
5199
+ type: "move",
5200
+ index: targetIndex,
5201
+ zone: targetZone,
5202
+ props: item.props
5203
+ }
5204
+ }
5205
+ });
4880
5206
  }
4881
5207
  }
4882
- (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
5208
+ (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
4883
5209
  fn(event, manager);
4884
5210
  });
4885
5211
  },
@@ -4889,45 +5215,61 @@ var DragDropContextClient = ({
4889
5215
  type: "setUi",
4890
5216
  ui: { itemSelector: null, isDragging: true }
4891
5217
  });
5218
+ const { source } = event.operation;
5219
+ if (source && source.type !== "void") {
5220
+ const sourceData = source.data;
5221
+ const item = getItem(
5222
+ {
5223
+ zone: sourceData.zone,
5224
+ index: sourceData.index
5225
+ },
5226
+ data
5227
+ );
5228
+ if (item) {
5229
+ zoneStore.setState({
5230
+ previewIndex: {
5231
+ [sourceData.zone]: {
5232
+ componentType: sourceData.componentType,
5233
+ type: "move",
5234
+ index: sourceData.index,
5235
+ zone: sourceData.zone,
5236
+ props: item.props
5237
+ }
5238
+ }
5239
+ });
5240
+ }
5241
+ }
4892
5242
  (_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
4893
5243
  fn(event, manager);
4894
5244
  });
4895
5245
  },
4896
5246
  onBeforeDragStart: (event) => {
4897
5247
  var _a;
4898
- if (draggedItem) {
4899
- console.warn("New drag started before previous drag cleaned up");
4900
- }
4901
5248
  const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
4902
5249
  dragMode.current = isNewComponent ? "new" : "existing";
4903
5250
  initialSelector.current = void 0;
4904
- setDraggedItem(event.operation.source);
5251
+ zoneStore.setState({ draggedItem: event.operation.source });
4905
5252
  },
4906
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5253
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4907
5254
  DropZoneProvider,
4908
5255
  {
4909
5256
  value: {
4910
5257
  data,
4911
5258
  config,
4912
- draggedItem,
4913
5259
  mode: "edit",
4914
5260
  areaId: "root",
4915
5261
  depth: 0,
4916
5262
  registerPath,
4917
5263
  pathData,
4918
- deepestZone: deepest == null ? void 0 : deepest.zone,
4919
- deepestArea: deepest == null ? void 0 : deepest.area,
4920
- nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
4921
- nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
4922
5264
  path: []
4923
5265
  },
4924
5266
  children
4925
5267
  }
4926
- )
5268
+ ) })
4927
5269
  }
4928
- ) })
5270
+ )
4929
5271
  }
4930
- );
5272
+ ) });
4931
5273
  };
4932
5274
  var DragDropContext = ({
4933
5275
  children,
@@ -4937,11 +5279,11 @@ var DragDropContext = ({
4937
5279
  if (status === "LOADING") {
4938
5280
  return children;
4939
5281
  }
4940
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DragDropContextClient, { disableAutoScroll, children });
5282
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragDropContextClient, { disableAutoScroll, children });
4941
5283
  };
4942
5284
 
4943
5285
  // components/Drawer/index.tsx
4944
- var import_jsx_runtime23 = require("react/jsx-runtime");
5286
+ var import_jsx_runtime24 = require("react/jsx-runtime");
4945
5287
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
4946
5288
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
4947
5289
  var DrawerItemInner = ({
@@ -4951,11 +5293,11 @@ var DrawerItemInner = ({
4951
5293
  dragRef,
4952
5294
  isDragDisabled
4953
5295
  }) => {
4954
- const CustomInner = (0, import_react26.useMemo)(
4955
- () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
5296
+ const CustomInner = (0, import_react32.useMemo)(
5297
+ () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
4956
5298
  [children]
4957
5299
  );
4958
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5300
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4959
5301
  "div",
4960
5302
  {
4961
5303
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -4963,9 +5305,9 @@ var DrawerItemInner = ({
4963
5305
  onMouseDown: (e) => e.preventDefault(),
4964
5306
  "data-testid": dragRef ? `drawer-item:${name}` : "",
4965
5307
  "data-puck-drawer-item": true,
4966
- 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: [
4967
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
4968
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragIcon, {}) })
5308
+ 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: [
5309
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5310
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragIcon, {}) })
4969
5311
  ] }) }) })
4970
5312
  }
4971
5313
  );
@@ -4982,9 +5324,9 @@ var DrawerItemDraggable = ({
4982
5324
  data: { type: "drawer", componentType: name },
4983
5325
  disabled: isDragDisabled
4984
5326
  });
4985
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName18("draggable"), children: [
4986
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DrawerItemInner, { name, label, children }) }),
4987
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5327
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName18("draggable"), children: [
5328
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DrawerItemInner, { name, label, children }) }),
5329
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4988
5330
  DrawerItemInner,
4989
5331
  {
4990
5332
  name,
@@ -5005,7 +5347,7 @@ var DrawerItem = ({
5005
5347
  isDragDisabled
5006
5348
  }) => {
5007
5349
  const resolvedId = id || name;
5008
- const [dynamicId, setDynamicId] = (0, import_react26.useState)(generateId(resolvedId));
5350
+ const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
5009
5351
  if (typeof index !== "undefined") {
5010
5352
  console.error(
5011
5353
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -5018,7 +5360,7 @@ var DrawerItem = ({
5018
5360
  },
5019
5361
  [resolvedId]
5020
5362
  );
5021
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5363
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5022
5364
  DrawerItemDraggable,
5023
5365
  {
5024
5366
  name,
@@ -5044,14 +5386,14 @@ var Drawer = ({
5044
5386
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5045
5387
  );
5046
5388
  }
5047
- const [id] = (0, import_react26.useState)(generateId());
5389
+ const id = (0, import_react32.useId)();
5048
5390
  const { ref } = useDroppableSafe({
5049
5391
  id,
5050
5392
  type: "void",
5051
5393
  collisionPriority: 0
5052
5394
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
5053
5395
  });
5054
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5396
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5055
5397
  "div",
5056
5398
  {
5057
5399
  className: getClassName18(),
@@ -5066,7 +5408,7 @@ Drawer.Item = DrawerItem;
5066
5408
 
5067
5409
  // components/Puck/index.tsx
5068
5410
  init_react_import();
5069
- var import_react42 = require("react");
5411
+ var import_react48 = require("react");
5070
5412
 
5071
5413
  // components/SidebarSection/index.tsx
5072
5414
  init_react_import();
@@ -5077,7 +5419,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
5077
5419
 
5078
5420
  // lib/use-breadcrumbs.ts
5079
5421
  init_react_import();
5080
- var import_react27 = require("react");
5422
+ var import_react33 = require("react");
5081
5423
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
5082
5424
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
5083
5425
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -5127,8 +5469,8 @@ var useBreadcrumbs = (renderCount) => {
5127
5469
  state: { data },
5128
5470
  selectedItem
5129
5471
  } = useAppContext();
5130
- const dzContext = (0, import_react27.useContext)(dropZoneContext);
5131
- return (0, import_react27.useMemo)(() => {
5472
+ const dzContext = (0, import_react33.useContext)(dropZoneContext);
5473
+ return (0, import_react33.useMemo)(() => {
5132
5474
  const breadcrumbs = convertPathDataToBreadcrumbs(
5133
5475
  selectedItem,
5134
5476
  dzContext == null ? void 0 : dzContext.pathData,
@@ -5142,7 +5484,7 @@ var useBreadcrumbs = (renderCount) => {
5142
5484
  };
5143
5485
 
5144
5486
  // components/SidebarSection/index.tsx
5145
- var import_jsx_runtime24 = require("react/jsx-runtime");
5487
+ var import_jsx_runtime25 = require("react/jsx-runtime");
5146
5488
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5147
5489
  var SidebarSection = ({
5148
5490
  children,
@@ -5155,15 +5497,15 @@ var SidebarSection = ({
5155
5497
  }) => {
5156
5498
  const { setUi } = useAppContext();
5157
5499
  const breadcrumbs = useBreadcrumbs(1);
5158
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
5500
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
5159
5501
  "div",
5160
5502
  {
5161
5503
  className: getClassName19({ noBorderTop, noPadding }),
5162
5504
  style: { background },
5163
5505
  children: [
5164
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
5165
- showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
5166
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5506
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
5507
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
5508
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5167
5509
  "button",
5168
5510
  {
5169
5511
  type: "button",
@@ -5172,12 +5514,12 @@ var SidebarSection = ({
5172
5514
  children: breadcrumb.label
5173
5515
  }
5174
5516
  ),
5175
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChevronRight, { size: 16 })
5517
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
5176
5518
  ] }, i)) : null,
5177
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
5519
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
5178
5520
  ] }) }),
5179
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName19("content"), children }),
5180
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Loader, { size: 32 }) })
5521
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
5522
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
5181
5523
  ]
5182
5524
  }
5183
5525
  );
@@ -5208,7 +5550,7 @@ init_react_import();
5208
5550
  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" };
5209
5551
 
5210
5552
  // components/MenuBar/index.tsx
5211
- var import_jsx_runtime25 = require("react/jsx-runtime");
5553
+ var import_jsx_runtime26 = require("react/jsx-runtime");
5212
5554
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5213
5555
  function MenuBar({
5214
5556
  appState,
@@ -5222,7 +5564,7 @@ function MenuBar({
5222
5564
  history: { back, forward, historyStore }
5223
5565
  } = useAppContext();
5224
5566
  const { hasFuture = false, hasPast = false } = historyStore || {};
5225
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5567
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5226
5568
  "div",
5227
5569
  {
5228
5570
  className: getClassName20({ menuOpen }),
@@ -5236,12 +5578,12 @@ function MenuBar({
5236
5578
  setMenuOpen(false);
5237
5579
  }
5238
5580
  },
5239
- children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName20("inner"), children: [
5240
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName20("history"), children: [
5241
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Undo2, { size: 21 }) }),
5242
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Redo2, { size: 21 }) })
5581
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
5582
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
5583
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
5584
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
5243
5585
  ] }),
5244
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: renderHeaderActions && renderHeaderActions({
5586
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
5245
5587
  state: appState,
5246
5588
  dispatch
5247
5589
  }) })
@@ -5252,25 +5594,25 @@ function MenuBar({
5252
5594
 
5253
5595
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5254
5596
  init_react_import();
5255
- 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" };
5597
+ 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" };
5256
5598
 
5257
5599
  // components/Puck/components/Fields/index.tsx
5258
5600
  init_react_import();
5259
5601
 
5260
5602
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5261
5603
  init_react_import();
5262
- 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" };
5604
+ 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" };
5263
5605
 
5264
5606
  // components/Puck/components/Fields/index.tsx
5265
- var import_react29 = require("react");
5607
+ var import_react35 = require("react");
5266
5608
 
5267
5609
  // lib/use-parent.ts
5268
5610
  init_react_import();
5269
- var import_react28 = require("react");
5611
+ var import_react34 = require("react");
5270
5612
  var useParent = (itemSelector) => {
5271
5613
  var _a;
5272
5614
  const { selectedItem, state } = useAppContext();
5273
- const { pathData } = (0, import_react28.useContext)(dropZoneContext) || {};
5615
+ const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
5274
5616
  const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5275
5617
  const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5276
5618
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
@@ -5279,7 +5621,7 @@ var useParent = (itemSelector) => {
5279
5621
  };
5280
5622
 
5281
5623
  // components/Puck/components/Fields/index.tsx
5282
- var import_jsx_runtime26 = require("react/jsx-runtime");
5624
+ var import_jsx_runtime27 = require("react/jsx-runtime");
5283
5625
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5284
5626
  var defaultPageFields = {
5285
5627
  title: { type: "text" }
@@ -5287,7 +5629,7 @@ var defaultPageFields = {
5287
5629
  var DefaultFields = ({
5288
5630
  children
5289
5631
  }) => {
5290
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
5632
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
5291
5633
  };
5292
5634
  var useResolvedFields = () => {
5293
5635
  var _a, _b;
@@ -5296,20 +5638,20 @@ var useResolvedFields = () => {
5296
5638
  const { data } = state;
5297
5639
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5298
5640
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5299
- const defaultFields = (0, import_react29.useMemo)(
5641
+ const defaultFields = (0, import_react35.useMemo)(
5300
5642
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5301
5643
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5302
5644
  );
5303
5645
  const rootProps = data.root.props || data.root;
5304
- const [lastSelectedData, setLastSelectedData] = (0, import_react29.useState)({});
5305
- const [resolvedFields, setResolvedFields] = (0, import_react29.useState)(defaultFields);
5306
- const [fieldsLoading, setFieldsLoading] = (0, import_react29.useState)(false);
5646
+ const [lastSelectedData, setLastSelectedData] = (0, import_react35.useState)({});
5647
+ const [resolvedFields, setResolvedFields] = (0, import_react35.useState)(defaultFields);
5648
+ const [fieldsLoading, setFieldsLoading] = (0, import_react35.useState)(false);
5307
5649
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5308
5650
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5309
5651
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5310
5652
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5311
5653
  const hasResolver = hasComponentResolver || hasRootResolver;
5312
- const resolveFields = (0, import_react29.useCallback)(
5654
+ const resolveFields = (0, import_react35.useCallback)(
5313
5655
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5314
5656
  var _a2;
5315
5657
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5345,22 +5687,36 @@ var useResolvedFields = () => {
5345
5687
  lastData
5346
5688
  });
5347
5689
  }),
5348
- [data, config, componentData, selectedItem, resolvedFields, state]
5690
+ [data, config, componentData, selectedItem, resolvedFields, state, parent]
5349
5691
  );
5350
- (0, import_react29.useEffect)(() => {
5351
- if (hasResolver) {
5352
- setFieldsLoading(true);
5353
- resolveFields(defaultFields).then((fields) => {
5354
- setResolvedFields(fields || {});
5355
- setFieldsLoading(false);
5356
- });
5357
- } else {
5358
- setResolvedFields(defaultFields);
5692
+ const [hasParent, setHasParent] = (0, import_react35.useState)(false);
5693
+ (0, import_react35.useEffect)(() => {
5694
+ setHasParent(!!parent);
5695
+ }, [parent]);
5696
+ (0, import_react35.useEffect)(() => {
5697
+ var _a2, _b2;
5698
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || hasParent) {
5699
+ if (hasResolver) {
5700
+ setFieldsLoading(true);
5701
+ resolveFields(defaultFields).then((fields) => {
5702
+ setResolvedFields(fields || {});
5703
+ setFieldsLoading(false);
5704
+ });
5705
+ return;
5706
+ }
5359
5707
  }
5360
- }, [data, defaultFields, selectedItem, hasResolver]);
5708
+ setResolvedFields(defaultFields);
5709
+ }, [
5710
+ data,
5711
+ defaultFields,
5712
+ state.ui.itemSelector,
5713
+ selectedItem,
5714
+ hasResolver,
5715
+ hasParent
5716
+ ]);
5361
5717
  return [resolvedFields, fieldsLoading];
5362
5718
  };
5363
- var Fields = () => {
5719
+ var Fields = ({ wrapFields = true }) => {
5364
5720
  var _a, _b;
5365
5721
  const {
5366
5722
  selectedItem,
@@ -5378,16 +5734,16 @@ var Fields = () => {
5378
5734
  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;
5379
5735
  const isLoading = fieldsResolving || componentResolving;
5380
5736
  const rootProps = data.root.props || data.root;
5381
- const Wrapper = (0, import_react29.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
5382
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
5737
+ const Wrapper = (0, import_react35.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
5738
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
5383
5739
  "form",
5384
5740
  {
5385
- className: getClassName21(),
5741
+ className: getClassName21({ wrapFields }),
5386
5742
  onSubmit: (e) => {
5387
5743
  e.preventDefault();
5388
5744
  },
5389
5745
  children: [
5390
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5746
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5391
5747
  const field = fields[fieldName];
5392
5748
  if (!(field == null ? void 0 : field.type)) return null;
5393
5749
  const onChange = (value, updatedUi) => {
@@ -5458,7 +5814,7 @@ var Fields = () => {
5458
5814
  item: selectedItem
5459
5815
  });
5460
5816
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5461
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5817
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5462
5818
  AutoFieldPrivate,
5463
5819
  {
5464
5820
  field,
@@ -5467,16 +5823,15 @@ var Fields = () => {
5467
5823
  readOnly: !edit || readOnly[fieldName],
5468
5824
  value: selectedItem.props[fieldName],
5469
5825
  onChange
5470
- },
5471
- id
5472
- );
5826
+ }
5827
+ ) }, id);
5473
5828
  } else {
5474
5829
  const readOnly = data.root.readOnly || {};
5475
5830
  const { edit } = getPermissions({
5476
5831
  root: true
5477
5832
  });
5478
5833
  const id = `root_${field.type}_${fieldName}`;
5479
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5834
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5480
5835
  AutoFieldPrivate,
5481
5836
  {
5482
5837
  field,
@@ -5485,12 +5840,11 @@ var Fields = () => {
5485
5840
  readOnly: !edit || readOnly[fieldName],
5486
5841
  value: rootProps[fieldName],
5487
5842
  onChange
5488
- },
5489
- id
5490
- );
5843
+ }
5844
+ ) }, id);
5491
5845
  }
5492
5846
  }) }),
5493
- 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 }) }) })
5847
+ 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 }) }) })
5494
5848
  ]
5495
5849
  }
5496
5850
  );
@@ -5501,7 +5855,7 @@ init_react_import();
5501
5855
 
5502
5856
  // lib/use-component-list.tsx
5503
5857
  init_react_import();
5504
- var import_react30 = require("react");
5858
+ var import_react36 = require("react");
5505
5859
 
5506
5860
  // components/ComponentList/index.tsx
5507
5861
  init_react_import();
@@ -5511,7 +5865,7 @@ init_react_import();
5511
5865
  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" };
5512
5866
 
5513
5867
  // components/ComponentList/index.tsx
5514
- var import_jsx_runtime27 = require("react/jsx-runtime");
5868
+ var import_jsx_runtime28 = require("react/jsx-runtime");
5515
5869
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
5516
5870
  var ComponentListItem = ({
5517
5871
  name,
@@ -5521,7 +5875,7 @@ var ComponentListItem = ({
5521
5875
  const canInsert = getPermissions({
5522
5876
  type: name
5523
5877
  }).insert;
5524
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5878
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5525
5879
  };
5526
5880
  var ComponentList = ({
5527
5881
  children,
@@ -5530,8 +5884,8 @@ var ComponentList = ({
5530
5884
  }) => {
5531
5885
  const { config, state, setUi } = useAppContext();
5532
5886
  const { expanded = true } = state.ui.componentList[id] || {};
5533
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
5534
- title && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
5887
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
5888
+ title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
5535
5889
  "button",
5536
5890
  {
5537
5891
  type: "button",
@@ -5545,14 +5899,14 @@ var ComponentList = ({
5545
5899
  }),
5546
5900
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
5547
5901
  children: [
5548
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: title }),
5549
- /* @__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 }) })
5902
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
5903
+ /* @__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 }) })
5550
5904
  ]
5551
5905
  }
5552
5906
  ),
5553
- /* @__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) => {
5907
+ /* @__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) => {
5554
5908
  var _a;
5555
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5909
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
5556
5910
  ComponentListItem,
5557
5911
  {
5558
5912
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -5566,10 +5920,10 @@ var ComponentList = ({
5566
5920
  ComponentList.Item = ComponentListItem;
5567
5921
 
5568
5922
  // lib/use-component-list.tsx
5569
- var import_jsx_runtime28 = require("react/jsx-runtime");
5923
+ var import_jsx_runtime29 = require("react/jsx-runtime");
5570
5924
  var useComponentList = (config, ui) => {
5571
- const [componentList, setComponentList] = (0, import_react30.useState)();
5572
- (0, import_react30.useEffect)(() => {
5925
+ const [componentList, setComponentList] = (0, import_react36.useState)();
5926
+ (0, import_react36.useEffect)(() => {
5573
5927
  var _a, _b, _c;
5574
5928
  if (Object.keys(ui.componentList).length > 0) {
5575
5929
  const matchedComponents = [];
@@ -5579,7 +5933,7 @@ var useComponentList = (config, ui) => {
5579
5933
  if (category.visible === false || !category.components) {
5580
5934
  return null;
5581
5935
  }
5582
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
5936
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5583
5937
  ComponentList,
5584
5938
  {
5585
5939
  id: categoryKey,
@@ -5588,7 +5942,7 @@ var useComponentList = (config, ui) => {
5588
5942
  var _a2;
5589
5943
  matchedComponents.push(componentName);
5590
5944
  const componentConf = config.components[componentName] || {};
5591
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
5945
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5592
5946
  ComponentList.Item,
5593
5947
  {
5594
5948
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -5608,7 +5962,7 @@ var useComponentList = (config, ui) => {
5608
5962
  );
5609
5963
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
5610
5964
  _componentList.push(
5611
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
5965
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5612
5966
  ComponentList,
5613
5967
  {
5614
5968
  id: "other",
@@ -5616,7 +5970,7 @@ var useComponentList = (config, ui) => {
5616
5970
  children: remainingComponents.map((componentName, i) => {
5617
5971
  var _a2;
5618
5972
  const componentConf = config.components[componentName] || {};
5619
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
5973
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5620
5974
  ComponentList.Item,
5621
5975
  {
5622
5976
  name: componentName,
@@ -5638,25 +5992,25 @@ var useComponentList = (config, ui) => {
5638
5992
  };
5639
5993
 
5640
5994
  // components/Puck/components/Components/index.tsx
5641
- var import_react31 = require("react");
5642
- var import_jsx_runtime29 = require("react/jsx-runtime");
5995
+ var import_react37 = require("react");
5996
+ var import_jsx_runtime30 = require("react/jsx-runtime");
5643
5997
  var Components = () => {
5644
5998
  const { config, state, overrides } = useAppContext();
5645
5999
  const componentList = useComponentList(config, state.ui);
5646
- const Wrapper = (0, import_react31.useMemo)(() => overrides.components || "div", [overrides]);
5647
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ComponentList, { id: "all" }) });
6000
+ const Wrapper = (0, import_react37.useMemo)(() => overrides.components || "div", [overrides]);
6001
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
5648
6002
  };
5649
6003
 
5650
6004
  // components/Puck/components/Preview/index.tsx
5651
6005
  init_react_import();
5652
- var import_react33 = require("react");
6006
+ var import_react39 = require("react");
5653
6007
 
5654
6008
  // components/AutoFrame/index.tsx
5655
6009
  init_react_import();
5656
- var import_react32 = require("react");
6010
+ var import_react38 = require("react");
5657
6011
  var import_object_hash = __toESM(require("object-hash"));
5658
6012
  var import_react_dom3 = require("react-dom");
5659
- var import_jsx_runtime30 = require("react/jsx-runtime");
6013
+ var import_jsx_runtime31 = require("react/jsx-runtime");
5660
6014
  var styleSelector = 'style, link[rel="stylesheet"]';
5661
6015
  var collectStyles = (doc) => {
5662
6016
  const collected = [];
@@ -5699,7 +6053,7 @@ var CopyHostStyles = ({
5699
6053
  onStylesLoaded = () => null
5700
6054
  }) => {
5701
6055
  const { document: doc, window: win } = useFrame();
5702
- (0, import_react32.useEffect)(() => {
6056
+ (0, import_react38.useEffect)(() => {
5703
6057
  if (!win || !doc) {
5704
6058
  return () => {
5705
6059
  };
@@ -5856,10 +6210,10 @@ var CopyHostStyles = ({
5856
6210
  observer.disconnect();
5857
6211
  };
5858
6212
  }, []);
5859
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
6213
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
5860
6214
  };
5861
- var autoFrameContext = (0, import_react32.createContext)({});
5862
- var useFrame = () => (0, import_react32.useContext)(autoFrameContext);
6215
+ var autoFrameContext = (0, import_react38.createContext)({});
6216
+ var useFrame = () => (0, import_react38.useContext)(autoFrameContext);
5863
6217
  function AutoFrame(_a) {
5864
6218
  var _b = _a, {
5865
6219
  children,
@@ -5876,10 +6230,10 @@ function AutoFrame(_a) {
5876
6230
  "onStylesLoaded",
5877
6231
  "frameRef"
5878
6232
  ]);
5879
- const [loaded, setLoaded] = (0, import_react32.useState)(false);
5880
- const [ctx, setCtx] = (0, import_react32.useState)({});
5881
- const [mountTarget, setMountTarget] = (0, import_react32.useState)();
5882
- (0, import_react32.useEffect)(() => {
6233
+ const [loaded, setLoaded] = (0, import_react38.useState)(false);
6234
+ const [ctx, setCtx] = (0, import_react38.useState)({});
6235
+ const [mountTarget, setMountTarget] = (0, import_react38.useState)();
6236
+ (0, import_react38.useEffect)(() => {
5883
6237
  var _a2;
5884
6238
  if (frameRef.current) {
5885
6239
  setCtx({
@@ -5891,7 +6245,7 @@ function AutoFrame(_a) {
5891
6245
  );
5892
6246
  }
5893
6247
  }, [frameRef, loaded]);
5894
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6248
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
5895
6249
  "iframe",
5896
6250
  __spreadProps(__spreadValues({}, props), {
5897
6251
  className,
@@ -5901,7 +6255,7 @@ function AutoFrame(_a) {
5901
6255
  onLoad: () => {
5902
6256
  setLoaded(true);
5903
6257
  },
5904
- 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) }) })
6258
+ 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) }) })
5905
6259
  })
5906
6260
  );
5907
6261
  }
@@ -5914,7 +6268,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
5914
6268
 
5915
6269
  // components/Render/index.tsx
5916
6270
  init_react_import();
5917
- var import_jsx_runtime31 = require("react/jsx-runtime");
6271
+ var import_jsx_runtime32 = require("react/jsx-runtime");
5918
6272
  function Render({
5919
6273
  config,
5920
6274
  data
@@ -5927,7 +6281,7 @@ function Render({
5927
6281
  const rootProps = defaultedData.root.props || defaultedData.root;
5928
6282
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
5929
6283
  if ((_a = config.root) == null ? void 0 : _a.render) {
5930
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6284
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5931
6285
  DropZoneProvider,
5932
6286
  {
5933
6287
  value: {
@@ -5937,7 +6291,7 @@ function Render({
5937
6291
  depth: 0,
5938
6292
  path: []
5939
6293
  },
5940
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6294
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5941
6295
  config.root.render,
5942
6296
  __spreadProps(__spreadValues({}, rootProps), {
5943
6297
  puck: {
@@ -5947,13 +6301,13 @@ function Render({
5947
6301
  title,
5948
6302
  editMode: false,
5949
6303
  id: "puck-root",
5950
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DropZone, { zone: rootDroppableId })
6304
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
5951
6305
  })
5952
6306
  )
5953
6307
  }
5954
6308
  );
5955
6309
  }
5956
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6310
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5957
6311
  DropZoneProvider,
5958
6312
  {
5959
6313
  value: {
@@ -5963,17 +6317,17 @@ function Render({
5963
6317
  depth: 0,
5964
6318
  path: []
5965
6319
  },
5966
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DropZone, { zone: rootDroppableId })
6320
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
5967
6321
  }
5968
6322
  );
5969
6323
  }
5970
6324
 
5971
6325
  // components/Puck/components/Preview/index.tsx
5972
- var import_jsx_runtime32 = require("react/jsx-runtime");
6326
+ var import_jsx_runtime33 = require("react/jsx-runtime");
5973
6327
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
5974
6328
  var useBubbleIframeEvents = (ref) => {
5975
6329
  const { status } = useAppContext();
5976
- (0, import_react33.useEffect)(() => {
6330
+ (0, import_react39.useEffect)(() => {
5977
6331
  var _a;
5978
6332
  if (ref.current && status === "READY") {
5979
6333
  const iframe = ref.current;
@@ -6010,22 +6364,22 @@ var useBubbleIframeEvents = (ref) => {
6010
6364
  }
6011
6365
  }, [status]);
6012
6366
  };
6013
- var Preview = ({ id = "puck-preview" }) => {
6367
+ var Preview2 = ({ id = "puck-preview" }) => {
6014
6368
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
6015
- const Page = (0, import_react33.useCallback)(
6369
+ const Page = (0, import_react39.useCallback)(
6016
6370
  (pageProps) => {
6017
6371
  var _a, _b;
6018
6372
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
6019
6373
  id: "puck-root"
6020
- }, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: pageProps.children });
6374
+ }, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
6021
6375
  },
6022
6376
  [config.root]
6023
6377
  );
6024
- const Frame = (0, import_react33.useMemo)(() => overrides.iframe, [overrides]);
6378
+ const Frame = (0, import_react39.useMemo)(() => overrides.iframe, [overrides]);
6025
6379
  const rootProps = state.data.root.props || state.data.root;
6026
- const ref = (0, import_react33.useRef)(null);
6380
+ const ref = (0, import_react39.useRef)(null);
6027
6381
  useBubbleIframeEvents(ref);
6028
- const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6382
+ const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6029
6383
  Page,
6030
6384
  __spreadProps(__spreadValues({}, rootProps), {
6031
6385
  puck: {
@@ -6034,10 +6388,10 @@ var Preview = ({ id = "puck-preview" }) => {
6034
6388
  dragRef: null
6035
6389
  },
6036
6390
  editMode: true,
6037
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
6391
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
6038
6392
  })
6039
- ) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Render, { data: state.data, config });
6040
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6393
+ ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
6394
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6041
6395
  "div",
6042
6396
  {
6043
6397
  className: getClassName23(),
@@ -6046,7 +6400,7 @@ var Preview = ({ id = "puck-preview" }) => {
6046
6400
  onClick: () => {
6047
6401
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
6048
6402
  },
6049
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6403
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6050
6404
  AutoFrame_default,
6051
6405
  {
6052
6406
  id: "preview-frame",
@@ -6056,14 +6410,14 @@ var Preview = ({ id = "puck-preview" }) => {
6056
6410
  setStatus("READY");
6057
6411
  },
6058
6412
  frameRef: ref,
6059
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6413
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6060
6414
  if (Frame) {
6061
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Frame, { document: document2, children: inner });
6415
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
6062
6416
  }
6063
6417
  return inner;
6064
6418
  } })
6065
6419
  }
6066
- ) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6420
+ ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6067
6421
  "div",
6068
6422
  {
6069
6423
  id: "preview-frame",
@@ -6120,7 +6474,7 @@ var scrollIntoView = (el) => {
6120
6474
  };
6121
6475
 
6122
6476
  // components/LayerTree/index.tsx
6123
- var import_react34 = require("react");
6477
+ var import_react40 = require("react");
6124
6478
 
6125
6479
  // lib/is-child-of-zone.ts
6126
6480
  init_react_import();
@@ -6153,7 +6507,7 @@ var onScrollEnd = (frame, cb) => {
6153
6507
  };
6154
6508
 
6155
6509
  // components/LayerTree/index.tsx
6156
- var import_jsx_runtime33 = require("react/jsx-runtime");
6510
+ var import_jsx_runtime34 = require("react/jsx-runtime");
6157
6511
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
6158
6512
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
6159
6513
  var LayerTree = ({
@@ -6166,15 +6520,15 @@ var LayerTree = ({
6166
6520
  label
6167
6521
  }) => {
6168
6522
  const zones = data.zones || {};
6169
- const ctx = (0, import_react34.useContext)(dropZoneContext);
6170
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
6171
- label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
6172
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Layers, { size: "16" }) }),
6523
+ const ctx = (0, import_react40.useContext)(dropZoneContext);
6524
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
6525
+ label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
6526
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
6173
6527
  " ",
6174
6528
  label
6175
6529
  ] }),
6176
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("ul", { className: getClassName24(), children: [
6177
- zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
6530
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
6531
+ zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
6178
6532
  zoneContent.map((item, i) => {
6179
6533
  var _a;
6180
6534
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -6187,7 +6541,7 @@ var LayerTree = ({
6187
6541
  const childIsSelected = isChildOfZone(item, selectedItem, ctx);
6188
6542
  const componentConfig = config.components[item.type];
6189
6543
  const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
6190
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
6544
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
6191
6545
  "li",
6192
6546
  {
6193
6547
  className: getClassNameLayer({
@@ -6197,7 +6551,7 @@ var LayerTree = ({
6197
6551
  childIsSelected
6198
6552
  }),
6199
6553
  children: [
6200
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
6554
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
6201
6555
  "button",
6202
6556
  {
6203
6557
  type: "button",
@@ -6236,22 +6590,22 @@ var LayerTree = ({
6236
6590
  setHoveringComponent(null);
6237
6591
  },
6238
6592
  children: [
6239
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6593
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
6240
6594
  "div",
6241
6595
  {
6242
6596
  className: getClassNameLayer("chevron"),
6243
6597
  title: isSelected ? "Collapse" : "Expand",
6244
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ChevronDown, { size: "12" })
6598
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
6245
6599
  }
6246
6600
  ),
6247
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassNameLayer("title"), children: [
6248
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(LayoutGrid, { size: "16" }) }),
6249
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
6601
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
6602
+ /* @__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" }) }),
6603
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
6250
6604
  ] })
6251
6605
  ]
6252
6606
  }
6253
6607
  ) }),
6254
- containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6608
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
6255
6609
  LayerTree,
6256
6610
  {
6257
6611
  config,
@@ -6273,13 +6627,13 @@ var LayerTree = ({
6273
6627
  };
6274
6628
 
6275
6629
  // components/Puck/components/Outline/index.tsx
6276
- var import_react35 = require("react");
6277
- var import_jsx_runtime34 = require("react/jsx-runtime");
6630
+ var import_react41 = require("react");
6631
+ var import_jsx_runtime35 = require("react/jsx-runtime");
6278
6632
  var Outline = () => {
6279
6633
  const { dispatch, state, overrides, config } = useAppContext();
6280
6634
  const { data, ui } = state;
6281
6635
  const { itemSelector } = ui;
6282
- const setItemSelector = (0, import_react35.useCallback)(
6636
+ const setItemSelector = (0, import_react41.useCallback)(
6283
6637
  (newItemSelector) => {
6284
6638
  dispatch({
6285
6639
  type: "setUi",
@@ -6288,9 +6642,9 @@ var Outline = () => {
6288
6642
  },
6289
6643
  []
6290
6644
  );
6291
- const Wrapper = (0, import_react35.useMemo)(() => overrides.outline || "div", [overrides]);
6292
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
6293
- (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
6645
+ const Wrapper = (0, import_react41.useMemo)(() => overrides.outline || "div", [overrides]);
6646
+ 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: [
6647
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
6294
6648
  LayerTree,
6295
6649
  {
6296
6650
  config,
@@ -6303,7 +6657,7 @@ var Outline = () => {
6303
6657
  ),
6304
6658
  Object.entries(findZonesForArea(data, "root")).map(
6305
6659
  ([zoneKey, zone]) => {
6306
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
6660
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
6307
6661
  LayerTree,
6308
6662
  {
6309
6663
  config,
@@ -6402,19 +6756,19 @@ function usePuckHistory({
6402
6756
 
6403
6757
  // lib/use-history-store.ts
6404
6758
  init_react_import();
6405
- var import_react36 = require("react");
6759
+ var import_react42 = require("react");
6406
6760
  var import_use_debounce3 = require("use-debounce");
6407
6761
  var EMPTY_HISTORY_INDEX = 0;
6408
6762
  function useHistoryStore(initialHistory) {
6409
6763
  var _a, _b;
6410
- const [histories, setHistories] = (0, import_react36.useState)(
6764
+ const [histories, setHistories] = (0, import_react42.useState)(
6411
6765
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
6412
6766
  );
6413
6767
  const updateHistories = (histories2) => {
6414
6768
  setHistories(histories2);
6415
6769
  setIndex(histories2.length - 1);
6416
6770
  };
6417
- const [index, setIndex] = (0, import_react36.useState)(
6771
+ const [index, setIndex] = (0, import_react42.useState)(
6418
6772
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
6419
6773
  );
6420
6774
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -6574,22 +6928,22 @@ var getBox = function getBox2(el) {
6574
6928
  };
6575
6929
 
6576
6930
  // components/Puck/components/Canvas/index.tsx
6577
- var import_react38 = require("react");
6931
+ var import_react44 = require("react");
6578
6932
 
6579
6933
  // components/ViewportControls/index.tsx
6580
6934
  init_react_import();
6581
- var import_react37 = require("react");
6935
+ var import_react43 = require("react");
6582
6936
 
6583
6937
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6584
6938
  init_react_import();
6585
6939
  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" };
6586
6940
 
6587
6941
  // components/ViewportControls/index.tsx
6588
- var import_jsx_runtime35 = require("react/jsx-runtime");
6942
+ var import_jsx_runtime36 = require("react/jsx-runtime");
6589
6943
  var icons = {
6590
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Smartphone, { size: 16 }),
6591
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Tablet, { size: 16 }),
6592
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Monitor, { size: 16 })
6944
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
6945
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
6946
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
6593
6947
  };
6594
6948
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
6595
6949
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -6601,11 +6955,11 @@ var ViewportButton = ({
6601
6955
  onClick
6602
6956
  }) => {
6603
6957
  const { state } = useAppContext();
6604
- const [isActive, setIsActive] = (0, import_react37.useState)(false);
6605
- (0, import_react37.useEffect)(() => {
6958
+ const [isActive, setIsActive] = (0, import_react43.useState)(false);
6959
+ (0, import_react43.useEffect)(() => {
6606
6960
  setIsActive(width === state.ui.viewports.current.width);
6607
6961
  }, [width, state.ui.viewports.current.width]);
6608
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
6962
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6609
6963
  IconButton,
6610
6964
  {
6611
6965
  title,
@@ -6614,7 +6968,7 @@ var ViewportButton = ({
6614
6968
  e.stopPropagation();
6615
6969
  onClick({ width, height });
6616
6970
  },
6617
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton("inner"), children })
6971
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
6618
6972
  }
6619
6973
  ) });
6620
6974
  };
@@ -6638,7 +6992,7 @@ var ViewportControls = ({
6638
6992
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6639
6993
  (option) => option.value === autoZoom
6640
6994
  );
6641
- const zoomOptions = (0, import_react37.useMemo)(
6995
+ const zoomOptions = (0, import_react43.useMemo)(
6642
6996
  () => [
6643
6997
  ...defaultZoomOptions,
6644
6998
  ...defaultsContainAutoZoom ? [] : [
@@ -6650,8 +7004,8 @@ var ViewportControls = ({
6650
7004
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
6651
7005
  [autoZoom]
6652
7006
  );
6653
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25(), children: [
6654
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7007
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
7008
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6655
7009
  ViewportButton,
6656
7010
  {
6657
7011
  height: viewport.height,
@@ -6662,8 +7016,8 @@ var ViewportControls = ({
6662
7016
  },
6663
7017
  i
6664
7018
  )),
6665
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("divider") }),
6666
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7019
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7020
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6667
7021
  IconButton,
6668
7022
  {
6669
7023
  title: "Zoom viewport out",
@@ -6677,10 +7031,10 @@ var ViewportControls = ({
6677
7031
  )].value
6678
7032
  );
6679
7033
  },
6680
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ZoomOut, { size: 16 })
7034
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
6681
7035
  }
6682
7036
  ),
6683
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7037
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6684
7038
  IconButton,
6685
7039
  {
6686
7040
  title: "Zoom viewport in",
@@ -6694,11 +7048,11 @@ var ViewportControls = ({
6694
7048
  )].value
6695
7049
  );
6696
7050
  },
6697
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ZoomIn, { size: 16 })
7051
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
6698
7052
  }
6699
7053
  ),
6700
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("divider") }),
6701
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7054
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7055
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6702
7056
  "select",
6703
7057
  {
6704
7058
  className: getClassName25("zoomSelect"),
@@ -6706,7 +7060,7 @@ var ViewportControls = ({
6706
7060
  onChange: (e) => {
6707
7061
  onZoom(parseFloat(e.currentTarget.value));
6708
7062
  },
6709
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7063
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6710
7064
  "option",
6711
7065
  {
6712
7066
  value: option.value,
@@ -6754,24 +7108,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
6754
7108
  };
6755
7109
 
6756
7110
  // components/Puck/components/Canvas/index.tsx
6757
- var import_jsx_runtime36 = require("react/jsx-runtime");
7111
+ var import_jsx_runtime37 = require("react/jsx-runtime");
6758
7112
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
6759
7113
  var ZOOM_ON_CHANGE = true;
6760
7114
  var Canvas = () => {
6761
7115
  const { status, iframe } = useAppContext();
6762
7116
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
6763
7117
  const { ui } = state;
6764
- const frameRef = (0, import_react38.useRef)(null);
6765
- const [showTransition, setShowTransition] = (0, import_react38.useState)(false);
6766
- const defaultRender = (0, import_react38.useMemo)(() => {
6767
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
7118
+ const frameRef = (0, import_react44.useRef)(null);
7119
+ const [showTransition, setShowTransition] = (0, import_react44.useState)(false);
7120
+ const defaultRender = (0, import_react44.useMemo)(() => {
7121
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
6768
7122
  return PuckDefault;
6769
7123
  }, []);
6770
- const CustomPreview = (0, import_react38.useMemo)(
7124
+ const CustomPreview = (0, import_react44.useMemo)(
6771
7125
  () => overrides.preview || defaultRender,
6772
7126
  [overrides]
6773
7127
  );
6774
- const getFrameDimensions = (0, import_react38.useCallback)(() => {
7128
+ const getFrameDimensions = (0, import_react44.useCallback)(() => {
6775
7129
  if (frameRef.current) {
6776
7130
  const frame = frameRef.current;
6777
7131
  const box = getBox(frame);
@@ -6779,7 +7133,7 @@ var Canvas = () => {
6779
7133
  }
6780
7134
  return { width: 0, height: 0 };
6781
7135
  }, [frameRef]);
6782
- const resetAutoZoom = (0, import_react38.useCallback)(
7136
+ const resetAutoZoom = (0, import_react44.useCallback)(
6783
7137
  (ui2 = state.ui) => {
6784
7138
  if (frameRef.current) {
6785
7139
  setZoomConfig(
@@ -6789,11 +7143,11 @@ var Canvas = () => {
6789
7143
  },
6790
7144
  [frameRef, zoomConfig, state.ui]
6791
7145
  );
6792
- (0, import_react38.useEffect)(() => {
7146
+ (0, import_react44.useEffect)(() => {
6793
7147
  setShowTransition(false);
6794
7148
  resetAutoZoom();
6795
7149
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6796
- (0, import_react38.useEffect)(() => {
7150
+ (0, import_react44.useEffect)(() => {
6797
7151
  const { height: frameHeight } = getFrameDimensions();
6798
7152
  if (ui.viewports.current.height === "auto") {
6799
7153
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6801,13 +7155,13 @@ var Canvas = () => {
6801
7155
  }));
6802
7156
  }
6803
7157
  }, [zoomConfig.zoom]);
6804
- (0, import_react38.useEffect)(() => {
7158
+ (0, import_react44.useEffect)(() => {
6805
7159
  if (ZOOM_ON_CHANGE) {
6806
7160
  setShowTransition(true);
6807
7161
  resetAutoZoom(ui);
6808
7162
  }
6809
7163
  }, [ui.viewports.current.width]);
6810
- (0, import_react38.useEffect)(() => {
7164
+ (0, import_react44.useEffect)(() => {
6811
7165
  const cb = () => {
6812
7166
  setShowTransition(false);
6813
7167
  resetAutoZoom();
@@ -6817,13 +7171,13 @@ var Canvas = () => {
6817
7171
  window.removeEventListener("resize", cb);
6818
7172
  };
6819
7173
  }, []);
6820
- const [showLoader, setShowLoader] = (0, import_react38.useState)(false);
6821
- (0, import_react38.useEffect)(() => {
7174
+ const [showLoader, setShowLoader] = (0, import_react44.useState)(false);
7175
+ (0, import_react44.useEffect)(() => {
6822
7176
  setTimeout(() => {
6823
7177
  setShowLoader(true);
6824
7178
  }, 500);
6825
7179
  }, []);
6826
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7180
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
6827
7181
  "div",
6828
7182
  {
6829
7183
  className: getClassName26({
@@ -6836,7 +7190,7 @@ var Canvas = () => {
6836
7190
  recordHistory: true
6837
7191
  }),
6838
7192
  children: [
6839
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7193
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
6840
7194
  ViewportControls,
6841
7195
  {
6842
7196
  autoZoom: zoomConfig.autoZoom,
@@ -6862,8 +7216,8 @@ var Canvas = () => {
6862
7216
  }
6863
7217
  }
6864
7218
  ) }),
6865
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
6866
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7219
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
7220
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
6867
7221
  "div",
6868
7222
  {
6869
7223
  className: getClassName26("root"),
@@ -6884,10 +7238,10 @@ var Canvas = () => {
6884
7238
  })
6885
7239
  );
6886
7240
  },
6887
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Preview, {}) })
7241
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview2, {}) })
6888
7242
  }
6889
7243
  ),
6890
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Loader, { size: 24 }) })
7244
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
6891
7245
  ] })
6892
7246
  ]
6893
7247
  }
@@ -6896,7 +7250,7 @@ var Canvas = () => {
6896
7250
 
6897
7251
  // lib/use-loaded-overrides.ts
6898
7252
  init_react_import();
6899
- var import_react39 = require("react");
7253
+ var import_react45 = require("react");
6900
7254
 
6901
7255
  // lib/load-overrides.ts
6902
7256
  init_react_import();
@@ -6935,26 +7289,26 @@ var useLoadedOverrides = ({
6935
7289
  overrides,
6936
7290
  plugins
6937
7291
  }) => {
6938
- return (0, import_react39.useMemo)(() => {
7292
+ return (0, import_react45.useMemo)(() => {
6939
7293
  return loadOverrides({ overrides, plugins });
6940
7294
  }, [plugins, overrides]);
6941
7295
  };
6942
7296
 
6943
7297
  // components/DefaultOverride/index.tsx
6944
7298
  init_react_import();
6945
- var import_jsx_runtime37 = require("react/jsx-runtime");
6946
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
7299
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7300
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
6947
7301
 
6948
7302
  // lib/use-inject-css.ts
6949
7303
  init_react_import();
6950
- var import_react40 = require("react");
7304
+ var import_react46 = require("react");
6951
7305
  var styles = ``;
6952
7306
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
6953
- const [el, setEl] = (0, import_react40.useState)();
6954
- (0, import_react40.useEffect)(() => {
7307
+ const [el, setEl] = (0, import_react46.useState)();
7308
+ (0, import_react46.useEffect)(() => {
6955
7309
  setEl(document.createElement("style"));
6956
7310
  }, []);
6957
- (0, import_react40.useEffect)(() => {
7311
+ (0, import_react46.useEffect)(() => {
6958
7312
  var _a;
6959
7313
  if (!el || typeof window === "undefined") {
6960
7314
  return;
@@ -6974,10 +7328,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
6974
7328
 
6975
7329
  // lib/use-preview-mode-hotkeys.ts
6976
7330
  init_react_import();
6977
- var import_react41 = require("react");
7331
+ var import_react47 = require("react");
6978
7332
  var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
6979
7333
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
6980
- const toggleInteractive = (0, import_react41.useCallback)(() => {
7334
+ const toggleInteractive = (0, import_react47.useCallback)(() => {
6981
7335
  dispatch({
6982
7336
  type: "setUi",
6983
7337
  ui: (ui) => ({
@@ -7000,7 +7354,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7000
7354
  };
7001
7355
 
7002
7356
  // components/Puck/index.tsx
7003
- var import_jsx_runtime38 = require("react/jsx-runtime");
7357
+ var import_jsx_runtime39 = require("react/jsx-runtime");
7004
7358
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
7005
7359
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
7006
7360
  function Puck({
@@ -7029,7 +7383,7 @@ function Puck({
7029
7383
  waitForStyles: true
7030
7384
  }, _iframe);
7031
7385
  useInjectGlobalCss(iframe.enabled);
7032
- const [generatedAppState] = (0, import_react42.useState)(() => {
7386
+ const [generatedAppState] = (0, import_react48.useState)(() => {
7033
7387
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
7034
7388
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7035
7389
  let clientUiState = {};
@@ -7101,14 +7455,14 @@ function Puck({
7101
7455
  histories,
7102
7456
  index: initialHistoryIndex
7103
7457
  });
7104
- const [reducer] = (0, import_react42.useState)(
7458
+ const [reducer] = (0, import_react48.useState)(
7105
7459
  () => createReducer({
7106
7460
  config,
7107
7461
  record: historyStore.record,
7108
7462
  onAction
7109
7463
  })
7110
7464
  );
7111
- const [appState, dispatch] = (0, import_react42.useReducer)(
7465
+ const [appState, dispatch] = (0, import_react48.useReducer)(
7112
7466
  reducer,
7113
7467
  flushZones(initialAppState)
7114
7468
  );
@@ -7119,14 +7473,14 @@ function Puck({
7119
7473
  historyStore,
7120
7474
  iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
7121
7475
  });
7122
- const [menuOpen, setMenuOpen] = (0, import_react42.useState)(false);
7476
+ const [menuOpen, setMenuOpen] = (0, import_react48.useState)(false);
7123
7477
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
7124
7478
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
7125
- (0, import_react42.useEffect)(() => {
7479
+ (0, import_react48.useEffect)(() => {
7126
7480
  if (onChange) onChange(data);
7127
7481
  }, [data]);
7128
7482
  const rootProps = data.root.props || data.root;
7129
- const toggleSidebars = (0, import_react42.useCallback)(
7483
+ const toggleSidebars = (0, import_react48.useCallback)(
7130
7484
  (sidebar) => {
7131
7485
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7132
7486
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7140,7 +7494,7 @@ function Puck({
7140
7494
  },
7141
7495
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7142
7496
  );
7143
- (0, import_react42.useEffect)(() => {
7497
+ (0, import_react48.useEffect)(() => {
7144
7498
  if (!window.matchMedia("(min-width: 638px)").matches) {
7145
7499
  dispatch({
7146
7500
  type: "setUi",
@@ -7163,7 +7517,7 @@ function Puck({
7163
7517
  window.removeEventListener("resize", handleResize);
7164
7518
  };
7165
7519
  }, []);
7166
- const defaultHeaderRender = (0, import_react42.useMemo)(() => {
7520
+ const defaultHeaderRender = (0, import_react48.useMemo)(() => {
7167
7521
  if (renderHeader) {
7168
7522
  console.warn(
7169
7523
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7171,20 +7525,20 @@ function Puck({
7171
7525
  const RenderHeader = (_a2) => {
7172
7526
  var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
7173
7527
  const Comp = renderHeader;
7174
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7528
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7175
7529
  };
7176
7530
  return RenderHeader;
7177
7531
  }
7178
7532
  return DefaultOverride;
7179
7533
  }, [renderHeader]);
7180
- const defaultHeaderActionsRender = (0, import_react42.useMemo)(() => {
7534
+ const defaultHeaderActionsRender = (0, import_react48.useMemo)(() => {
7181
7535
  if (renderHeaderActions) {
7182
7536
  console.warn(
7183
7537
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7184
7538
  );
7185
7539
  const RenderHeader = (props) => {
7186
7540
  const Comp = renderHeaderActions;
7187
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7541
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7188
7542
  };
7189
7543
  return RenderHeader;
7190
7544
  }
@@ -7194,27 +7548,27 @@ function Puck({
7194
7548
  overrides,
7195
7549
  plugins
7196
7550
  });
7197
- const CustomPuck = (0, import_react42.useMemo)(
7551
+ const CustomPuck = (0, import_react48.useMemo)(
7198
7552
  () => loadedOverrides.puck || DefaultOverride,
7199
7553
  [loadedOverrides]
7200
7554
  );
7201
- const CustomHeader = (0, import_react42.useMemo)(
7555
+ const CustomHeader = (0, import_react48.useMemo)(
7202
7556
  () => loadedOverrides.header || defaultHeaderRender,
7203
7557
  [loadedOverrides]
7204
7558
  );
7205
- const CustomHeaderActions = (0, import_react42.useMemo)(
7559
+ const CustomHeaderActions = (0, import_react48.useMemo)(
7206
7560
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7207
7561
  [loadedOverrides]
7208
7562
  );
7209
- const [mounted, setMounted] = (0, import_react42.useState)(false);
7210
- (0, import_react42.useEffect)(() => {
7563
+ const [mounted, setMounted] = (0, import_react48.useState)(false);
7564
+ (0, import_react48.useEffect)(() => {
7211
7565
  setMounted(true);
7212
7566
  }, []);
7213
7567
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
7214
7568
  const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
7215
7569
  usePreviewModeHotkeys(dispatch, iframe.enabled);
7216
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
7217
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7570
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
7571
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7218
7572
  AppProvider,
7219
7573
  {
7220
7574
  value: {
@@ -7236,7 +7590,7 @@ function Puck({
7236
7590
  getPermissions: () => ({}),
7237
7591
  refreshPermissions: () => null
7238
7592
  },
7239
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7593
+ 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)(
7240
7594
  "div",
7241
7595
  {
7242
7596
  className: getLayoutClassName({
@@ -7245,60 +7599,60 @@ function Puck({
7245
7599
  mounted,
7246
7600
  rightSideBarVisible
7247
7601
  }),
7248
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getLayoutClassName("inner"), children: [
7249
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7602
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
7603
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7250
7604
  CustomHeader,
7251
7605
  {
7252
- actions: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7606
+ 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)(
7253
7607
  Button,
7254
7608
  {
7255
7609
  onClick: () => {
7256
7610
  onPublish && onPublish(data);
7257
7611
  },
7258
- icon: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Globe, { size: "14px" }),
7612
+ icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
7259
7613
  children: "Publish"
7260
7614
  }
7261
7615
  ) }) }),
7262
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
7263
- /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
7264
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7616
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
7617
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
7618
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7265
7619
  "div",
7266
7620
  {
7267
7621
  className: getLayoutClassName("leftSideBarToggle"),
7268
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7622
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7269
7623
  IconButton,
7270
7624
  {
7271
7625
  onClick: () => {
7272
7626
  toggleSidebars("left");
7273
7627
  },
7274
7628
  title: "Toggle left sidebar",
7275
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(PanelLeft, { focusable: "false" })
7629
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
7276
7630
  }
7277
7631
  )
7278
7632
  }
7279
7633
  ),
7280
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7634
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7281
7635
  "div",
7282
7636
  {
7283
7637
  className: getLayoutClassName("rightSideBarToggle"),
7284
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7638
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7285
7639
  IconButton,
7286
7640
  {
7287
7641
  onClick: () => {
7288
7642
  toggleSidebars("right");
7289
7643
  },
7290
7644
  title: "Toggle right sidebar",
7291
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(PanelRight, { focusable: "false" })
7645
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
7292
7646
  }
7293
7647
  )
7294
7648
  }
7295
7649
  )
7296
7650
  ] }),
7297
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Heading, { rank: "2", size: "xs", children: [
7651
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
7298
7652
  headerTitle || rootProps.title || "Page",
7299
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
7653
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
7300
7654
  " ",
7301
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7655
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7302
7656
  "code",
7303
7657
  {
7304
7658
  className: getLayoutClassName("headerPath"),
@@ -7307,31 +7661,31 @@ function Puck({
7307
7661
  )
7308
7662
  ] })
7309
7663
  ] }) }),
7310
- /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
7311
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7664
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
7665
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7312
7666
  IconButton,
7313
7667
  {
7314
7668
  onClick: () => {
7315
7669
  return setMenuOpen(!menuOpen);
7316
7670
  },
7317
7671
  title: "Toggle menu bar",
7318
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ChevronDown, { focusable: "false" })
7672
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
7319
7673
  }
7320
7674
  ) }),
7321
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7675
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7322
7676
  MenuBar,
7323
7677
  {
7324
7678
  appState,
7325
7679
  dispatch,
7326
7680
  onPublish,
7327
7681
  menuOpen,
7328
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7682
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7329
7683
  Button,
7330
7684
  {
7331
7685
  onClick: () => {
7332
7686
  onPublish && onPublish(data);
7333
7687
  },
7334
- icon: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Globe, { size: "14px" }),
7688
+ icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
7335
7689
  children: "Publish"
7336
7690
  }
7337
7691
  ) }),
@@ -7342,19 +7696,19 @@ function Puck({
7342
7696
  ] }) })
7343
7697
  }
7344
7698
  ),
7345
- /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
7346
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Components, {}) }),
7347
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Outline, {}) })
7699
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
7700
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
7701
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
7348
7702
  ] }),
7349
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Canvas, {}),
7350
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7703
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
7704
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7351
7705
  SidebarSection,
7352
7706
  {
7353
7707
  noPadding: true,
7354
7708
  noBorderTop: true,
7355
7709
  showBreadcrumbs: true,
7356
7710
  title: selectedItem ? selectedComponentLabel : "Page",
7357
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Fields, {})
7711
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
7358
7712
  }
7359
7713
  ) })
7360
7714
  ] })
@@ -7362,13 +7716,13 @@ function Puck({
7362
7716
  ) }) })
7363
7717
  }
7364
7718
  ),
7365
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
7719
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
7366
7720
  ] });
7367
7721
  }
7368
7722
  Puck.Components = Components;
7369
7723
  Puck.Fields = Fields;
7370
7724
  Puck.Outline = Outline;
7371
- Puck.Preview = Preview;
7725
+ Puck.Preview = Preview2;
7372
7726
 
7373
7727
  // lib/migrate.ts
7374
7728
  init_react_import();