@measured/puck 0.20.0-canary.3badc0ce → 0.20.0-canary.5780043

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
@@ -153,9 +153,9 @@ var require_classnames = __commonJS({
153
153
  }
154
154
  });
155
155
 
156
- // bundle/index.ts
157
- var bundle_exports = {};
158
- __export(bundle_exports, {
156
+ // index.ts
157
+ var core_exports = {};
158
+ __export(core_exports, {
159
159
  Action: () => Action,
160
160
  ActionBar: () => ActionBar,
161
161
  AutoField: () => AutoField,
@@ -167,7 +167,7 @@ __export(bundle_exports, {
167
167
  IconButton: () => IconButton,
168
168
  Label: () => Label,
169
169
  Puck: () => Puck,
170
- Render: () => Render,
170
+ Render: () => Render2,
171
171
  createUsePuck: () => createUsePuck,
172
172
  migrate: () => migrate,
173
173
  overrideKeys: () => overrideKeys,
@@ -178,10 +178,7 @@ __export(bundle_exports, {
178
178
  usePuck: () => usePuck,
179
179
  walkTree: () => walkTree
180
180
  });
181
- module.exports = __toCommonJS(bundle_exports);
182
- init_react_import();
183
-
184
- // bundle/core.ts
181
+ module.exports = __toCommonJS(core_exports);
185
182
  init_react_import();
186
183
 
187
184
  // types/API/index.ts
@@ -309,7 +306,7 @@ init_react_import();
309
306
  var styles_module_default2 = { "InputWrapper": "_InputWrapper_py9hf_1", "Input-label": "_Input-label_py9hf_5", "Input-labelIcon": "_Input-labelIcon_py9hf_14", "Input-disabledIcon": "_Input-disabledIcon_py9hf_21", "Input-input": "_Input-input_py9hf_26", "Input": "_Input_py9hf_1", "Input--readOnly": "_Input--readOnly_py9hf_76", "Input-radioGroupItems": "_Input-radioGroupItems_py9hf_87", "Input-radio": "_Input-radio_py9hf_87", "Input-radioInner": "_Input-radioInner_py9hf_104", "Input-radioInput": "_Input-radioInput_py9hf_149" };
310
307
 
311
308
  // components/AutoField/index.tsx
312
- var import_react22 = require("react");
309
+ var import_react24 = require("react");
313
310
 
314
311
  // components/AutoField/fields/index.tsx
315
312
  init_react_import();
@@ -769,7 +766,7 @@ var IconButton = ({
769
766
  };
770
767
 
771
768
  // components/AutoField/fields/ArrayField/index.tsx
772
- var import_react14 = require("react");
769
+ var import_react16 = require("react");
773
770
 
774
771
  // components/DragIcon/index.tsx
775
772
  init_react_import();
@@ -1256,161 +1253,639 @@ function insertAction(state, action, appStore) {
1256
1253
 
1257
1254
  // reducer/actions/replace.ts
1258
1255
  init_react_import();
1259
- var replaceAction = (state, action, appStore) => {
1260
- const [parentId] = action.destinationZone.split(":");
1261
- const idsInPath = getIdsForParent(action.destinationZone, state);
1262
- const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
1263
- const idChanged = originalId !== action.data.props.id;
1264
- if (idChanged) {
1265
- throw new Error(
1266
- `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1267
- );
1268
- }
1269
- const newSlotIds = [];
1270
- const data = walkTree(action.data, appStore.config, (contents, opts) => {
1271
- newSlotIds.push(`${opts.parentId}:${opts.propName}`);
1272
- return contents.map((item) => {
1273
- const id = generateId(item.type);
1274
- return __spreadProps(__spreadValues({}, item), {
1275
- props: __spreadValues({ id }, item.props)
1276
- });
1277
- });
1278
- });
1279
- const stateWithDeepSlotsRemoved = __spreadValues({}, state);
1280
- Object.keys(state.indexes.zones).forEach((zoneCompound) => {
1281
- const id = zoneCompound.split(":")[0];
1282
- if (id === originalId) {
1283
- if (!newSlotIds.includes(zoneCompound)) {
1284
- delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
1285
- }
1286
- }
1287
- });
1288
- return walkAppState(
1289
- stateWithDeepSlotsRemoved,
1290
- appStore.config,
1291
- (content, zoneCompound) => {
1292
- const newContent = [...content];
1293
- if (zoneCompound === action.destinationZone) {
1294
- newContent[action.destinationIndex] = data;
1295
- }
1296
- return newContent;
1297
- },
1298
- (childItem, path) => {
1299
- const pathIds = path.map((p) => p.split(":")[0]);
1300
- if (childItem.props.id === data.props.id) {
1301
- return data;
1302
- } else if (childItem.props.id === parentId) {
1303
- return childItem;
1304
- } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1305
- return childItem;
1306
- } else if (pathIds.indexOf(data.props.id) > -1) {
1307
- return childItem;
1308
- }
1309
- return null;
1310
- }
1311
- );
1312
- };
1313
1256
 
1314
- // reducer/actions/replace-root.ts
1257
+ // rsc.tsx
1315
1258
  init_react_import();
1316
- var replaceRootAction = (state, action, appStore) => {
1317
- return walkAppState(
1318
- state,
1319
- appStore.config,
1320
- (content) => content,
1321
- (childItem) => {
1322
- if (childItem.props.id === "root") {
1323
- return __spreadProps(__spreadValues({}, childItem), {
1324
- props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1325
- readOnly: action.root.readOnly
1326
- });
1327
- }
1328
- return childItem;
1329
- }
1330
- );
1331
- };
1332
1259
 
1333
- // reducer/actions/duplicate.ts
1260
+ // components/ServerRender/index.tsx
1334
1261
  init_react_import();
1335
1262
 
1336
- // lib/data/get-item.ts
1263
+ // lib/data/setup-zone.ts
1337
1264
  init_react_import();
1338
- function getItem(selector, state) {
1339
- var _a, _b;
1340
- const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
1341
- return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
1342
- }
1265
+ var setupZone = (data, zoneKey) => {
1266
+ if (zoneKey === rootDroppableId) {
1267
+ return data;
1268
+ }
1269
+ const newData = __spreadProps(__spreadValues({}, data), {
1270
+ zones: data.zones ? __spreadValues({}, data.zones) : {}
1271
+ });
1272
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1273
+ return newData;
1274
+ };
1343
1275
 
1344
- // reducer/actions/duplicate.ts
1345
- function duplicateAction(state, action, appStore) {
1346
- const item = getItem(
1347
- { index: action.sourceIndex, zone: action.sourceZone },
1348
- state
1276
+ // lib/use-slots.tsx
1277
+ init_react_import();
1278
+ var import_react5 = require("react");
1279
+ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
1280
+ const slotProps = (0, import_react5.useMemo)(() => {
1281
+ const mapped = mapSlots(
1282
+ item,
1283
+ (content, _parentId, propName, field, propPath) => {
1284
+ const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
1285
+ const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
1286
+ const render = isReadOnly ? renderSlotRender : renderSlotEdit;
1287
+ const Slot = (dzProps) => render(__spreadProps(__spreadValues({
1288
+ allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
1289
+ disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
1290
+ }, dzProps), {
1291
+ zone: propName,
1292
+ content
1293
+ }));
1294
+ return Slot;
1295
+ },
1296
+ config
1297
+ ).props;
1298
+ return mapped;
1299
+ }, [config, item, readOnly, forceReadOnly]);
1300
+ const mergedProps = (0, import_react5.useMemo)(
1301
+ () => __spreadValues(__spreadValues({}, item.props), slotProps),
1302
+ [item.props, slotProps]
1349
1303
  );
1350
- const idsInPath = getIdsForParent(action.sourceZone, state);
1351
- const newItem = __spreadProps(__spreadValues({}, item), {
1352
- props: __spreadProps(__spreadValues({}, item.props), {
1353
- id: generateId(item.type)
1304
+ return mergedProps;
1305
+ }
1306
+
1307
+ // components/SlotRender/server.tsx
1308
+ init_react_import();
1309
+ var import_react6 = require("react");
1310
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1311
+ var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SlotRender, __spreadValues({}, props));
1312
+ var Item = ({
1313
+ config,
1314
+ item,
1315
+ metadata
1316
+ }) => {
1317
+ const Component = config.components[item.type];
1318
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
1319
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1320
+ Component.render,
1321
+ __spreadProps(__spreadValues({}, props), {
1322
+ puck: __spreadProps(__spreadValues({}, props.puck), {
1323
+ renderDropZone: DropZoneRender,
1324
+ metadata: metadata || {}
1325
+ })
1354
1326
  })
1355
- });
1356
- const modified = walkAppState(
1357
- state,
1358
- appStore.config,
1359
- (content, zoneCompound) => {
1360
- if (zoneCompound === action.sourceZone) {
1361
- return insert(content, action.sourceIndex + 1, item);
1362
- }
1363
- return content;
1364
- },
1365
- (childItem, path, index) => {
1366
- const zoneCompound = path[path.length - 1];
1367
- const parents = path.map((p) => p.split(":")[0]);
1368
- if (parents.indexOf(newItem.props.id) > -1) {
1369
- return __spreadProps(__spreadValues({}, childItem), {
1370
- props: __spreadProps(__spreadValues({}, childItem.props), {
1371
- id: generateId(childItem.type)
1372
- })
1373
- });
1374
- }
1375
- if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1376
- return newItem;
1327
+ );
1328
+ };
1329
+ var SlotRender = (0, import_react6.forwardRef)(
1330
+ function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
1331
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, style, ref, children: content.map((item) => {
1332
+ if (!config.components[item.type]) {
1333
+ return null;
1377
1334
  }
1378
- const [sourceZoneParent] = action.sourceZone.split(":");
1379
- if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1380
- return childItem;
1335
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1336
+ Item,
1337
+ {
1338
+ config,
1339
+ item,
1340
+ metadata
1341
+ },
1342
+ item.props.id
1343
+ );
1344
+ }) });
1345
+ }
1346
+ );
1347
+
1348
+ // components/ServerRender/index.tsx
1349
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1350
+ function DropZoneRender({
1351
+ zone,
1352
+ data,
1353
+ areaId = "root",
1354
+ config,
1355
+ metadata = {}
1356
+ }) {
1357
+ let zoneCompound = rootDroppableId;
1358
+ let content = (data == null ? void 0 : data.content) || [];
1359
+ if (!data || !config) {
1360
+ return null;
1361
+ }
1362
+ if (areaId !== rootAreaId && zone !== rootZone) {
1363
+ zoneCompound = `${areaId}:${zone}`;
1364
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
1365
+ }
1366
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: content.map((item) => {
1367
+ const Component = config.components[item.type];
1368
+ const props = __spreadProps(__spreadValues({}, item.props), {
1369
+ puck: {
1370
+ renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1371
+ DropZoneRender,
1372
+ {
1373
+ zone: zone2,
1374
+ data,
1375
+ areaId: item.props.id,
1376
+ config,
1377
+ metadata
1378
+ }
1379
+ ),
1380
+ metadata,
1381
+ dragRef: null,
1382
+ isEditing: false
1381
1383
  }
1382
- return null;
1384
+ });
1385
+ const renderItem = __spreadProps(__spreadValues({}, item), { props });
1386
+ const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
1387
+ if (Component) {
1388
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
1383
1389
  }
1384
- );
1385
- return __spreadProps(__spreadValues({}, modified), {
1386
- ui: __spreadProps(__spreadValues({}, modified.ui), {
1387
- itemSelector: {
1388
- index: action.sourceIndex + 1,
1389
- zone: action.sourceZone
1390
- }
1391
- })
1392
- });
1390
+ return null;
1391
+ }) });
1393
1392
  }
1394
1393
 
1395
- // reducer/actions/reorder.ts
1394
+ // lib/resolve-all-data.ts
1396
1395
  init_react_import();
1397
1396
 
1398
- // reducer/actions/move.ts
1397
+ // lib/resolve-component-data.ts
1399
1398
  init_react_import();
1400
1399
 
1401
- // lib/data/remove.ts
1400
+ // lib/get-changed.ts
1402
1401
  init_react_import();
1403
- var remove = (list, index) => {
1404
- const result = Array.from(list);
1405
- result.splice(index, 1);
1406
- return result;
1407
- };
1408
-
1409
- // reducer/actions/move.ts
1410
- var moveAction = (state, action, appStore) => {
1411
- if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
1412
- return state;
1413
- }
1402
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1403
+ var getChanged = (newItem, oldItem) => {
1404
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1405
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1406
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1407
+ return __spreadProps(__spreadValues({}, acc), {
1408
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1409
+ });
1410
+ }, {}) : {};
1411
+ };
1412
+
1413
+ // lib/resolve-component-data.ts
1414
+ var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
1415
+ var cache = { lastChange: {} };
1416
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1417
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1418
+ const resolvedItem = __spreadValues({}, item);
1419
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
1420
+ const id = "id" in item.props ? item.props.id : "root";
1421
+ if (shouldRunResolver) {
1422
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1423
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1424
+ return { node: resolved, didChange: false };
1425
+ }
1426
+ const changed = getChanged(item, oldItem);
1427
+ if (onResolveStart) {
1428
+ onResolveStart(item);
1429
+ }
1430
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1431
+ changed,
1432
+ lastData: oldItem,
1433
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1434
+ trigger
1435
+ });
1436
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1437
+ if (Object.keys(readOnly).length) {
1438
+ resolvedItem.readOnly = readOnly;
1439
+ }
1440
+ }
1441
+ let itemWithResolvedChildren = yield mapSlots(
1442
+ resolvedItem,
1443
+ (content) => __async(void 0, null, function* () {
1444
+ return yield Promise.all(
1445
+ content.map(
1446
+ (childItem) => __async(void 0, null, function* () {
1447
+ return (yield resolveComponentData(
1448
+ childItem,
1449
+ config,
1450
+ metadata,
1451
+ onResolveStart,
1452
+ onResolveEnd,
1453
+ trigger
1454
+ )).node;
1455
+ })
1456
+ )
1457
+ );
1458
+ }),
1459
+ config
1460
+ );
1461
+ if (shouldRunResolver && onResolveEnd) {
1462
+ onResolveEnd(resolvedItem);
1463
+ }
1464
+ cache.lastChange[id] = {
1465
+ item,
1466
+ resolved: itemWithResolvedChildren
1467
+ };
1468
+ return {
1469
+ node: itemWithResolvedChildren,
1470
+ didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
1471
+ };
1472
+ });
1473
+
1474
+ // lib/data/default-data.ts
1475
+ init_react_import();
1476
+ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
1477
+ root: data.root || {},
1478
+ content: data.content || []
1479
+ });
1480
+
1481
+ // lib/data/to-component.ts
1482
+ init_react_import();
1483
+ var toComponent = (item) => {
1484
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
1485
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
1486
+ type: "root"
1487
+ });
1488
+ };
1489
+
1490
+ // lib/resolve-all-data.ts
1491
+ function resolveAllData(_0, _1) {
1492
+ return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
1493
+ var _a;
1494
+ const defaultedData = defaultData(data);
1495
+ const resolveNode = (_node) => __async(this, null, function* () {
1496
+ const node = toComponent(_node);
1497
+ onResolveStart == null ? void 0 : onResolveStart(node);
1498
+ const resolved = (yield resolveComponentData(
1499
+ node,
1500
+ config,
1501
+ metadata,
1502
+ () => {
1503
+ },
1504
+ () => {
1505
+ },
1506
+ "force"
1507
+ )).node;
1508
+ const resolvedDeep = yield mapSlots(
1509
+ resolved,
1510
+ processContent,
1511
+ config
1512
+ );
1513
+ onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
1514
+ return resolvedDeep;
1515
+ });
1516
+ const processContent = (content) => __async(this, null, function* () {
1517
+ return Promise.all(content.map(resolveNode));
1518
+ });
1519
+ const processZones = () => __async(this, null, function* () {
1520
+ var _a2;
1521
+ const zones = (_a2 = data.zones) != null ? _a2 : {};
1522
+ Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
1523
+ zones[zoneKey] = yield Promise.all(content.map(resolveNode));
1524
+ }));
1525
+ return zones;
1526
+ });
1527
+ const dynamic = {
1528
+ root: yield resolveNode(defaultedData.root),
1529
+ content: yield processContent(defaultedData.content),
1530
+ zones: yield processZones()
1531
+ };
1532
+ Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
1533
+ const content = defaultedData.zones[zoneKey];
1534
+ dynamic.zones[zoneKey] = yield processContent(content);
1535
+ }), {});
1536
+ return dynamic;
1537
+ });
1538
+ }
1539
+
1540
+ // lib/transform-props.ts
1541
+ init_react_import();
1542
+ function transformProps(data, propTransforms, config = { components: {} }) {
1543
+ const mapItem = (item) => {
1544
+ if (propTransforms[item.type]) {
1545
+ return __spreadProps(__spreadValues({}, item), {
1546
+ props: __spreadValues({
1547
+ id: item.props.id
1548
+ }, propTransforms[item.type](item.props))
1549
+ });
1550
+ }
1551
+ return item;
1552
+ };
1553
+ const defaultedData = defaultData(data);
1554
+ const rootProps = defaultedData.root.props || defaultedData.root;
1555
+ let newRoot = __spreadValues({}, defaultedData.root);
1556
+ if (propTransforms["root"]) {
1557
+ newRoot.props = propTransforms["root"](rootProps);
1558
+ }
1559
+ const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
1560
+ const updatedData = walkTree(
1561
+ dataWithUpdatedRoot,
1562
+ config,
1563
+ (content) => content.map(mapItem)
1564
+ );
1565
+ if (!defaultedData.root.props) {
1566
+ updatedData.root = updatedData.root.props;
1567
+ }
1568
+ return updatedData;
1569
+ }
1570
+
1571
+ // lib/migrate.ts
1572
+ init_react_import();
1573
+
1574
+ // store/default-app-state.ts
1575
+ init_react_import();
1576
+
1577
+ // components/ViewportControls/default-viewports.ts
1578
+ init_react_import();
1579
+ var defaultViewports = [
1580
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1581
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1582
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1583
+ ];
1584
+
1585
+ // store/default-app-state.ts
1586
+ var defaultAppState = {
1587
+ data: { content: [], root: {}, zones: {} },
1588
+ ui: {
1589
+ leftSideBarVisible: true,
1590
+ rightSideBarVisible: true,
1591
+ arrayState: {},
1592
+ itemSelector: null,
1593
+ componentList: {},
1594
+ isDragging: false,
1595
+ previewMode: "edit",
1596
+ viewports: {
1597
+ current: {
1598
+ width: defaultViewports[0].width,
1599
+ height: defaultViewports[0].height || "auto"
1600
+ },
1601
+ options: [],
1602
+ controlsVisible: true
1603
+ },
1604
+ field: { focus: null }
1605
+ },
1606
+ indexes: {
1607
+ nodes: {},
1608
+ zones: {}
1609
+ }
1610
+ };
1611
+
1612
+ // lib/migrate.ts
1613
+ var migrations = [
1614
+ // Migrate root to root.props
1615
+ (data) => {
1616
+ const rootProps = data.root.props || data.root;
1617
+ if (Object.keys(data.root).length > 0 && !data.root.props) {
1618
+ console.warn(
1619
+ "Migration applied: Root props moved from `root` to `root.props`."
1620
+ );
1621
+ return __spreadProps(__spreadValues({}, data), {
1622
+ root: {
1623
+ props: __spreadValues({}, rootProps)
1624
+ }
1625
+ });
1626
+ }
1627
+ return data;
1628
+ },
1629
+ // Migrate zones to slots
1630
+ (data, config, migrationOptions) => {
1631
+ var _a, _b;
1632
+ if (!config) return data;
1633
+ console.log("Migrating DropZones to slots...");
1634
+ const updatedItems = {};
1635
+ const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
1636
+ const { indexes } = walkAppState(appState, config);
1637
+ const deletedCompounds = [];
1638
+ walkAppState(appState, config, (content, zoneCompound, zoneType) => {
1639
+ var _a2, _b2, _c;
1640
+ if (zoneType === "dropzone") {
1641
+ const [id, slotName] = zoneCompound.split(":");
1642
+ const nodeData = indexes.nodes[id].data;
1643
+ const componentType = nodeData.type;
1644
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
1645
+ if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
1646
+ updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
1647
+ props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
1648
+ [slotName]: content
1649
+ })
1650
+ });
1651
+ deletedCompounds.push(zoneCompound);
1652
+ }
1653
+ return content;
1654
+ }
1655
+ return content;
1656
+ });
1657
+ const updated = walkAppState(
1658
+ appState,
1659
+ config,
1660
+ (content) => content,
1661
+ (item) => {
1662
+ var _a2;
1663
+ return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
1664
+ }
1665
+ );
1666
+ deletedCompounds.forEach((zoneCompound) => {
1667
+ var _a2;
1668
+ const [_, propName] = zoneCompound.split(":");
1669
+ console.log(
1670
+ `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
1671
+ );
1672
+ (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
1673
+ });
1674
+ if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
1675
+ const unmigratedZonesGrouped = {};
1676
+ Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
1677
+ var _a2;
1678
+ const [componentId, propName] = zoneCompound.split(":");
1679
+ const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
1680
+ if (!content) {
1681
+ return;
1682
+ }
1683
+ if (!unmigratedZonesGrouped[componentId]) {
1684
+ unmigratedZonesGrouped[componentId] = {};
1685
+ }
1686
+ if (!unmigratedZonesGrouped[componentId][propName]) {
1687
+ unmigratedZonesGrouped[componentId][propName] = content;
1688
+ }
1689
+ });
1690
+ Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
1691
+ updated.data = walkTree(updated.data, config, (content) => {
1692
+ return content.map((child) => {
1693
+ var _a2;
1694
+ if (child.props.id !== componentId) {
1695
+ return child;
1696
+ }
1697
+ const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
1698
+ if (!migrateFn) {
1699
+ return child;
1700
+ }
1701
+ const zones = unmigratedZonesGrouped[componentId];
1702
+ const migratedProps = migrateFn(child.props, zones);
1703
+ Object.keys(zones).forEach((propName) => {
1704
+ var _a3;
1705
+ const zoneCompound = `${componentId}:${propName}`;
1706
+ console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
1707
+ (_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
1708
+ });
1709
+ return __spreadProps(__spreadValues({}, child), {
1710
+ props: migratedProps
1711
+ });
1712
+ });
1713
+ });
1714
+ });
1715
+ }
1716
+ Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
1717
+ const [_, propName] = zoneCompound.split(":");
1718
+ throw new Error(
1719
+ `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
1720
+ );
1721
+ });
1722
+ delete updated.data.zones;
1723
+ return updated.data;
1724
+ }
1725
+ ];
1726
+ function migrate(data, config, migrationOptions) {
1727
+ return migrations == null ? void 0 : migrations.reduce(
1728
+ (acc, migration) => migration(acc, config, migrationOptions),
1729
+ data
1730
+ );
1731
+ }
1732
+
1733
+ // reducer/actions/replace.ts
1734
+ var replaceAction = (state, action, appStore) => {
1735
+ const [parentId] = action.destinationZone.split(":");
1736
+ const idsInPath = getIdsForParent(action.destinationZone, state);
1737
+ const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
1738
+ const idChanged = originalId !== action.data.props.id;
1739
+ if (idChanged) {
1740
+ throw new Error(
1741
+ `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1742
+ );
1743
+ }
1744
+ const newSlotIds = [];
1745
+ const data = walkTree(action.data, appStore.config, (contents, opts) => {
1746
+ newSlotIds.push(`${opts.parentId}:${opts.propName}`);
1747
+ return contents.map((item) => {
1748
+ const id = generateId(item.type);
1749
+ return __spreadProps(__spreadValues({}, item), {
1750
+ props: __spreadValues({ id }, item.props)
1751
+ });
1752
+ });
1753
+ });
1754
+ const stateWithDeepSlotsRemoved = __spreadValues({}, state);
1755
+ Object.keys(state.indexes.zones).forEach((zoneCompound) => {
1756
+ const id = zoneCompound.split(":")[0];
1757
+ if (id === originalId) {
1758
+ if (!newSlotIds.includes(zoneCompound)) {
1759
+ delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
1760
+ }
1761
+ }
1762
+ });
1763
+ return walkAppState(
1764
+ stateWithDeepSlotsRemoved,
1765
+ appStore.config,
1766
+ (content, zoneCompound) => {
1767
+ const newContent = [...content];
1768
+ if (zoneCompound === action.destinationZone) {
1769
+ newContent[action.destinationIndex] = data;
1770
+ }
1771
+ return newContent;
1772
+ },
1773
+ (childItem, path) => {
1774
+ const pathIds = path.map((p) => p.split(":")[0]);
1775
+ if (childItem.props.id === data.props.id) {
1776
+ return data;
1777
+ } else if (childItem.props.id === parentId) {
1778
+ return childItem;
1779
+ } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1780
+ return childItem;
1781
+ } else if (pathIds.indexOf(data.props.id) > -1) {
1782
+ return childItem;
1783
+ }
1784
+ return null;
1785
+ }
1786
+ );
1787
+ };
1788
+
1789
+ // reducer/actions/replace-root.ts
1790
+ init_react_import();
1791
+ var replaceRootAction = (state, action, appStore) => {
1792
+ return walkAppState(
1793
+ state,
1794
+ appStore.config,
1795
+ (content) => content,
1796
+ (childItem) => {
1797
+ if (childItem.props.id === "root") {
1798
+ return __spreadProps(__spreadValues({}, childItem), {
1799
+ props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1800
+ readOnly: action.root.readOnly
1801
+ });
1802
+ }
1803
+ return childItem;
1804
+ }
1805
+ );
1806
+ };
1807
+
1808
+ // reducer/actions/duplicate.ts
1809
+ init_react_import();
1810
+
1811
+ // lib/data/get-item.ts
1812
+ init_react_import();
1813
+ function getItem(selector, state) {
1814
+ var _a, _b;
1815
+ const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
1816
+ return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
1817
+ }
1818
+
1819
+ // reducer/actions/duplicate.ts
1820
+ function duplicateAction(state, action, appStore) {
1821
+ const item = getItem(
1822
+ { index: action.sourceIndex, zone: action.sourceZone },
1823
+ state
1824
+ );
1825
+ const idsInPath = getIdsForParent(action.sourceZone, state);
1826
+ const newItem = __spreadProps(__spreadValues({}, item), {
1827
+ props: __spreadProps(__spreadValues({}, item.props), {
1828
+ id: generateId(item.type)
1829
+ })
1830
+ });
1831
+ const modified = walkAppState(
1832
+ state,
1833
+ appStore.config,
1834
+ (content, zoneCompound) => {
1835
+ if (zoneCompound === action.sourceZone) {
1836
+ return insert(content, action.sourceIndex + 1, item);
1837
+ }
1838
+ return content;
1839
+ },
1840
+ (childItem, path, index) => {
1841
+ const zoneCompound = path[path.length - 1];
1842
+ const parents = path.map((p) => p.split(":")[0]);
1843
+ if (parents.indexOf(newItem.props.id) > -1) {
1844
+ return __spreadProps(__spreadValues({}, childItem), {
1845
+ props: __spreadProps(__spreadValues({}, childItem.props), {
1846
+ id: generateId(childItem.type)
1847
+ })
1848
+ });
1849
+ }
1850
+ if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1851
+ return newItem;
1852
+ }
1853
+ const [sourceZoneParent] = action.sourceZone.split(":");
1854
+ if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1855
+ return childItem;
1856
+ }
1857
+ return null;
1858
+ }
1859
+ );
1860
+ return __spreadProps(__spreadValues({}, modified), {
1861
+ ui: __spreadProps(__spreadValues({}, modified.ui), {
1862
+ itemSelector: {
1863
+ index: action.sourceIndex + 1,
1864
+ zone: action.sourceZone
1865
+ }
1866
+ })
1867
+ });
1868
+ }
1869
+
1870
+ // reducer/actions/reorder.ts
1871
+ init_react_import();
1872
+
1873
+ // reducer/actions/move.ts
1874
+ init_react_import();
1875
+
1876
+ // lib/data/remove.ts
1877
+ init_react_import();
1878
+ var remove = (list, index) => {
1879
+ const result = Array.from(list);
1880
+ result.splice(index, 1);
1881
+ return result;
1882
+ };
1883
+
1884
+ // reducer/actions/move.ts
1885
+ var moveAction = (state, action, appStore) => {
1886
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
1887
+ return state;
1888
+ }
1414
1889
  const item = getItem(
1415
1890
  { zone: action.sourceZone, index: action.sourceIndex },
1416
1891
  state
@@ -1506,21 +1981,6 @@ var removeAction = (state, action, appStore) => {
1506
1981
 
1507
1982
  // reducer/actions/register-zone.ts
1508
1983
  init_react_import();
1509
-
1510
- // lib/data/setup-zone.ts
1511
- init_react_import();
1512
- var setupZone = (data, zoneKey) => {
1513
- if (zoneKey === rootDroppableId) {
1514
- return data;
1515
- }
1516
- const newData = __spreadProps(__spreadValues({}, data), {
1517
- zones: data.zones ? __spreadValues({}, data.zones) : {}
1518
- });
1519
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1520
- return newData;
1521
- };
1522
-
1523
- // reducer/actions/register-zone.ts
1524
1984
  var zoneCache = {};
1525
1985
  function registerZoneAction(state, action) {
1526
1986
  if (zoneCache[action.zone]) {
@@ -1673,26 +2133,18 @@ function createReducer({
1673
2133
  );
1674
2134
  }
1675
2135
 
1676
- // components/ViewportControls/default-viewports.ts
1677
- init_react_import();
1678
- var defaultViewports = [
1679
- { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1680
- { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1681
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1682
- ];
1683
-
1684
2136
  // store/index.ts
1685
2137
  var import_zustand2 = require("zustand");
1686
2138
  var import_middleware2 = require("zustand/middleware");
1687
- var import_react9 = require("react");
2139
+ var import_react11 = require("react");
1688
2140
 
1689
2141
  // store/slices/history.ts
1690
2142
  init_react_import();
1691
- var import_react6 = require("react");
2143
+ var import_react8 = require("react");
1692
2144
 
1693
2145
  // lib/use-hotkey.ts
1694
2146
  init_react_import();
1695
- var import_react5 = require("react");
2147
+ var import_react7 = require("react");
1696
2148
  var import_zustand = require("zustand");
1697
2149
  var import_middleware = require("zustand/middleware");
1698
2150
  var keyCodeMap = {
@@ -1785,10 +2237,10 @@ var monitorHotkeys = (doc) => {
1785
2237
  };
1786
2238
  };
1787
2239
  var useMonitorHotkeys = () => {
1788
- (0, import_react5.useEffect)(() => monitorHotkeys(document), []);
2240
+ (0, import_react7.useEffect)(() => monitorHotkeys(document), []);
1789
2241
  };
1790
2242
  var useHotkey = (combo, cb) => {
1791
- (0, import_react5.useEffect)(
2243
+ (0, import_react7.useEffect)(
1792
2244
  () => useHotkeyStore.setState((s) => ({
1793
2245
  triggers: __spreadProps(__spreadValues({}, s.triggers), {
1794
2246
  [`${Object.keys(combo).join("+")}`]: { combo, cb }
@@ -1897,7 +2349,7 @@ function useRegisterHistorySlice(appStore, {
1897
2349
  index,
1898
2350
  initialAppState
1899
2351
  }) {
1900
- (0, import_react6.useEffect)(
2352
+ (0, import_react8.useEffect)(
1901
2353
  () => appStore.setState({
1902
2354
  history: __spreadProps(__spreadValues({}, appStore.getState().history), {
1903
2355
  histories,
@@ -1964,7 +2416,7 @@ var createNodesSlice = (set, get) => ({
1964
2416
 
1965
2417
  // store/slices/permissions.ts
1966
2418
  init_react_import();
1967
- var import_react7 = require("react");
2419
+ var import_react9 = require("react");
1968
2420
 
1969
2421
  // lib/data/flatten-data.ts
1970
2422
  init_react_import();
@@ -1982,19 +2434,6 @@ var flattenData = (state, config) => {
1982
2434
  return data;
1983
2435
  };
1984
2436
 
1985
- // lib/get-changed.ts
1986
- init_react_import();
1987
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1988
- var getChanged = (newItem, oldItem) => {
1989
- return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1990
- const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1991
- const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1992
- return __spreadProps(__spreadValues({}, acc), {
1993
- [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1994
- });
1995
- }, {}) : {};
1996
- };
1997
-
1998
2437
  // store/slices/permissions.ts
1999
2438
  var createPermissionsSlice = (set, get) => {
2000
2439
  const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
@@ -2101,7 +2540,7 @@ var createPermissionsSlice = (set, get) => {
2101
2540
  };
2102
2541
  };
2103
2542
  var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
2104
- (0, import_react7.useEffect)(() => {
2543
+ (0, import_react9.useEffect)(() => {
2105
2544
  const { permissions } = appStore.getState();
2106
2545
  const { globalPermissions: existingGlobalPermissions } = permissions;
2107
2546
  appStore.setState({
@@ -2111,7 +2550,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
2111
2550
  });
2112
2551
  permissions.resolvePermissions();
2113
2552
  }, [globalPermissions]);
2114
- (0, import_react7.useEffect)(() => {
2553
+ (0, import_react9.useEffect)(() => {
2115
2554
  return appStore.subscribe(
2116
2555
  (s) => s.state.data,
2117
2556
  () => {
@@ -2119,7 +2558,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
2119
2558
  }
2120
2559
  );
2121
2560
  }, []);
2122
- (0, import_react7.useEffect)(() => {
2561
+ (0, import_react9.useEffect)(() => {
2123
2562
  return appStore.subscribe(
2124
2563
  (s) => s.config,
2125
2564
  () => {
@@ -2131,7 +2570,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
2131
2570
 
2132
2571
  // store/slices/fields.ts
2133
2572
  init_react_import();
2134
- var import_react8 = require("react");
2573
+ var import_react10 = require("react");
2135
2574
  var createFieldsSlice = (_set, _get) => {
2136
2575
  return {
2137
2576
  fields: {},
@@ -2141,7 +2580,7 @@ var createFieldsSlice = (_set, _get) => {
2141
2580
  };
2142
2581
  };
2143
2582
  var useRegisterFieldsSlice = (appStore, id) => {
2144
- const resolveFields = (0, import_react8.useCallback)(
2583
+ const resolveFields = (0, import_react10.useCallback)(
2145
2584
  (reset) => __async(void 0, null, function* () {
2146
2585
  var _a, _b;
2147
2586
  const { fields, lastResolvedData } = appStore.getState().fields;
@@ -2183,91 +2622,29 @@ var useRegisterFieldsSlice = (appStore, id) => {
2183
2622
  return;
2184
2623
  }
2185
2624
  appStore.setState({
2186
- fields: {
2187
- fields: newFields,
2188
- loading: false,
2189
- lastResolvedData: componentData,
2190
- id
2191
- }
2192
- });
2193
- } else {
2194
- appStore.setState((s) => ({
2195
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
2196
- }));
2197
- }
2198
- }),
2199
- [id]
2200
- );
2201
- (0, import_react8.useEffect)(() => {
2202
- resolveFields(true);
2203
- return appStore.subscribe(
2204
- (s) => s.state.indexes.nodes[id || "root"],
2205
- () => resolveFields()
2206
- );
2207
- }, [id]);
2208
- };
2209
-
2210
- // lib/resolve-component-data.ts
2211
- init_react_import();
2212
- var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
2213
- var cache = { lastChange: {} };
2214
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2215
- const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
2216
- const resolvedItem = __spreadValues({}, item);
2217
- const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
2218
- const id = "id" in item.props ? item.props.id : "root";
2219
- if (shouldRunResolver) {
2220
- const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
2221
- if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
2222
- return { node: resolved, didChange: false };
2223
- }
2224
- const changed = getChanged(item, oldItem);
2225
- if (onResolveStart) {
2226
- onResolveStart(item);
2227
- }
2228
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
2229
- changed,
2230
- lastData: oldItem,
2231
- metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
2232
- trigger
2233
- });
2234
- resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
2235
- if (Object.keys(readOnly).length) {
2236
- resolvedItem.readOnly = readOnly;
2237
- }
2238
- }
2239
- let itemWithResolvedChildren = yield mapSlots(
2240
- resolvedItem,
2241
- (content) => __async(void 0, null, function* () {
2242
- return yield Promise.all(
2243
- content.map(
2244
- (childItem) => __async(void 0, null, function* () {
2245
- return (yield resolveComponentData(
2246
- childItem,
2247
- config,
2248
- metadata,
2249
- onResolveStart,
2250
- onResolveEnd,
2251
- trigger
2252
- )).node;
2253
- })
2254
- )
2255
- );
2625
+ fields: {
2626
+ fields: newFields,
2627
+ loading: false,
2628
+ lastResolvedData: componentData,
2629
+ id
2630
+ }
2631
+ });
2632
+ } else {
2633
+ appStore.setState((s) => ({
2634
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
2635
+ }));
2636
+ }
2256
2637
  }),
2257
- config
2638
+ [id]
2258
2639
  );
2259
- if (shouldRunResolver && onResolveEnd) {
2260
- onResolveEnd(resolvedItem);
2261
- }
2262
- cache.lastChange[id] = {
2263
- item,
2264
- resolved: itemWithResolvedChildren
2265
- };
2266
- return {
2267
- node: itemWithResolvedChildren,
2268
- didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
2269
- };
2270
- });
2640
+ (0, import_react10.useEffect)(() => {
2641
+ resolveFields(true);
2642
+ return appStore.subscribe(
2643
+ (s) => s.state.indexes.nodes[id || "root"],
2644
+ () => resolveFields()
2645
+ );
2646
+ }, [id]);
2647
+ };
2271
2648
 
2272
2649
  // lib/data/to-root.ts
2273
2650
  init_react_import();
@@ -2286,34 +2663,6 @@ var toRoot = (item) => {
2286
2663
  return { props: {}, readOnly };
2287
2664
  };
2288
2665
 
2289
- // store/default-app-state.ts
2290
- init_react_import();
2291
- var defaultAppState = {
2292
- data: { content: [], root: {}, zones: {} },
2293
- ui: {
2294
- leftSideBarVisible: true,
2295
- rightSideBarVisible: true,
2296
- arrayState: {},
2297
- itemSelector: null,
2298
- componentList: {},
2299
- isDragging: false,
2300
- previewMode: "edit",
2301
- viewports: {
2302
- current: {
2303
- width: defaultViewports[0].width,
2304
- height: defaultViewports[0].height || "auto"
2305
- },
2306
- options: [],
2307
- controlsVisible: true
2308
- },
2309
- field: { focus: null }
2310
- },
2311
- indexes: {
2312
- nodes: {},
2313
- zones: {}
2314
- }
2315
- };
2316
-
2317
2666
  // store/index.ts
2318
2667
  var defaultPageFields = {
2319
2668
  title: { type: "text" }
@@ -2490,23 +2839,23 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
2490
2839
  });
2491
2840
  })
2492
2841
  );
2493
- var appStoreContext = (0, import_react9.createContext)(createAppStore());
2842
+ var appStoreContext = (0, import_react11.createContext)(createAppStore());
2494
2843
  function useAppStore(selector) {
2495
- const context = (0, import_react9.useContext)(appStoreContext);
2844
+ const context = (0, import_react11.useContext)(appStoreContext);
2496
2845
  return (0, import_zustand2.useStore)(context, selector);
2497
2846
  }
2498
2847
  function useAppStoreApi() {
2499
- return (0, import_react9.useContext)(appStoreContext);
2848
+ return (0, import_react11.useContext)(appStoreContext);
2500
2849
  }
2501
2850
 
2502
2851
  // components/Sortable/index.tsx
2503
2852
  init_react_import();
2504
- var import_react12 = require("@dnd-kit/react");
2853
+ var import_react14 = require("@dnd-kit/react");
2505
2854
 
2506
2855
  // lib/dnd/use-sensors.ts
2507
2856
  init_react_import();
2508
- var import_react10 = require("react");
2509
- var import_react11 = require("@dnd-kit/react");
2857
+ var import_react12 = require("react");
2858
+ var import_react13 = require("@dnd-kit/react");
2510
2859
  var import_utilities = require("@dnd-kit/dom/utilities");
2511
2860
  var touchDefault = { delay: { value: 200, tolerance: 10 } };
2512
2861
  var otherDefault = {
@@ -2521,8 +2870,8 @@ var useSensors = ({
2521
2870
  touch: touchDefault,
2522
2871
  other: otherDefault
2523
2872
  }) => {
2524
- const [sensors] = (0, import_react10.useState)(() => [
2525
- import_react11.PointerSensor.configure({
2873
+ const [sensors] = (0, import_react12.useState)(() => [
2874
+ import_react13.PointerSensor.configure({
2526
2875
  activationConstraints(event, source) {
2527
2876
  var _a;
2528
2877
  const { pointerType, target } = event;
@@ -2857,7 +3206,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2857
3206
 
2858
3207
  // components/Sortable/index.tsx
2859
3208
  var import_sortable = require("@dnd-kit/react/sortable");
2860
- var import_jsx_runtime5 = require("react/jsx-runtime");
3209
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2861
3210
  var SortableProvider = ({
2862
3211
  children,
2863
3212
  onDragStart,
@@ -2867,8 +3216,8 @@ var SortableProvider = ({
2867
3216
  const sensors = useSensors({
2868
3217
  mouse: { distance: { value: 5 } }
2869
3218
  });
2870
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2871
- import_react12.DragDropProvider,
3219
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3220
+ import_react14.DragDropProvider,
2872
3221
  {
2873
3222
  sensors,
2874
3223
  onDragStart: (event) => {
@@ -2932,11 +3281,11 @@ var Sortable = ({
2932
3281
 
2933
3282
  // components/AutoField/context.tsx
2934
3283
  init_react_import();
2935
- var import_react13 = require("react");
2936
- var import_jsx_runtime6 = require("react/jsx-runtime");
2937
- var NestedFieldContext = (0, import_react13.createContext)({});
3284
+ var import_react15 = require("react");
3285
+ var import_jsx_runtime8 = require("react/jsx-runtime");
3286
+ var NestedFieldContext = (0, import_react15.createContext)({});
2938
3287
  var useNestedFieldContext = () => {
2939
- const context = (0, import_react13.useContext)(NestedFieldContext);
3288
+ const context = (0, import_react15.useContext)(NestedFieldContext);
2940
3289
  return __spreadProps(__spreadValues({}, context), {
2941
3290
  readOnlyFields: context.readOnlyFields || {}
2942
3291
  });
@@ -2950,7 +3299,7 @@ var NestedFieldProvider = ({
2950
3299
  }) => {
2951
3300
  const subPath = `${name}.${subName}`;
2952
3301
  const wildcardSubPath = `${wildcardName}.${subName}`;
2953
- const subReadOnlyFields = (0, import_react13.useMemo)(
3302
+ const subReadOnlyFields = (0, import_react15.useMemo)(
2954
3303
  () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
2955
3304
  const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
2956
3305
  if (isLocal) {
@@ -2966,7 +3315,7 @@ var NestedFieldProvider = ({
2966
3315
  }, {}),
2967
3316
  [name, subName, wildcardName, readOnlyFields]
2968
3317
  );
2969
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3318
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2970
3319
  NestedFieldContext.Provider,
2971
3320
  {
2972
3321
  value: { readOnlyFields: subReadOnlyFields, localName: subName },
@@ -2976,7 +3325,7 @@ var NestedFieldProvider = ({
2976
3325
  };
2977
3326
 
2978
3327
  // components/AutoField/fields/ArrayField/index.tsx
2979
- var import_jsx_runtime7 = require("react/jsx-runtime");
3328
+ var import_jsx_runtime9 = require("react/jsx-runtime");
2980
3329
  var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
2981
3330
  var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
2982
3331
  var ArrayField = ({
@@ -2988,7 +3337,7 @@ var ArrayField = ({
2988
3337
  labelIcon,
2989
3338
  readOnly,
2990
3339
  id,
2991
- Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", __spreadValues({}, props))
3340
+ Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", __spreadValues({}, props))
2992
3341
  }) => {
2993
3342
  const thisArrayState = useAppStore((s) => s.state.ui.arrayState[id]);
2994
3343
  const setUi = useAppStore((s) => s.setUi);
@@ -3003,14 +3352,14 @@ var ArrayField = ({
3003
3352
  }),
3004
3353
  openId: ""
3005
3354
  };
3006
- const [localState, setLocalState] = (0, import_react14.useState)({ arrayState, value });
3007
- (0, import_react14.useEffect)(() => {
3355
+ const [localState, setLocalState] = (0, import_react16.useState)({ arrayState, value });
3356
+ (0, import_react16.useEffect)(() => {
3008
3357
  var _a;
3009
3358
  const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
3010
3359
  setLocalState({ arrayState: _arrayState, value });
3011
3360
  }, [value]);
3012
3361
  const appStore = useAppStoreApi();
3013
- const mapArrayStateToUi = (0, import_react14.useCallback)(
3362
+ const mapArrayStateToUi = (0, import_react16.useCallback)(
3014
3363
  (partialArrayState) => {
3015
3364
  const state = appStore.getState().state;
3016
3365
  return {
@@ -3021,13 +3370,13 @@ var ArrayField = ({
3021
3370
  },
3022
3371
  [arrayState, appStore]
3023
3372
  );
3024
- const getHighestIndex = (0, import_react14.useCallback)(() => {
3373
+ const getHighestIndex = (0, import_react16.useCallback)(() => {
3025
3374
  return arrayState.items.reduce(
3026
3375
  (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
3027
3376
  -1
3028
3377
  );
3029
3378
  }, [arrayState]);
3030
- const regenerateArrayState = (0, import_react14.useCallback)(
3379
+ const regenerateArrayState = (0, import_react16.useCallback)(
3031
3380
  (value2) => {
3032
3381
  let highestIndex = getHighestIndex();
3033
3382
  const newItems = Array.from(value2 || []).map((item, idx) => {
@@ -3046,19 +3395,19 @@ var ArrayField = ({
3046
3395
  },
3047
3396
  [arrayState]
3048
3397
  );
3049
- (0, import_react14.useEffect)(() => {
3398
+ (0, import_react16.useEffect)(() => {
3050
3399
  if (arrayState.items.length > 0) {
3051
3400
  setUi(mapArrayStateToUi(arrayState));
3052
3401
  }
3053
3402
  }, []);
3054
- const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
3403
+ const [draggedItem, setDraggedItem] = (0, import_react16.useState)("");
3055
3404
  const isDraggingAny = !!draggedItem;
3056
3405
  const canEdit = useAppStore(
3057
3406
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
3058
3407
  );
3059
3408
  const forceReadOnly = !canEdit;
3060
- const valueRef = (0, import_react14.useRef)(value);
3061
- const uniqifyItem = (0, import_react14.useCallback)(
3409
+ const valueRef = (0, import_react16.useRef)(value);
3410
+ const uniqifyItem = (0, import_react16.useCallback)(
3062
3411
  (val) => {
3063
3412
  if (field.type !== "array" || !field.arrayFields) return;
3064
3413
  const config = appStore.getState().config;
@@ -3075,14 +3424,14 @@ var ArrayField = ({
3075
3424
  return null;
3076
3425
  }
3077
3426
  const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
3078
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3427
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3079
3428
  Label2,
3080
3429
  {
3081
3430
  label: label || name,
3082
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
3431
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(List, { size: 16 }),
3083
3432
  el: "div",
3084
3433
  readOnly,
3085
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3434
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3086
3435
  SortableProvider,
3087
3436
  {
3088
3437
  onDragStart: (id2) => setDraggedItem(id2),
@@ -3113,7 +3462,7 @@ var ArrayField = ({
3113
3462
  });
3114
3463
  valueRef.current = newValue;
3115
3464
  },
3116
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3465
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3117
3466
  "div",
3118
3467
  {
3119
3468
  className: getClassName5({
@@ -3121,16 +3470,16 @@ var ArrayField = ({
3121
3470
  addDisabled
3122
3471
  }),
3123
3472
  children: [
3124
- localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
3473
+ localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
3125
3474
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
3126
3475
  const data = Array.from(localState.value || [])[i] || {};
3127
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3476
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3128
3477
  Sortable,
3129
3478
  {
3130
3479
  id: _arrayId,
3131
3480
  index: i,
3132
3481
  disabled: readOnly,
3133
- children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3482
+ children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3134
3483
  "div",
3135
3484
  {
3136
3485
  ref,
@@ -3140,7 +3489,7 @@ var ArrayField = ({
3140
3489
  readOnly
3141
3490
  }),
3142
3491
  children: [
3143
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3492
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3144
3493
  "div",
3145
3494
  {
3146
3495
  ref: handleRef,
@@ -3165,9 +3514,9 @@ var ArrayField = ({
3165
3514
  className: getClassNameItem("summary"),
3166
3515
  children: [
3167
3516
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
3168
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
3169
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
3170
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3517
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("rhs"), children: [
3518
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("actions"), children: [
3519
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3171
3520
  IconButton,
3172
3521
  {
3173
3522
  type: "button",
@@ -3186,10 +3535,10 @@ var ArrayField = ({
3186
3535
  onChange(existingValue);
3187
3536
  },
3188
3537
  title: "Duplicate",
3189
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
3538
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Copy, { size: 16 })
3190
3539
  }
3191
3540
  ) }),
3192
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3541
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3193
3542
  IconButton,
3194
3543
  {
3195
3544
  type: "button",
@@ -3211,16 +3560,16 @@ var ArrayField = ({
3211
3560
  onChange(existingValue);
3212
3561
  },
3213
3562
  title: "Delete",
3214
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
3563
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Trash, { size: 16 })
3215
3564
  }
3216
3565
  ) })
3217
3566
  ] }),
3218
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
3567
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DragIcon, {}) })
3219
3568
  ] })
3220
3569
  ]
3221
3570
  }
3222
3571
  ),
3223
- /* @__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((subName) => {
3572
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
3224
3573
  const subField = field.arrayFields[subName];
3225
3574
  const indexName = `${name}[${i}]`;
3226
3575
  const subPath = `${indexName}.${subName}`;
@@ -3230,14 +3579,14 @@ var ArrayField = ({
3230
3579
  const localWildcardSubPath = `${localWildcardName}.${subName}`;
3231
3580
  const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
3232
3581
  const label2 = subField.label || subName;
3233
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3582
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3234
3583
  NestedFieldProvider,
3235
3584
  {
3236
3585
  name: localIndexName,
3237
3586
  wildcardName: localWildcardName,
3238
3587
  subName,
3239
3588
  readOnlyFields,
3240
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3589
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3241
3590
  AutoFieldPrivate,
3242
3591
  {
3243
3592
  name: subPath,
@@ -3270,7 +3619,7 @@ var ArrayField = ({
3270
3619
  _arrayId
3271
3620
  );
3272
3621
  }) }),
3273
- !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3622
+ !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3274
3623
  "button",
3275
3624
  {
3276
3625
  type: "button",
@@ -3288,7 +3637,7 @@ var ArrayField = ({
3288
3637
  setUi(mapArrayStateToUi(newArrayState), false);
3289
3638
  onChange(newValue);
3290
3639
  },
3291
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
3640
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Plus, { size: 21 })
3292
3641
  }
3293
3642
  )
3294
3643
  ]
@@ -3302,7 +3651,7 @@ var ArrayField = ({
3302
3651
 
3303
3652
  // components/AutoField/fields/DefaultField/index.tsx
3304
3653
  init_react_import();
3305
- var import_jsx_runtime8 = require("react/jsx-runtime");
3654
+ var import_jsx_runtime10 = require("react/jsx-runtime");
3306
3655
  var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
3307
3656
  var DefaultField = ({
3308
3657
  field,
@@ -3316,16 +3665,16 @@ var DefaultField = ({
3316
3665
  id
3317
3666
  }) => {
3318
3667
  const value = _value;
3319
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3668
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3320
3669
  Label2,
3321
3670
  {
3322
3671
  label: label || name,
3323
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3324
- field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Type, { size: 16 }),
3325
- field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hash, { size: 16 })
3672
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
3673
+ field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Type, { size: 16 }),
3674
+ field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Hash, { size: 16 })
3326
3675
  ] }),
3327
3676
  readOnly,
3328
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3677
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3329
3678
  "input",
3330
3679
  {
3331
3680
  className: getClassName6("input"),
@@ -3363,11 +3712,11 @@ var DefaultField = ({
3363
3712
 
3364
3713
  // components/AutoField/fields/ExternalField/index.tsx
3365
3714
  init_react_import();
3366
- var import_react18 = require("react");
3715
+ var import_react20 = require("react");
3367
3716
 
3368
3717
  // components/ExternalInput/index.tsx
3369
3718
  init_react_import();
3370
- var import_react17 = require("react");
3719
+ var import_react19 = require("react");
3371
3720
 
3372
3721
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
3373
3722
  init_react_import();
@@ -3375,7 +3724,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
3375
3724
 
3376
3725
  // components/Modal/index.tsx
3377
3726
  init_react_import();
3378
- var import_react15 = require("react");
3727
+ var import_react17 = require("react");
3379
3728
 
3380
3729
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
3381
3730
  init_react_import();
@@ -3383,22 +3732,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
3383
3732
 
3384
3733
  // components/Modal/index.tsx
3385
3734
  var import_react_dom = require("react-dom");
3386
- var import_jsx_runtime9 = require("react/jsx-runtime");
3735
+ var import_jsx_runtime11 = require("react/jsx-runtime");
3387
3736
  var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
3388
3737
  var Modal = ({
3389
3738
  children,
3390
3739
  onClose,
3391
3740
  isOpen
3392
3741
  }) => {
3393
- const [rootEl, setRootEl] = (0, import_react15.useState)(null);
3394
- (0, import_react15.useEffect)(() => {
3742
+ const [rootEl, setRootEl] = (0, import_react17.useState)(null);
3743
+ (0, import_react17.useEffect)(() => {
3395
3744
  setRootEl(document.getElementById("puck-portal-root"));
3396
3745
  }, []);
3397
3746
  if (!rootEl) {
3398
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {});
3747
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {});
3399
3748
  }
3400
3749
  return (0, import_react_dom.createPortal)(
3401
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3750
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3402
3751
  "div",
3403
3752
  {
3404
3753
  className: getClassName7("inner"),
@@ -3418,11 +3767,11 @@ init_react_import();
3418
3767
  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" };
3419
3768
 
3420
3769
  // components/Heading/index.tsx
3421
- var import_jsx_runtime10 = require("react/jsx-runtime");
3770
+ var import_jsx_runtime12 = require("react/jsx-runtime");
3422
3771
  var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
3423
3772
  var Heading = ({ children, rank, size = "m" }) => {
3424
3773
  const Tag = rank ? `h${rank}` : "span";
3425
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3774
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3426
3775
  Tag,
3427
3776
  {
3428
3777
  className: getClassName8({
@@ -3438,7 +3787,7 @@ init_react_import();
3438
3787
 
3439
3788
  // components/Button/Button.tsx
3440
3789
  init_react_import();
3441
- var import_react16 = require("react");
3790
+ var import_react18 = require("react");
3442
3791
 
3443
3792
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
3444
3793
  init_react_import();
@@ -3458,7 +3807,7 @@ var filterDataAttrs = (props) => {
3458
3807
  };
3459
3808
 
3460
3809
  // components/Button/Button.tsx
3461
- var import_jsx_runtime11 = require("react/jsx-runtime");
3810
+ var import_jsx_runtime13 = require("react/jsx-runtime");
3462
3811
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
3463
3812
  var Button = (_a) => {
3464
3813
  var _b = _a, {
@@ -3488,11 +3837,11 @@ var Button = (_a) => {
3488
3837
  "size",
3489
3838
  "loading"
3490
3839
  ]);
3491
- const [loading, setLoading] = (0, import_react16.useState)(loadingProp);
3492
- (0, import_react16.useEffect)(() => setLoading(loadingProp), [loadingProp]);
3840
+ const [loading, setLoading] = (0, import_react18.useState)(loadingProp);
3841
+ (0, import_react18.useEffect)(() => setLoading(loadingProp), [loadingProp]);
3493
3842
  const ElementType = href ? "a" : type ? "button" : "span";
3494
3843
  const dataAttrs = filterDataAttrs(props);
3495
- const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
3844
+ const el = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
3496
3845
  ElementType,
3497
3846
  __spreadProps(__spreadValues({
3498
3847
  className: getClassName9({
@@ -3517,9 +3866,9 @@ var Button = (_a) => {
3517
3866
  href
3518
3867
  }, dataAttrs), {
3519
3868
  children: [
3520
- icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("icon"), children: icon }),
3869
+ icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName9("icon"), children: icon }),
3521
3870
  children,
3522
- loading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Loader, { size: 14 }) })
3871
+ loading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 14 }) })
3523
3872
  ]
3524
3873
  })
3525
3874
  );
@@ -3527,7 +3876,7 @@ var Button = (_a) => {
3527
3876
  };
3528
3877
 
3529
3878
  // components/ExternalInput/index.tsx
3530
- var import_jsx_runtime12 = require("react/jsx-runtime");
3879
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3531
3880
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
3532
3881
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
3533
3882
  var dataCache = {};
@@ -3544,28 +3893,28 @@ var ExternalInput = ({
3544
3893
  mapRow = (val) => val,
3545
3894
  filterFields
3546
3895
  } = field || {};
3547
- const [data, setData] = (0, import_react17.useState)([]);
3548
- const [isOpen, setOpen] = (0, import_react17.useState)(false);
3549
- const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
3896
+ const [data, setData] = (0, import_react19.useState)([]);
3897
+ const [isOpen, setOpen] = (0, import_react19.useState)(false);
3898
+ const [isLoading, setIsLoading] = (0, import_react19.useState)(true);
3550
3899
  const hasFilterFields = !!filterFields;
3551
- const [filters, setFilters] = (0, import_react17.useState)(field.initialFilters || {});
3552
- const [filtersToggled, setFiltersToggled] = (0, import_react17.useState)(hasFilterFields);
3553
- const mappedData = (0, import_react17.useMemo)(() => {
3900
+ const [filters, setFilters] = (0, import_react19.useState)(field.initialFilters || {});
3901
+ const [filtersToggled, setFiltersToggled] = (0, import_react19.useState)(hasFilterFields);
3902
+ const mappedData = (0, import_react19.useMemo)(() => {
3554
3903
  return data.map(mapRow);
3555
3904
  }, [data]);
3556
- const keys = (0, import_react17.useMemo)(() => {
3905
+ const keys = (0, import_react19.useMemo)(() => {
3557
3906
  const validKeys = /* @__PURE__ */ new Set();
3558
3907
  for (const item of mappedData) {
3559
3908
  for (const key of Object.keys(item)) {
3560
- if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react17.isValidElement)(item[key])) {
3909
+ if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react19.isValidElement)(item[key])) {
3561
3910
  validKeys.add(key);
3562
3911
  }
3563
3912
  }
3564
3913
  }
3565
3914
  return Array.from(validKeys);
3566
3915
  }, [mappedData]);
3567
- const [searchQuery, setSearchQuery] = (0, import_react17.useState)(field.initialQuery || "");
3568
- const search = (0, import_react17.useCallback)(
3916
+ const [searchQuery, setSearchQuery] = (0, import_react19.useState)(field.initialQuery || "");
3917
+ const search = (0, import_react19.useCallback)(
3569
3918
  (query, filters2) => __async(void 0, null, function* () {
3570
3919
  setIsLoading(true);
3571
3920
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
@@ -3578,18 +3927,18 @@ var ExternalInput = ({
3578
3927
  }),
3579
3928
  [id, field]
3580
3929
  );
3581
- const Footer = (0, import_react17.useCallback)(
3582
- (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
3930
+ const Footer = (0, import_react19.useCallback)(
3931
+ (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: getClassNameModal("footer"), children: [
3583
3932
  props.items.length,
3584
3933
  " result",
3585
3934
  props.items.length === 1 ? "" : "s"
3586
3935
  ] }),
3587
3936
  [field.renderFooter]
3588
3937
  );
3589
- (0, import_react17.useEffect)(() => {
3938
+ (0, import_react19.useEffect)(() => {
3590
3939
  search(searchQuery, filters);
3591
3940
  }, []);
3592
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3941
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3593
3942
  "div",
3594
3943
  {
3595
3944
  className: getClassName10({
@@ -3599,21 +3948,21 @@ var ExternalInput = ({
3599
3948
  }),
3600
3949
  id,
3601
3950
  children: [
3602
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("actions"), children: [
3603
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3951
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassName10("actions"), children: [
3952
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3604
3953
  "button",
3605
3954
  {
3606
3955
  type: "button",
3607
3956
  onClick: () => setOpen(true),
3608
3957
  className: getClassName10("button"),
3609
3958
  disabled: readOnly,
3610
- children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
3611
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Link, { size: "16" }),
3612
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: field.placeholder })
3959
+ children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
3960
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link, { size: "16" }),
3961
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: field.placeholder })
3613
3962
  ] })
3614
3963
  }
3615
3964
  ),
3616
- value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3965
+ value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3617
3966
  "button",
3618
3967
  {
3619
3968
  type: "button",
@@ -3622,11 +3971,11 @@ var ExternalInput = ({
3622
3971
  onChange(null);
3623
3972
  },
3624
3973
  disabled: readOnly,
3625
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LockOpen, { size: 16 })
3974
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LockOpen, { size: 16 })
3626
3975
  }
3627
3976
  )
3628
3977
  ] }),
3629
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3978
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3630
3979
  "form",
3631
3980
  {
3632
3981
  className: getClassNameModal({
@@ -3640,11 +3989,11 @@ var ExternalInput = ({
3640
3989
  search(searchQuery, filters);
3641
3990
  },
3642
3991
  children: [
3643
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
3644
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: getClassNameModal("search"), children: [
3645
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
3646
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Search, { size: "18" }) }),
3647
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3992
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
3993
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: getClassNameModal("search"), children: [
3994
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
3995
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Search, { size: "18" }) }),
3996
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3648
3997
  "input",
3649
3998
  {
3650
3999
  className: getClassNameModal("searchInput"),
@@ -3659,9 +4008,9 @@ var ExternalInput = ({
3659
4008
  }
3660
4009
  )
3661
4010
  ] }),
3662
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
3663
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
3664
- hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4011
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
4012
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
4013
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3665
4014
  IconButton,
3666
4015
  {
3667
4016
  type: "button",
@@ -3671,19 +4020,19 @@ var ExternalInput = ({
3671
4020
  e.stopPropagation();
3672
4021
  setFiltersToggled(!filtersToggled);
3673
4022
  },
3674
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SlidersHorizontal, { size: 20 })
4023
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SlidersHorizontal, { size: 20 })
3675
4024
  }
3676
4025
  ) })
3677
4026
  ] })
3678
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
3679
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("grid"), children: [
3680
- hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
4027
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
4028
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("grid"), children: [
4029
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
3681
4030
  const filterField = filterFields[fieldName];
3682
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4031
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3683
4032
  "div",
3684
4033
  {
3685
4034
  className: getClassNameModal("field"),
3686
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4035
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3687
4036
  AutoFieldPrivate,
3688
4037
  {
3689
4038
  field: filterField,
@@ -3704,9 +4053,9 @@ var ExternalInput = ({
3704
4053
  fieldName
3705
4054
  );
3706
4055
  }) }),
3707
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
3708
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { className: getClassNameModal("table"), children: [
3709
- /* @__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)(
4056
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
4057
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("table", { className: getClassNameModal("table"), children: [
4058
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3710
4059
  "th",
3711
4060
  {
3712
4061
  className: getClassNameModal("th"),
@@ -3715,8 +4064,8 @@ var ExternalInput = ({
3715
4064
  },
3716
4065
  key
3717
4066
  )) }) }),
3718
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
3719
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4067
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
4068
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3720
4069
  "tr",
3721
4070
  {
3722
4071
  style: { whiteSpace: "nowrap" },
@@ -3725,16 +4074,16 @@ var ExternalInput = ({
3725
4074
  onChange(mapProp(data[i]));
3726
4075
  setOpen(false);
3727
4076
  },
3728
- children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
4077
+ children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
3729
4078
  },
3730
4079
  i
3731
4080
  );
3732
4081
  }) })
3733
4082
  ] }),
3734
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 24 }) })
4083
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader, { size: 24 }) })
3735
4084
  ] })
3736
4085
  ] }),
3737
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Footer, { items: mappedData }) })
4086
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Footer, { items: mappedData }) })
3738
4087
  ]
3739
4088
  }
3740
4089
  ) })
@@ -3744,7 +4093,7 @@ var ExternalInput = ({
3744
4093
  };
3745
4094
 
3746
4095
  // components/AutoField/fields/ExternalField/index.tsx
3747
- var import_jsx_runtime13 = require("react/jsx-runtime");
4096
+ var import_jsx_runtime15 = require("react/jsx-runtime");
3748
4097
  var ExternalField = ({
3749
4098
  field,
3750
4099
  onChange,
@@ -3759,7 +4108,7 @@ var ExternalField = ({
3759
4108
  var _a, _b, _c;
3760
4109
  const validField = field;
3761
4110
  const deprecatedField = field;
3762
- (0, import_react18.useEffect)(() => {
4111
+ (0, import_react20.useEffect)(() => {
3763
4112
  if (deprecatedField.adaptor) {
3764
4113
  console.error(
3765
4114
  "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."
@@ -3769,13 +4118,13 @@ var ExternalField = ({
3769
4118
  if (field.type !== "external") {
3770
4119
  return null;
3771
4120
  }
3772
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
4121
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3773
4122
  Label2,
3774
4123
  {
3775
4124
  label: label || name,
3776
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: 16 }),
4125
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Link, { size: 16 }),
3777
4126
  el: "div",
3778
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
4127
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3779
4128
  ExternalInput,
3780
4129
  {
3781
4130
  name,
@@ -3802,7 +4151,7 @@ var ExternalField = ({
3802
4151
 
3803
4152
  // components/AutoField/fields/RadioField/index.tsx
3804
4153
  init_react_import();
3805
- var import_react19 = require("react");
4154
+ var import_react21 = require("react");
3806
4155
 
3807
4156
  // lib/safe-json-parse.ts
3808
4157
  init_react_import();
@@ -3816,7 +4165,7 @@ var safeJsonParse = (str) => {
3816
4165
  };
3817
4166
 
3818
4167
  // components/AutoField/fields/RadioField/index.tsx
3819
- var import_jsx_runtime14 = require("react/jsx-runtime");
4168
+ var import_jsx_runtime16 = require("react/jsx-runtime");
3820
4169
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
3821
4170
  var RadioField = ({
3822
4171
  field,
@@ -3829,26 +4178,26 @@ var RadioField = ({
3829
4178
  labelIcon,
3830
4179
  Label: Label2
3831
4180
  }) => {
3832
- const flatOptions = (0, import_react19.useMemo)(
4181
+ const flatOptions = (0, import_react21.useMemo)(
3833
4182
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
3834
4183
  [field]
3835
4184
  );
3836
4185
  if (field.type !== "radio" || !field.options) {
3837
4186
  return null;
3838
4187
  }
3839
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
4188
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3840
4189
  Label2,
3841
4190
  {
3842
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
4191
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CircleCheckBig, { size: 16 }),
3843
4192
  label: label || name,
3844
4193
  readOnly,
3845
4194
  el: "div",
3846
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
4195
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3847
4196
  "label",
3848
4197
  {
3849
4198
  className: getClassName11("radio"),
3850
4199
  children: [
3851
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
4200
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3852
4201
  "input",
3853
4202
  {
3854
4203
  type: "radio",
@@ -3868,7 +4217,7 @@ var RadioField = ({
3868
4217
  checked: value === option.value
3869
4218
  }
3870
4219
  ),
3871
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
4220
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
3872
4221
  ]
3873
4222
  },
3874
4223
  option.label + option.value
@@ -3879,8 +4228,8 @@ var RadioField = ({
3879
4228
 
3880
4229
  // components/AutoField/fields/SelectField/index.tsx
3881
4230
  init_react_import();
3882
- var import_react20 = require("react");
3883
- var import_jsx_runtime15 = require("react/jsx-runtime");
4231
+ var import_react22 = require("react");
4232
+ var import_jsx_runtime17 = require("react/jsx-runtime");
3884
4233
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
3885
4234
  var SelectField = ({
3886
4235
  field,
@@ -3893,20 +4242,20 @@ var SelectField = ({
3893
4242
  readOnly,
3894
4243
  id
3895
4244
  }) => {
3896
- const flatOptions = (0, import_react20.useMemo)(
4245
+ const flatOptions = (0, import_react22.useMemo)(
3897
4246
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
3898
4247
  [field]
3899
4248
  );
3900
4249
  if (field.type !== "select" || !field.options) {
3901
4250
  return null;
3902
4251
  }
3903
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4252
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3904
4253
  Label2,
3905
4254
  {
3906
4255
  label: label || name,
3907
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
4256
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChevronDown, { size: 16 }),
3908
4257
  readOnly,
3909
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4258
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3910
4259
  "select",
3911
4260
  {
3912
4261
  id,
@@ -3923,7 +4272,7 @@ var SelectField = ({
3923
4272
  }
3924
4273
  },
3925
4274
  value,
3926
- children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4275
+ children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3927
4276
  "option",
3928
4277
  {
3929
4278
  label: option.label,
@@ -3939,7 +4288,7 @@ var SelectField = ({
3939
4288
 
3940
4289
  // components/AutoField/fields/TextareaField/index.tsx
3941
4290
  init_react_import();
3942
- var import_jsx_runtime16 = require("react/jsx-runtime");
4291
+ var import_jsx_runtime18 = require("react/jsx-runtime");
3943
4292
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
3944
4293
  var TextareaField = ({
3945
4294
  field,
@@ -3952,13 +4301,13 @@ var TextareaField = ({
3952
4301
  Label: Label2,
3953
4302
  id
3954
4303
  }) => {
3955
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4304
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3956
4305
  Label2,
3957
4306
  {
3958
4307
  label: label || name,
3959
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Type, { size: 16 }),
4308
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Type, { size: 16 }),
3960
4309
  readOnly,
3961
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4310
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3962
4311
  "textarea",
3963
4312
  {
3964
4313
  id,
@@ -3985,7 +4334,7 @@ init_react_import();
3985
4334
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
3986
4335
 
3987
4336
  // components/AutoField/fields/ObjectField/index.tsx
3988
- var import_jsx_runtime17 = require("react/jsx-runtime");
4337
+ var import_jsx_runtime19 = require("react/jsx-runtime");
3989
4338
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
3990
4339
  var ObjectField = ({
3991
4340
  field,
@@ -4003,25 +4352,25 @@ var ObjectField = ({
4003
4352
  return null;
4004
4353
  }
4005
4354
  const data = value || {};
4006
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4355
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4007
4356
  Label2,
4008
4357
  {
4009
4358
  label: label || name,
4010
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
4359
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EllipsisVertical, { size: 16 }),
4011
4360
  el: "div",
4012
4361
  readOnly,
4013
- 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((subName) => {
4362
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
4014
4363
  const subField = field.objectFields[subName];
4015
4364
  const subPath = `${localName}.${subName}`;
4016
4365
  const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
4017
4366
  const label2 = subField.label || subName;
4018
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4367
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4019
4368
  NestedFieldProvider,
4020
4369
  {
4021
4370
  name: localName || id,
4022
4371
  subName,
4023
4372
  readOnlyFields,
4024
- children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4373
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4025
4374
  AutoFieldPrivate,
4026
4375
  {
4027
4376
  name: subPath,
@@ -4053,17 +4402,17 @@ var ObjectField = ({
4053
4402
 
4054
4403
  // lib/use-safe-id.ts
4055
4404
  init_react_import();
4056
- var import_react21 = __toESM(require("react"));
4405
+ var import_react23 = __toESM(require("react"));
4057
4406
  var useSafeId = () => {
4058
- if (typeof import_react21.default.useId !== "undefined") {
4059
- return import_react21.default.useId();
4407
+ if (typeof import_react23.default.useId !== "undefined") {
4408
+ return import_react23.default.useId();
4060
4409
  }
4061
- const [id] = (0, import_react21.useState)(generateId());
4410
+ const [id] = (0, import_react23.useState)(generateId());
4062
4411
  return id;
4063
4412
  };
4064
4413
 
4065
4414
  // components/AutoField/index.tsx
4066
- var import_jsx_runtime18 = require("react/jsx-runtime");
4415
+ var import_jsx_runtime20 = require("react/jsx-runtime");
4067
4416
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
4068
4417
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
4069
4418
  var FieldLabel = ({
@@ -4075,11 +4424,11 @@ var FieldLabel = ({
4075
4424
  className
4076
4425
  }) => {
4077
4426
  const El = el;
4078
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(El, { className, children: [
4079
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: getClassName15("label"), children: [
4080
- icon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {}),
4427
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(El, { className, children: [
4428
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassName15("label"), children: [
4429
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, {}),
4081
4430
  label,
4082
- readOnly && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Lock, { size: "12" }) })
4431
+ readOnly && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Lock, { size: "12" }) })
4083
4432
  ] }),
4084
4433
  children
4085
4434
  ] });
@@ -4092,14 +4441,14 @@ var FieldLabelInternal = ({
4092
4441
  readOnly
4093
4442
  }) => {
4094
4443
  const overrides = useAppStore((s) => s.overrides);
4095
- const Wrapper = (0, import_react22.useMemo)(
4444
+ const Wrapper = (0, import_react24.useMemo)(
4096
4445
  () => overrides.fieldLabel || FieldLabel,
4097
4446
  [overrides]
4098
4447
  );
4099
4448
  if (!label) {
4100
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
4449
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
4101
4450
  }
4102
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4451
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4103
4452
  Wrapper,
4104
4453
  {
4105
4454
  label,
@@ -4119,7 +4468,7 @@ function AutoFieldInternal(props) {
4119
4468
  var _a2;
4120
4469
  return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
4121
4470
  });
4122
- const nestedFieldContext = (0, import_react22.useContext)(NestedFieldContext);
4471
+ const nestedFieldContext = (0, import_react24.useContext)(NestedFieldContext);
4123
4472
  const { id, Label: Label2 = FieldLabelInternal } = props;
4124
4473
  const field = props.field;
4125
4474
  const label = field.label;
@@ -4153,7 +4502,7 @@ function AutoFieldInternal(props) {
4153
4502
  Label: Label2,
4154
4503
  id: resolvedId
4155
4504
  });
4156
- const onFocus = (0, import_react22.useCallback)(
4505
+ const onFocus = (0, import_react24.useCallback)(
4157
4506
  (e) => {
4158
4507
  if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
4159
4508
  e.stopPropagation();
@@ -4167,7 +4516,7 @@ function AutoFieldInternal(props) {
4167
4516
  },
4168
4517
  [mergedProps.name]
4169
4518
  );
4170
- const onBlur = (0, import_react22.useCallback)((e) => {
4519
+ const onBlur = (0, import_react24.useCallback)((e) => {
4171
4520
  if ("name" in e.target) {
4172
4521
  dispatch({
4173
4522
  type: "setUi",
@@ -4195,14 +4544,14 @@ function AutoFieldInternal(props) {
4195
4544
  children = defaultFields[field.type](mergedProps);
4196
4545
  FieldComponent = render[field.type];
4197
4546
  }
4198
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4547
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4199
4548
  NestedFieldContext.Provider,
4200
4549
  {
4201
4550
  value: {
4202
4551
  readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
4203
4552
  localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
4204
4553
  },
4205
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4554
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4206
4555
  "div",
4207
4556
  {
4208
4557
  className: getClassNameWrapper(),
@@ -4211,7 +4560,7 @@ function AutoFieldInternal(props) {
4211
4560
  onClick: (e) => {
4212
4561
  e.stopPropagation();
4213
4562
  },
4214
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
4563
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
4215
4564
  }
4216
4565
  )
4217
4566
  }
@@ -4220,20 +4569,20 @@ function AutoFieldInternal(props) {
4220
4569
  function AutoFieldPrivate(props) {
4221
4570
  const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
4222
4571
  const { value, onChange } = props;
4223
- const [localValue, setLocalValue] = (0, import_react22.useState)(value);
4224
- const onChangeLocal = (0, import_react22.useCallback)(
4572
+ const [localValue, setLocalValue] = (0, import_react24.useState)(value);
4573
+ const onChangeLocal = (0, import_react24.useCallback)(
4225
4574
  (val, ui) => {
4226
4575
  setLocalValue(val);
4227
4576
  onChange(val, ui);
4228
4577
  },
4229
4578
  [onChange]
4230
4579
  );
4231
- (0, import_react22.useEffect)(() => {
4580
+ (0, import_react24.useEffect)(() => {
4232
4581
  if (!isFocused) {
4233
4582
  setLocalValue(value);
4234
4583
  }
4235
4584
  }, [value]);
4236
- (0, import_react22.useEffect)(() => {
4585
+ (0, import_react24.useEffect)(() => {
4237
4586
  if (!isFocused) {
4238
4587
  if (value !== localValue) {
4239
4588
  setLocalValue(value);
@@ -4244,11 +4593,11 @@ function AutoFieldPrivate(props) {
4244
4593
  value: localValue,
4245
4594
  onChange: onChangeLocal
4246
4595
  };
4247
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
4596
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
4248
4597
  }
4249
4598
  function AutoField(props) {
4250
- const DefaultLabel = (0, import_react22.useMemo)(() => {
4251
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4599
+ const DefaultLabel = (0, import_react24.useMemo)(() => {
4600
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4252
4601
  "div",
4253
4602
  __spreadProps(__spreadValues({}, labelProps), {
4254
4603
  className: getClassName15({ readOnly: props.readOnly })
@@ -4259,7 +4608,7 @@ function AutoField(props) {
4259
4608
  if (props.field.type === "slot") {
4260
4609
  return null;
4261
4610
  }
4262
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
4611
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
4263
4612
  }
4264
4613
 
4265
4614
  // components/Drawer/index.tsx
@@ -4284,7 +4633,7 @@ var import_react35 = require("react");
4284
4633
 
4285
4634
  // components/DraggableComponent/index.tsx
4286
4635
  init_react_import();
4287
- var import_react26 = require("react");
4636
+ var import_react28 = require("react");
4288
4637
 
4289
4638
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4290
4639
  init_react_import();
@@ -4314,11 +4663,11 @@ function getDeepScrollPosition(element) {
4314
4663
 
4315
4664
  // components/DropZone/context.tsx
4316
4665
  init_react_import();
4317
- var import_react23 = require("react");
4666
+ var import_react25 = require("react");
4318
4667
  var import_zustand3 = require("zustand");
4319
- var import_jsx_runtime19 = require("react/jsx-runtime");
4320
- var dropZoneContext = (0, import_react23.createContext)(null);
4321
- var ZoneStoreContext = (0, import_react23.createContext)(
4668
+ var import_jsx_runtime21 = require("react/jsx-runtime");
4669
+ var dropZoneContext = (0, import_react25.createContext)(null);
4670
+ var ZoneStoreContext = (0, import_react25.createContext)(
4322
4671
  (0, import_zustand3.createStore)(() => ({
4323
4672
  zoneDepthIndex: {},
4324
4673
  nextZoneDepthIndex: {},
@@ -4334,14 +4683,14 @@ var ZoneStoreProvider = ({
4334
4683
  children,
4335
4684
  store
4336
4685
  }) => {
4337
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ZoneStoreContext.Provider, { value: store, children });
4686
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ZoneStoreContext.Provider, { value: store, children });
4338
4687
  };
4339
4688
  var DropZoneProvider = ({
4340
4689
  children,
4341
4690
  value
4342
4691
  }) => {
4343
4692
  const dispatch = useAppStore((s) => s.dispatch);
4344
- const registerZone = (0, import_react23.useCallback)(
4693
+ const registerZone = (0, import_react25.useCallback)(
4345
4694
  (zoneCompound) => {
4346
4695
  dispatch({
4347
4696
  type: "registerZone",
@@ -4350,23 +4699,13 @@ var DropZoneProvider = ({
4350
4699
  },
4351
4700
  [dispatch]
4352
4701
  );
4353
- const unregisterZone = (0, import_react23.useCallback)(
4354
- (zoneCompound) => {
4355
- dispatch({
4356
- type: "unregisterZone",
4357
- zone: zoneCompound
4358
- });
4359
- },
4360
- [dispatch]
4361
- );
4362
- const memoValue = (0, import_react23.useMemo)(
4702
+ const memoValue = (0, import_react25.useMemo)(
4363
4703
  () => __spreadValues({
4364
- registerZone,
4365
- unregisterZone
4704
+ registerZone
4366
4705
  }, value),
4367
4706
  [value]
4368
4707
  );
4369
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4708
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4370
4709
  };
4371
4710
 
4372
4711
  // components/DraggableComponent/index.tsx
@@ -4390,11 +4729,11 @@ function accumulateTransform(el) {
4390
4729
 
4391
4730
  // lib/use-context-store.ts
4392
4731
  init_react_import();
4393
- var import_react24 = require("react");
4732
+ var import_react26 = require("react");
4394
4733
  var import_zustand4 = require("zustand");
4395
4734
  var import_shallow = require("zustand/react/shallow");
4396
4735
  function useContextStore(context, selector) {
4397
- const store = (0, import_react24.useContext)(context);
4736
+ const store = (0, import_react26.useContext)(context);
4398
4737
  if (!store) {
4399
4738
  throw new Error("useContextStore must be used inside context");
4400
4739
  }
@@ -4403,10 +4742,10 @@ function useContextStore(context, selector) {
4403
4742
 
4404
4743
  // lib/dnd/use-on-drag-finished.ts
4405
4744
  init_react_import();
4406
- var import_react25 = require("react");
4745
+ var import_react27 = require("react");
4407
4746
  var useOnDragFinished = (cb, deps = []) => {
4408
4747
  const appStore = useAppStoreApi();
4409
- return (0, import_react25.useCallback)(() => {
4748
+ return (0, import_react27.useCallback)(() => {
4410
4749
  let dispose = () => {
4411
4750
  };
4412
4751
  const processDragging = (isDragging2) => {
@@ -4434,7 +4773,7 @@ var useOnDragFinished = (cb, deps = []) => {
4434
4773
  };
4435
4774
 
4436
4775
  // components/DraggableComponent/index.tsx
4437
- var import_jsx_runtime20 = require("react/jsx-runtime");
4776
+ var import_jsx_runtime22 = require("react/jsx-runtime");
4438
4777
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
4439
4778
  var DEBUG2 = false;
4440
4779
  var space = 8;
@@ -4445,12 +4784,12 @@ var DefaultActionBar = ({
4445
4784
  label,
4446
4785
  children,
4447
4786
  parentAction
4448
- }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar, { children: [
4449
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar.Group, { children: [
4787
+ }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ActionBar, { children: [
4788
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ActionBar.Group, { children: [
4450
4789
  parentAction,
4451
- label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Label, { label })
4790
+ label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Label, { label })
4452
4791
  ] }),
4453
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
4792
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Group, { children })
4454
4793
  ] });
4455
4794
  var DraggableComponent = ({
4456
4795
  children,
@@ -4476,9 +4815,9 @@ var DraggableComponent = ({
4476
4815
  const overrides = useAppStore((s) => s.overrides);
4477
4816
  const dispatch = useAppStore((s) => s.dispatch);
4478
4817
  const iframe = useAppStore((s) => s.iframe);
4479
- const ctx = (0, import_react26.useContext)(dropZoneContext);
4480
- const [localZones, setLocalZones] = (0, import_react26.useState)({});
4481
- const registerLocalZone = (0, import_react26.useCallback)(
4818
+ const ctx = (0, import_react28.useContext)(dropZoneContext);
4819
+ const [localZones, setLocalZones] = (0, import_react28.useState)({});
4820
+ const registerLocalZone = (0, import_react28.useCallback)(
4482
4821
  (zoneCompound2, active) => {
4483
4822
  var _a;
4484
4823
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4488,7 +4827,7 @@ var DraggableComponent = ({
4488
4827
  },
4489
4828
  [setLocalZones]
4490
4829
  );
4491
- const unregisterLocalZone = (0, import_react26.useCallback)(
4830
+ const unregisterLocalZone = (0, import_react28.useCallback)(
4492
4831
  (zoneCompound2) => {
4493
4832
  var _a;
4494
4833
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4511,9 +4850,9 @@ var DraggableComponent = ({
4511
4850
  return s.permissions.getPermissions({ item });
4512
4851
  })
4513
4852
  );
4514
- const zoneStore = (0, import_react26.useContext)(ZoneStoreContext);
4515
- const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
4516
- const dynamicCollisionDetector = (0, import_react26.useMemo)(
4853
+ const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
4854
+ const [dragAxis, setDragAxis] = (0, import_react28.useState)(userDragAxis || autoDragAxis);
4855
+ const dynamicCollisionDetector = (0, import_react28.useMemo)(
4517
4856
  () => createDynamicCollisionDetector(dragAxis),
4518
4857
  [dragAxis]
4519
4858
  );
@@ -4545,7 +4884,7 @@ var DraggableComponent = ({
4545
4884
  },
4546
4885
  feedback: "clone"
4547
4886
  });
4548
- (0, import_react26.useEffect)(() => {
4887
+ (0, import_react28.useEffect)(() => {
4549
4888
  const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
4550
4889
  sortable.droppable.disabled = !isEnabled;
4551
4890
  sortable.draggable.disabled = !permissions.drag;
@@ -4562,8 +4901,8 @@ var DraggableComponent = ({
4562
4901
  }
4563
4902
  return cleanup;
4564
4903
  }, [permissions.drag, zoneCompound]);
4565
- const ref = (0, import_react26.useRef)(null);
4566
- const refSetter = (0, import_react26.useCallback)(
4904
+ const ref = (0, import_react28.useRef)(null);
4905
+ const refSetter = (0, import_react28.useCallback)(
4567
4906
  (el) => {
4568
4907
  sortableRef(el);
4569
4908
  if (el) {
@@ -4572,14 +4911,14 @@ var DraggableComponent = ({
4572
4911
  },
4573
4912
  [sortableRef]
4574
4913
  );
4575
- const [portalEl, setPortalEl] = (0, import_react26.useState)();
4576
- (0, import_react26.useEffect)(() => {
4914
+ const [portalEl, setPortalEl] = (0, import_react28.useState)();
4915
+ (0, import_react28.useEffect)(() => {
4577
4916
  var _a, _b, _c;
4578
4917
  setPortalEl(
4579
4918
  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
4580
4919
  );
4581
4920
  }, [iframe.enabled, ref.current]);
4582
- const getStyle = (0, import_react26.useCallback)(() => {
4921
+ const getStyle = (0, import_react28.useCallback)(() => {
4583
4922
  var _a, _b, _c;
4584
4923
  if (!ref.current) return;
4585
4924
  const rect = ref.current.getBoundingClientRect();
@@ -4604,11 +4943,11 @@ var DraggableComponent = ({
4604
4943
  };
4605
4944
  return style2;
4606
4945
  }, [ref.current]);
4607
- const [style, setStyle] = (0, import_react26.useState)();
4608
- const sync = (0, import_react26.useCallback)(() => {
4946
+ const [style, setStyle] = (0, import_react28.useState)();
4947
+ const sync = (0, import_react28.useCallback)(() => {
4609
4948
  setStyle(getStyle());
4610
4949
  }, [ref.current, iframe]);
4611
- (0, import_react26.useEffect)(() => {
4950
+ (0, import_react28.useEffect)(() => {
4612
4951
  if (ref.current) {
4613
4952
  const observer = new ResizeObserver(sync);
4614
4953
  observer.observe(ref.current);
@@ -4618,13 +4957,13 @@ var DraggableComponent = ({
4618
4957
  }
4619
4958
  }, [ref.current]);
4620
4959
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4621
- const hideOverlay = (0, import_react26.useCallback)(() => {
4960
+ const hideOverlay = (0, import_react28.useCallback)(() => {
4622
4961
  setIsVisible(false);
4623
4962
  }, []);
4624
- const showOverlay = (0, import_react26.useCallback)(() => {
4963
+ const showOverlay = (0, import_react28.useCallback)(() => {
4625
4964
  setIsVisible(true);
4626
4965
  }, []);
4627
- (0, import_react26.useEffect)(() => {
4966
+ (0, import_react28.useEffect)(() => {
4628
4967
  var _a;
4629
4968
  registerNode(id, {
4630
4969
  methods: { sync, showOverlay, hideOverlay },
@@ -4641,11 +4980,11 @@ var DraggableComponent = ({
4641
4980
  });
4642
4981
  };
4643
4982
  }, [id, zoneCompound, index, componentType, sync]);
4644
- const CustomActionBar = (0, import_react26.useMemo)(
4983
+ const CustomActionBar = (0, import_react28.useMemo)(
4645
4984
  () => overrides.actionBar || DefaultActionBar,
4646
4985
  [overrides.actionBar]
4647
4986
  );
4648
- const onClick = (0, import_react26.useCallback)(
4987
+ const onClick = (0, import_react28.useCallback)(
4649
4988
  (e) => {
4650
4989
  e.stopPropagation();
4651
4990
  dispatch({
@@ -4658,7 +4997,7 @@ var DraggableComponent = ({
4658
4997
  [index, zoneCompound, id]
4659
4998
  );
4660
4999
  const appStore = useAppStoreApi();
4661
- const onSelectParent = (0, import_react26.useCallback)(() => {
5000
+ const onSelectParent = (0, import_react28.useCallback)(() => {
4662
5001
  const { nodes, zones } = appStore.getState().state.indexes;
4663
5002
  const node = nodes[id];
4664
5003
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4679,26 +5018,26 @@ var DraggableComponent = ({
4679
5018
  }
4680
5019
  });
4681
5020
  }, [ctx, path]);
4682
- const onDuplicate = (0, import_react26.useCallback)(() => {
5021
+ const onDuplicate = (0, import_react28.useCallback)(() => {
4683
5022
  dispatch({
4684
5023
  type: "duplicate",
4685
5024
  sourceIndex: index,
4686
5025
  sourceZone: zoneCompound
4687
5026
  });
4688
5027
  }, [index, zoneCompound]);
4689
- const onDelete = (0, import_react26.useCallback)(() => {
5028
+ const onDelete = (0, import_react28.useCallback)(() => {
4690
5029
  dispatch({
4691
5030
  type: "remove",
4692
5031
  index,
4693
5032
  zone: zoneCompound
4694
5033
  });
4695
5034
  }, [index, zoneCompound]);
4696
- const [hover, setHover] = (0, import_react26.useState)(false);
5035
+ const [hover, setHover] = (0, import_react28.useState)(false);
4697
5036
  const indicativeHover = useContextStore(
4698
5037
  ZoneStoreContext,
4699
5038
  (s) => s.hoveringComponent === id
4700
5039
  );
4701
- (0, import_react26.useEffect)(() => {
5040
+ (0, import_react28.useEffect)(() => {
4702
5041
  if (!ref.current) {
4703
5042
  return;
4704
5043
  }
@@ -4742,10 +5081,10 @@ var DraggableComponent = ({
4742
5081
  thisIsDragging,
4743
5082
  inDroppableZone
4744
5083
  ]);
4745
- const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
4746
- const [dragFinished, setDragFinished] = (0, import_react26.useState)(true);
4747
- const [_, startTransition] = (0, import_react26.useTransition)();
4748
- (0, import_react26.useEffect)(() => {
5084
+ const [isVisible, setIsVisible] = (0, import_react28.useState)(false);
5085
+ const [dragFinished, setDragFinished] = (0, import_react28.useState)(true);
5086
+ const [_, startTransition] = (0, import_react28.useTransition)();
5087
+ (0, import_react28.useEffect)(() => {
4749
5088
  startTransition(() => {
4750
5089
  if (hover || indicativeHover || isSelected) {
4751
5090
  sync();
@@ -4756,7 +5095,7 @@ var DraggableComponent = ({
4756
5095
  }
4757
5096
  });
4758
5097
  }, [hover, indicativeHover, isSelected, iframe]);
4759
- const [thisWasDragging, setThisWasDragging] = (0, import_react26.useState)(false);
5098
+ const [thisWasDragging, setThisWasDragging] = (0, import_react28.useState)(false);
4760
5099
  const onDragFinished = useOnDragFinished((finished) => {
4761
5100
  if (finished) {
4762
5101
  startTransition(() => {
@@ -4767,15 +5106,15 @@ var DraggableComponent = ({
4767
5106
  setDragFinished(false);
4768
5107
  }
4769
5108
  });
4770
- (0, import_react26.useEffect)(() => {
5109
+ (0, import_react28.useEffect)(() => {
4771
5110
  if (thisIsDragging) {
4772
5111
  setThisWasDragging(true);
4773
5112
  }
4774
5113
  }, [thisIsDragging]);
4775
- (0, import_react26.useEffect)(() => {
5114
+ (0, import_react28.useEffect)(() => {
4776
5115
  if (thisWasDragging) return onDragFinished();
4777
5116
  }, [thisWasDragging, onDragFinished]);
4778
- const syncActionsPosition = (0, import_react26.useCallback)(
5117
+ const syncActionsPosition = (0, import_react28.useCallback)(
4779
5118
  (el) => {
4780
5119
  if (el) {
4781
5120
  const view = el.ownerDocument.defaultView;
@@ -4800,7 +5139,7 @@ var DraggableComponent = ({
4800
5139
  },
4801
5140
  [zoom]
4802
5141
  );
4803
- (0, import_react26.useEffect)(() => {
5142
+ (0, import_react28.useEffect)(() => {
4804
5143
  if (userDragAxis) {
4805
5144
  setDragAxis(userDragAxis);
4806
5145
  return;
@@ -4814,11 +5153,11 @@ var DraggableComponent = ({
4814
5153
  }
4815
5154
  setDragAxis(autoDragAxis);
4816
5155
  }, [ref, userDragAxis, autoDragAxis]);
4817
- const parentAction = (0, import_react26.useMemo)(
4818
- () => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) }),
5156
+ const parentAction = (0, import_react28.useMemo)(
5157
+ () => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CornerLeftUp, { size: 16 }) }),
4819
5158
  [ctx == null ? void 0 : ctx.areaId]
4820
5159
  );
4821
- const nextContextValue = (0, import_react26.useMemo)(
5160
+ const nextContextValue = (0, import_react28.useMemo)(
4822
5161
  () => __spreadProps(__spreadValues({}, ctx), {
4823
5162
  areaId: id,
4824
5163
  zoneCompound,
@@ -4837,9 +5176,9 @@ var DraggableComponent = ({
4837
5176
  unregisterLocalZone
4838
5177
  ]
4839
5178
  );
4840
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
5179
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
4841
5180
  dragFinished && isVisible && (0, import_react_dom2.createPortal)(
4842
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
5181
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
4843
5182
  "div",
4844
5183
  {
4845
5184
  className: getClassName16({
@@ -4851,15 +5190,15 @@ var DraggableComponent = ({
4851
5190
  "data-puck-overlay": true,
4852
5191
  children: [
4853
5192
  debug,
4854
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
4855
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
5193
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Loader, {}) }),
5194
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4856
5195
  "div",
4857
5196
  {
4858
5197
  className: getClassName16("actionsOverlay"),
4859
5198
  style: {
4860
5199
  top: actionsOverlayTop / zoom
4861
5200
  },
4862
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
5201
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4863
5202
  "div",
4864
5203
  {
4865
5204
  className: getClassName16("actions"),
@@ -4871,14 +5210,14 @@ var DraggableComponent = ({
4871
5210
  paddingRight: actionsSide
4872
5211
  },
4873
5212
  ref: syncActionsPosition,
4874
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
5213
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
4875
5214
  CustomActionBar,
4876
5215
  {
4877
5216
  parentAction,
4878
5217
  label: DEBUG2 ? id : label,
4879
5218
  children: [
4880
- permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
4881
- permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
5219
+ permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Copy, { size: 16 }) }),
5220
+ permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Trash, { size: 16 }) })
4882
5221
  ]
4883
5222
  }
4884
5223
  )
@@ -4886,7 +5225,7 @@ var DraggableComponent = ({
4886
5225
  )
4887
5226
  }
4888
5227
  ),
4889
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
5228
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassName16("overlay") })
4890
5229
  ]
4891
5230
  }
4892
5231
  ),
@@ -4905,7 +5244,7 @@ var import_react36 = require("@dnd-kit/react");
4905
5244
 
4906
5245
  // components/DropZone/lib/use-min-empty-height.ts
4907
5246
  init_react_import();
4908
- var import_react27 = require("react");
5247
+ var import_react29 = require("react");
4909
5248
  var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
4910
5249
  var useMinEmptyHeight = ({
4911
5250
  zoneCompound,
@@ -4913,8 +5252,8 @@ var useMinEmptyHeight = ({
4913
5252
  ref
4914
5253
  }) => {
4915
5254
  const appStore = useAppStoreApi();
4916
- const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
4917
- const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
5255
+ const [prevHeight, setPrevHeight] = (0, import_react29.useState)(0);
5256
+ const [isAnimating, setIsAnimating] = (0, import_react29.useState)(false);
4918
5257
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
4919
5258
  var _a, _b;
4920
5259
  return {
@@ -4922,7 +5261,7 @@ var useMinEmptyHeight = ({
4922
5261
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4923
5262
  };
4924
5263
  });
4925
- const numItems = (0, import_react27.useRef)(0);
5264
+ const numItems = (0, import_react29.useRef)(0);
4926
5265
  const onDragFinished = useOnDragFinished(
4927
5266
  (finished) => {
4928
5267
  var _a;
@@ -4957,7 +5296,7 @@ var useMinEmptyHeight = ({
4957
5296
  },
4958
5297
  [appStore, prevHeight, zoneCompound]
4959
5298
  );
4960
- (0, import_react27.useEffect)(() => {
5299
+ (0, import_react29.useEffect)(() => {
4961
5300
  if (draggedItem && ref.current) {
4962
5301
  if (isZone) {
4963
5302
  const rect = ref.current.getBoundingClientRect();
@@ -4988,15 +5327,15 @@ function assignRefs(refs, node) {
4988
5327
 
4989
5328
  // components/DropZone/lib/use-content-with-preview.ts
4990
5329
  init_react_import();
4991
- var import_react30 = require("react");
5330
+ var import_react32 = require("react");
4992
5331
 
4993
5332
  // lib/dnd/use-rendered-callback.ts
4994
5333
  init_react_import();
4995
- var import_react28 = require("@dnd-kit/react");
4996
- var import_react29 = require("react");
5334
+ var import_react30 = require("@dnd-kit/react");
5335
+ var import_react31 = require("react");
4997
5336
  function useRenderedCallback(callback, deps) {
4998
- const manager = (0, import_react28.useDragDropManager)();
4999
- return (0, import_react29.useCallback)(
5337
+ const manager = (0, import_react30.useDragDropManager)();
5338
+ return (0, import_react31.useCallback)(
5000
5339
  (...args) => __async(this, null, function* () {
5001
5340
  yield manager == null ? void 0 : manager.renderer.rendering;
5002
5341
  return callback(...args);
@@ -5007,14 +5346,14 @@ function useRenderedCallback(callback, deps) {
5007
5346
 
5008
5347
  // components/DropZone/lib/use-content-with-preview.ts
5009
5348
  var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5010
- const zoneStore = (0, import_react30.useContext)(ZoneStoreContext);
5349
+ const zoneStore = (0, import_react32.useContext)(ZoneStoreContext);
5011
5350
  const preview = useContextStore(
5012
5351
  ZoneStoreContext,
5013
5352
  (s) => s.previewIndex[zoneCompound]
5014
5353
  );
5015
5354
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
5016
- const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
5017
- const [localPreview, setLocalPreview] = (0, import_react30.useState)(
5355
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react32.useState)(contentIds);
5356
+ const [localPreview, setLocalPreview] = (0, import_react32.useState)(
5018
5357
  preview
5019
5358
  );
5020
5359
  const updateContent = useRenderedCallback(
@@ -5049,7 +5388,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5049
5388
  },
5050
5389
  []
5051
5390
  );
5052
- (0, import_react30.useEffect)(() => {
5391
+ (0, import_react32.useEffect)(() => {
5053
5392
  var _a;
5054
5393
  const s = zoneStore.getState();
5055
5394
  const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
@@ -5067,16 +5406,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5067
5406
 
5068
5407
  // components/DropZone/lib/use-drag-axis.ts
5069
5408
  init_react_import();
5070
- var import_react31 = require("react");
5409
+ var import_react33 = require("react");
5071
5410
  var GRID_DRAG_AXIS = "dynamic";
5072
5411
  var FLEX_ROW_DRAG_AXIS = "x";
5073
5412
  var DEFAULT_DRAG_AXIS = "y";
5074
5413
  var useDragAxis = (ref, collisionAxis) => {
5075
5414
  const status = useAppStore((s) => s.status);
5076
- const [dragAxis, setDragAxis] = (0, import_react31.useState)(
5415
+ const [dragAxis, setDragAxis] = (0, import_react33.useState)(
5077
5416
  collisionAxis || DEFAULT_DRAG_AXIS
5078
5417
  );
5079
- const calculateDragAxis = (0, import_react31.useCallback)(() => {
5418
+ const calculateDragAxis = (0, import_react33.useCallback)(() => {
5080
5419
  if (ref.current) {
5081
5420
  const computedStyle = window.getComputedStyle(ref.current);
5082
5421
  if (computedStyle.display === "grid") {
@@ -5088,7 +5427,7 @@ var useDragAxis = (ref, collisionAxis) => {
5088
5427
  }
5089
5428
  }
5090
5429
  }, [ref.current]);
5091
- (0, import_react31.useEffect)(() => {
5430
+ (0, import_react33.useEffect)(() => {
5092
5431
  const onViewportChange = () => {
5093
5432
  calculateDragAxis();
5094
5433
  };
@@ -5097,145 +5436,20 @@ var useDragAxis = (ref, collisionAxis) => {
5097
5436
  window.removeEventListener("viewportchange", onViewportChange);
5098
5437
  };
5099
5438
  }, []);
5100
- (0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
5101
- return [dragAxis, calculateDragAxis];
5102
- };
5103
-
5104
- // components/DropZone/index.tsx
5105
- var import_shallow4 = require("zustand/react/shallow");
5106
-
5107
- // components/Render/index.tsx
5108
- init_react_import();
5109
-
5110
- // lib/use-slots.tsx
5111
- init_react_import();
5112
- var import_react32 = require("react");
5113
- function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5114
- const slotProps = (0, import_react32.useMemo)(() => {
5115
- const mapped = mapSlots(
5116
- item,
5117
- (content, _parentId, propName, field, propPath) => {
5118
- const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
5119
- const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
5120
- const render = isReadOnly ? renderSlotRender : renderSlotEdit;
5121
- const Slot = (dzProps) => render(__spreadProps(__spreadValues({
5122
- allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
5123
- disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
5124
- }, dzProps), {
5125
- zone: propName,
5126
- content
5127
- }));
5128
- return Slot;
5129
- },
5130
- config
5131
- ).props;
5132
- return mapped;
5133
- }, [config, item, readOnly, forceReadOnly]);
5134
- const mergedProps = (0, import_react32.useMemo)(
5135
- () => __spreadValues(__spreadValues({}, item.props), slotProps),
5136
- [item.props, slotProps]
5137
- );
5138
- return mergedProps;
5139
- }
5140
-
5141
- // components/Render/index.tsx
5142
- var import_react34 = __toESM(require("react"));
5143
-
5144
- // components/SlotRender/index.tsx
5145
- init_react_import();
5146
- var import_shallow3 = require("zustand/react/shallow");
5147
-
5148
- // components/SlotRender/server.tsx
5149
- init_react_import();
5150
- var import_react33 = require("react");
5151
-
5152
- // components/ServerRender/index.tsx
5153
- init_react_import();
5154
- var import_jsx_runtime21 = require("react/jsx-runtime");
5155
- function DropZoneRender({
5156
- zone,
5157
- data,
5158
- areaId = "root",
5159
- config,
5160
- metadata = {}
5161
- }) {
5162
- let zoneCompound = rootDroppableId;
5163
- let content = (data == null ? void 0 : data.content) || [];
5164
- if (!data || !config) {
5165
- return null;
5166
- }
5167
- if (areaId !== rootAreaId && zone !== rootZone) {
5168
- zoneCompound = `${areaId}:${zone}`;
5169
- content = setupZone(data, zoneCompound).zones[zoneCompound];
5170
- }
5171
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
5172
- const Component = config.components[item.type];
5173
- const props = __spreadProps(__spreadValues({}, item.props), {
5174
- puck: {
5175
- renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
5176
- DropZoneRender,
5177
- {
5178
- zone: zone2,
5179
- data,
5180
- areaId: item.props.id,
5181
- config,
5182
- metadata
5183
- }
5184
- ),
5185
- metadata,
5186
- dragRef: null,
5187
- isEditing: false
5188
- }
5189
- });
5190
- const renderItem = __spreadProps(__spreadValues({}, item), { props });
5191
- const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
5192
- if (Component) {
5193
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
5194
- }
5195
- return null;
5196
- }) });
5197
- }
5198
-
5199
- // components/SlotRender/server.tsx
5200
- var import_jsx_runtime22 = require("react/jsx-runtime");
5201
- var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
5202
- var Item = ({
5203
- config,
5204
- item,
5205
- metadata
5206
- }) => {
5207
- const Component = config.components[item.type];
5208
- const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5209
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5210
- Component.render,
5211
- __spreadProps(__spreadValues({}, props), {
5212
- puck: __spreadProps(__spreadValues({}, props.puck), {
5213
- renderDropZone: DropZoneRender,
5214
- metadata: metadata || {}
5215
- })
5216
- })
5217
- );
5439
+ (0, import_react33.useEffect)(calculateDragAxis, [status, collisionAxis]);
5440
+ return [dragAxis, calculateDragAxis];
5218
5441
  };
5219
- var SlotRender = (0, import_react33.forwardRef)(
5220
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5221
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
5222
- if (!config.components[item.type]) {
5223
- return null;
5224
- }
5225
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5226
- Item,
5227
- {
5228
- config,
5229
- item,
5230
- metadata
5231
- },
5232
- item.props.id
5233
- );
5234
- }) });
5235
- }
5236
- );
5442
+
5443
+ // components/DropZone/index.tsx
5444
+ var import_shallow4 = require("zustand/react/shallow");
5445
+
5446
+ // components/Render/index.tsx
5447
+ init_react_import();
5448
+ var import_react34 = __toESM(require("react"));
5237
5449
 
5238
5450
  // components/SlotRender/index.tsx
5451
+ init_react_import();
5452
+ var import_shallow3 = require("zustand/react/shallow");
5239
5453
  var import_jsx_runtime23 = require("react/jsx-runtime");
5240
5454
  var ContextSlotRender = ({
5241
5455
  componentId,
@@ -5269,7 +5483,7 @@ var renderContext = import_react34.default.createContext({
5269
5483
  data: { root: {}, content: [] },
5270
5484
  metadata: {}
5271
5485
  });
5272
- function Render({
5486
+ function Render2({
5273
5487
  config,
5274
5488
  data,
5275
5489
  metadata = {}
@@ -5361,7 +5575,8 @@ var DropZoneChild = ({
5361
5575
  return {
5362
5576
  type: preview.componentType,
5363
5577
  props: preview.props,
5364
- previewType: preview.type
5578
+ previewType: preview.type,
5579
+ element: preview.element
5365
5580
  };
5366
5581
  }
5367
5582
  return null;
@@ -5394,6 +5609,12 @@ var DropZoneChild = ({
5394
5609
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5395
5610
  const renderPreview = (0, import_react35.useMemo)(
5396
5611
  () => function Preview3() {
5612
+ if (item && "element" in item && item.element) {
5613
+ return (
5614
+ // Safe to use this since the HTML is set by the user
5615
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
5616
+ );
5617
+ }
5397
5618
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5398
5619
  },
5399
5620
  [componentId, label, overrides]
@@ -5423,14 +5644,14 @@ var DropZoneChild = ({
5423
5644
  isLoading
5424
5645
  );
5425
5646
  if (!item) return;
5426
- let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
5647
+ let Render3 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
5427
5648
  "No configuration for ",
5428
5649
  item.type
5429
5650
  ] });
5430
5651
  let componentType = item.type;
5431
5652
  const isInserting = "previewType" in item ? item.previewType === "insert" : false;
5432
5653
  if (isInserting) {
5433
- Render2 = renderPreview;
5654
+ Render3 = renderPreview;
5434
5655
  }
5435
5656
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5436
5657
  DraggableComponent,
@@ -5447,13 +5668,13 @@ var DropZoneChild = ({
5447
5668
  userDragAxis: collisionAxis,
5448
5669
  inDroppableZone,
5449
5670
  children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5450
- Render2,
5671
+ Render3,
5451
5672
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5452
5673
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
5453
5674
  dragRef
5454
5675
  })
5455
5676
  })
5456
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
5677
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render3, __spreadValues({}, defaultedPropsWithSlots)) })
5457
5678
  }
5458
5679
  );
5459
5680
  };
@@ -5469,6 +5690,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5469
5690
  collisionAxis
5470
5691
  }, userRef) {
5471
5692
  const ctx = (0, import_react35.useContext)(dropZoneContext);
5693
+ const appStoreApi = useAppStoreApi();
5472
5694
  const {
5473
5695
  // These all need setting via context
5474
5696
  areaId,
@@ -5510,13 +5732,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5510
5732
  if (ctx == null ? void 0 : ctx.registerZone) {
5511
5733
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5512
5734
  }
5513
- return () => {
5514
- if (ctx == null ? void 0 : ctx.unregisterZone) {
5515
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
5516
- }
5517
- };
5518
5735
  }
5519
- }, [zoneType]);
5736
+ }, [zoneType, appStoreApi]);
5520
5737
  (0, import_react35.useEffect)(() => {
5521
5738
  if (zoneType === "dropzone") {
5522
5739
  if (zoneCompound !== rootDroppableId) {
@@ -5688,11 +5905,6 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
5688
5905
  if (ctx == null ? void 0 : ctx.registerZone) {
5689
5906
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5690
5907
  }
5691
- return () => {
5692
- if (ctx == null ? void 0 : ctx.unregisterZone) {
5693
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
5694
- }
5695
- };
5696
5908
  }
5697
5909
  }, [content]);
5698
5910
  if (!data || !config) {
@@ -5953,6 +6165,7 @@ var findDeepestCandidate = (position, manager) => {
5953
6165
  });
5954
6166
  filteredCandidates.reverse();
5955
6167
  const primaryCandidate = filteredCandidates[0];
6168
+ if (!primaryCandidate) return { zone: null, area: null };
5956
6169
  const primaryCandidateData = primaryCandidate.data;
5957
6170
  const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
5958
6171
  const zone = getZoneId2(primaryCandidate);
@@ -6357,6 +6570,7 @@ var DragDropContextClient = ({
6357
6570
  type: "insert",
6358
6571
  index: targetIndex,
6359
6572
  zone: targetZone,
6573
+ element: source.element,
6360
6574
  props: {
6361
6575
  id: source.id.toString()
6362
6576
  }
@@ -6382,7 +6596,8 @@ var DragDropContextClient = ({
6382
6596
  type: "move",
6383
6597
  index: targetIndex,
6384
6598
  zone: targetZone,
6385
- props: item.props
6599
+ props: item.props,
6600
+ element: source.element
6386
6601
  }
6387
6602
  }
6388
6603
  });
@@ -6412,7 +6627,8 @@ var DragDropContextClient = ({
6412
6627
  type: "move",
6413
6628
  index: sourceData.index,
6414
6629
  zone: sourceData.zone,
6415
- props: item.props
6630
+ props: item.props,
6631
+ element: source.element
6416
6632
  }
6417
6633
  }
6418
6634
  });
@@ -7367,7 +7583,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
7367
7583
  editMode: true,
7368
7584
  children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7369
7585
  })
7370
- ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config });
7586
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render2, { data: renderData, config, metadata });
7371
7587
  (0, import_react46.useEffect)(() => {
7372
7588
  if (!iframe.enabled) {
7373
7589
  setStatus("READY");
@@ -8252,8 +8468,7 @@ var generateUsePuck = (store) => {
8252
8468
  return { zone: zoneCompound, index };
8253
8469
  }
8254
8470
  };
8255
- const get = () => storeData;
8256
- return __spreadProps(__spreadValues({}, storeData), { get });
8471
+ return storeData;
8257
8472
  };
8258
8473
  var UsePuckStoreContext = (0, import_react54.createContext)(
8259
8474
  null
@@ -8824,230 +9039,6 @@ Puck.Components = Components;
8824
9039
  Puck.Fields = Fields;
8825
9040
  Puck.Outline = Outline;
8826
9041
  Puck.Preview = Preview2;
8827
-
8828
- // lib/migrate.ts
8829
- init_react_import();
8830
- var migrations = [
8831
- // Migrate root to root.props
8832
- (data) => {
8833
- const rootProps = data.root.props || data.root;
8834
- if (Object.keys(data.root).length > 0 && !data.root.props) {
8835
- console.warn(
8836
- "Migration applied: Root props moved from `root` to `root.props`."
8837
- );
8838
- return __spreadProps(__spreadValues({}, data), {
8839
- root: {
8840
- props: __spreadValues({}, rootProps)
8841
- }
8842
- });
8843
- }
8844
- return data;
8845
- },
8846
- // Migrate zones to slots
8847
- (data, config, migrationOptions) => {
8848
- var _a, _b;
8849
- if (!config) return data;
8850
- console.log("Migrating DropZones to slots...");
8851
- const updatedItems = {};
8852
- const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
8853
- const { indexes } = walkAppState(appState, config);
8854
- const deletedCompounds = [];
8855
- walkAppState(appState, config, (content, zoneCompound, zoneType) => {
8856
- var _a2, _b2, _c;
8857
- if (zoneType === "dropzone") {
8858
- const [id, slotName] = zoneCompound.split(":");
8859
- const nodeData = indexes.nodes[id].data;
8860
- const componentType = nodeData.type;
8861
- const configForComponent = id === "root" ? config.root : config.components[componentType];
8862
- if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
8863
- updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8864
- props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
8865
- [slotName]: content
8866
- })
8867
- });
8868
- deletedCompounds.push(zoneCompound);
8869
- }
8870
- return content;
8871
- }
8872
- return content;
8873
- });
8874
- const updated = walkAppState(
8875
- appState,
8876
- config,
8877
- (content) => content,
8878
- (item) => {
8879
- var _a2;
8880
- return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
8881
- }
8882
- );
8883
- deletedCompounds.forEach((zoneCompound) => {
8884
- var _a2;
8885
- const [_, propName] = zoneCompound.split(":");
8886
- console.log(
8887
- `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
8888
- );
8889
- (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
8890
- });
8891
- if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
8892
- const unmigratedZonesGrouped = {};
8893
- Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
8894
- var _a2;
8895
- const [componentId, propName] = zoneCompound.split(":");
8896
- const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
8897
- if (!content) {
8898
- return;
8899
- }
8900
- if (!unmigratedZonesGrouped[componentId]) {
8901
- unmigratedZonesGrouped[componentId] = {};
8902
- }
8903
- if (!unmigratedZonesGrouped[componentId][propName]) {
8904
- unmigratedZonesGrouped[componentId][propName] = content;
8905
- }
8906
- });
8907
- Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
8908
- updated.data = walkTree(updated.data, config, (content) => {
8909
- return content.map((child) => {
8910
- var _a2;
8911
- if (child.props.id !== componentId) {
8912
- return child;
8913
- }
8914
- const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
8915
- if (!migrateFn) {
8916
- return child;
8917
- }
8918
- const zones = unmigratedZonesGrouped[componentId];
8919
- const migratedProps = migrateFn(child.props, zones);
8920
- Object.keys(zones).forEach((propName) => {
8921
- var _a3;
8922
- const zoneCompound = `${componentId}:${propName}`;
8923
- console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
8924
- (_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
8925
- });
8926
- return __spreadProps(__spreadValues({}, child), {
8927
- props: migratedProps
8928
- });
8929
- });
8930
- });
8931
- });
8932
- }
8933
- Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
8934
- const [_, propName] = zoneCompound.split(":");
8935
- throw new Error(
8936
- `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
8937
- );
8938
- });
8939
- delete updated.data.zones;
8940
- return updated.data;
8941
- }
8942
- ];
8943
- function migrate(data, config, migrationOptions) {
8944
- return migrations == null ? void 0 : migrations.reduce(
8945
- (acc, migration) => migration(acc, config, migrationOptions),
8946
- data
8947
- );
8948
- }
8949
-
8950
- // lib/transform-props.ts
8951
- init_react_import();
8952
-
8953
- // lib/data/default-data.ts
8954
- init_react_import();
8955
- var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
8956
- root: data.root || {},
8957
- content: data.content || []
8958
- });
8959
-
8960
- // lib/transform-props.ts
8961
- function transformProps(data, propTransforms, config = { components: {} }) {
8962
- const mapItem = (item) => {
8963
- if (propTransforms[item.type]) {
8964
- return __spreadProps(__spreadValues({}, item), {
8965
- props: __spreadValues({
8966
- id: item.props.id
8967
- }, propTransforms[item.type](item.props))
8968
- });
8969
- }
8970
- return item;
8971
- };
8972
- const defaultedData = defaultData(data);
8973
- const rootProps = defaultedData.root.props || defaultedData.root;
8974
- let newRoot = __spreadValues({}, defaultedData.root);
8975
- if (propTransforms["root"]) {
8976
- newRoot.props = propTransforms["root"](rootProps);
8977
- }
8978
- const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
8979
- const updatedData = walkTree(
8980
- dataWithUpdatedRoot,
8981
- config,
8982
- (content) => content.map(mapItem)
8983
- );
8984
- if (!defaultedData.root.props) {
8985
- updatedData.root = updatedData.root.props;
8986
- }
8987
- return updatedData;
8988
- }
8989
-
8990
- // lib/resolve-all-data.ts
8991
- init_react_import();
8992
-
8993
- // lib/data/to-component.ts
8994
- init_react_import();
8995
- var toComponent = (item) => {
8996
- return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
8997
- props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
8998
- type: "root"
8999
- });
9000
- };
9001
-
9002
- // lib/resolve-all-data.ts
9003
- function resolveAllData(_0, _1) {
9004
- return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
9005
- var _a;
9006
- const defaultedData = defaultData(data);
9007
- const resolveNode = (_node) => __async(this, null, function* () {
9008
- const node = toComponent(_node);
9009
- onResolveStart == null ? void 0 : onResolveStart(node);
9010
- const resolved = (yield resolveComponentData(
9011
- node,
9012
- config,
9013
- metadata,
9014
- () => {
9015
- },
9016
- () => {
9017
- },
9018
- "force"
9019
- )).node;
9020
- const resolvedDeep = yield mapSlots(
9021
- resolved,
9022
- processContent,
9023
- config
9024
- );
9025
- onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
9026
- return resolvedDeep;
9027
- });
9028
- const processContent = (content) => __async(this, null, function* () {
9029
- return Promise.all(content.map(resolveNode));
9030
- });
9031
- const processZones = () => __async(this, null, function* () {
9032
- var _a2;
9033
- const zones = (_a2 = data.zones) != null ? _a2 : {};
9034
- Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
9035
- zones[zoneKey] = yield Promise.all(content.map(resolveNode));
9036
- }));
9037
- return zones;
9038
- });
9039
- const dynamic = {
9040
- root: yield resolveNode(defaultedData.root),
9041
- content: yield processContent(defaultedData.content),
9042
- zones: yield processZones()
9043
- };
9044
- Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
9045
- const content = defaultedData.zones[zoneKey];
9046
- dynamic.zones[zoneKey] = yield processContent(content);
9047
- }), {});
9048
- return dynamic;
9049
- });
9050
- }
9051
9042
  // Annotate the CommonJS export names for ESM import in node:
9052
9043
  0 && (module.exports = {
9053
9044
  Action,