@measured/puck 0.18.0-canary.e6e29ad → 0.18.0-canary.f1dec0e

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,28 +1691,29 @@ 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,
1638
1698
  onChange,
1639
1699
  readOnly,
1640
- value,
1700
+ value: _value,
1641
1701
  name,
1642
1702
  label,
1643
1703
  Label: Label2,
1644
1704
  id
1645
1705
  }) => {
1646
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1706
+ const value = _value;
1707
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1647
1708
  Label2,
1648
1709
  {
1649
1710
  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 })
1711
+ icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1712
+ field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Type, { size: 16 }),
1713
+ field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Hash, { size: 16 })
1653
1714
  ] }),
1654
1715
  readOnly,
1655
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1716
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1656
1717
  "input",
1657
1718
  {
1658
1719
  className: getClassName6("input"),
@@ -1660,10 +1721,17 @@ var DefaultField = ({
1660
1721
  type: field.type,
1661
1722
  title: label || name,
1662
1723
  name,
1663
- value: typeof value === "undefined" ? "" : value.toString(),
1724
+ value: (value == null ? void 0 : value.toString) ? value.toString() : "",
1664
1725
  onChange: (e) => {
1665
1726
  if (field.type === "number") {
1666
- onChange(Number(e.currentTarget.value));
1727
+ const numberValue = Number(e.currentTarget.value);
1728
+ if (typeof field.min !== "undefined" && numberValue < field.min) {
1729
+ return;
1730
+ }
1731
+ if (typeof field.max !== "undefined" && numberValue > field.max) {
1732
+ return;
1733
+ }
1734
+ onChange(numberValue);
1667
1735
  } else {
1668
1736
  onChange(e.currentTarget.value);
1669
1737
  }
@@ -1681,11 +1749,11 @@ var DefaultField = ({
1681
1749
 
1682
1750
  // components/AutoField/fields/ExternalField/index.tsx
1683
1751
  init_react_import();
1684
- var import_react15 = require("react");
1752
+ var import_react16 = require("react");
1685
1753
 
1686
1754
  // components/ExternalInput/index.tsx
1687
1755
  init_react_import();
1688
- var import_react14 = require("react");
1756
+ var import_react15 = require("react");
1689
1757
 
1690
1758
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
1691
1759
  init_react_import();
@@ -1693,7 +1761,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
1693
1761
 
1694
1762
  // components/Modal/index.tsx
1695
1763
  init_react_import();
1696
- var import_react12 = require("react");
1764
+ var import_react13 = require("react");
1697
1765
 
1698
1766
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
1699
1767
  init_react_import();
@@ -1701,22 +1769,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
1701
1769
 
1702
1770
  // components/Modal/index.tsx
1703
1771
  var import_react_dom = require("react-dom");
1704
- var import_jsx_runtime9 = require("react/jsx-runtime");
1772
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1705
1773
  var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
1706
1774
  var Modal = ({
1707
1775
  children,
1708
1776
  onClose,
1709
1777
  isOpen
1710
1778
  }) => {
1711
- const [rootEl, setRootEl] = (0, import_react12.useState)(null);
1712
- (0, import_react12.useEffect)(() => {
1779
+ const [rootEl, setRootEl] = (0, import_react13.useState)(null);
1780
+ (0, import_react13.useEffect)(() => {
1713
1781
  setRootEl(document.getElementById("puck-portal-root"));
1714
1782
  }, []);
1715
1783
  if (!rootEl) {
1716
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {});
1784
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
1717
1785
  }
1718
1786
  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)(
1787
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1720
1788
  "div",
1721
1789
  {
1722
1790
  className: getClassName7("inner"),
@@ -1736,11 +1804,11 @@ init_react_import();
1736
1804
  var styles_module_default8 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
1737
1805
 
1738
1806
  // components/Heading/index.tsx
1739
- var import_jsx_runtime10 = require("react/jsx-runtime");
1807
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1740
1808
  var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
1741
1809
  var Heading = ({ children, rank, size = "m" }) => {
1742
1810
  const Tag = rank ? `h${rank}` : "span";
1743
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1811
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1744
1812
  Tag,
1745
1813
  {
1746
1814
  className: getClassName8({
@@ -1756,7 +1824,7 @@ init_react_import();
1756
1824
 
1757
1825
  // components/Button/Button.tsx
1758
1826
  init_react_import();
1759
- var import_react13 = require("react");
1827
+ var import_react14 = require("react");
1760
1828
 
1761
1829
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
1762
1830
  init_react_import();
@@ -1776,7 +1844,7 @@ var filterDataAttrs = (props) => {
1776
1844
  };
1777
1845
 
1778
1846
  // components/Button/Button.tsx
1779
- var import_jsx_runtime11 = require("react/jsx-runtime");
1847
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1780
1848
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
1781
1849
  var Button = (_a) => {
1782
1850
  var _b = _a, {
@@ -1806,11 +1874,11 @@ var Button = (_a) => {
1806
1874
  "size",
1807
1875
  "loading"
1808
1876
  ]);
1809
- const [loading, setLoading] = (0, import_react13.useState)(loadingProp);
1810
- (0, import_react13.useEffect)(() => setLoading(loadingProp), [loadingProp]);
1877
+ const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
1878
+ (0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
1811
1879
  const ElementType = href ? "a" : type ? "button" : "span";
1812
1880
  const dataAttrs = filterDataAttrs(props);
1813
- const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1881
+ const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1814
1882
  ElementType,
1815
1883
  __spreadProps(__spreadValues({
1816
1884
  className: getClassName9({
@@ -1835,9 +1903,9 @@ var Button = (_a) => {
1835
1903
  href
1836
1904
  }, dataAttrs), {
1837
1905
  children: [
1838
- icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("icon"), children: icon }),
1906
+ icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("icon"), children: icon }),
1839
1907
  children,
1840
- loading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Loader, { size: 14 }) })
1908
+ loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 14 }) })
1841
1909
  ]
1842
1910
  })
1843
1911
  );
@@ -1845,7 +1913,7 @@ var Button = (_a) => {
1845
1913
  };
1846
1914
 
1847
1915
  // components/ExternalInput/index.tsx
1848
- var import_jsx_runtime12 = require("react/jsx-runtime");
1916
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1849
1917
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
1850
1918
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
1851
1919
  var dataCache = {};
@@ -1862,28 +1930,28 @@ var ExternalInput = ({
1862
1930
  mapRow = (val) => val,
1863
1931
  filterFields
1864
1932
  } = 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);
1933
+ const [data, setData] = (0, import_react15.useState)([]);
1934
+ const [isOpen, setOpen] = (0, import_react15.useState)(false);
1935
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
1868
1936
  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)(() => {
1937
+ const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
1938
+ const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
1939
+ const mappedData = (0, import_react15.useMemo)(() => {
1872
1940
  return data.map(mapRow);
1873
1941
  }, [data]);
1874
- const keys = (0, import_react14.useMemo)(() => {
1942
+ const keys = (0, import_react15.useMemo)(() => {
1875
1943
  const validKeys = /* @__PURE__ */ new Set();
1876
1944
  for (const item of mappedData) {
1877
1945
  for (const key of Object.keys(item)) {
1878
- if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react14.isValidElement)(item[key])) {
1946
+ if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
1879
1947
  validKeys.add(key);
1880
1948
  }
1881
1949
  }
1882
1950
  }
1883
1951
  return Array.from(validKeys);
1884
1952
  }, [mappedData]);
1885
- const [searchQuery, setSearchQuery] = (0, import_react14.useState)(field.initialQuery || "");
1886
- const search = (0, import_react14.useCallback)(
1953
+ const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
1954
+ const search = (0, import_react15.useCallback)(
1887
1955
  (query, filters2) => __async(void 0, null, function* () {
1888
1956
  setIsLoading(true);
1889
1957
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
@@ -1896,18 +1964,18 @@ var ExternalInput = ({
1896
1964
  }),
1897
1965
  [id, field]
1898
1966
  );
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: [
1967
+ const Footer = (0, import_react15.useCallback)(
1968
+ (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
1901
1969
  props.items.length,
1902
1970
  " result",
1903
1971
  props.items.length === 1 ? "" : "s"
1904
1972
  ] }),
1905
1973
  [field.renderFooter]
1906
1974
  );
1907
- (0, import_react14.useEffect)(() => {
1975
+ (0, import_react15.useEffect)(() => {
1908
1976
  search(searchQuery, filters);
1909
1977
  }, []);
1910
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1978
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1911
1979
  "div",
1912
1980
  {
1913
1981
  className: getClassName10({
@@ -1917,21 +1985,21 @@ var ExternalInput = ({
1917
1985
  }),
1918
1986
  id,
1919
1987
  children: [
1920
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("actions"), children: [
1921
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1988
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("actions"), children: [
1989
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1922
1990
  "button",
1923
1991
  {
1924
1992
  type: "button",
1925
1993
  onClick: () => setOpen(true),
1926
1994
  className: getClassName10("button"),
1927
1995
  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 })
1996
+ children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1997
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: "16" }),
1998
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: field.placeholder })
1931
1999
  ] })
1932
2000
  }
1933
2001
  ),
1934
- value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2002
+ value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1935
2003
  "button",
1936
2004
  {
1937
2005
  type: "button",
@@ -1940,11 +2008,11 @@ var ExternalInput = ({
1940
2008
  onChange(null);
1941
2009
  },
1942
2010
  disabled: readOnly,
1943
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LockOpen, { size: 16 })
2011
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LockOpen, { size: 16 })
1944
2012
  }
1945
2013
  )
1946
2014
  ] }),
1947
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2015
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1948
2016
  "form",
1949
2017
  {
1950
2018
  className: getClassNameModal({
@@ -1958,11 +2026,11 @@ var ExternalInput = ({
1958
2026
  search(searchQuery, filters);
1959
2027
  },
1960
2028
  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)(
2029
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
2030
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: getClassNameModal("search"), children: [
2031
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
2032
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Search, { size: "18" }) }),
2033
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1966
2034
  "input",
1967
2035
  {
1968
2036
  className: getClassNameModal("searchInput"),
@@ -1977,9 +2045,9 @@ var ExternalInput = ({
1977
2045
  }
1978
2046
  )
1979
2047
  ] }),
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)(
2048
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
2049
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
2050
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1983
2051
  IconButton,
1984
2052
  {
1985
2053
  title: "Toggle filters",
@@ -1988,15 +2056,15 @@ var ExternalInput = ({
1988
2056
  e.stopPropagation();
1989
2057
  setFiltersToggled(!filtersToggled);
1990
2058
  },
1991
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SlidersHorizontal, { size: 20 })
2059
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SlidersHorizontal, { size: 20 })
1992
2060
  }
1993
2061
  ) })
1994
2062
  ] })
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) => {
2063
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
2064
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("grid"), children: [
2065
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1998
2066
  const filterField = filterFields[fieldName];
1999
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2067
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2000
2068
  AutoFieldPrivate,
2001
2069
  {
2002
2070
  field: filterField,
@@ -2013,9 +2081,9 @@ var ExternalInput = ({
2013
2081
  fieldName
2014
2082
  );
2015
2083
  }) }),
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)(
2084
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
2085
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: getClassNameModal("table"), children: [
2086
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2019
2087
  "th",
2020
2088
  {
2021
2089
  className: getClassNameModal("th"),
@@ -2024,8 +2092,8 @@ var ExternalInput = ({
2024
2092
  },
2025
2093
  key
2026
2094
  )) }) }),
2027
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
2028
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2095
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
2096
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2029
2097
  "tr",
2030
2098
  {
2031
2099
  style: { whiteSpace: "nowrap" },
@@ -2034,16 +2102,16 @@ var ExternalInput = ({
2034
2102
  onChange(mapProp(data[i]));
2035
2103
  setOpen(false);
2036
2104
  },
2037
- children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
2105
+ children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
2038
2106
  },
2039
2107
  i
2040
2108
  );
2041
2109
  }) })
2042
2110
  ] }),
2043
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 24 }) })
2111
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 24 }) })
2044
2112
  ] })
2045
2113
  ] }),
2046
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Footer, { items: mappedData }) })
2114
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footer, { items: mappedData }) })
2047
2115
  ]
2048
2116
  }
2049
2117
  ) })
@@ -2053,7 +2121,7 @@ var ExternalInput = ({
2053
2121
  };
2054
2122
 
2055
2123
  // components/AutoField/fields/ExternalField/index.tsx
2056
- var import_jsx_runtime13 = require("react/jsx-runtime");
2124
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2057
2125
  var ExternalField = ({
2058
2126
  field,
2059
2127
  onChange,
@@ -2067,7 +2135,7 @@ var ExternalField = ({
2067
2135
  var _a, _b, _c;
2068
2136
  const validField = field;
2069
2137
  const deprecatedField = field;
2070
- (0, import_react15.useEffect)(() => {
2138
+ (0, import_react16.useEffect)(() => {
2071
2139
  if (deprecatedField.adaptor) {
2072
2140
  console.error(
2073
2141
  "Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
@@ -2077,7 +2145,7 @@ var ExternalField = ({
2077
2145
  if (field.type !== "external") {
2078
2146
  return null;
2079
2147
  }
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)(
2148
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2081
2149
  ExternalInput,
2082
2150
  {
2083
2151
  name,
@@ -2102,7 +2170,7 @@ var ExternalField = ({
2102
2170
 
2103
2171
  // components/AutoField/fields/RadioField/index.tsx
2104
2172
  init_react_import();
2105
- var import_react16 = require("react");
2173
+ var import_react17 = require("react");
2106
2174
 
2107
2175
  // lib/safe-json-parse.ts
2108
2176
  init_react_import();
@@ -2116,7 +2184,7 @@ var safeJsonParse = (str) => {
2116
2184
  };
2117
2185
 
2118
2186
  // components/AutoField/fields/RadioField/index.tsx
2119
- var import_jsx_runtime14 = require("react/jsx-runtime");
2187
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2120
2188
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
2121
2189
  var RadioField = ({
2122
2190
  field,
@@ -2128,26 +2196,26 @@ var RadioField = ({
2128
2196
  label,
2129
2197
  Label: Label2
2130
2198
  }) => {
2131
- const flatOptions = (0, import_react16.useMemo)(
2199
+ const flatOptions = (0, import_react17.useMemo)(
2132
2200
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
2133
2201
  [field]
2134
2202
  );
2135
2203
  if (field.type !== "radio" || !field.options) {
2136
2204
  return null;
2137
2205
  }
2138
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2206
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2139
2207
  Label2,
2140
2208
  {
2141
- icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
2209
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CircleCheckBig, { size: 16 }),
2142
2210
  label: label || name,
2143
2211
  readOnly,
2144
2212
  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)(
2213
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2146
2214
  "label",
2147
2215
  {
2148
2216
  className: getClassName11("radio"),
2149
2217
  children: [
2150
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2218
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2151
2219
  "input",
2152
2220
  {
2153
2221
  type: "radio",
@@ -2167,7 +2235,7 @@ var RadioField = ({
2167
2235
  checked: value === option.value
2168
2236
  }
2169
2237
  ),
2170
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2238
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
2171
2239
  ]
2172
2240
  },
2173
2241
  option.label + option.value
@@ -2178,8 +2246,8 @@ var RadioField = ({
2178
2246
 
2179
2247
  // components/AutoField/fields/SelectField/index.tsx
2180
2248
  init_react_import();
2181
- var import_react17 = require("react");
2182
- var import_jsx_runtime15 = require("react/jsx-runtime");
2249
+ var import_react18 = require("react");
2250
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2183
2251
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
2184
2252
  var SelectField = ({
2185
2253
  field,
@@ -2191,20 +2259,20 @@ var SelectField = ({
2191
2259
  readOnly,
2192
2260
  id
2193
2261
  }) => {
2194
- const flatOptions = (0, import_react17.useMemo)(
2262
+ const flatOptions = (0, import_react18.useMemo)(
2195
2263
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
2196
2264
  [field]
2197
2265
  );
2198
2266
  if (field.type !== "select" || !field.options) {
2199
2267
  return null;
2200
2268
  }
2201
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2269
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2202
2270
  Label2,
2203
2271
  {
2204
2272
  label: label || name,
2205
- icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
2273
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronDown, { size: 16 }),
2206
2274
  readOnly,
2207
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2275
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2208
2276
  "select",
2209
2277
  {
2210
2278
  id,
@@ -2221,7 +2289,7 @@ var SelectField = ({
2221
2289
  }
2222
2290
  },
2223
2291
  value,
2224
- children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2292
+ children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2225
2293
  "option",
2226
2294
  {
2227
2295
  label: option.label,
@@ -2237,7 +2305,7 @@ var SelectField = ({
2237
2305
 
2238
2306
  // components/AutoField/fields/TextareaField/index.tsx
2239
2307
  init_react_import();
2240
- var import_jsx_runtime16 = require("react/jsx-runtime");
2308
+ var import_jsx_runtime17 = require("react/jsx-runtime");
2241
2309
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
2242
2310
  var TextareaField = ({
2243
2311
  onChange,
@@ -2248,7 +2316,7 @@ var TextareaField = ({
2248
2316
  Label: Label2,
2249
2317
  id
2250
2318
  }) => {
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)(
2319
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2252
2320
  "textarea",
2253
2321
  {
2254
2322
  id,
@@ -2275,7 +2343,7 @@ init_react_import();
2275
2343
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
2276
2344
 
2277
2345
  // components/AutoField/fields/ObjectField/index.tsx
2278
- var import_jsx_runtime17 = require("react/jsx-runtime");
2346
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2279
2347
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
2280
2348
  var ObjectField = ({
2281
2349
  field,
@@ -2287,43 +2355,54 @@ var ObjectField = ({
2287
2355
  readOnly,
2288
2356
  id
2289
2357
  }) => {
2290
- const { selectedItem } = useAppContext();
2358
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
2291
2359
  if (field.type !== "object" || !field.objectFields) {
2292
2360
  return null;
2293
2361
  }
2294
- const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
2295
2362
  const data = value || {};
2296
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2363
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2297
2364
  Label2,
2298
2365
  {
2299
2366
  label: label || name,
2300
- icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
2367
+ icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EllipsisVertical, { size: 16 }),
2301
2368
  el: "div",
2302
2369
  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,
2370
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
2371
+ const subField = field.objectFields[subName];
2372
+ const subPath = `${name}.${subName}`;
2373
+ const localSubPath = `${localName || name}.${subName}`;
2374
+ const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
2375
+ const label2 = subField.label || subName;
2376
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2377
+ NestedFieldProvider,
2310
2378
  {
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
2379
+ name: localName || id,
2380
+ subName,
2381
+ readOnlyFields,
2382
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2383
+ AutoFieldPrivate,
2384
+ {
2385
+ name: subPath,
2386
+ label: subPath,
2387
+ id: `${id}_${subName}`,
2388
+ readOnly: subReadOnly,
2389
+ field: __spreadProps(__spreadValues({}, subField), {
2390
+ label: label2
2391
+ // May be used by custom fields
2321
2392
  }),
2322
- ui
2323
- );
2324
- }
2393
+ value: data[subName],
2394
+ onChange: (val, ui) => {
2395
+ onChange(
2396
+ __spreadProps(__spreadValues({}, data), {
2397
+ [subName]: val
2398
+ }),
2399
+ ui
2400
+ );
2401
+ }
2402
+ }
2403
+ )
2325
2404
  },
2326
- subFieldName
2405
+ subPath
2327
2406
  );
2328
2407
  }) }) })
2329
2408
  }
@@ -2332,7 +2411,7 @@ var ObjectField = ({
2332
2411
 
2333
2412
  // lib/use-safe-id.ts
2334
2413
  init_react_import();
2335
- var import_react18 = __toESM(require("react"));
2414
+ var import_react19 = __toESM(require("react"));
2336
2415
 
2337
2416
  // lib/generate-id.ts
2338
2417
  init_react_import();
@@ -2341,15 +2420,15 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
2341
2420
 
2342
2421
  // lib/use-safe-id.ts
2343
2422
  var useSafeId = () => {
2344
- if (typeof import_react18.default.useId !== "undefined") {
2345
- return import_react18.default.useId();
2423
+ if (typeof import_react19.default.useId !== "undefined") {
2424
+ return import_react19.default.useId();
2346
2425
  }
2347
- const [id] = (0, import_react18.useState)(generateId());
2426
+ const [id] = (0, import_react19.useState)(generateId());
2348
2427
  return id;
2349
2428
  };
2350
2429
 
2351
2430
  // components/AutoField/index.tsx
2352
- var import_jsx_runtime18 = require("react/jsx-runtime");
2431
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2353
2432
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2354
2433
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2355
2434
  var FieldLabel = ({
@@ -2361,16 +2440,16 @@ var FieldLabel = ({
2361
2440
  className
2362
2441
  }) => {
2363
2442
  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, {}),
2443
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(El, { className, children: [
2444
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName15("label"), children: [
2445
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {}),
2367
2446
  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" }) })
2447
+ readOnly && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Lock, { size: "12" }) })
2369
2448
  ] }),
2370
2449
  children
2371
2450
  ] });
2372
2451
  };
2373
- var FieldLabelInternal2 = ({
2452
+ var FieldLabelInternal = ({
2374
2453
  children,
2375
2454
  icon,
2376
2455
  label,
@@ -2378,14 +2457,14 @@ var FieldLabelInternal2 = ({
2378
2457
  readOnly
2379
2458
  }) => {
2380
2459
  const { overrides } = useAppContext();
2381
- const Wrapper = (0, import_react19.useMemo)(
2460
+ const Wrapper = (0, import_react20.useMemo)(
2382
2461
  () => overrides.fieldLabel || FieldLabel,
2383
2462
  [overrides]
2384
2463
  );
2385
2464
  if (!label) {
2386
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
2465
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
2387
2466
  }
2388
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2467
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2389
2468
  Wrapper,
2390
2469
  {
2391
2470
  label,
@@ -2399,8 +2478,9 @@ var FieldLabelInternal2 = ({
2399
2478
  };
2400
2479
  function AutoFieldInternal(props) {
2401
2480
  var _a, _b, _c, _d, _e, _f, _g, _h;
2402
- const { dispatch, overrides } = useAppContext();
2403
- const { id, Label: Label2 = FieldLabelInternal2 } = props;
2481
+ const { dispatch, overrides, selectedItem } = useAppContext();
2482
+ const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
2483
+ const { id, Label: Label2 = FieldLabelInternal } = props;
2404
2484
  const field = props.field;
2405
2485
  const label = field.label;
2406
2486
  const defaultId = useSafeId();
@@ -2431,7 +2511,7 @@ function AutoFieldInternal(props) {
2431
2511
  Label: Label2,
2432
2512
  id: resolvedId
2433
2513
  });
2434
- const onFocus = (0, import_react19.useCallback)(
2514
+ const onFocus = (0, import_react20.useCallback)(
2435
2515
  (e) => {
2436
2516
  if (mergedProps.name && e.target.nodeName === "INPUT") {
2437
2517
  e.stopPropagation();
@@ -2445,7 +2525,7 @@ function AutoFieldInternal(props) {
2445
2525
  },
2446
2526
  [mergedProps.name]
2447
2527
  );
2448
- const onBlur = (0, import_react19.useCallback)((e) => {
2528
+ const onBlur = (0, import_react20.useCallback)((e) => {
2449
2529
  if ("name" in e.target) {
2450
2530
  dispatch({
2451
2531
  type: "setUi",
@@ -2460,27 +2540,36 @@ function AutoFieldInternal(props) {
2460
2540
  return null;
2461
2541
  }
2462
2542
  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)) }) });
2543
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
2464
2544
  }
2465
2545
  const children = defaultFields[field.type](mergedProps);
2466
2546
  const Render2 = render[field.type];
2467
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2468
- "div",
2547
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2548
+ NestedFieldContext.Provider,
2469
2549
  {
2470
- className: getClassNameWrapper(),
2471
- onFocus,
2472
- onBlur,
2473
- onClick: (e) => {
2474
- e.stopPropagation();
2550
+ value: {
2551
+ readOnlyFields: nestedFieldContext.readOnlyFields || (selectedItem == null ? void 0 : selectedItem.readOnly) || {},
2552
+ localName: nestedFieldContext.localName
2475
2553
  },
2476
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2554
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2555
+ "div",
2556
+ {
2557
+ className: getClassNameWrapper(),
2558
+ onFocus,
2559
+ onBlur,
2560
+ onClick: (e) => {
2561
+ e.stopPropagation();
2562
+ },
2563
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2564
+ }
2565
+ )
2477
2566
  }
2478
2567
  );
2479
2568
  }
2480
2569
  function AutoFieldPrivate(props) {
2481
2570
  const { state } = useAppContext();
2482
2571
  const { value, onChange } = props;
2483
- const [localValue, setLocalValue] = (0, import_react19.useState)(value);
2572
+ const [localValue, setLocalValue] = (0, import_react20.useState)(value);
2484
2573
  const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
2485
2574
  (val, ui) => {
2486
2575
  onChange(val, ui);
@@ -2488,11 +2577,11 @@ function AutoFieldPrivate(props) {
2488
2577
  50,
2489
2578
  { leading: true }
2490
2579
  );
2491
- const onChangeLocal = (0, import_react19.useCallback)((val, ui) => {
2580
+ const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
2492
2581
  setLocalValue(val);
2493
2582
  onChangeDb(val, ui);
2494
2583
  }, []);
2495
- (0, import_react19.useEffect)(() => {
2584
+ (0, import_react20.useEffect)(() => {
2496
2585
  if (state.ui.field.focus !== props.name) {
2497
2586
  setLocalValue(value);
2498
2587
  }
@@ -2501,11 +2590,11 @@ function AutoFieldPrivate(props) {
2501
2590
  value: localValue,
2502
2591
  onChange: onChangeLocal
2503
2592
  };
2504
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2593
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2505
2594
  }
2506
2595
  function AutoField(props) {
2507
- const DefaultLabel = (0, import_react19.useMemo)(() => {
2508
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2596
+ const DefaultLabel = (0, import_react20.useMemo)(() => {
2597
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2509
2598
  "div",
2510
2599
  __spreadProps(__spreadValues({}, labelProps), {
2511
2600
  className: getClassName15({ readOnly: props.readOnly })
@@ -2513,7 +2602,7 @@ function AutoField(props) {
2513
2602
  );
2514
2603
  return DefaultLabel2;
2515
2604
  }, [props.readOnly]);
2516
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2605
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
2517
2606
  }
2518
2607
 
2519
2608
  // components/Drawer/index.tsx
@@ -2524,21 +2613,21 @@ init_react_import();
2524
2613
  var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
2525
2614
 
2526
2615
  // components/Drawer/index.tsx
2527
- var import_react26 = require("react");
2616
+ var import_react32 = require("react");
2528
2617
 
2529
2618
  // components/DragDropContext/index.tsx
2530
2619
  init_react_import();
2531
- var import_react24 = require("@dnd-kit/react");
2532
- var import_react25 = require("react");
2620
+ var import_react30 = require("@dnd-kit/react");
2621
+ var import_react31 = require("react");
2533
2622
  var import_dom = require("@dnd-kit/dom");
2534
2623
 
2535
2624
  // components/DropZone/index.tsx
2536
2625
  init_react_import();
2537
- var import_react23 = require("react");
2626
+ var import_react29 = require("react");
2538
2627
 
2539
2628
  // components/DraggableComponent/index.tsx
2540
2629
  init_react_import();
2541
- var import_react20 = require("react");
2630
+ var import_react23 = require("react");
2542
2631
 
2543
2632
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
2544
2633
  init_react_import();
@@ -2547,15 +2636,15 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
2547
2636
  // components/DraggableComponent/index.tsx
2548
2637
  var import_react_dom2 = require("react-dom");
2549
2638
 
2550
- // components/DraggableComponent/collision/dynamic/index.ts
2639
+ // lib/dnd/collision/dynamic/index.ts
2551
2640
  init_react_import();
2552
2641
  var import_abstract8 = require("@dnd-kit/abstract");
2553
2642
 
2554
- // components/DraggableComponent/collision/directional/index.ts
2643
+ // lib/dnd/collision/directional/index.ts
2555
2644
  init_react_import();
2556
2645
  var import_abstract = require("@dnd-kit/abstract");
2557
2646
 
2558
- // components/DraggableComponent/collision/collision-debug.ts
2647
+ // lib/dnd/collision/collision-debug.ts
2559
2648
  init_react_import();
2560
2649
  var DEBUG = false;
2561
2650
  var debugElements = {};
@@ -2604,7 +2693,7 @@ var collisionDebug = (a, b, id, color, label) => {
2604
2693
  });
2605
2694
  };
2606
2695
 
2607
- // components/DraggableComponent/collision/directional/index.ts
2696
+ // lib/dnd/collision/directional/index.ts
2608
2697
  var distanceChange = "increasing";
2609
2698
  var directionalCollision = (input, previous) => {
2610
2699
  var _a;
@@ -2637,7 +2726,7 @@ var directionalCollision = (input, previous) => {
2637
2726
  return null;
2638
2727
  };
2639
2728
 
2640
- // components/DraggableComponent/collision/dynamic/get-direction.ts
2729
+ // lib/dnd/collision/dynamic/get-direction.ts
2641
2730
  init_react_import();
2642
2731
  var getDirection = (dragAxis, delta) => {
2643
2732
  if (dragAxis === "dynamic") {
@@ -2652,7 +2741,7 @@ var getDirection = (dragAxis, delta) => {
2652
2741
  return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2653
2742
  };
2654
2743
 
2655
- // components/DraggableComponent/collision/dynamic/get-midpoint-impact.ts
2744
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
2656
2745
  init_react_import();
2657
2746
  var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
2658
2747
  const dragRect = dragShape.boundingRectangle;
@@ -2671,7 +2760,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2671
2760
  return dragRect.right - offset >= dropCenter.x;
2672
2761
  };
2673
2762
 
2674
- // components/DraggableComponent/collision/dynamic/track-movement-interval.ts
2763
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
2675
2764
  init_react_import();
2676
2765
  var import_geometry = require("@dnd-kit/geometry");
2677
2766
  var INTERVAL_SENSITIVITY = 10;
@@ -2775,7 +2864,14 @@ var closestCorners = (input) => {
2775
2864
  };
2776
2865
  };
2777
2866
 
2778
- // components/DraggableComponent/collision/dynamic/index.ts
2867
+ // lib/dnd/collision/dynamic/store.ts
2868
+ init_react_import();
2869
+ var import_vanilla = require("zustand/vanilla");
2870
+ var collisionStore = (0, import_vanilla.createStore)(() => ({
2871
+ fallbackEnabled: false
2872
+ }));
2873
+
2874
+ // lib/dnd/collision/dynamic/index.ts
2779
2875
  var flushNext = "";
2780
2876
  var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2781
2877
  var _a, _b, _c, _d, _e;
@@ -2787,6 +2883,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2787
2883
  return null;
2788
2884
  }
2789
2885
  const { center: dragCenter } = dragShape;
2886
+ const { fallbackEnabled } = collisionStore.getState();
2790
2887
  const interval = trackMovementInterval(position.current, dragAxis);
2791
2888
  dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2792
2889
  direction: interval.direction
@@ -2832,7 +2929,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2832
2929
  flushNext = "";
2833
2930
  return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2834
2931
  }
2835
- if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2932
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2836
2933
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2837
2934
  const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2838
2935
  if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
@@ -2893,8 +2990,102 @@ function getDeepScrollPosition(element) {
2893
2990
  return totalScroll;
2894
2991
  }
2895
2992
 
2993
+ // components/DropZone/context.tsx
2994
+ init_react_import();
2995
+ var import_react21 = require("react");
2996
+ var import_zustand = require("zustand");
2997
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2998
+ var dropZoneContext = (0, import_react21.createContext)(null);
2999
+ var ZoneStoreContext = (0, import_react21.createContext)(
3000
+ (0, import_zustand.createStore)(() => ({
3001
+ zoneDepthIndex: {},
3002
+ nextZoneDepthIndex: {},
3003
+ areaDepthIndex: {},
3004
+ nextAreaDepthIndex: {},
3005
+ draggedItem: null,
3006
+ previewIndex: {}
3007
+ }))
3008
+ );
3009
+ var ZoneStoreProvider = ({
3010
+ children,
3011
+ store
3012
+ }) => {
3013
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ZoneStoreContext.Provider, { value: store, children });
3014
+ };
3015
+ var DropZoneProvider = ({
3016
+ children,
3017
+ value
3018
+ }) => {
3019
+ const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
3020
+ const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
3021
+ {}
3022
+ );
3023
+ const [activeZones, setActiveZones] = (0, import_react21.useState)({});
3024
+ const { dispatch } = useAppContext();
3025
+ const registerZoneArea = (0, import_react21.useCallback)(
3026
+ (area) => {
3027
+ setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
3028
+ },
3029
+ [setAreasWithZones]
3030
+ );
3031
+ const registerZone = (0, import_react21.useCallback)(
3032
+ (zoneCompound) => {
3033
+ if (!dispatch) {
3034
+ return;
3035
+ }
3036
+ dispatch({
3037
+ type: "registerZone",
3038
+ zone: zoneCompound
3039
+ });
3040
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
3041
+ },
3042
+ [setActiveZones, dispatch]
3043
+ );
3044
+ const unregisterZone = (0, import_react21.useCallback)(
3045
+ (zoneCompound) => {
3046
+ if (!dispatch) {
3047
+ return;
3048
+ }
3049
+ dispatch({
3050
+ type: "unregisterZone",
3051
+ zone: zoneCompound
3052
+ });
3053
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
3054
+ [zoneCompound]: false
3055
+ }));
3056
+ },
3057
+ [setActiveZones, dispatch]
3058
+ );
3059
+ const memoValue = (0, import_react21.useMemo)(
3060
+ () => __spreadValues({
3061
+ hoveringComponent,
3062
+ setHoveringComponent,
3063
+ registerZoneArea,
3064
+ areasWithZones,
3065
+ registerZone,
3066
+ unregisterZone,
3067
+ activeZones
3068
+ }, value),
3069
+ [value, hoveringComponent, areasWithZones, activeZones]
3070
+ );
3071
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
3072
+ };
3073
+
3074
+ // lib/use-context-store.ts
3075
+ init_react_import();
3076
+ var import_react22 = require("react");
3077
+ var import_zustand2 = require("zustand");
3078
+ var import_shallow = require("zustand/react/shallow");
3079
+ function useContextStore(context, selector) {
3080
+ const store = (0, import_react22.useContext)(context);
3081
+ if (!store) {
3082
+ throw new Error("useContextStore must be used inside context");
3083
+ }
3084
+ return (0, import_zustand2.useStore)(store, (0, import_shallow.useShallow)(selector));
3085
+ }
3086
+
2896
3087
  // components/DraggableComponent/index.tsx
2897
- var import_jsx_runtime19 = require("react/jsx-runtime");
3088
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2898
3089
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
2899
3090
  var DEBUG2 = false;
2900
3091
  var space = 8;
@@ -2905,12 +3096,12 @@ var DefaultActionBar = ({
2905
3096
  label,
2906
3097
  children,
2907
3098
  parentAction
2908
- }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ActionBar, { children: [
2909
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ActionBar.Group, { children: [
3099
+ }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar, { children: [
3100
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ActionBar.Group, { children: [
2910
3101
  parentAction,
2911
- label && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Label, { label })
3102
+ label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Label, { label })
2912
3103
  ] }),
2913
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ActionBar.Group, { children })
3104
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Group, { children })
2914
3105
  ] });
2915
3106
  var convertIdToSelector = (id, zoneCompound, data) => {
2916
3107
  const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
@@ -2945,9 +3136,9 @@ var DraggableComponent = ({
2945
3136
  iframe,
2946
3137
  state
2947
3138
  } = useAppContext();
2948
- const ctx = (0, import_react20.useContext)(dropZoneContext);
2949
- const [localZones, setLocalZones] = (0, import_react20.useState)({});
2950
- const registerLocalZone = (0, import_react20.useCallback)(
3139
+ const ctx = (0, import_react23.useContext)(dropZoneContext);
3140
+ const [localZones, setLocalZones] = (0, import_react23.useState)({});
3141
+ const registerLocalZone = (0, import_react23.useCallback)(
2951
3142
  (zoneCompound2, active) => {
2952
3143
  var _a;
2953
3144
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -2957,7 +3148,7 @@ var DraggableComponent = ({
2957
3148
  },
2958
3149
  [setLocalZones]
2959
3150
  );
2960
- const unregisterLocalZone = (0, import_react20.useCallback)(
3151
+ const unregisterLocalZone = (0, import_react23.useCallback)(
2961
3152
  (zoneCompound2) => {
2962
3153
  var _a;
2963
3154
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -2971,8 +3162,8 @@ var DraggableComponent = ({
2971
3162
  );
2972
3163
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
2973
3164
  const { path = [] } = ctx || {};
2974
- const [canDrag, setCanDrag] = (0, import_react20.useState)(false);
2975
- (0, import_react20.useEffect)(() => {
3165
+ const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
3166
+ (0, import_react23.useEffect)(() => {
2976
3167
  var _a;
2977
3168
  const item = getItem({ index, zone: zoneCompound }, state.data);
2978
3169
  if (item) {
@@ -2982,10 +3173,13 @@ var DraggableComponent = ({
2982
3173
  setCanDrag((_a = perms.drag) != null ? _a : true);
2983
3174
  }
2984
3175
  }, [state, index, zoneCompound, getPermissions]);
2985
- const userIsDragging = !!(ctx == null ? void 0 : ctx.draggedItem);
3176
+ const userIsDragging = useContextStore(
3177
+ ZoneStoreContext,
3178
+ (s) => !!s.draggedItem
3179
+ );
2986
3180
  const canCollide = canDrag || userIsDragging;
2987
3181
  const disabled = !isEnabled || !canCollide;
2988
- const [dragAxis, setDragAxis] = (0, import_react20.useState)(userDragAxis || autoDragAxis);
3182
+ const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
2989
3183
  const { ref: sortableRef, status } = useSortableSafe({
2990
3184
  id,
2991
3185
  index,
@@ -3011,8 +3205,8 @@ var DraggableComponent = ({
3011
3205
  }
3012
3206
  });
3013
3207
  const thisIsDragging = status === "dragging";
3014
- const ref = (0, import_react20.useRef)(null);
3015
- const refSetter = (0, import_react20.useCallback)(
3208
+ const ref = (0, import_react23.useRef)(null);
3209
+ const refSetter = (0, import_react23.useCallback)(
3016
3210
  (el) => {
3017
3211
  sortableRef(el);
3018
3212
  if (el) {
@@ -3021,14 +3215,14 @@ var DraggableComponent = ({
3021
3215
  },
3022
3216
  [sortableRef]
3023
3217
  );
3024
- const [portalEl, setPortalEl] = (0, import_react20.useState)();
3025
- (0, import_react20.useEffect)(() => {
3218
+ const [portalEl, setPortalEl] = (0, import_react23.useState)();
3219
+ (0, import_react23.useEffect)(() => {
3026
3220
  var _a, _b, _c;
3027
3221
  setPortalEl(
3028
3222
  iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
3029
3223
  );
3030
3224
  }, [iframe.enabled, ref.current]);
3031
- const getStyle = (0, import_react20.useCallback)(() => {
3225
+ const getStyle = (0, import_react23.useCallback)(() => {
3032
3226
  var _a, _b, _c;
3033
3227
  if (!ref.current) return;
3034
3228
  const rect = ref.current.getBoundingClientRect();
@@ -3048,11 +3242,11 @@ var DraggableComponent = ({
3048
3242
  };
3049
3243
  return style2;
3050
3244
  }, [ref.current]);
3051
- const [style, setStyle] = (0, import_react20.useState)();
3052
- const sync = (0, import_react20.useCallback)(() => {
3245
+ const [style, setStyle] = (0, import_react23.useState)();
3246
+ const sync = (0, import_react23.useCallback)(() => {
3053
3247
  setStyle(getStyle());
3054
3248
  }, [ref.current, iframe]);
3055
- (0, import_react20.useEffect)(() => {
3249
+ (0, import_react23.useEffect)(() => {
3056
3250
  if (ref.current) {
3057
3251
  const observer = new ResizeObserver(sync);
3058
3252
  observer.observe(ref.current);
@@ -3061,20 +3255,28 @@ var DraggableComponent = ({
3061
3255
  };
3062
3256
  }
3063
3257
  }, [ref.current]);
3064
- (0, import_react20.useEffect)(() => {
3065
- ctx == null ? void 0 : ctx.registerPath({
3066
- index,
3067
- zone: zoneCompound
3068
- });
3069
- }, [isSelected]);
3070
- const CustomActionBar = (0, import_react20.useMemo)(
3258
+ (0, import_react23.useEffect)(() => {
3259
+ ctx == null ? void 0 : ctx.registerPath(
3260
+ id,
3261
+ {
3262
+ index,
3263
+ zone: zoneCompound
3264
+ },
3265
+ componentType
3266
+ );
3267
+ return () => {
3268
+ var _a;
3269
+ (_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
3270
+ };
3271
+ }, [id, zoneCompound, index, componentType]);
3272
+ const CustomActionBar = (0, import_react23.useMemo)(
3071
3273
  () => overrides.actionBar || DefaultActionBar,
3072
3274
  [overrides.actionBar]
3073
3275
  );
3074
3276
  const permissions = getPermissions({
3075
3277
  item: selectedItem
3076
3278
  });
3077
- const onClick = (0, import_react20.useCallback)(
3279
+ const onClick = (0, import_react23.useCallback)(
3078
3280
  (e) => {
3079
3281
  e.stopPropagation();
3080
3282
  dispatch({
@@ -3086,7 +3288,7 @@ var DraggableComponent = ({
3086
3288
  },
3087
3289
  [index, zoneCompound, id]
3088
3290
  );
3089
- const onSelectParent = (0, import_react20.useCallback)(() => {
3291
+ const onSelectParent = (0, import_react23.useCallback)(() => {
3090
3292
  if (!(ctx == null ? void 0 : ctx.areaId)) {
3091
3293
  return;
3092
3294
  }
@@ -3104,23 +3306,23 @@ var DraggableComponent = ({
3104
3306
  }
3105
3307
  });
3106
3308
  }, [ctx, path]);
3107
- const onDuplicate = (0, import_react20.useCallback)(() => {
3309
+ const onDuplicate = (0, import_react23.useCallback)(() => {
3108
3310
  dispatch({
3109
3311
  type: "duplicate",
3110
3312
  sourceIndex: index,
3111
3313
  sourceZone: zoneCompound
3112
3314
  });
3113
3315
  }, [index, zoneCompound]);
3114
- const onDelete = (0, import_react20.useCallback)(() => {
3316
+ const onDelete = (0, import_react23.useCallback)(() => {
3115
3317
  dispatch({
3116
3318
  type: "remove",
3117
3319
  index,
3118
3320
  zone: zoneCompound
3119
3321
  });
3120
3322
  }, [index, zoneCompound]);
3121
- const [hover, setHover] = (0, import_react20.useState)(false);
3323
+ const [hover, setHover] = (0, import_react23.useState)(false);
3122
3324
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
3123
- (0, import_react20.useEffect)(() => {
3325
+ (0, import_react23.useEffect)(() => {
3124
3326
  if (!ref.current) {
3125
3327
  return;
3126
3328
  }
@@ -3170,7 +3372,7 @@ var DraggableComponent = ({
3170
3372
  thisIsDragging,
3171
3373
  inDroppableZone
3172
3374
  ]);
3173
- (0, import_react20.useEffect)(() => {
3375
+ (0, import_react23.useEffect)(() => {
3174
3376
  if (ref.current && disabled) {
3175
3377
  ref.current.setAttribute("data-puck-disabled", "");
3176
3378
  return () => {
@@ -3179,8 +3381,8 @@ var DraggableComponent = ({
3179
3381
  };
3180
3382
  }
3181
3383
  }, [disabled, ref]);
3182
- const [isVisible, setIsVisible] = (0, import_react20.useState)(false);
3183
- (0, import_react20.useEffect)(() => {
3384
+ const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
3385
+ (0, import_react23.useEffect)(() => {
3184
3386
  sync();
3185
3387
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
3186
3388
  setIsVisible(true);
@@ -3188,7 +3390,7 @@ var DraggableComponent = ({
3188
3390
  setIsVisible(false);
3189
3391
  }
3190
3392
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3191
- const syncActionsPosition = (0, import_react20.useCallback)(
3393
+ const syncActionsPosition = (0, import_react23.useCallback)(
3192
3394
  (el) => {
3193
3395
  if (el) {
3194
3396
  const view = el.ownerDocument.defaultView;
@@ -3205,7 +3407,7 @@ var DraggableComponent = ({
3205
3407
  },
3206
3408
  [zoomConfig]
3207
3409
  );
3208
- (0, import_react20.useEffect)(() => {
3410
+ (0, import_react23.useEffect)(() => {
3209
3411
  if (userDragAxis) {
3210
3412
  setDragAxis(userDragAxis);
3211
3413
  return;
@@ -3219,8 +3421,8 @@ var DraggableComponent = ({
3219
3421
  }
3220
3422
  setDragAxis(autoDragAxis);
3221
3423
  }, [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)(
3424
+ 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 }) });
3425
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3224
3426
  DropZoneProvider,
3225
3427
  {
3226
3428
  value: __spreadProps(__spreadValues({}, ctx), {
@@ -3234,7 +3436,7 @@ var DraggableComponent = ({
3234
3436
  }),
3235
3437
  children: [
3236
3438
  isVisible && (0, import_react_dom2.createPortal)(
3237
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3439
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3238
3440
  "div",
3239
3441
  {
3240
3442
  className: getClassName16({
@@ -3246,15 +3448,15 @@ var DraggableComponent = ({
3246
3448
  "data-puck-overlay": true,
3247
3449
  children: [
3248
3450
  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)(
3451
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {}) }),
3452
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3251
3453
  "div",
3252
3454
  {
3253
3455
  className: getClassName16("actionsOverlay"),
3254
3456
  style: {
3255
3457
  top: actionsOverlayTop / zoomConfig.zoom
3256
3458
  },
3257
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3459
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3258
3460
  "div",
3259
3461
  {
3260
3462
  className: getClassName16("actions"),
@@ -3266,14 +3468,14 @@ var DraggableComponent = ({
3266
3468
  paddingRight: actionsSide
3267
3469
  },
3268
3470
  ref: syncActionsPosition,
3269
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3471
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3270
3472
  CustomActionBar,
3271
3473
  {
3272
3474
  parentAction,
3273
3475
  label: DEBUG2 ? id : label,
3274
3476
  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 }) })
3477
+ permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Copy, { size: 16 }) }),
3478
+ 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
3479
  ]
3278
3480
  }
3279
3481
  )
@@ -3281,7 +3483,7 @@ var DraggableComponent = ({
3281
3483
  )
3282
3484
  }
3283
3485
  ),
3284
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("overlay") })
3486
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassName16("overlay") })
3285
3487
  ]
3286
3488
  }
3287
3489
  ),
@@ -3297,93 +3499,26 @@ var DraggableComponent = ({
3297
3499
  init_react_import();
3298
3500
  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
3501
 
3300
- // components/DropZone/context.tsx
3502
+ // components/DropZone/lib/use-min-empty-height.ts
3301
3503
  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
3365
- 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");
3504
+ var import_react24 = require("react");
3375
3505
  var useMinEmptyHeight = ({
3376
- draggedItem,
3377
3506
  zoneCompound,
3378
3507
  userMinEmptyHeight,
3379
3508
  ref
3380
3509
  }) => {
3381
- const [prevHeight, setPrevHeight] = (0, import_react22.useState)(0);
3382
- const [isAnimating, setIsAnimating] = (0, import_react22.useState)(false);
3383
- (0, import_react22.useEffect)(() => {
3510
+ const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
3511
+ const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
3512
+ const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3513
+ var _a, _b;
3514
+ return {
3515
+ draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
3516
+ isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3517
+ };
3518
+ });
3519
+ (0, import_react24.useEffect)(() => {
3384
3520
  if (draggedItem && ref.current) {
3385
- const componentData = draggedItem.data;
3386
- if (componentData.zone === zoneCompound) {
3521
+ if (isZone) {
3387
3522
  const rect = ref.current.getBoundingClientRect();
3388
3523
  setPrevHeight(rect.height);
3389
3524
  setIsAnimating(true);
@@ -3413,15 +3548,143 @@ function assignRefs(refs, node) {
3413
3548
  });
3414
3549
  }
3415
3550
 
3416
- // components/DropZone/index.tsx
3417
- var import_jsx_runtime21 = require("react/jsx-runtime");
3418
- var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3419
- var DEBUG3 = false;
3551
+ // components/DropZone/lib/use-content-with-preview.ts
3552
+ init_react_import();
3553
+ var import_react27 = require("react");
3554
+
3555
+ // lib/dnd/use-rendered-callback.ts
3556
+ init_react_import();
3557
+ var import_react25 = require("@dnd-kit/react");
3558
+ var import_react26 = require("react");
3559
+ function useRenderedCallback(callback, deps) {
3560
+ const manager = (0, import_react25.useDragDropManager)();
3561
+ return (0, import_react26.useCallback)(
3562
+ (...args) => __async(this, null, function* () {
3563
+ yield manager == null ? void 0 : manager.renderer.rendering;
3564
+ return callback(...args);
3565
+ }),
3566
+ [...deps, manager]
3567
+ );
3568
+ }
3569
+
3570
+ // lib/insert.ts
3571
+ init_react_import();
3572
+ var insert = (list, index, item) => {
3573
+ const result = Array.from(list);
3574
+ result.splice(index, 0, item);
3575
+ return result;
3576
+ };
3577
+
3578
+ // components/DropZone/lib/use-content-with-preview.ts
3579
+ var useContentWithPreview = (content, zoneCompound) => {
3580
+ const { draggedItemId, preview, previewExists } = useContextStore(
3581
+ ZoneStoreContext,
3582
+ (s) => {
3583
+ var _a;
3584
+ return {
3585
+ draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
3586
+ preview: s.previewIndex[zoneCompound],
3587
+ previewExists: Object.keys(s.previewIndex || {}).length > 0
3588
+ };
3589
+ }
3590
+ );
3591
+ const {
3592
+ state: {
3593
+ ui: { isDragging }
3594
+ }
3595
+ } = useAppContext();
3596
+ const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
3597
+ const [localPreview, setLocalPreview] = (0, import_react27.useState)(
3598
+ preview
3599
+ );
3600
+ const updateContent = useRenderedCallback(
3601
+ (content2, preview2, isDragging2) => {
3602
+ if (isDragging2 && !previewExists) {
3603
+ return;
3604
+ }
3605
+ if (preview2) {
3606
+ if (preview2.type === "insert") {
3607
+ setContentWithPreview(
3608
+ insert(
3609
+ content2.filter((item) => item.props.id !== preview2.props.id),
3610
+ preview2.index,
3611
+ {
3612
+ type: "preview",
3613
+ props: { id: preview2.props.id }
3614
+ }
3615
+ )
3616
+ );
3617
+ } else {
3618
+ setContentWithPreview(
3619
+ insert(
3620
+ content2.filter((item) => item.props.id !== preview2.props.id),
3621
+ preview2.index,
3622
+ {
3623
+ type: preview2.componentType,
3624
+ props: preview2.props
3625
+ }
3626
+ )
3627
+ );
3628
+ }
3629
+ } else {
3630
+ setContentWithPreview(
3631
+ previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3632
+ );
3633
+ }
3634
+ setLocalPreview(preview2);
3635
+ },
3636
+ [draggedItemId, previewExists]
3637
+ );
3638
+ (0, import_react27.useEffect)(() => {
3639
+ updateContent(content, preview, isDragging);
3640
+ }, [content, preview, isDragging]);
3641
+ return [contentWithPreview, localPreview];
3642
+ };
3643
+
3644
+ // components/DropZone/lib/use-drag-axis.ts
3645
+ init_react_import();
3646
+ var import_react28 = require("react");
3420
3647
  var GRID_DRAG_AXIS = "dynamic";
3421
3648
  var FLEX_ROW_DRAG_AXIS = "x";
3422
3649
  var DEFAULT_DRAG_AXIS = "y";
3423
- var DropZoneEdit = (0, import_react23.forwardRef)(
3424
- function DropZoneEdit2({
3650
+ var useDragAxis = (ref, collisionAxis) => {
3651
+ const { status } = useAppContext();
3652
+ const [dragAxis, setDragAxis] = (0, import_react28.useState)(
3653
+ collisionAxis || DEFAULT_DRAG_AXIS
3654
+ );
3655
+ const calculateDragAxis = (0, import_react28.useCallback)(() => {
3656
+ if (ref.current) {
3657
+ const computedStyle = window.getComputedStyle(ref.current);
3658
+ if (computedStyle.display === "grid") {
3659
+ setDragAxis(GRID_DRAG_AXIS);
3660
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3661
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3662
+ } else {
3663
+ setDragAxis(DEFAULT_DRAG_AXIS);
3664
+ }
3665
+ }
3666
+ }, [ref.current]);
3667
+ (0, import_react28.useEffect)(() => {
3668
+ const onViewportChange = () => {
3669
+ calculateDragAxis();
3670
+ };
3671
+ window.addEventListener("viewportchange", onViewportChange);
3672
+ return () => {
3673
+ window.removeEventListener("viewportchange", onViewportChange);
3674
+ };
3675
+ }, []);
3676
+ (0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
3677
+ return [dragAxis, calculateDragAxis];
3678
+ };
3679
+
3680
+ // components/DropZone/index.tsx
3681
+ var import_jsx_runtime22 = require("react/jsx-runtime");
3682
+ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3683
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3684
+ var RENDER_DEBUG = false;
3685
+ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
3686
+ var DropZoneEdit = (0, import_react29.forwardRef)(
3687
+ function DropZoneEditInternal({
3425
3688
  zone,
3426
3689
  allow,
3427
3690
  disallow,
@@ -3431,31 +3694,48 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3431
3694
  collisionAxis
3432
3695
  }, userRef) {
3433
3696
  const appContext2 = useAppContext();
3434
- const ctx = (0, import_react23.useContext)(dropZoneContext);
3697
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
3435
3698
  const {
3436
3699
  // These all need setting via context
3437
3700
  data,
3438
3701
  config,
3439
3702
  areaId,
3440
- draggedItem,
3441
3703
  registerZoneArea,
3442
3704
  depth,
3443
3705
  registerLocalZone,
3444
3706
  unregisterLocalZone,
3445
- deepestZone = rootDroppableId,
3446
- deepestArea,
3447
- nextDeepestArea,
3448
3707
  path = [],
3449
3708
  activeZones
3450
3709
  } = ctx;
3451
- const { itemSelector } = appContext2.state.ui;
3452
3710
  let zoneCompound = rootDroppableId;
3453
- (0, import_react23.useEffect)(() => {
3711
+ if (areaId) {
3712
+ if (zone !== rootDroppableId) {
3713
+ zoneCompound = `${areaId}:${zone}`;
3714
+ }
3715
+ }
3716
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3717
+ const {
3718
+ isDeepestZone,
3719
+ inNextDeepestArea,
3720
+ draggedComponentType,
3721
+ userIsDragging
3722
+ } = useContextStore(ZoneStoreContext, (s) => {
3723
+ var _a, _b, _c;
3724
+ return {
3725
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3726
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3727
+ draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3728
+ draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3729
+ userIsDragging: !!s.draggedItem
3730
+ };
3731
+ });
3732
+ const { itemSelector } = appContext2.state.ui;
3733
+ (0, import_react29.useEffect)(() => {
3454
3734
  if (areaId && registerZoneArea) {
3455
3735
  registerZoneArea(areaId);
3456
3736
  }
3457
3737
  }, [areaId]);
3458
- (0, import_react23.useEffect)(() => {
3738
+ (0, import_react29.useEffect)(() => {
3459
3739
  if (ctx == null ? void 0 : ctx.registerZone) {
3460
3740
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3461
3741
  }
@@ -3465,25 +3745,18 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3465
3745
  }
3466
3746
  };
3467
3747
  }, []);
3468
- if (areaId) {
3469
- if (zone !== rootDroppableId) {
3470
- zoneCompound = `${areaId}:${zone}`;
3471
- }
3472
- }
3473
- const content = (0, import_react23.useMemo)(() => {
3748
+ const content = (0, import_react29.useMemo)(() => {
3474
3749
  if (areaId && zone !== rootDroppableId) {
3475
3750
  return setupZone(data, zoneCompound).zones[zoneCompound];
3476
3751
  }
3477
3752
  return data.content || [];
3478
3753
  }, [data, zoneCompound]);
3479
- const ref = (0, import_react23.useRef)(null);
3480
- const acceptsTarget = (0, import_react23.useCallback)(
3481
- (target) => {
3482
- if (!target) {
3754
+ const ref = (0, import_react29.useRef)(null);
3755
+ const acceptsTarget = (0, import_react29.useCallback)(
3756
+ (componentType) => {
3757
+ if (!componentType) {
3483
3758
  return true;
3484
3759
  }
3485
- const data2 = target.data;
3486
- const { componentType } = data2;
3487
3760
  if (disallow) {
3488
3761
  const defaultedAllow = allow || [];
3489
3762
  const filteredDisallow = (disallow || []).filter(
@@ -3501,49 +3774,29 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3501
3774
  },
3502
3775
  [allow, disallow]
3503
3776
  );
3504
- (0, import_react23.useEffect)(() => {
3777
+ (0, import_react29.useEffect)(() => {
3505
3778
  if (registerLocalZone) {
3506
- registerLocalZone(zoneCompound, acceptsTarget(draggedItem));
3779
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3507
3780
  }
3508
3781
  return () => {
3509
3782
  if (unregisterLocalZone) {
3510
3783
  unregisterLocalZone(zoneCompound);
3511
3784
  }
3512
3785
  };
3513
- }, [draggedItem, zoneCompound]);
3514
- const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3515
- const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
3516
- const userIsDragging = !!draggedItem;
3786
+ }, [draggedComponentType, zoneCompound]);
3787
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3517
3788
  let isEnabled = true;
3518
- if (draggedItem) {
3519
- isEnabled = deepestZone === zoneCompound;
3789
+ if (userIsDragging) {
3790
+ isEnabled = isDeepestZone;
3520
3791
  }
3521
3792
  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);
3793
+ isEnabled = acceptsTarget(draggedComponentType);
3794
+ }
3795
+ const [contentWithPreview, preview] = useContentWithPreview(
3796
+ content,
3797
+ zoneCompound
3798
+ );
3799
+ const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3547
3800
  const droppableConfig = {
3548
3801
  id: zoneCompound,
3549
3802
  collisionPriority: isEnabled ? depth : 0,
@@ -3552,46 +3805,21 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3552
3805
  type: "dropzone",
3553
3806
  data: {
3554
3807
  areaId,
3555
- depth,
3556
- isDroppableTarget: acceptsTarget(draggedItem),
3557
- path
3558
- }
3559
- };
3560
- const { ref: dropRef } = useDroppableSafe(droppableConfig);
3561
- const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3562
- 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
- }, []);
3808
+ depth,
3809
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3810
+ path
3811
+ }
3812
+ };
3813
+ const { ref: dropRef } = useDroppableSafe(droppableConfig);
3814
+ const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3815
+ const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
3816
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3588
3817
  const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3589
- draggedItem,
3590
3818
  zoneCompound,
3591
3819
  userMinEmptyHeight,
3592
3820
  ref
3593
3821
  });
3594
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3822
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3595
3823
  "div",
3596
3824
  {
3597
3825
  className: `${getClassName17({
@@ -3611,88 +3839,84 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
3611
3839
  "data-puck-dropzone": zoneCompound,
3612
3840
  "data-puck-dnd": zoneCompound,
3613
3841
  style: __spreadProps(__spreadValues({}, style), {
3614
- "--min-empty-height": `${minEmptyHeight}px`
3842
+ "--min-empty-height": `${minEmptyHeight}px`,
3843
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3615
3844
  }),
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
3845
+ children: contentWithPreview.map((item, i) => {
3846
+ var _a, _b, _c, _d, _e, _f, _g;
3847
+ const componentId = item.props.id;
3848
+ const puckProps = {
3849
+ renderDropZone: DropZoneEditPure,
3850
+ isEditing: true,
3851
+ dragRef: null
3852
+ };
3853
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3854
+ puck: puckProps,
3855
+ editMode: true
3856
+ // DEPRECATED
3857
+ });
3858
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3859
+ 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: [
3860
+ "No configuration for ",
3861
+ item.type
3862
+ ] });
3863
+ const componentConfig = config.components[item.type];
3864
+ let componentType = item.type;
3865
+ let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3866
+ if (item.type === "preview") {
3867
+ let Preview4 = function() {
3868
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3628
3869
  };
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
- })
3870
+ var Preview3 = Preview4;
3871
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3872
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3873
+ Render2 = Preview4;
3874
+ }
3875
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3876
+ DropZoneProvider,
3877
+ {
3878
+ value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3879
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3880
+ DraggableComponent,
3881
+ {
3882
+ id: componentId,
3883
+ componentType,
3884
+ zoneCompound,
3885
+ depth: depth + 1,
3886
+ index: i,
3887
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3888
+ isSelected,
3889
+ label,
3890
+ isEnabled,
3891
+ autoDragAxis: dragAxis,
3892
+ userDragAxis: collisionAxis,
3893
+ inDroppableZone: acceptsTarget(draggedComponentType),
3894
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3895
+ Render2,
3896
+ __spreadProps(__spreadValues({}, defaultedProps), {
3897
+ puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3898
+ dragRef
3676
3899
  })
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
- ]
3900
+ })
3901
+ ) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Render2, __spreadValues({}, defaultedProps)) })
3902
+ }
3903
+ )
3904
+ },
3905
+ componentId
3906
+ );
3907
+ })
3685
3908
  }
3686
3909
  );
3687
3910
  }
3688
3911
  );
3689
- var DropZoneRender = (0, import_react23.forwardRef)(
3690
- function DropZoneRender2({ className, style, zone }, ref) {
3691
- const ctx = (0, import_react23.useContext)(dropZoneContext);
3912
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
3913
+ var DropZoneRender = (0, import_react29.forwardRef)(
3914
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3915
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
3692
3916
  const { data, areaId = "root", config } = ctx || {};
3693
3917
  let zoneCompound = rootDroppableId;
3694
3918
  let content = (data == null ? void 0 : data.content) || [];
3695
- (0, import_react23.useEffect)(() => {
3919
+ (0, import_react29.useEffect)(() => {
3696
3920
  if (ctx == null ? void 0 : ctx.registerZone) {
3697
3921
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3698
3922
  }
@@ -3709,10 +3933,10 @@ var DropZoneRender = (0, import_react23.forwardRef)(
3709
3933
  zoneCompound = `${areaId}:${zone}`;
3710
3934
  content = setupZone(data, zoneCompound).zones[zoneCompound];
3711
3935
  }
3712
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
3936
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
3713
3937
  const Component = config.components[item.type];
3714
3938
  if (Component) {
3715
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3939
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3716
3940
  DropZoneProvider,
3717
3941
  {
3718
3942
  value: {
@@ -3722,10 +3946,12 @@ var DropZoneRender = (0, import_react23.forwardRef)(
3722
3946
  depth: 1,
3723
3947
  path: []
3724
3948
  },
3725
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3949
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3726
3950
  Component.render,
3727
3951
  __spreadProps(__spreadValues({}, item.props), {
3728
- puck: { renderDropZone: DropZoneRender2 }
3952
+ puck: {
3953
+ renderDropZone: DropZoneRenderPure
3954
+ }
3729
3955
  })
3730
3956
  )
3731
3957
  },
@@ -3736,13 +3962,13 @@ var DropZoneRender = (0, import_react23.forwardRef)(
3736
3962
  }) });
3737
3963
  }
3738
3964
  );
3739
- var DropZone = (0, import_react23.forwardRef)(
3965
+ var DropZone = (0, import_react29.forwardRef)(
3740
3966
  function DropZone2(props, ref) {
3741
- const ctx = (0, import_react23.useContext)(dropZoneContext);
3967
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
3742
3968
  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 })) });
3969
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3744
3970
  }
3745
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3971
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3746
3972
  }
3747
3973
  );
3748
3974
 
@@ -3758,7 +3984,7 @@ var getZoneId = (zoneCompound) => {
3758
3984
  return [rootDroppableId, zoneCompound];
3759
3985
  };
3760
3986
 
3761
- // components/DragDropContext/NestedDroppablePlugin.ts
3987
+ // lib/dnd/NestedDroppablePlugin.ts
3762
3988
  init_react_import();
3763
3989
  var import_abstract9 = require("@dnd-kit/abstract");
3764
3990
  var import_state = require("@dnd-kit/state");
@@ -3800,7 +4026,49 @@ var getFrame = () => {
3800
4026
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3801
4027
  };
3802
4028
 
3803
- // components/DragDropContext/NestedDroppablePlugin.ts
4029
+ // lib/global-position.ts
4030
+ init_react_import();
4031
+ var GlobalPosition = class {
4032
+ constructor(target, original) {
4033
+ this.scaleFactor = 1;
4034
+ this.frameEl = null;
4035
+ this.frameRect = null;
4036
+ var _a;
4037
+ this.target = target;
4038
+ this.original = original;
4039
+ this.frameEl = document.querySelector("iframe");
4040
+ if (this.frameEl) {
4041
+ this.frameRect = this.frameEl.getBoundingClientRect();
4042
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
4043
+ }
4044
+ }
4045
+ get x() {
4046
+ return this.original.x;
4047
+ }
4048
+ get y() {
4049
+ return this.original.y;
4050
+ }
4051
+ get global() {
4052
+ if (document !== this.target.ownerDocument && this.frameRect) {
4053
+ return {
4054
+ x: this.x * this.scaleFactor + this.frameRect.left,
4055
+ y: this.y * this.scaleFactor + this.frameRect.top
4056
+ };
4057
+ }
4058
+ return this.original;
4059
+ }
4060
+ get frame() {
4061
+ if (document === this.target.ownerDocument && this.frameRect) {
4062
+ return {
4063
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
4064
+ y: (this.y - this.frameRect.top) / this.scaleFactor
4065
+ };
4066
+ }
4067
+ return this.original;
4068
+ }
4069
+ };
4070
+
4071
+ // lib/dnd/NestedDroppablePlugin.ts
3804
4072
  var depthSort = (candidates) => {
3805
4073
  return candidates.sort((a, b) => {
3806
4074
  const aData = a.data;
@@ -3829,10 +4097,12 @@ var getZoneId2 = (candidate) => {
3829
4097
  }
3830
4098
  return id;
3831
4099
  };
3832
- var getPointerCollisions = (position, manager, ownerDocument) => {
3833
- var _a;
4100
+ var getPointerCollisions = (position, manager) => {
3834
4101
  const candidates = [];
3835
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
4102
+ let elements = position.target.ownerDocument.elementsFromPoint(
4103
+ position.x,
4104
+ position.y
4105
+ );
3836
4106
  const previewFrame = elements.find(
3837
4107
  (el) => el.getAttribute("data-puck-preview")
3838
4108
  );
@@ -3841,17 +4111,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3841
4111
  elements = [drawer];
3842
4112
  }
3843
4113
  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
- }
4114
+ const frame = getFrame();
4115
+ if (frame) {
4116
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3855
4117
  }
3856
4118
  }
3857
4119
  if (elements) {
@@ -3868,9 +4130,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3868
4130
  }
3869
4131
  return candidates;
3870
4132
  };
3871
- var findDeepestCandidate = (position, manager, ownerDocument) => {
4133
+ var findDeepestCandidate = (position, manager) => {
3872
4134
  var _a;
3873
- const candidates = getPointerCollisions(position, manager, ownerDocument);
4135
+ const candidates = getPointerCollisions(position, manager);
3874
4136
  if (candidates.length > 0) {
3875
4137
  const sortedCandidates = depthSort(candidates);
3876
4138
  const draggable = manager.dragOperation.source;
@@ -3915,9 +4177,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
3915
4177
  area: null
3916
4178
  };
3917
4179
  };
3918
- var createNestedDroppablePlugin = ({
3919
- onChange
3920
- }) => class NestedDroppablePlugin extends import_abstract9.Plugin {
4180
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
3921
4181
  constructor(manager, options) {
3922
4182
  super(manager);
3923
4183
  if (typeof window === "undefined") {
@@ -3925,16 +4185,19 @@ var createNestedDroppablePlugin = ({
3925
4185
  }
3926
4186
  const cleanupEffect = (0, import_state.effects)(() => {
3927
4187
  const handleMove = (event) => {
3928
- const position = {
4188
+ const target = event.originalTarget || event.target;
4189
+ const position = new GlobalPosition(target, {
3929
4190
  x: event.clientX,
3930
4191
  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
4192
+ });
4193
+ const elements = document.elementsFromPoint(
4194
+ position.global.x,
4195
+ position.global.y
3937
4196
  );
4197
+ const overEl = elements.some((el) => el.id === id);
4198
+ if (overEl) {
4199
+ onChange(findDeepestCandidate(position, manager), manager);
4200
+ }
3938
4201
  };
3939
4202
  const handleMoveThrottled = throttle(handleMove, 50);
3940
4203
  const handlePointerMove = (event) => {
@@ -4264,6 +4527,11 @@ var reduceUi = (ui, action) => {
4264
4527
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4265
4528
  });
4266
4529
  }
4530
+ if (action.type === "remove") {
4531
+ return __spreadProps(__spreadValues({}, ui), {
4532
+ itemSelector: null
4533
+ });
4534
+ }
4267
4535
  return ui;
4268
4536
  };
4269
4537
 
@@ -4351,7 +4619,7 @@ var insertComponent = (componentType, zone, index, {
4351
4619
  var import_use_debounce2 = require("use-debounce");
4352
4620
  var import_utilities2 = require("@dnd-kit/dom/utilities");
4353
4621
 
4354
- // components/DragDropContext/PointerSensor.ts
4622
+ // lib/dnd/PointerSensor.ts
4355
4623
  init_react_import();
4356
4624
  var import_state3 = require("@dnd-kit/state");
4357
4625
  var import_abstract10 = require("@dnd-kit/abstract");
@@ -4514,6 +4782,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
4514
4782
  }
4515
4783
  }
4516
4784
  handlePointerUp(event) {
4785
+ if (!this.source) {
4786
+ return;
4787
+ }
4517
4788
  event.preventDefault();
4518
4789
  event.stopPropagation();
4519
4790
  const { status } = this.manager.dragOperation;
@@ -4613,13 +4884,15 @@ function patchWindow(window2) {
4613
4884
  }
4614
4885
 
4615
4886
  // components/DragDropContext/index.tsx
4616
- var import_jsx_runtime22 = require("react/jsx-runtime");
4617
- var dragListenerContext = (0, import_react25.createContext)({
4887
+ var import_zustand3 = require("zustand");
4888
+ var import_jsx_runtime23 = require("react/jsx-runtime");
4889
+ var DEBUG3 = false;
4890
+ var dragListenerContext = (0, import_react31.createContext)({
4618
4891
  dragListeners: {}
4619
4892
  });
4620
4893
  function useDragListener(type, fn, deps = []) {
4621
- const { setDragListeners } = (0, import_react25.useContext)(dragListenerContext);
4622
- (0, import_react25.useEffect)(() => {
4894
+ const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
4895
+ (0, import_react31.useEffect)(() => {
4623
4896
  if (setDragListeners) {
4624
4897
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
4625
4898
  [type]: [...old[type] || [], fn]
@@ -4627,80 +4900,147 @@ function useDragListener(type, fn, deps = []) {
4627
4900
  }
4628
4901
  }, deps);
4629
4902
  }
4630
- var previewContext = (0, import_react25.createContext)(null);
4631
4903
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4904
+ var useTempDisableFallback = (timeout3) => {
4905
+ const lastFallbackDisable = (0, import_react31.useRef)(null);
4906
+ return (0, import_react31.useCallback)((manager) => {
4907
+ collisionStore.setState({ fallbackEnabled: false });
4908
+ const fallbackId = generateId();
4909
+ lastFallbackDisable.current = fallbackId;
4910
+ setTimeout(() => {
4911
+ if (lastFallbackDisable.current === fallbackId) {
4912
+ collisionStore.setState({ fallbackEnabled: true });
4913
+ manager.collisionObserver.forceUpdate(true);
4914
+ }
4915
+ }, timeout3);
4916
+ }, []);
4917
+ };
4632
4918
  var DragDropContextClient = ({
4633
4919
  children,
4634
4920
  disableAutoScroll
4635
4921
  }) => {
4636
4922
  const { state, config, dispatch, resolveData } = useAppContext();
4637
- const [preview, setPreview] = (0, import_react25.useState)(null);
4638
- const previewRef = (0, import_react25.useRef)(null);
4923
+ const id = (0, import_react31.useId)();
4639
4924
  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)(
4925
+ const debouncedParamsRef = (0, import_react31.useRef)(null);
4926
+ const tempDisableFallback = useTempDisableFallback(100);
4927
+ const [zoneStore] = (0, import_react31.useState)(
4928
+ () => (0, import_zustand3.createStore)(() => ({
4929
+ zoneDepthIndex: {},
4930
+ nextZoneDepthIndex: {},
4931
+ areaDepthIndex: {},
4932
+ nextAreaDepthIndex: {},
4933
+ draggedItem: null,
4934
+ previewIndex: {}
4935
+ }))
4936
+ );
4937
+ const getChanged2 = (0, import_react31.useCallback)(
4938
+ (params, id2) => {
4939
+ const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
4940
+ const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
4941
+ const stateHasArea = Object.keys(areaDepthIndex).length > 0;
4942
+ let zoneChanged = false;
4943
+ let areaChanged = false;
4944
+ if (params.zone && !zoneDepthIndex[params.zone]) {
4945
+ zoneChanged = true;
4946
+ } else if (!params.zone && stateHasZone) {
4947
+ zoneChanged = true;
4948
+ }
4949
+ if (params.area && !areaDepthIndex[params.area]) {
4950
+ areaChanged = true;
4951
+ } else if (!params.area && stateHasArea) {
4952
+ areaChanged = true;
4953
+ }
4954
+ return { zoneChanged, areaChanged };
4955
+ },
4956
+ [zoneStore]
4957
+ );
4958
+ const setDeepestAndCollide = (0, import_react31.useCallback)(
4645
4959
  (params, manager) => {
4646
- setDeepest(params);
4960
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4961
+ if (!zoneChanged && !areaChanged) return;
4962
+ zoneStore.setState({
4963
+ zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
4964
+ areaDepthIndex: params.area ? { [params.area]: true } : {}
4965
+ });
4966
+ tempDisableFallback(manager);
4647
4967
  setTimeout(() => {
4648
4968
  manager.collisionObserver.forceUpdate(true);
4649
4969
  }, 50);
4650
4970
  debouncedParamsRef.current = null;
4651
4971
  },
4652
- []
4972
+ [zoneStore]
4653
4973
  );
4654
4974
  const setDeepestDb = (0, import_use_debounce2.useDebouncedCallback)(
4655
4975
  setDeepestAndCollide,
4656
4976
  AREA_CHANGE_DEBOUNCE_MS
4657
4977
  );
4658
- (0, import_react25.useEffect)(() => {
4659
- deepestRef.current = deepest;
4660
- }, [deepest]);
4661
4978
  const cancelDb = () => {
4662
4979
  setDeepestDb.cancel();
4663
4980
  debouncedParamsRef.current = null;
4664
4981
  };
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;
4982
+ (0, import_react31.useEffect)(() => {
4983
+ if (DEBUG3) {
4984
+ zoneStore.subscribe(
4985
+ (s) => {
4986
+ var _a, _b;
4987
+ return console.log(
4988
+ s.previewIndex,
4989
+ (_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
4990
+ (_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
4991
+ );
4680
4992
  }
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) {
4993
+ );
4994
+ }
4995
+ }, []);
4996
+ const [plugins] = (0, import_react31.useState)(() => [
4997
+ ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
4998
+ createNestedDroppablePlugin(
4999
+ {
5000
+ onChange: (params, manager) => {
5001
+ const state2 = zoneStore.getState();
5002
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
5003
+ const isDragging = manager.dragOperation.status.dragging;
5004
+ if (areaChanged || zoneChanged) {
5005
+ let nextZoneDepthIndex = {};
5006
+ let nextAreaDepthIndex = {};
5007
+ if (params.zone) {
5008
+ nextZoneDepthIndex = { [params.zone]: true };
5009
+ }
5010
+ if (params.area) {
5011
+ nextAreaDepthIndex = { [params.area]: true };
5012
+ }
5013
+ zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
5014
+ }
5015
+ if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
5016
+ setDeepestAndCollide(params, manager);
5017
+ return;
5018
+ }
5019
+ if (areaChanged) {
5020
+ if (isDragging) {
5021
+ const debouncedParams = debouncedParamsRef.current;
5022
+ const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
5023
+ if (!isSameParams) {
5024
+ cancelDb();
5025
+ setDeepestDb(params, manager);
5026
+ debouncedParamsRef.current = params;
5027
+ }
5028
+ } else {
4686
5029
  cancelDb();
4687
- setDeepestDb(params, manager);
4688
- debouncedParamsRef.current = params;
5030
+ setDeepestAndCollide(params, manager);
4689
5031
  }
4690
- } else {
4691
- cancelDb();
5032
+ return;
5033
+ }
5034
+ if (zoneChanged) {
4692
5035
  setDeepestAndCollide(params, manager);
4693
5036
  }
4694
- return;
5037
+ cancelDb();
4695
5038
  }
4696
- if (zoneChanged) {
4697
- setDeepestAndCollide(params, manager);
4698
- }
4699
- cancelDb();
4700
- }
4701
- })
5039
+ },
5040
+ id
5041
+ )
4702
5042
  ]);
4703
- const [sensors] = (0, import_react25.useState)(() => [
5043
+ const [sensors] = (0, import_react31.useState)(() => [
4704
5044
  PointerSensor.configure({
4705
5045
  activationConstraints(event, source) {
4706
5046
  var _a;
@@ -4719,67 +5059,72 @@ var DragDropContextClient = ({
4719
5059
  }
4720
5060
  })
4721
5061
  ]);
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)(
4727
- (selector) => {
4728
- const item = getItem(selector, data);
4729
- if (!item) {
4730
- return;
4731
- }
5062
+ const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
5063
+ const [pathData, setPathData] = (0, import_react31.useState)();
5064
+ const dragMode = (0, import_react31.useRef)(null);
5065
+ const registerPath = (0, import_react31.useCallback)(
5066
+ (id2, selector, label) => {
4732
5067
  const [area] = getZoneId(selector.zone);
4733
5068
  setPathData((latestPathData = {}) => {
4734
5069
  const parentPathData = latestPathData[area] || { path: [] };
4735
5070
  return __spreadProps(__spreadValues({}, latestPathData), {
4736
- [item.props.id]: {
5071
+ [id2]: {
4737
5072
  path: [
4738
5073
  ...parentPathData.path,
4739
5074
  ...selector.zone ? [selector.zone] : []
4740
5075
  ],
4741
- label: item.type
5076
+ label
4742
5077
  }
4743
5078
  });
4744
5079
  });
4745
5080
  },
4746
5081
  [data, setPathData]
4747
5082
  );
4748
- const initialSelector = (0, import_react25.useRef)(void 0);
4749
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5083
+ const unregisterPath = (0, import_react31.useCallback)(
5084
+ (id2) => {
5085
+ setPathData((latestPathData = {}) => {
5086
+ const newPathData = __spreadValues({}, latestPathData);
5087
+ delete newPathData[id2];
5088
+ return newPathData;
5089
+ });
5090
+ },
5091
+ [data, setPathData]
5092
+ );
5093
+ const initialSelector = (0, import_react31.useRef)(void 0);
5094
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4750
5095
  dragListenerContext.Provider,
4751
5096
  {
4752
5097
  value: {
4753
5098
  dragListeners,
4754
5099
  setDragListeners
4755
5100
  },
4756
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(previewContext.Provider, { value: preview, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4757
- import_react24.DragDropProvider,
5101
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5102
+ import_react30.DragDropProvider,
4758
5103
  {
4759
5104
  plugins,
4760
5105
  sensors,
4761
5106
  onDragEnd: (event, manager) => {
5107
+ var _a;
4762
5108
  const { source, target } = event.operation;
4763
- deepestRef.current = null;
4764
5109
  if (!source) {
4765
- setDraggedItem(null);
5110
+ zoneStore.setState({ draggedItem: null });
4766
5111
  return;
4767
5112
  }
4768
5113
  const { zone, index } = source.data;
4769
- const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
4770
- previewRef.current = null;
5114
+ const { previewIndex = {} } = zoneStore.getState() || {};
5115
+ const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
4771
5116
  setTimeout(() => {
4772
- var _a, _b;
4773
- setDraggedItem(null);
5117
+ var _a2, _b;
5118
+ zoneStore.setState({ draggedItem: null });
4774
5119
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4775
- setPreview(null);
4776
- (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
5120
+ zoneStore.setState({ previewIndex: {} });
5121
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
4777
5122
  fn(event, manager);
4778
5123
  });
4779
5124
  return;
4780
5125
  }
4781
5126
  if (thisPreview) {
4782
- setPreview(null);
5127
+ zoneStore.setState({ previewIndex: {} });
4783
5128
  if (thisPreview.type === "insert") {
4784
5129
  insertComponent(
4785
5130
  thisPreview.componentType,
@@ -4814,8 +5159,9 @@ var DragDropContextClient = ({
4814
5159
  }, 250);
4815
5160
  },
4816
5161
  onDragOver: (event, manager) => {
4817
- var _a, _b, _c, _d;
5162
+ var _a, _b, _c, _d, _e;
4818
5163
  event.preventDefault();
5164
+ const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
4819
5165
  if (!draggedItem) return;
4820
5166
  cancelDb();
4821
5167
  const { source, target } = event.operation;
@@ -4831,7 +5177,7 @@ var DragDropContextClient = ({
4831
5177
  const targetData = target.data;
4832
5178
  targetZone = targetData.zone;
4833
5179
  targetIndex = targetData.index;
4834
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
5180
+ const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
4835
5181
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
4836
5182
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
4837
5183
  targetIndex = targetIndex - 1;
@@ -4843,23 +5189,26 @@ var DragDropContextClient = ({
4843
5189
  targetZone = target.id.toString();
4844
5190
  targetIndex = 0;
4845
5191
  }
4846
- if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
5192
+ if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
4847
5193
  const [pathId] = path.split(":");
4848
5194
  return pathId === sourceId;
4849
5195
  }))) {
4850
5196
  return;
4851
5197
  }
4852
5198
  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()
5199
+ zoneStore.setState({
5200
+ previewIndex: {
5201
+ [targetZone]: {
5202
+ componentType: sourceData.componentType,
5203
+ type: "insert",
5204
+ index: targetIndex,
5205
+ zone: targetZone,
5206
+ props: {
5207
+ id: source.id.toString()
5208
+ }
5209
+ }
4860
5210
  }
4861
- };
4862
- setPreview(previewRef.current);
5211
+ });
4863
5212
  } else {
4864
5213
  if (!initialSelector.current) {
4865
5214
  initialSelector.current = {
@@ -4869,17 +5218,20 @@ var DragDropContextClient = ({
4869
5218
  }
4870
5219
  const item = getItem(initialSelector.current, data);
4871
5220
  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);
5221
+ zoneStore.setState({
5222
+ previewIndex: {
5223
+ [targetZone]: {
5224
+ componentType: sourceData.componentType,
5225
+ type: "move",
5226
+ index: targetIndex,
5227
+ zone: targetZone,
5228
+ props: item.props
5229
+ }
5230
+ }
5231
+ });
4880
5232
  }
4881
5233
  }
4882
- (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
5234
+ (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
4883
5235
  fn(event, manager);
4884
5236
  });
4885
5237
  },
@@ -4889,45 +5241,62 @@ var DragDropContextClient = ({
4889
5241
  type: "setUi",
4890
5242
  ui: { itemSelector: null, isDragging: true }
4891
5243
  });
5244
+ const { source } = event.operation;
5245
+ if (source && source.type !== "void") {
5246
+ const sourceData = source.data;
5247
+ const item = getItem(
5248
+ {
5249
+ zone: sourceData.zone,
5250
+ index: sourceData.index
5251
+ },
5252
+ data
5253
+ );
5254
+ if (item) {
5255
+ zoneStore.setState({
5256
+ previewIndex: {
5257
+ [sourceData.zone]: {
5258
+ componentType: sourceData.componentType,
5259
+ type: "move",
5260
+ index: sourceData.index,
5261
+ zone: sourceData.zone,
5262
+ props: item.props
5263
+ }
5264
+ }
5265
+ });
5266
+ }
5267
+ }
4892
5268
  (_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
4893
5269
  fn(event, manager);
4894
5270
  });
4895
5271
  },
4896
5272
  onBeforeDragStart: (event) => {
4897
5273
  var _a;
4898
- if (draggedItem) {
4899
- console.warn("New drag started before previous drag cleaned up");
4900
- }
4901
5274
  const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
4902
5275
  dragMode.current = isNewComponent ? "new" : "existing";
4903
5276
  initialSelector.current = void 0;
4904
- setDraggedItem(event.operation.source);
5277
+ zoneStore.setState({ draggedItem: event.operation.source });
4905
5278
  },
4906
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5279
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4907
5280
  DropZoneProvider,
4908
5281
  {
4909
5282
  value: {
4910
5283
  data,
4911
5284
  config,
4912
- draggedItem,
4913
5285
  mode: "edit",
4914
5286
  areaId: "root",
4915
5287
  depth: 0,
4916
5288
  registerPath,
5289
+ unregisterPath,
4917
5290
  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
5291
  path: []
4923
5292
  },
4924
5293
  children
4925
5294
  }
4926
- )
5295
+ ) })
4927
5296
  }
4928
- ) })
5297
+ )
4929
5298
  }
4930
- );
5299
+ ) });
4931
5300
  };
4932
5301
  var DragDropContext = ({
4933
5302
  children,
@@ -4937,11 +5306,11 @@ var DragDropContext = ({
4937
5306
  if (status === "LOADING") {
4938
5307
  return children;
4939
5308
  }
4940
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DragDropContextClient, { disableAutoScroll, children });
5309
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DragDropContextClient, { disableAutoScroll, children });
4941
5310
  };
4942
5311
 
4943
5312
  // components/Drawer/index.tsx
4944
- var import_jsx_runtime23 = require("react/jsx-runtime");
5313
+ var import_jsx_runtime24 = require("react/jsx-runtime");
4945
5314
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
4946
5315
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
4947
5316
  var DrawerItemInner = ({
@@ -4951,11 +5320,11 @@ var DrawerItemInner = ({
4951
5320
  dragRef,
4952
5321
  isDragDisabled
4953
5322
  }) => {
4954
- const CustomInner = (0, import_react26.useMemo)(
4955
- () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
5323
+ const CustomInner = (0, import_react32.useMemo)(
5324
+ () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
4956
5325
  [children]
4957
5326
  );
4958
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5327
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4959
5328
  "div",
4960
5329
  {
4961
5330
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -4963,9 +5332,9 @@ var DrawerItemInner = ({
4963
5332
  onMouseDown: (e) => e.preventDefault(),
4964
5333
  "data-testid": dragRef ? `drawer-item:${name}` : "",
4965
5334
  "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, {}) })
5335
+ 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: [
5336
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5337
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragIcon, {}) })
4969
5338
  ] }) }) })
4970
5339
  }
4971
5340
  );
@@ -4982,9 +5351,9 @@ var DrawerItemDraggable = ({
4982
5351
  data: { type: "drawer", componentType: name },
4983
5352
  disabled: isDragDisabled
4984
5353
  });
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)(
5354
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName18("draggable"), children: [
5355
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DrawerItemInner, { name, label, children }) }),
5356
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4988
5357
  DrawerItemInner,
4989
5358
  {
4990
5359
  name,
@@ -5005,7 +5374,7 @@ var DrawerItem = ({
5005
5374
  isDragDisabled
5006
5375
  }) => {
5007
5376
  const resolvedId = id || name;
5008
- const [dynamicId, setDynamicId] = (0, import_react26.useState)(generateId(resolvedId));
5377
+ const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
5009
5378
  if (typeof index !== "undefined") {
5010
5379
  console.error(
5011
5380
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -5018,7 +5387,7 @@ var DrawerItem = ({
5018
5387
  },
5019
5388
  [resolvedId]
5020
5389
  );
5021
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5390
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5022
5391
  DrawerItemDraggable,
5023
5392
  {
5024
5393
  name,
@@ -5044,14 +5413,14 @@ var Drawer = ({
5044
5413
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5045
5414
  );
5046
5415
  }
5047
- const [id] = (0, import_react26.useState)(generateId());
5416
+ const id = (0, import_react32.useId)();
5048
5417
  const { ref } = useDroppableSafe({
5049
5418
  id,
5050
5419
  type: "void",
5051
5420
  collisionPriority: 0
5052
5421
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
5053
5422
  });
5054
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5423
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5055
5424
  "div",
5056
5425
  {
5057
5426
  className: getClassName18(),
@@ -5066,7 +5435,7 @@ Drawer.Item = DrawerItem;
5066
5435
 
5067
5436
  // components/Puck/index.tsx
5068
5437
  init_react_import();
5069
- var import_react42 = require("react");
5438
+ var import_react50 = require("react");
5070
5439
 
5071
5440
  // components/SidebarSection/index.tsx
5072
5441
  init_react_import();
@@ -5077,7 +5446,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
5077
5446
 
5078
5447
  // lib/use-breadcrumbs.ts
5079
5448
  init_react_import();
5080
- var import_react27 = require("react");
5449
+ var import_react33 = require("react");
5081
5450
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
5082
5451
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
5083
5452
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -5127,8 +5496,8 @@ var useBreadcrumbs = (renderCount) => {
5127
5496
  state: { data },
5128
5497
  selectedItem
5129
5498
  } = useAppContext();
5130
- const dzContext = (0, import_react27.useContext)(dropZoneContext);
5131
- return (0, import_react27.useMemo)(() => {
5499
+ const dzContext = (0, import_react33.useContext)(dropZoneContext);
5500
+ return (0, import_react33.useMemo)(() => {
5132
5501
  const breadcrumbs = convertPathDataToBreadcrumbs(
5133
5502
  selectedItem,
5134
5503
  dzContext == null ? void 0 : dzContext.pathData,
@@ -5142,7 +5511,7 @@ var useBreadcrumbs = (renderCount) => {
5142
5511
  };
5143
5512
 
5144
5513
  // components/SidebarSection/index.tsx
5145
- var import_jsx_runtime24 = require("react/jsx-runtime");
5514
+ var import_jsx_runtime25 = require("react/jsx-runtime");
5146
5515
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5147
5516
  var SidebarSection = ({
5148
5517
  children,
@@ -5155,15 +5524,15 @@ var SidebarSection = ({
5155
5524
  }) => {
5156
5525
  const { setUi } = useAppContext();
5157
5526
  const breadcrumbs = useBreadcrumbs(1);
5158
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
5527
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
5159
5528
  "div",
5160
5529
  {
5161
5530
  className: getClassName19({ noBorderTop, noPadding }),
5162
5531
  style: { background },
5163
5532
  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)(
5533
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
5534
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
5535
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5167
5536
  "button",
5168
5537
  {
5169
5538
  type: "button",
@@ -5172,12 +5541,12 @@ var SidebarSection = ({
5172
5541
  children: breadcrumb.label
5173
5542
  }
5174
5543
  ),
5175
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChevronRight, { size: 16 })
5544
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
5176
5545
  ] }, 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 }) })
5546
+ /* @__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
5547
  ] }) }),
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 }) })
5548
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
5549
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
5181
5550
  ]
5182
5551
  }
5183
5552
  );
@@ -5208,7 +5577,7 @@ init_react_import();
5208
5577
  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
5578
 
5210
5579
  // components/MenuBar/index.tsx
5211
- var import_jsx_runtime25 = require("react/jsx-runtime");
5580
+ var import_jsx_runtime26 = require("react/jsx-runtime");
5212
5581
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5213
5582
  function MenuBar({
5214
5583
  appState,
@@ -5222,7 +5591,7 @@ function MenuBar({
5222
5591
  history: { back, forward, historyStore }
5223
5592
  } = useAppContext();
5224
5593
  const { hasFuture = false, hasPast = false } = historyStore || {};
5225
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5594
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5226
5595
  "div",
5227
5596
  {
5228
5597
  className: getClassName20({ menuOpen }),
@@ -5236,12 +5605,12 @@ function MenuBar({
5236
5605
  setMenuOpen(false);
5237
5606
  }
5238
5607
  },
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 }) })
5608
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
5609
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
5610
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
5611
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
5243
5612
  ] }),
5244
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: renderHeaderActions && renderHeaderActions({
5613
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
5245
5614
  state: appState,
5246
5615
  dispatch
5247
5616
  }) })
@@ -5252,43 +5621,68 @@ function MenuBar({
5252
5621
 
5253
5622
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5254
5623
  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" };
5624
+ 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
5625
 
5257
5626
  // components/Puck/components/Fields/index.tsx
5258
5627
  init_react_import();
5259
5628
 
5260
5629
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5261
5630
  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" };
5631
+ 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
5632
 
5264
5633
  // components/Puck/components/Fields/index.tsx
5265
- var import_react29 = require("react");
5634
+ var import_react37 = require("react");
5635
+
5636
+ // lib/use-resolved-fields.ts
5637
+ init_react_import();
5638
+ var import_react36 = require("react");
5266
5639
 
5267
5640
  // lib/use-parent.ts
5268
5641
  init_react_import();
5269
- var import_react28 = require("react");
5270
- var useParent = (itemSelector) => {
5642
+ var import_react34 = require("react");
5643
+ var getParent = (itemSelector, pathData, data) => {
5271
5644
  var _a;
5272
- const { selectedItem, state } = useAppContext();
5273
- const { pathData } = (0, import_react28.useContext)(dropZoneContext) || {};
5274
- const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5275
- const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5645
+ if (!itemSelector) return null;
5646
+ const item = getItem(itemSelector, data);
5647
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
5276
5648
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
5277
- const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
5649
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
5278
5650
  return parent || null;
5279
5651
  };
5652
+ var useGetParent = () => {
5653
+ const { state } = useAppContext();
5654
+ const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
5655
+ return (0, import_react34.useCallback)(
5656
+ () => getParent(state.ui.itemSelector, pathData, state.data),
5657
+ [state.ui.itemSelector, pathData, state.data]
5658
+ );
5659
+ };
5660
+ var useParent = () => {
5661
+ return useGetParent()();
5662
+ };
5280
5663
 
5281
- // components/Puck/components/Fields/index.tsx
5282
- var import_jsx_runtime26 = require("react/jsx-runtime");
5283
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5664
+ // lib/use-on-value-change.ts
5665
+ init_react_import();
5666
+ var import_react35 = require("react");
5667
+ function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5668
+ const tracked = (0, import_react35.useRef)(value);
5669
+ (0, import_react35.useEffect)(() => {
5670
+ const oldValue = tracked.current;
5671
+ if (!compare(value, oldValue)) {
5672
+ tracked.current = value;
5673
+ onChange(value, oldValue);
5674
+ }
5675
+ }, [onChange, compare, value, ...deps]);
5676
+ }
5677
+
5678
+ // lib/selector-is.ts
5679
+ init_react_import();
5680
+ var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
5681
+
5682
+ // lib/use-resolved-fields.ts
5284
5683
  var defaultPageFields = {
5285
5684
  title: { type: "text" }
5286
5685
  };
5287
- var DefaultFields = ({
5288
- children
5289
- }) => {
5290
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
5291
- };
5292
5686
  var useResolvedFields = () => {
5293
5687
  var _a, _b;
5294
5688
  const { selectedItem, state, config } = useAppContext();
@@ -5296,20 +5690,21 @@ var useResolvedFields = () => {
5296
5690
  const { data } = state;
5297
5691
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5298
5692
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5299
- const defaultFields = (0, import_react29.useMemo)(
5693
+ const defaultFields = (0, import_react36.useMemo)(
5300
5694
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5301
5695
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5302
5696
  );
5303
5697
  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);
5698
+ const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
5699
+ const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
5700
+ const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
5701
+ const lastFields = (0, import_react36.useRef)(defaultFields);
5307
5702
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5308
5703
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5309
5704
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5310
5705
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5311
5706
  const hasResolver = hasComponentResolver || hasRootResolver;
5312
- const resolveFields = (0, import_react29.useCallback)(
5707
+ const resolveFields = (0, import_react36.useCallback)(
5313
5708
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5314
5709
  var _a2;
5315
5710
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5321,7 +5716,7 @@ var useResolvedFields = () => {
5321
5716
  {
5322
5717
  changed,
5323
5718
  fields,
5324
- lastFields: resolvedFields,
5719
+ lastFields: lastFields.current,
5325
5720
  lastData,
5326
5721
  appState: state,
5327
5722
  parent
@@ -5332,7 +5727,7 @@ var useResolvedFields = () => {
5332
5727
  return yield config.root.resolveFields(componentData, {
5333
5728
  changed,
5334
5729
  fields,
5335
- lastFields: resolvedFields,
5730
+ lastFields: lastFields.current,
5336
5731
  lastData,
5337
5732
  appState: state,
5338
5733
  parent
@@ -5341,26 +5736,56 @@ var useResolvedFields = () => {
5341
5736
  return defaultResolveFields(componentData, {
5342
5737
  changed,
5343
5738
  fields,
5344
- lastFields: resolvedFields,
5739
+ lastFields: lastFields.current,
5345
5740
  lastData
5346
5741
  });
5347
5742
  }),
5348
- [data, config, componentData, selectedItem, resolvedFields, state]
5743
+ [data, config, componentData, selectedItem, state, parent]
5349
5744
  );
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);
5745
+ const triggerResolver = (0, import_react36.useCallback)(() => {
5746
+ var _a2, _b2;
5747
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5748
+ if (hasResolver) {
5749
+ setFieldsLoading(true);
5750
+ resolveFields(defaultFields).then((fields) => {
5751
+ setResolvedFields(fields || {});
5752
+ lastFields.current = fields;
5753
+ setFieldsLoading(false);
5754
+ });
5755
+ return;
5756
+ }
5359
5757
  }
5360
- }, [data, defaultFields, selectedItem, hasResolver]);
5758
+ setResolvedFields(defaultFields);
5759
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5760
+ useOnValueChange(
5761
+ state.ui.itemSelector,
5762
+ () => {
5763
+ lastFields.current = defaultFields;
5764
+ },
5765
+ selectorIs
5766
+ );
5767
+ useOnValueChange(
5768
+ { data, parent, itemSelector: state.ui.itemSelector },
5769
+ () => {
5770
+ triggerResolver();
5771
+ },
5772
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
5773
+ );
5774
+ (0, import_react36.useEffect)(() => {
5775
+ triggerResolver();
5776
+ }, []);
5361
5777
  return [resolvedFields, fieldsLoading];
5362
5778
  };
5363
- var Fields = () => {
5779
+
5780
+ // components/Puck/components/Fields/index.tsx
5781
+ var import_jsx_runtime27 = require("react/jsx-runtime");
5782
+ var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5783
+ var DefaultFields = ({
5784
+ children
5785
+ }) => {
5786
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
5787
+ };
5788
+ var Fields = ({ wrapFields = true }) => {
5364
5789
  var _a, _b;
5365
5790
  const {
5366
5791
  selectedItem,
@@ -5378,16 +5803,16 @@ var Fields = () => {
5378
5803
  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
5804
  const isLoading = fieldsResolving || componentResolving;
5380
5805
  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)(
5806
+ const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
5807
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
5383
5808
  "form",
5384
5809
  {
5385
- className: getClassName21(),
5810
+ className: getClassName21({ wrapFields }),
5386
5811
  onSubmit: (e) => {
5387
5812
  e.preventDefault();
5388
5813
  },
5389
5814
  children: [
5390
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5815
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
5391
5816
  const field = fields[fieldName];
5392
5817
  if (!(field == null ? void 0 : field.type)) return null;
5393
5818
  const onChange = (value, updatedUi) => {
@@ -5458,7 +5883,7 @@ var Fields = () => {
5458
5883
  item: selectedItem
5459
5884
  });
5460
5885
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5461
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5886
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5462
5887
  AutoFieldPrivate,
5463
5888
  {
5464
5889
  field,
@@ -5467,16 +5892,15 @@ var Fields = () => {
5467
5892
  readOnly: !edit || readOnly[fieldName],
5468
5893
  value: selectedItem.props[fieldName],
5469
5894
  onChange
5470
- },
5471
- id
5472
- );
5895
+ }
5896
+ ) }, id);
5473
5897
  } else {
5474
5898
  const readOnly = data.root.readOnly || {};
5475
5899
  const { edit } = getPermissions({
5476
5900
  root: true
5477
5901
  });
5478
5902
  const id = `root_${field.type}_${fieldName}`;
5479
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5903
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5480
5904
  AutoFieldPrivate,
5481
5905
  {
5482
5906
  field,
@@ -5485,12 +5909,11 @@ var Fields = () => {
5485
5909
  readOnly: !edit || readOnly[fieldName],
5486
5910
  value: rootProps[fieldName],
5487
5911
  onChange
5488
- },
5489
- id
5490
- );
5912
+ }
5913
+ ) }, id);
5491
5914
  }
5492
5915
  }) }),
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 }) }) })
5916
+ 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
5917
  ]
5495
5918
  }
5496
5919
  );
@@ -5501,7 +5924,7 @@ init_react_import();
5501
5924
 
5502
5925
  // lib/use-component-list.tsx
5503
5926
  init_react_import();
5504
- var import_react30 = require("react");
5927
+ var import_react38 = require("react");
5505
5928
 
5506
5929
  // components/ComponentList/index.tsx
5507
5930
  init_react_import();
@@ -5511,7 +5934,7 @@ init_react_import();
5511
5934
  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
5935
 
5513
5936
  // components/ComponentList/index.tsx
5514
- var import_jsx_runtime27 = require("react/jsx-runtime");
5937
+ var import_jsx_runtime28 = require("react/jsx-runtime");
5515
5938
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
5516
5939
  var ComponentListItem = ({
5517
5940
  name,
@@ -5521,7 +5944,7 @@ var ComponentListItem = ({
5521
5944
  const canInsert = getPermissions({
5522
5945
  type: name
5523
5946
  }).insert;
5524
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5947
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
5525
5948
  };
5526
5949
  var ComponentList = ({
5527
5950
  children,
@@ -5530,8 +5953,8 @@ var ComponentList = ({
5530
5953
  }) => {
5531
5954
  const { config, state, setUi } = useAppContext();
5532
5955
  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)(
5956
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
5957
+ title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
5535
5958
  "button",
5536
5959
  {
5537
5960
  type: "button",
@@ -5545,14 +5968,14 @@ var ComponentList = ({
5545
5968
  }),
5546
5969
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
5547
5970
  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 }) })
5971
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
5972
+ /* @__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
5973
  ]
5551
5974
  }
5552
5975
  ),
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) => {
5976
+ /* @__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
5977
  var _a;
5555
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5978
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
5556
5979
  ComponentListItem,
5557
5980
  {
5558
5981
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -5566,10 +5989,10 @@ var ComponentList = ({
5566
5989
  ComponentList.Item = ComponentListItem;
5567
5990
 
5568
5991
  // lib/use-component-list.tsx
5569
- var import_jsx_runtime28 = require("react/jsx-runtime");
5992
+ var import_jsx_runtime29 = require("react/jsx-runtime");
5570
5993
  var useComponentList = (config, ui) => {
5571
- const [componentList, setComponentList] = (0, import_react30.useState)();
5572
- (0, import_react30.useEffect)(() => {
5994
+ const [componentList, setComponentList] = (0, import_react38.useState)();
5995
+ (0, import_react38.useEffect)(() => {
5573
5996
  var _a, _b, _c;
5574
5997
  if (Object.keys(ui.componentList).length > 0) {
5575
5998
  const matchedComponents = [];
@@ -5579,7 +6002,7 @@ var useComponentList = (config, ui) => {
5579
6002
  if (category.visible === false || !category.components) {
5580
6003
  return null;
5581
6004
  }
5582
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6005
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5583
6006
  ComponentList,
5584
6007
  {
5585
6008
  id: categoryKey,
@@ -5588,7 +6011,7 @@ var useComponentList = (config, ui) => {
5588
6011
  var _a2;
5589
6012
  matchedComponents.push(componentName);
5590
6013
  const componentConf = config.components[componentName] || {};
5591
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6014
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5592
6015
  ComponentList.Item,
5593
6016
  {
5594
6017
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -5608,7 +6031,7 @@ var useComponentList = (config, ui) => {
5608
6031
  );
5609
6032
  if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
5610
6033
  _componentList.push(
5611
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6034
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5612
6035
  ComponentList,
5613
6036
  {
5614
6037
  id: "other",
@@ -5616,7 +6039,7 @@ var useComponentList = (config, ui) => {
5616
6039
  children: remainingComponents.map((componentName, i) => {
5617
6040
  var _a2;
5618
6041
  const componentConf = config.components[componentName] || {};
5619
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6042
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
5620
6043
  ComponentList.Item,
5621
6044
  {
5622
6045
  name: componentName,
@@ -5638,25 +6061,25 @@ var useComponentList = (config, ui) => {
5638
6061
  };
5639
6062
 
5640
6063
  // components/Puck/components/Components/index.tsx
5641
- var import_react31 = require("react");
5642
- var import_jsx_runtime29 = require("react/jsx-runtime");
6064
+ var import_react39 = require("react");
6065
+ var import_jsx_runtime30 = require("react/jsx-runtime");
5643
6066
  var Components = () => {
5644
6067
  const { config, state, overrides } = useAppContext();
5645
6068
  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" }) });
6069
+ const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
6070
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
5648
6071
  };
5649
6072
 
5650
6073
  // components/Puck/components/Preview/index.tsx
5651
6074
  init_react_import();
5652
- var import_react33 = require("react");
6075
+ var import_react41 = require("react");
5653
6076
 
5654
6077
  // components/AutoFrame/index.tsx
5655
6078
  init_react_import();
5656
- var import_react32 = require("react");
6079
+ var import_react40 = require("react");
5657
6080
  var import_object_hash = __toESM(require("object-hash"));
5658
6081
  var import_react_dom3 = require("react-dom");
5659
- var import_jsx_runtime30 = require("react/jsx-runtime");
6082
+ var import_jsx_runtime31 = require("react/jsx-runtime");
5660
6083
  var styleSelector = 'style, link[rel="stylesheet"]';
5661
6084
  var collectStyles = (doc) => {
5662
6085
  const collected = [];
@@ -5699,7 +6122,7 @@ var CopyHostStyles = ({
5699
6122
  onStylesLoaded = () => null
5700
6123
  }) => {
5701
6124
  const { document: doc, window: win } = useFrame();
5702
- (0, import_react32.useEffect)(() => {
6125
+ (0, import_react40.useEffect)(() => {
5703
6126
  if (!win || !doc) {
5704
6127
  return () => {
5705
6128
  };
@@ -5856,10 +6279,10 @@ var CopyHostStyles = ({
5856
6279
  observer.disconnect();
5857
6280
  };
5858
6281
  }, []);
5859
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
6282
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
5860
6283
  };
5861
- var autoFrameContext = (0, import_react32.createContext)({});
5862
- var useFrame = () => (0, import_react32.useContext)(autoFrameContext);
6284
+ var autoFrameContext = (0, import_react40.createContext)({});
6285
+ var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
5863
6286
  function AutoFrame(_a) {
5864
6287
  var _b = _a, {
5865
6288
  children,
@@ -5876,10 +6299,10 @@ function AutoFrame(_a) {
5876
6299
  "onStylesLoaded",
5877
6300
  "frameRef"
5878
6301
  ]);
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)(() => {
6302
+ const [loaded, setLoaded] = (0, import_react40.useState)(false);
6303
+ const [ctx, setCtx] = (0, import_react40.useState)({});
6304
+ const [mountTarget, setMountTarget] = (0, import_react40.useState)();
6305
+ (0, import_react40.useEffect)(() => {
5883
6306
  var _a2;
5884
6307
  if (frameRef.current) {
5885
6308
  setCtx({
@@ -5891,7 +6314,7 @@ function AutoFrame(_a) {
5891
6314
  );
5892
6315
  }
5893
6316
  }, [frameRef, loaded]);
5894
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6317
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
5895
6318
  "iframe",
5896
6319
  __spreadProps(__spreadValues({}, props), {
5897
6320
  className,
@@ -5901,7 +6324,7 @@ function AutoFrame(_a) {
5901
6324
  onLoad: () => {
5902
6325
  setLoaded(true);
5903
6326
  },
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) }) })
6327
+ 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
6328
  })
5906
6329
  );
5907
6330
  }
@@ -5914,7 +6337,7 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
5914
6337
 
5915
6338
  // components/Render/index.tsx
5916
6339
  init_react_import();
5917
- var import_jsx_runtime31 = require("react/jsx-runtime");
6340
+ var import_jsx_runtime32 = require("react/jsx-runtime");
5918
6341
  function Render({
5919
6342
  config,
5920
6343
  data
@@ -5927,7 +6350,7 @@ function Render({
5927
6350
  const rootProps = defaultedData.root.props || defaultedData.root;
5928
6351
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
5929
6352
  if ((_a = config.root) == null ? void 0 : _a.render) {
5930
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6353
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5931
6354
  DropZoneProvider,
5932
6355
  {
5933
6356
  value: {
@@ -5937,7 +6360,7 @@ function Render({
5937
6360
  depth: 0,
5938
6361
  path: []
5939
6362
  },
5940
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6363
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5941
6364
  config.root.render,
5942
6365
  __spreadProps(__spreadValues({}, rootProps), {
5943
6366
  puck: {
@@ -5947,13 +6370,13 @@ function Render({
5947
6370
  title,
5948
6371
  editMode: false,
5949
6372
  id: "puck-root",
5950
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DropZone, { zone: rootDroppableId })
6373
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
5951
6374
  })
5952
6375
  )
5953
6376
  }
5954
6377
  );
5955
6378
  }
5956
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6379
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5957
6380
  DropZoneProvider,
5958
6381
  {
5959
6382
  value: {
@@ -5963,17 +6386,17 @@ function Render({
5963
6386
  depth: 0,
5964
6387
  path: []
5965
6388
  },
5966
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DropZone, { zone: rootDroppableId })
6389
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
5967
6390
  }
5968
6391
  );
5969
6392
  }
5970
6393
 
5971
6394
  // components/Puck/components/Preview/index.tsx
5972
- var import_jsx_runtime32 = require("react/jsx-runtime");
6395
+ var import_jsx_runtime33 = require("react/jsx-runtime");
5973
6396
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
5974
6397
  var useBubbleIframeEvents = (ref) => {
5975
6398
  const { status } = useAppContext();
5976
- (0, import_react33.useEffect)(() => {
6399
+ (0, import_react41.useEffect)(() => {
5977
6400
  var _a;
5978
6401
  if (ref.current && status === "READY") {
5979
6402
  const iframe = ref.current;
@@ -6010,22 +6433,22 @@ var useBubbleIframeEvents = (ref) => {
6010
6433
  }
6011
6434
  }, [status]);
6012
6435
  };
6013
- var Preview = ({ id = "puck-preview" }) => {
6436
+ var Preview2 = ({ id = "puck-preview" }) => {
6014
6437
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
6015
- const Page = (0, import_react33.useCallback)(
6438
+ const Page = (0, import_react41.useCallback)(
6016
6439
  (pageProps) => {
6017
6440
  var _a, _b;
6018
6441
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
6019
6442
  id: "puck-root"
6020
- }, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: pageProps.children });
6443
+ }, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
6021
6444
  },
6022
6445
  [config.root]
6023
6446
  );
6024
- const Frame = (0, import_react33.useMemo)(() => overrides.iframe, [overrides]);
6447
+ const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
6025
6448
  const rootProps = state.data.root.props || state.data.root;
6026
- const ref = (0, import_react33.useRef)(null);
6449
+ const ref = (0, import_react41.useRef)(null);
6027
6450
  useBubbleIframeEvents(ref);
6028
- const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6451
+ const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6029
6452
  Page,
6030
6453
  __spreadProps(__spreadValues({}, rootProps), {
6031
6454
  puck: {
@@ -6034,10 +6457,10 @@ var Preview = ({ id = "puck-preview" }) => {
6034
6457
  dragRef: null
6035
6458
  },
6036
6459
  editMode: true,
6037
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
6460
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
6038
6461
  })
6039
- ) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Render, { data: state.data, config });
6040
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6462
+ ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
6463
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6041
6464
  "div",
6042
6465
  {
6043
6466
  className: getClassName23(),
@@ -6046,7 +6469,7 @@ var Preview = ({ id = "puck-preview" }) => {
6046
6469
  onClick: () => {
6047
6470
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
6048
6471
  },
6049
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6472
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6050
6473
  AutoFrame_default,
6051
6474
  {
6052
6475
  id: "preview-frame",
@@ -6056,14 +6479,14 @@ var Preview = ({ id = "puck-preview" }) => {
6056
6479
  setStatus("READY");
6057
6480
  },
6058
6481
  frameRef: ref,
6059
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6482
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6060
6483
  if (Frame) {
6061
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Frame, { document: document2, children: inner });
6484
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
6062
6485
  }
6063
6486
  return inner;
6064
6487
  } })
6065
6488
  }
6066
- ) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6489
+ ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6067
6490
  "div",
6068
6491
  {
6069
6492
  id: "preview-frame",
@@ -6120,7 +6543,7 @@ var scrollIntoView = (el) => {
6120
6543
  };
6121
6544
 
6122
6545
  // components/LayerTree/index.tsx
6123
- var import_react34 = require("react");
6546
+ var import_react42 = require("react");
6124
6547
 
6125
6548
  // lib/is-child-of-zone.ts
6126
6549
  init_react_import();
@@ -6153,7 +6576,7 @@ var onScrollEnd = (frame, cb) => {
6153
6576
  };
6154
6577
 
6155
6578
  // components/LayerTree/index.tsx
6156
- var import_jsx_runtime33 = require("react/jsx-runtime");
6579
+ var import_jsx_runtime34 = require("react/jsx-runtime");
6157
6580
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
6158
6581
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
6159
6582
  var LayerTree = ({
@@ -6166,15 +6589,15 @@ var LayerTree = ({
6166
6589
  label
6167
6590
  }) => {
6168
6591
  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" }) }),
6592
+ const ctx = (0, import_react42.useContext)(dropZoneContext);
6593
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
6594
+ label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
6595
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
6173
6596
  " ",
6174
6597
  label
6175
6598
  ] }),
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" }),
6599
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
6600
+ zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
6178
6601
  zoneContent.map((item, i) => {
6179
6602
  var _a;
6180
6603
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
@@ -6187,7 +6610,7 @@ var LayerTree = ({
6187
6610
  const childIsSelected = isChildOfZone(item, selectedItem, ctx);
6188
6611
  const componentConfig = config.components[item.type];
6189
6612
  const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
6190
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
6613
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
6191
6614
  "li",
6192
6615
  {
6193
6616
  className: getClassNameLayer({
@@ -6197,7 +6620,7 @@ var LayerTree = ({
6197
6620
  childIsSelected
6198
6621
  }),
6199
6622
  children: [
6200
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
6623
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
6201
6624
  "button",
6202
6625
  {
6203
6626
  type: "button",
@@ -6236,22 +6659,22 @@ var LayerTree = ({
6236
6659
  setHoveringComponent(null);
6237
6660
  },
6238
6661
  children: [
6239
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6662
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
6240
6663
  "div",
6241
6664
  {
6242
6665
  className: getClassNameLayer("chevron"),
6243
6666
  title: isSelected ? "Collapse" : "Expand",
6244
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ChevronDown, { size: "12" })
6667
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
6245
6668
  }
6246
6669
  ),
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 })
6670
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
6671
+ /* @__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" }) }),
6672
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
6250
6673
  ] })
6251
6674
  ]
6252
6675
  }
6253
6676
  ) }),
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)(
6677
+ 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
6678
  LayerTree,
6256
6679
  {
6257
6680
  config,
@@ -6273,13 +6696,13 @@ var LayerTree = ({
6273
6696
  };
6274
6697
 
6275
6698
  // components/Puck/components/Outline/index.tsx
6276
- var import_react35 = require("react");
6277
- var import_jsx_runtime34 = require("react/jsx-runtime");
6699
+ var import_react43 = require("react");
6700
+ var import_jsx_runtime35 = require("react/jsx-runtime");
6278
6701
  var Outline = () => {
6279
6702
  const { dispatch, state, overrides, config } = useAppContext();
6280
6703
  const { data, ui } = state;
6281
6704
  const { itemSelector } = ui;
6282
- const setItemSelector = (0, import_react35.useCallback)(
6705
+ const setItemSelector = (0, import_react43.useCallback)(
6283
6706
  (newItemSelector) => {
6284
6707
  dispatch({
6285
6708
  type: "setUi",
@@ -6288,9 +6711,9 @@ var Outline = () => {
6288
6711
  },
6289
6712
  []
6290
6713
  );
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)(
6714
+ const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
6715
+ 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: [
6716
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
6294
6717
  LayerTree,
6295
6718
  {
6296
6719
  config,
@@ -6303,7 +6726,7 @@ var Outline = () => {
6303
6726
  ),
6304
6727
  Object.entries(findZonesForArea(data, "root")).map(
6305
6728
  ([zoneKey, zone]) => {
6306
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
6729
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
6307
6730
  LayerTree,
6308
6731
  {
6309
6732
  config,
@@ -6402,19 +6825,19 @@ function usePuckHistory({
6402
6825
 
6403
6826
  // lib/use-history-store.ts
6404
6827
  init_react_import();
6405
- var import_react36 = require("react");
6828
+ var import_react44 = require("react");
6406
6829
  var import_use_debounce3 = require("use-debounce");
6407
6830
  var EMPTY_HISTORY_INDEX = 0;
6408
6831
  function useHistoryStore(initialHistory) {
6409
6832
  var _a, _b;
6410
- const [histories, setHistories] = (0, import_react36.useState)(
6833
+ const [histories, setHistories] = (0, import_react44.useState)(
6411
6834
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
6412
6835
  );
6413
6836
  const updateHistories = (histories2) => {
6414
6837
  setHistories(histories2);
6415
6838
  setIndex(histories2.length - 1);
6416
6839
  };
6417
- const [index, setIndex] = (0, import_react36.useState)(
6840
+ const [index, setIndex] = (0, import_react44.useState)(
6418
6841
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
6419
6842
  );
6420
6843
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -6574,22 +6997,22 @@ var getBox = function getBox2(el) {
6574
6997
  };
6575
6998
 
6576
6999
  // components/Puck/components/Canvas/index.tsx
6577
- var import_react38 = require("react");
7000
+ var import_react46 = require("react");
6578
7001
 
6579
7002
  // components/ViewportControls/index.tsx
6580
7003
  init_react_import();
6581
- var import_react37 = require("react");
7004
+ var import_react45 = require("react");
6582
7005
 
6583
7006
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6584
7007
  init_react_import();
6585
7008
  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
7009
 
6587
7010
  // components/ViewportControls/index.tsx
6588
- var import_jsx_runtime35 = require("react/jsx-runtime");
7011
+ var import_jsx_runtime36 = require("react/jsx-runtime");
6589
7012
  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 })
7013
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
7014
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
7015
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
6593
7016
  };
6594
7017
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
6595
7018
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -6601,11 +7024,11 @@ var ViewportButton = ({
6601
7024
  onClick
6602
7025
  }) => {
6603
7026
  const { state } = useAppContext();
6604
- const [isActive, setIsActive] = (0, import_react37.useState)(false);
6605
- (0, import_react37.useEffect)(() => {
7027
+ const [isActive, setIsActive] = (0, import_react45.useState)(false);
7028
+ (0, import_react45.useEffect)(() => {
6606
7029
  setIsActive(width === state.ui.viewports.current.width);
6607
7030
  }, [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)(
7031
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6609
7032
  IconButton,
6610
7033
  {
6611
7034
  title,
@@ -6614,7 +7037,7 @@ var ViewportButton = ({
6614
7037
  e.stopPropagation();
6615
7038
  onClick({ width, height });
6616
7039
  },
6617
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton("inner"), children })
7040
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
6618
7041
  }
6619
7042
  ) });
6620
7043
  };
@@ -6638,7 +7061,7 @@ var ViewportControls = ({
6638
7061
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6639
7062
  (option) => option.value === autoZoom
6640
7063
  );
6641
- const zoomOptions = (0, import_react37.useMemo)(
7064
+ const zoomOptions = (0, import_react45.useMemo)(
6642
7065
  () => [
6643
7066
  ...defaultZoomOptions,
6644
7067
  ...defaultsContainAutoZoom ? [] : [
@@ -6650,8 +7073,8 @@ var ViewportControls = ({
6650
7073
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
6651
7074
  [autoZoom]
6652
7075
  );
6653
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25(), children: [
6654
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7076
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
7077
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6655
7078
  ViewportButton,
6656
7079
  {
6657
7080
  height: viewport.height,
@@ -6662,8 +7085,8 @@ var ViewportControls = ({
6662
7085
  },
6663
7086
  i
6664
7087
  )),
6665
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("divider") }),
6666
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7088
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7089
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6667
7090
  IconButton,
6668
7091
  {
6669
7092
  title: "Zoom viewport out",
@@ -6677,10 +7100,10 @@ var ViewportControls = ({
6677
7100
  )].value
6678
7101
  );
6679
7102
  },
6680
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ZoomOut, { size: 16 })
7103
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
6681
7104
  }
6682
7105
  ),
6683
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7106
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6684
7107
  IconButton,
6685
7108
  {
6686
7109
  title: "Zoom viewport in",
@@ -6694,11 +7117,11 @@ var ViewportControls = ({
6694
7117
  )].value
6695
7118
  );
6696
7119
  },
6697
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ZoomIn, { size: 16 })
7120
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
6698
7121
  }
6699
7122
  ),
6700
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("divider") }),
6701
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7123
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7124
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6702
7125
  "select",
6703
7126
  {
6704
7127
  className: getClassName25("zoomSelect"),
@@ -6706,7 +7129,7 @@ var ViewportControls = ({
6706
7129
  onChange: (e) => {
6707
7130
  onZoom(parseFloat(e.currentTarget.value));
6708
7131
  },
6709
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7132
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6710
7133
  "option",
6711
7134
  {
6712
7135
  value: option.value,
@@ -6754,24 +7177,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
6754
7177
  };
6755
7178
 
6756
7179
  // components/Puck/components/Canvas/index.tsx
6757
- var import_jsx_runtime36 = require("react/jsx-runtime");
7180
+ var import_jsx_runtime37 = require("react/jsx-runtime");
6758
7181
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
6759
7182
  var ZOOM_ON_CHANGE = true;
6760
7183
  var Canvas = () => {
6761
7184
  const { status, iframe } = useAppContext();
6762
7185
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
6763
7186
  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 });
7187
+ const frameRef = (0, import_react46.useRef)(null);
7188
+ const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
7189
+ const defaultRender = (0, import_react46.useMemo)(() => {
7190
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
6768
7191
  return PuckDefault;
6769
7192
  }, []);
6770
- const CustomPreview = (0, import_react38.useMemo)(
7193
+ const CustomPreview = (0, import_react46.useMemo)(
6771
7194
  () => overrides.preview || defaultRender,
6772
7195
  [overrides]
6773
7196
  );
6774
- const getFrameDimensions = (0, import_react38.useCallback)(() => {
7197
+ const getFrameDimensions = (0, import_react46.useCallback)(() => {
6775
7198
  if (frameRef.current) {
6776
7199
  const frame = frameRef.current;
6777
7200
  const box = getBox(frame);
@@ -6779,7 +7202,7 @@ var Canvas = () => {
6779
7202
  }
6780
7203
  return { width: 0, height: 0 };
6781
7204
  }, [frameRef]);
6782
- const resetAutoZoom = (0, import_react38.useCallback)(
7205
+ const resetAutoZoom = (0, import_react46.useCallback)(
6783
7206
  (ui2 = state.ui) => {
6784
7207
  if (frameRef.current) {
6785
7208
  setZoomConfig(
@@ -6789,11 +7212,11 @@ var Canvas = () => {
6789
7212
  },
6790
7213
  [frameRef, zoomConfig, state.ui]
6791
7214
  );
6792
- (0, import_react38.useEffect)(() => {
7215
+ (0, import_react46.useEffect)(() => {
6793
7216
  setShowTransition(false);
6794
7217
  resetAutoZoom();
6795
7218
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6796
- (0, import_react38.useEffect)(() => {
7219
+ (0, import_react46.useEffect)(() => {
6797
7220
  const { height: frameHeight } = getFrameDimensions();
6798
7221
  if (ui.viewports.current.height === "auto") {
6799
7222
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6801,13 +7224,13 @@ var Canvas = () => {
6801
7224
  }));
6802
7225
  }
6803
7226
  }, [zoomConfig.zoom]);
6804
- (0, import_react38.useEffect)(() => {
7227
+ (0, import_react46.useEffect)(() => {
6805
7228
  if (ZOOM_ON_CHANGE) {
6806
7229
  setShowTransition(true);
6807
7230
  resetAutoZoom(ui);
6808
7231
  }
6809
7232
  }, [ui.viewports.current.width]);
6810
- (0, import_react38.useEffect)(() => {
7233
+ (0, import_react46.useEffect)(() => {
6811
7234
  const cb = () => {
6812
7235
  setShowTransition(false);
6813
7236
  resetAutoZoom();
@@ -6817,13 +7240,13 @@ var Canvas = () => {
6817
7240
  window.removeEventListener("resize", cb);
6818
7241
  };
6819
7242
  }, []);
6820
- const [showLoader, setShowLoader] = (0, import_react38.useState)(false);
6821
- (0, import_react38.useEffect)(() => {
7243
+ const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
7244
+ (0, import_react46.useEffect)(() => {
6822
7245
  setTimeout(() => {
6823
7246
  setShowLoader(true);
6824
7247
  }, 500);
6825
7248
  }, []);
6826
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7249
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
6827
7250
  "div",
6828
7251
  {
6829
7252
  className: getClassName26({
@@ -6836,7 +7259,7 @@ var Canvas = () => {
6836
7259
  recordHistory: true
6837
7260
  }),
6838
7261
  children: [
6839
- ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7262
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
6840
7263
  ViewportControls,
6841
7264
  {
6842
7265
  autoZoom: zoomConfig.autoZoom,
@@ -6862,8 +7285,8 @@ var Canvas = () => {
6862
7285
  }
6863
7286
  }
6864
7287
  ) }),
6865
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
6866
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7288
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
7289
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
6867
7290
  "div",
6868
7291
  {
6869
7292
  className: getClassName26("root"),
@@ -6884,10 +7307,10 @@ var Canvas = () => {
6884
7307
  })
6885
7308
  );
6886
7309
  },
6887
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Preview, {}) })
7310
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview2, {}) })
6888
7311
  }
6889
7312
  ),
6890
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Loader, { size: 24 }) })
7313
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
6891
7314
  ] })
6892
7315
  ]
6893
7316
  }
@@ -6896,7 +7319,7 @@ var Canvas = () => {
6896
7319
 
6897
7320
  // lib/use-loaded-overrides.ts
6898
7321
  init_react_import();
6899
- var import_react39 = require("react");
7322
+ var import_react47 = require("react");
6900
7323
 
6901
7324
  // lib/load-overrides.ts
6902
7325
  init_react_import();
@@ -6935,26 +7358,26 @@ var useLoadedOverrides = ({
6935
7358
  overrides,
6936
7359
  plugins
6937
7360
  }) => {
6938
- return (0, import_react39.useMemo)(() => {
7361
+ return (0, import_react47.useMemo)(() => {
6939
7362
  return loadOverrides({ overrides, plugins });
6940
7363
  }, [plugins, overrides]);
6941
7364
  };
6942
7365
 
6943
7366
  // components/DefaultOverride/index.tsx
6944
7367
  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 });
7368
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7369
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
6947
7370
 
6948
7371
  // lib/use-inject-css.ts
6949
7372
  init_react_import();
6950
- var import_react40 = require("react");
7373
+ var import_react48 = require("react");
6951
7374
  var styles = ``;
6952
7375
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
6953
- const [el, setEl] = (0, import_react40.useState)();
6954
- (0, import_react40.useEffect)(() => {
7376
+ const [el, setEl] = (0, import_react48.useState)();
7377
+ (0, import_react48.useEffect)(() => {
6955
7378
  setEl(document.createElement("style"));
6956
7379
  }, []);
6957
- (0, import_react40.useEffect)(() => {
7380
+ (0, import_react48.useEffect)(() => {
6958
7381
  var _a;
6959
7382
  if (!el || typeof window === "undefined") {
6960
7383
  return;
@@ -6974,10 +7397,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
6974
7397
 
6975
7398
  // lib/use-preview-mode-hotkeys.ts
6976
7399
  init_react_import();
6977
- var import_react41 = require("react");
7400
+ var import_react49 = require("react");
6978
7401
  var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
6979
7402
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
6980
- const toggleInteractive = (0, import_react41.useCallback)(() => {
7403
+ const toggleInteractive = (0, import_react49.useCallback)(() => {
6981
7404
  dispatch({
6982
7405
  type: "setUi",
6983
7406
  ui: (ui) => ({
@@ -7000,7 +7423,7 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7000
7423
  };
7001
7424
 
7002
7425
  // components/Puck/index.tsx
7003
- var import_jsx_runtime38 = require("react/jsx-runtime");
7426
+ var import_jsx_runtime39 = require("react/jsx-runtime");
7004
7427
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
7005
7428
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
7006
7429
  function Puck({
@@ -7029,7 +7452,7 @@ function Puck({
7029
7452
  waitForStyles: true
7030
7453
  }, _iframe);
7031
7454
  useInjectGlobalCss(iframe.enabled);
7032
- const [generatedAppState] = (0, import_react42.useState)(() => {
7455
+ const [generatedAppState] = (0, import_react50.useState)(() => {
7033
7456
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
7034
7457
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7035
7458
  let clientUiState = {};
@@ -7101,14 +7524,14 @@ function Puck({
7101
7524
  histories,
7102
7525
  index: initialHistoryIndex
7103
7526
  });
7104
- const [reducer] = (0, import_react42.useState)(
7527
+ const [reducer] = (0, import_react50.useState)(
7105
7528
  () => createReducer({
7106
7529
  config,
7107
7530
  record: historyStore.record,
7108
7531
  onAction
7109
7532
  })
7110
7533
  );
7111
- const [appState, dispatch] = (0, import_react42.useReducer)(
7534
+ const [appState, dispatch] = (0, import_react50.useReducer)(
7112
7535
  reducer,
7113
7536
  flushZones(initialAppState)
7114
7537
  );
@@ -7119,14 +7542,14 @@ function Puck({
7119
7542
  historyStore,
7120
7543
  iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
7121
7544
  });
7122
- const [menuOpen, setMenuOpen] = (0, import_react42.useState)(false);
7545
+ const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
7123
7546
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
7124
7547
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
7125
- (0, import_react42.useEffect)(() => {
7548
+ (0, import_react50.useEffect)(() => {
7126
7549
  if (onChange) onChange(data);
7127
7550
  }, [data]);
7128
7551
  const rootProps = data.root.props || data.root;
7129
- const toggleSidebars = (0, import_react42.useCallback)(
7552
+ const toggleSidebars = (0, import_react50.useCallback)(
7130
7553
  (sidebar) => {
7131
7554
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7132
7555
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7140,7 +7563,7 @@ function Puck({
7140
7563
  },
7141
7564
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7142
7565
  );
7143
- (0, import_react42.useEffect)(() => {
7566
+ (0, import_react50.useEffect)(() => {
7144
7567
  if (!window.matchMedia("(min-width: 638px)").matches) {
7145
7568
  dispatch({
7146
7569
  type: "setUi",
@@ -7163,7 +7586,7 @@ function Puck({
7163
7586
  window.removeEventListener("resize", handleResize);
7164
7587
  };
7165
7588
  }, []);
7166
- const defaultHeaderRender = (0, import_react42.useMemo)(() => {
7589
+ const defaultHeaderRender = (0, import_react50.useMemo)(() => {
7167
7590
  if (renderHeader) {
7168
7591
  console.warn(
7169
7592
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7171,20 +7594,20 @@ function Puck({
7171
7594
  const RenderHeader = (_a2) => {
7172
7595
  var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
7173
7596
  const Comp = renderHeader;
7174
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7597
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7175
7598
  };
7176
7599
  return RenderHeader;
7177
7600
  }
7178
7601
  return DefaultOverride;
7179
7602
  }, [renderHeader]);
7180
- const defaultHeaderActionsRender = (0, import_react42.useMemo)(() => {
7603
+ const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
7181
7604
  if (renderHeaderActions) {
7182
7605
  console.warn(
7183
7606
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7184
7607
  );
7185
7608
  const RenderHeader = (props) => {
7186
7609
  const Comp = renderHeaderActions;
7187
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7610
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7188
7611
  };
7189
7612
  return RenderHeader;
7190
7613
  }
@@ -7194,27 +7617,27 @@ function Puck({
7194
7617
  overrides,
7195
7618
  plugins
7196
7619
  });
7197
- const CustomPuck = (0, import_react42.useMemo)(
7620
+ const CustomPuck = (0, import_react50.useMemo)(
7198
7621
  () => loadedOverrides.puck || DefaultOverride,
7199
7622
  [loadedOverrides]
7200
7623
  );
7201
- const CustomHeader = (0, import_react42.useMemo)(
7624
+ const CustomHeader = (0, import_react50.useMemo)(
7202
7625
  () => loadedOverrides.header || defaultHeaderRender,
7203
7626
  [loadedOverrides]
7204
7627
  );
7205
- const CustomHeaderActions = (0, import_react42.useMemo)(
7628
+ const CustomHeaderActions = (0, import_react50.useMemo)(
7206
7629
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7207
7630
  [loadedOverrides]
7208
7631
  );
7209
- const [mounted, setMounted] = (0, import_react42.useState)(false);
7210
- (0, import_react42.useEffect)(() => {
7632
+ const [mounted, setMounted] = (0, import_react50.useState)(false);
7633
+ (0, import_react50.useEffect)(() => {
7211
7634
  setMounted(true);
7212
7635
  }, []);
7213
7636
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
7214
7637
  const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
7215
7638
  usePreviewModeHotkeys(dispatch, iframe.enabled);
7216
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
7217
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7639
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
7640
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7218
7641
  AppProvider,
7219
7642
  {
7220
7643
  value: {
@@ -7236,7 +7659,7 @@ function Puck({
7236
7659
  getPermissions: () => ({}),
7237
7660
  refreshPermissions: () => null
7238
7661
  },
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)(
7662
+ 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
7663
  "div",
7241
7664
  {
7242
7665
  className: getLayoutClassName({
@@ -7245,60 +7668,60 @@ function Puck({
7245
7668
  mounted,
7246
7669
  rightSideBarVisible
7247
7670
  }),
7248
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getLayoutClassName("inner"), children: [
7249
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7671
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
7672
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7250
7673
  CustomHeader,
7251
7674
  {
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)(
7675
+ 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
7676
  Button,
7254
7677
  {
7255
7678
  onClick: () => {
7256
7679
  onPublish && onPublish(data);
7257
7680
  },
7258
- icon: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Globe, { size: "14px" }),
7681
+ icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
7259
7682
  children: "Publish"
7260
7683
  }
7261
7684
  ) }) }),
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)(
7685
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
7686
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
7687
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7265
7688
  "div",
7266
7689
  {
7267
7690
  className: getLayoutClassName("leftSideBarToggle"),
7268
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7691
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7269
7692
  IconButton,
7270
7693
  {
7271
7694
  onClick: () => {
7272
7695
  toggleSidebars("left");
7273
7696
  },
7274
7697
  title: "Toggle left sidebar",
7275
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(PanelLeft, { focusable: "false" })
7698
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
7276
7699
  }
7277
7700
  )
7278
7701
  }
7279
7702
  ),
7280
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7703
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7281
7704
  "div",
7282
7705
  {
7283
7706
  className: getLayoutClassName("rightSideBarToggle"),
7284
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7707
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7285
7708
  IconButton,
7286
7709
  {
7287
7710
  onClick: () => {
7288
7711
  toggleSidebars("right");
7289
7712
  },
7290
7713
  title: "Toggle right sidebar",
7291
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(PanelRight, { focusable: "false" })
7714
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
7292
7715
  }
7293
7716
  )
7294
7717
  }
7295
7718
  )
7296
7719
  ] }),
7297
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Heading, { rank: "2", size: "xs", children: [
7720
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
7298
7721
  headerTitle || rootProps.title || "Page",
7299
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
7722
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
7300
7723
  " ",
7301
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7724
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7302
7725
  "code",
7303
7726
  {
7304
7727
  className: getLayoutClassName("headerPath"),
@@ -7307,31 +7730,31 @@ function Puck({
7307
7730
  )
7308
7731
  ] })
7309
7732
  ] }) }),
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)(
7733
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
7734
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7312
7735
  IconButton,
7313
7736
  {
7314
7737
  onClick: () => {
7315
7738
  return setMenuOpen(!menuOpen);
7316
7739
  },
7317
7740
  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" })
7741
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
7319
7742
  }
7320
7743
  ) }),
7321
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7744
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7322
7745
  MenuBar,
7323
7746
  {
7324
7747
  appState,
7325
7748
  dispatch,
7326
7749
  onPublish,
7327
7750
  menuOpen,
7328
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7751
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7329
7752
  Button,
7330
7753
  {
7331
7754
  onClick: () => {
7332
7755
  onPublish && onPublish(data);
7333
7756
  },
7334
- icon: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Globe, { size: "14px" }),
7757
+ icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
7335
7758
  children: "Publish"
7336
7759
  }
7337
7760
  ) }),
@@ -7342,19 +7765,19 @@ function Puck({
7342
7765
  ] }) })
7343
7766
  }
7344
7767
  ),
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, {}) })
7768
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
7769
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
7770
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
7348
7771
  ] }),
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)(
7772
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
7773
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7351
7774
  SidebarSection,
7352
7775
  {
7353
7776
  noPadding: true,
7354
7777
  noBorderTop: true,
7355
7778
  showBreadcrumbs: true,
7356
7779
  title: selectedItem ? selectedComponentLabel : "Page",
7357
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Fields, {})
7780
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {})
7358
7781
  }
7359
7782
  ) })
7360
7783
  ] })
@@ -7362,13 +7785,13 @@ function Puck({
7362
7785
  ) }) })
7363
7786
  }
7364
7787
  ),
7365
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
7788
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
7366
7789
  ] });
7367
7790
  }
7368
7791
  Puck.Components = Components;
7369
7792
  Puck.Fields = Fields;
7370
7793
  Puck.Outline = Outline;
7371
- Puck.Preview = Preview;
7794
+ Puck.Preview = Preview2;
7372
7795
 
7373
7796
  // lib/migrate.ts
7374
7797
  init_react_import();