@measured/puck 0.19.0-canary.896a6279 → 0.19.0-canary.91cb9cee

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
@@ -9,9 +9,6 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __typeError = (msg) => {
13
- throw TypeError(msg);
14
- };
15
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
13
  var __spreadValues = (a, b) => {
17
14
  for (var prop in b || (b = {}))
@@ -64,10 +61,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
64
61
  mod
65
62
  ));
66
63
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
67
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
68
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
69
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
70
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
71
64
  var __async = (__this, __arguments, generator) => {
72
65
  return new Promise((resolve, reject) => {
73
66
  var fulfilled = (value) => {
@@ -181,7 +174,9 @@ __export(core_exports, {
181
174
  renderContext: () => renderContext,
182
175
  resolveAllData: () => resolveAllData,
183
176
  transformProps: () => transformProps,
184
- usePuck: () => usePuck
177
+ useGetPuck: () => useGetPuck,
178
+ usePuck: () => usePuck,
179
+ walkTree: () => walkTree
185
180
  });
186
181
  module.exports = __toCommonJS(core_exports);
187
182
  init_react_import();
@@ -308,7 +303,7 @@ init_react_import();
308
303
 
309
304
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
310
305
  init_react_import();
311
- var styles_module_default2 = { "InputWrapper": "_InputWrapper_g5w3n_1", "Input-label": "_Input-label_g5w3n_5", "Input-labelIcon": "_Input-labelIcon_g5w3n_14", "Input-disabledIcon": "_Input-disabledIcon_g5w3n_21", "Input-input": "_Input-input_g5w3n_26", "Input": "_Input_g5w3n_1", "Input--readOnly": "_Input--readOnly_g5w3n_74", "Input-radioGroupItems": "_Input-radioGroupItems_g5w3n_85", "Input-radio": "_Input-radio_g5w3n_85", "Input-radioInner": "_Input-radioInner_g5w3n_102", "Input-radioInput": "_Input-radioInput_g5w3n_147" };
306
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_4xor1_1", "Input-label": "_Input-label_4xor1_5", "Input-labelIcon": "_Input-labelIcon_4xor1_14", "Input-disabledIcon": "_Input-disabledIcon_4xor1_21", "Input-input": "_Input-input_4xor1_26", "Input": "_Input_4xor1_1", "Input--readOnly": "_Input--readOnly_4xor1_75", "Input-radioGroupItems": "_Input-radioGroupItems_4xor1_86", "Input-radio": "_Input-radio_4xor1_86", "Input-radioInner": "_Input-radioInner_4xor1_103", "Input-radioInput": "_Input-radioInput_4xor1_148" };
312
307
 
313
308
  // components/AutoField/index.tsx
314
309
  var import_react22 = require("react");
@@ -794,7 +789,7 @@ init_react_import();
794
789
  // reducer/actions/set.ts
795
790
  init_react_import();
796
791
 
797
- // lib/data/walk-tree.ts
792
+ // lib/data/walk-app-state.ts
798
793
  init_react_import();
799
794
 
800
795
  // lib/data/for-each-slot.ts
@@ -883,8 +878,8 @@ var stripSlots = (data) => {
883
878
  });
884
879
  };
885
880
 
886
- // lib/data/walk-tree.ts
887
- function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
881
+ // lib/data/walk-app-state.ts
882
+ function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
888
883
  var _a;
889
884
  let newZones = {};
890
885
  const newZoneIndex = {};
@@ -1017,7 +1012,7 @@ var setAction = (state, action, appStore) => {
1017
1012
  console.warn(
1018
1013
  "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1019
1014
  );
1020
- return walkTree(newState, appStore.config);
1015
+ return walkAppState(newState, appStore.config);
1021
1016
  }
1022
1017
  return __spreadValues(__spreadValues({}, state), action.state(state));
1023
1018
  };
@@ -1046,18 +1041,116 @@ var getIdsForParent = (zoneCompound, state) => {
1046
1041
  return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
1047
1042
  };
1048
1043
 
1044
+ // lib/data/populate-ids.ts
1045
+ init_react_import();
1046
+
1047
+ // lib/data/walk-tree.ts
1048
+ init_react_import();
1049
+
1050
+ // lib/data/map-slots.ts
1051
+ init_react_import();
1052
+ function mapSlotsAsync(_0, _1) {
1053
+ return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
1054
+ const props = __spreadValues({}, item.props);
1055
+ const propKeys = Object.keys(props);
1056
+ for (let i = 0; i < propKeys.length; i++) {
1057
+ const propKey = propKeys[i];
1058
+ const itemType = "type" in item ? item.type : "root";
1059
+ if (isSlot2(itemType, propKey, props[propKey])) {
1060
+ const content = props[propKey];
1061
+ const mappedContent = recursive ? yield Promise.all(
1062
+ content.map((item2) => __async(this, null, function* () {
1063
+ return yield mapSlotsAsync(item2, map, recursive, isSlot2);
1064
+ }))
1065
+ ) : content;
1066
+ props[propKey] = yield map(mappedContent, propKey);
1067
+ }
1068
+ }
1069
+ return __spreadProps(__spreadValues({}, item), { props });
1070
+ });
1071
+ }
1072
+ function mapSlotsSync(item, map, isSlot2 = isSlot) {
1073
+ var _a, _b;
1074
+ const props = __spreadValues({}, item.props);
1075
+ const propKeys = Object.keys(props);
1076
+ for (let i = 0; i < propKeys.length; i++) {
1077
+ const propKey = propKeys[i];
1078
+ const itemType = "type" in item ? item.type : "root";
1079
+ if (isSlot2(itemType, propKey, props[propKey])) {
1080
+ const content = props[propKey];
1081
+ const mappedContent = content.map((item2) => {
1082
+ return mapSlotsSync(item2, map, isSlot2);
1083
+ });
1084
+ props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
1085
+ }
1086
+ }
1087
+ return __spreadProps(__spreadValues({}, item), { props });
1088
+ }
1089
+
1090
+ // lib/data/walk-tree.ts
1091
+ function walkTree(data, config, callbackFn) {
1092
+ var _a, _b;
1093
+ const isSlot2 = createIsSlotConfig(config);
1094
+ const walkItem = (item) => {
1095
+ return mapSlotsSync(
1096
+ item,
1097
+ (content, parentId, propName) => callbackFn(content, { parentId, propName }),
1098
+ isSlot2
1099
+ );
1100
+ };
1101
+ if ("props" in data) {
1102
+ return walkItem(data);
1103
+ }
1104
+ const _data = data;
1105
+ const zones = (_a = _data.zones) != null ? _a : {};
1106
+ const mappedContent = _data.content.map(walkItem);
1107
+ return {
1108
+ root: walkItem(_data.root),
1109
+ content: (_b = callbackFn(mappedContent, {
1110
+ parentId: "root",
1111
+ propName: "default-zone"
1112
+ })) != null ? _b : mappedContent,
1113
+ zones: Object.keys(zones).reduce(
1114
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
1115
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
1116
+ }),
1117
+ {}
1118
+ )
1119
+ };
1120
+ }
1121
+
1122
+ // lib/data/populate-ids.ts
1123
+ var populateIds = (data, config, override = false) => {
1124
+ const id = generateId(data.type);
1125
+ return walkTree(
1126
+ __spreadProps(__spreadValues({}, data), {
1127
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
1128
+ }),
1129
+ config,
1130
+ (contents) => contents.map((item) => {
1131
+ const id2 = generateId(item.type);
1132
+ return __spreadProps(__spreadValues({}, item), {
1133
+ props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
1134
+ });
1135
+ })
1136
+ );
1137
+ };
1138
+
1049
1139
  // reducer/actions/insert.ts
1050
1140
  function insertAction(state, action, appStore) {
1051
1141
  const id = action.id || generateId(action.componentType);
1052
- const emptyComponentData = {
1053
- type: action.componentType,
1054
- props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
1055
- id
1056
- })
1057
- };
1142
+ const emptyComponentData = populateIds(
1143
+ {
1144
+ type: action.componentType,
1145
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
1146
+ id
1147
+ })
1148
+ },
1149
+ appStore.config
1150
+ );
1058
1151
  const [parentId] = action.destinationZone.split(":");
1059
1152
  const idsInPath = getIdsForParent(action.destinationZone, state);
1060
- return walkTree(
1153
+ return walkAppState(
1061
1154
  state,
1062
1155
  appStore.config,
1063
1156
  (content, zoneCompound) => {
@@ -1095,25 +1188,26 @@ var replaceAction = (state, action, appStore) => {
1095
1188
  `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1096
1189
  );
1097
1190
  }
1098
- return walkTree(
1191
+ const data = populateIds(action.data, appStore.config);
1192
+ return walkAppState(
1099
1193
  state,
1100
1194
  appStore.config,
1101
1195
  (content, zoneCompound) => {
1102
1196
  const newContent = [...content];
1103
1197
  if (zoneCompound === action.destinationZone) {
1104
- newContent[action.destinationIndex] = action.data;
1198
+ newContent[action.destinationIndex] = data;
1105
1199
  }
1106
1200
  return newContent;
1107
1201
  },
1108
1202
  (childItem, path) => {
1109
1203
  const pathIds = path.map((p) => p.split(":")[0]);
1110
- if (childItem.props.id === action.data.props.id) {
1111
- return action.data;
1204
+ if (childItem.props.id === data.props.id) {
1205
+ return data;
1112
1206
  } else if (childItem.props.id === parentId) {
1113
1207
  return childItem;
1114
1208
  } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1115
1209
  return childItem;
1116
- } else if (pathIds.indexOf(action.data.props.id) > -1) {
1210
+ } else if (pathIds.indexOf(data.props.id) > -1) {
1117
1211
  return childItem;
1118
1212
  }
1119
1213
  return null;
@@ -1124,7 +1218,7 @@ var replaceAction = (state, action, appStore) => {
1124
1218
  // reducer/actions/replace-root.ts
1125
1219
  init_react_import();
1126
1220
  var replaceRootAction = (state, action, appStore) => {
1127
- return walkTree(
1221
+ return walkAppState(
1128
1222
  state,
1129
1223
  appStore.config,
1130
1224
  (content) => content,
@@ -1163,7 +1257,7 @@ function duplicateAction(state, action, appStore) {
1163
1257
  id: generateId(item.type)
1164
1258
  })
1165
1259
  });
1166
- const modified = walkTree(
1260
+ const modified = walkAppState(
1167
1261
  state,
1168
1262
  appStore.config,
1169
1263
  (content, zoneCompound) => {
@@ -1228,7 +1322,7 @@ var moveAction = (state, action, appStore) => {
1228
1322
  if (!item) return state;
1229
1323
  const idsInSourcePath = getIdsForParent(action.sourceZone, state);
1230
1324
  const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
1231
- return walkTree(
1325
+ return walkAppState(
1232
1326
  state,
1233
1327
  appStore.config,
1234
1328
  (content, zoneCompound) => {
@@ -1276,7 +1370,6 @@ var reorderAction = (state, action, appStore) => {
1276
1370
  init_react_import();
1277
1371
  var removeAction = (state, action, appStore) => {
1278
1372
  const item = getItem({ index: action.index, zone: action.zone }, state);
1279
- const [parentId] = action.zone.split(":");
1280
1373
  const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
1281
1374
  (acc, [nodeId, nodeData]) => {
1282
1375
  const pathIds = nodeData.path.map((p) => p.split(":")[0]);
@@ -1287,7 +1380,7 @@ var removeAction = (state, action, appStore) => {
1287
1380
  },
1288
1381
  [item.props.id]
1289
1382
  );
1290
- const newState = walkTree(
1383
+ const newState = walkAppState(
1291
1384
  state,
1292
1385
  appStore.config,
1293
1386
  (content, zoneCompound) => {
@@ -1295,24 +1388,17 @@ var removeAction = (state, action, appStore) => {
1295
1388
  return remove(content, action.index);
1296
1389
  }
1297
1390
  return content;
1298
- },
1299
- (childItem, path) => {
1300
- const parentIds = path.map((p) => p.split(":")[0]);
1301
- if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
1302
- return childItem;
1303
- }
1304
- return null;
1305
1391
  }
1306
1392
  );
1307
1393
  Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
1308
- const parentId2 = zoneCompound.split(":")[0];
1309
- if (nodesToDelete.includes(parentId2) && newState.data.zones) {
1394
+ const parentId = zoneCompound.split(":")[0];
1395
+ if (nodesToDelete.includes(parentId) && newState.data.zones) {
1310
1396
  delete newState.data.zones[zoneCompound];
1311
1397
  }
1312
1398
  });
1313
1399
  Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
1314
- const parentId2 = zoneCompound.split(":")[0];
1315
- if (nodesToDelete.includes(parentId2)) {
1400
+ const parentId = zoneCompound.split(":")[0];
1401
+ if (nodesToDelete.includes(parentId)) {
1316
1402
  delete newState.indexes.zones[zoneCompound];
1317
1403
  }
1318
1404
  });
@@ -1385,14 +1471,14 @@ var setDataAction = (state, action, appStore) => {
1385
1471
  console.warn(
1386
1472
  "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1387
1473
  );
1388
- return walkTree(
1474
+ return walkAppState(
1389
1475
  __spreadProps(__spreadValues({}, state), {
1390
1476
  data: __spreadValues(__spreadValues({}, state.data), action.data)
1391
1477
  }),
1392
1478
  appStore.config
1393
1479
  );
1394
1480
  }
1395
- return walkTree(
1481
+ return walkAppState(
1396
1482
  __spreadProps(__spreadValues({}, state), {
1397
1483
  data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
1398
1484
  }),
@@ -1696,7 +1782,7 @@ var createHistorySlice = (set, get) => {
1696
1782
  const { dispatch, history } = get();
1697
1783
  dispatch({
1698
1784
  type: "set",
1699
- state: ((_a = history.histories[history.index]) == null ? void 0 : _a.state) || history.initialAppState
1785
+ state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
1700
1786
  });
1701
1787
  set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1702
1788
  },
@@ -1740,7 +1826,11 @@ var createNodesSlice = (set, get) => ({
1740
1826
  const s = get().nodes;
1741
1827
  const emptyNode = {
1742
1828
  id,
1743
- methods: { sync: () => null },
1829
+ methods: {
1830
+ sync: () => null,
1831
+ hideOverlay: () => null,
1832
+ showOverlay: () => null
1833
+ },
1744
1834
  element: null
1745
1835
  };
1746
1836
  const existingNode = s.nodes[id];
@@ -1777,7 +1867,7 @@ var import_react7 = require("react");
1777
1867
  init_react_import();
1778
1868
  var flattenData = (state, config) => {
1779
1869
  const data = [];
1780
- walkTree(
1870
+ walkAppState(
1781
1871
  state,
1782
1872
  config,
1783
1873
  (content) => content,
@@ -1942,7 +2032,8 @@ var createFieldsSlice = (_set, _get) => {
1942
2032
  return {
1943
2033
  fields: {},
1944
2034
  loading: false,
1945
- lastResolvedData: {}
2035
+ lastResolvedData: {},
2036
+ id: void 0
1946
2037
  };
1947
2038
  };
1948
2039
  var useRegisterFieldsSlice = (appStore, id) => {
@@ -1963,7 +2054,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
1963
2054
  let lastFields = fields;
1964
2055
  if (reset) {
1965
2056
  appStore.setState((s) => ({
1966
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2057
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1967
2058
  }));
1968
2059
  lastFields = defaultFields;
1969
2060
  }
@@ -1991,12 +2082,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
1991
2082
  fields: {
1992
2083
  fields: newFields,
1993
2084
  loading: false,
1994
- lastResolvedData: componentData
2085
+ lastResolvedData: componentData,
2086
+ id
1995
2087
  }
1996
2088
  });
1997
2089
  } else {
1998
2090
  appStore.setState((s) => ({
1999
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2091
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
2000
2092
  }));
2001
2093
  }
2002
2094
  }),
@@ -2013,31 +2105,6 @@ var useRegisterFieldsSlice = (appStore, id) => {
2013
2105
 
2014
2106
  // lib/resolve-component-data.ts
2015
2107
  init_react_import();
2016
-
2017
- // lib/data/map-slots.ts
2018
- init_react_import();
2019
- function mapSlots(_0, _1) {
2020
- return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
2021
- const props = __spreadValues({}, item.props);
2022
- const propKeys = Object.keys(props);
2023
- for (let i = 0; i < propKeys.length; i++) {
2024
- const propKey = propKeys[i];
2025
- const itemType = "type" in item ? item.type : "root";
2026
- if (isSlot2(itemType, propKey, props[propKey])) {
2027
- const content = props[propKey];
2028
- const mappedContent = recursive ? yield Promise.all(
2029
- content.map((item2) => __async(this, null, function* () {
2030
- return yield mapSlots(item2, map, recursive, isSlot2);
2031
- }))
2032
- ) : content;
2033
- props[propKey] = yield map(mappedContent, propKey);
2034
- }
2035
- }
2036
- return __spreadProps(__spreadValues({}, item), { props });
2037
- });
2038
- }
2039
-
2040
- // lib/resolve-component-data.ts
2041
2108
  var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
2042
2109
  var cache = { lastChange: {} };
2043
2110
  var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
@@ -2055,14 +2122,14 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2055
2122
  const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
2056
2123
  changed,
2057
2124
  lastData: oldItem,
2058
- metadata,
2125
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
2059
2126
  trigger
2060
2127
  });
2061
2128
  let resolvedItem = __spreadProps(__spreadValues({}, item), {
2062
2129
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
2063
2130
  });
2064
2131
  if (recursive) {
2065
- resolvedItem = yield mapSlots(
2132
+ resolvedItem = yield mapSlotsAsync(
2066
2133
  resolvedItem,
2067
2134
  (content) => __async(void 0, null, function* () {
2068
2135
  return Promise.all(
@@ -2117,7 +2184,8 @@ var toRoot = (item) => {
2117
2184
  return { props: {}, readOnly };
2118
2185
  };
2119
2186
 
2120
- // store/index.ts
2187
+ // store/default-app-state.ts
2188
+ init_react_import();
2121
2189
  var defaultAppState = {
2122
2190
  data: { content: [], root: {}, zones: {} },
2123
2191
  ui: {
@@ -2143,6 +2211,8 @@ var defaultAppState = {
2143
2211
  zones: {}
2144
2212
  }
2145
2213
  };
2214
+
2215
+ // store/index.ts
2146
2216
  var defaultPageFields = {
2147
2217
  title: { type: "text" }
2148
2218
  };
@@ -2282,7 +2352,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
2282
2352
  }),
2283
2353
  resolveAndCommitData: () => __async(void 0, null, function* () {
2284
2354
  const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
2285
- walkTree(
2355
+ walkAppState(
2286
2356
  state,
2287
2357
  config,
2288
2358
  (content) => content,
@@ -2331,314 +2401,11 @@ function useAppStoreApi() {
2331
2401
  init_react_import();
2332
2402
  var import_react12 = require("@dnd-kit/react");
2333
2403
 
2334
- // lib/dnd/dnd-kit/safe.ts
2335
- init_react_import();
2336
- var import_react10 = require("@dnd-kit/react");
2337
- var import_sortable = require("@dnd-kit/react/sortable");
2338
- function useDroppableSafe(input) {
2339
- if (typeof window === "undefined") {
2340
- return { ref: () => {
2341
- } };
2342
- }
2343
- return (0, import_react10.useDroppable)(input);
2344
- }
2345
- function useDraggableSafe(input) {
2346
- if (typeof window === "undefined") {
2347
- return { ref: () => {
2348
- } };
2349
- }
2350
- return (0, import_react10.useDraggable)(input);
2351
- }
2352
- function useSortableSafe(input) {
2353
- if (typeof window === "undefined") {
2354
- return { ref: () => {
2355
- }, status: "idle", handleRef: () => {
2356
- } };
2357
- }
2358
- return (0, import_sortable.useSortable)(input);
2359
- }
2360
-
2361
2404
  // lib/dnd/use-sensors.ts
2362
2405
  init_react_import();
2363
- var import_react11 = require("react");
2364
-
2365
- // lib/dnd/PointerSensor.ts
2366
- init_react_import();
2367
- var import_state = require("@dnd-kit/state");
2368
- var import_abstract = require("@dnd-kit/abstract");
2369
- var import_geometry = require("@dnd-kit/geometry");
2406
+ var import_react10 = require("react");
2407
+ var import_react11 = require("@dnd-kit/react");
2370
2408
  var import_utilities = require("@dnd-kit/dom/utilities");
2371
- var _clearTimeout;
2372
- var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
2373
- constructor(manager, options) {
2374
- super(manager);
2375
- this.manager = manager;
2376
- this.options = options;
2377
- this.listeners = new import_utilities.Listeners();
2378
- this.cleanup = /* @__PURE__ */ new Set();
2379
- this.source = void 0;
2380
- this.started = false;
2381
- __privateAdd(this, _clearTimeout);
2382
- this.handleCancel = this.handleCancel.bind(this);
2383
- this.handlePointerUp = this.handlePointerUp.bind(this);
2384
- this.handleKeyDown = this.handleKeyDown.bind(this);
2385
- (0, import_state.effect)(() => {
2386
- const unbindGlobal = this.bindGlobal(options != null ? options : {});
2387
- return () => {
2388
- unbindGlobal();
2389
- };
2390
- });
2391
- }
2392
- bind(source, options = this.options) {
2393
- const unbind = (0, import_state.effect)(() => {
2394
- var _a;
2395
- const target = (_a = source.handle) != null ? _a : source.element;
2396
- const listener = (event) => {
2397
- if ((0, import_utilities.isPointerEvent)(event)) {
2398
- this.handlePointerDown(event, source, options);
2399
- }
2400
- };
2401
- if (target) {
2402
- patchWindow(target.ownerDocument.defaultView);
2403
- target.addEventListener("pointerdown", listener);
2404
- return () => {
2405
- target.removeEventListener("pointerdown", listener);
2406
- };
2407
- }
2408
- });
2409
- return unbind;
2410
- }
2411
- bindGlobal(options) {
2412
- const documents = /* @__PURE__ */ new Set();
2413
- for (const draggable of this.manager.registry.draggables.value) {
2414
- if (draggable.element) {
2415
- documents.add((0, import_utilities.getDocument)(draggable.element));
2416
- }
2417
- }
2418
- for (const droppable of this.manager.registry.droppables.value) {
2419
- if (droppable.element) {
2420
- documents.add((0, import_utilities.getDocument)(droppable.element));
2421
- }
2422
- }
2423
- const unbindFns = Array.from(documents).map(
2424
- (doc) => this.listeners.bind(doc, [
2425
- {
2426
- type: "pointermove",
2427
- listener: (event) => this.handlePointerMove(event, doc, options)
2428
- },
2429
- {
2430
- type: "pointerup",
2431
- listener: this.handlePointerUp,
2432
- options: {
2433
- capture: true
2434
- }
2435
- },
2436
- {
2437
- // Cancel activation if there is a competing Drag and Drop interaction
2438
- type: "dragstart",
2439
- listener: this.handleDragStart
2440
- }
2441
- ])
2442
- );
2443
- return () => {
2444
- unbindFns.forEach((unbind) => unbind());
2445
- };
2446
- }
2447
- handlePointerDown(event, source, options = {}) {
2448
- if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
2449
- return;
2450
- }
2451
- const offset = (0, import_utilities.getFrameTransform)(source.element);
2452
- this.initialCoordinates = {
2453
- x: event.clientX * offset.scaleX + offset.x,
2454
- y: event.clientY * offset.scaleY + offset.y
2455
- };
2456
- this.source = source;
2457
- const { activationConstraints } = options;
2458
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
2459
- event.stopImmediatePropagation();
2460
- if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
2461
- this.handleStart(source, event);
2462
- } else {
2463
- const { delay } = constraints;
2464
- if (delay) {
2465
- const timeout3 = setTimeout(
2466
- () => this.handleStart(source, event),
2467
- delay.value
2468
- );
2469
- __privateSet(this, _clearTimeout, () => {
2470
- clearTimeout(timeout3);
2471
- __privateSet(this, _clearTimeout, void 0);
2472
- });
2473
- }
2474
- }
2475
- const cleanup = () => {
2476
- var _a;
2477
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2478
- this.initialCoordinates = void 0;
2479
- this.source = void 0;
2480
- };
2481
- this.cleanup.add(cleanup);
2482
- }
2483
- handlePointerMove(event, doc, options) {
2484
- if (!this.source) {
2485
- return;
2486
- }
2487
- const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
2488
- if (doc !== ownerDocument) {
2489
- return;
2490
- }
2491
- const coordinates = {
2492
- x: event.clientX,
2493
- y: event.clientY
2494
- };
2495
- const offset = (0, import_utilities.getFrameTransform)(this.source.element);
2496
- coordinates.x = coordinates.x * offset.scaleX + offset.x;
2497
- coordinates.y = coordinates.y * offset.scaleY + offset.y;
2498
- if (this.manager.dragOperation.status.dragging) {
2499
- event.preventDefault();
2500
- event.stopPropagation();
2501
- this.manager.actions.move({ to: coordinates });
2502
- return;
2503
- }
2504
- if (!this.initialCoordinates) {
2505
- return;
2506
- }
2507
- const delta = {
2508
- x: coordinates.x - this.initialCoordinates.x,
2509
- y: coordinates.y - this.initialCoordinates.y
2510
- };
2511
- const { activationConstraints } = options;
2512
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
2513
- const { distance, delay } = constraints != null ? constraints : {};
2514
- if (distance) {
2515
- if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
2516
- return this.handleCancel();
2517
- }
2518
- if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
2519
- return this.handleStart(this.source, event);
2520
- }
2521
- }
2522
- if (delay) {
2523
- if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
2524
- return this.handleCancel();
2525
- }
2526
- }
2527
- }
2528
- handlePointerUp(event) {
2529
- if (!this.source) {
2530
- return;
2531
- }
2532
- event.preventDefault();
2533
- event.stopPropagation();
2534
- const { status } = this.manager.dragOperation;
2535
- if (!status.idle) {
2536
- const canceled = !status.initialized;
2537
- this.manager.actions.stop({ canceled });
2538
- } else if (this.started) {
2539
- setTimeout(() => {
2540
- if (!this.manager.dragOperation.status.idle) {
2541
- this.manager.actions.stop({ canceled: false });
2542
- }
2543
- }, 10);
2544
- }
2545
- this.cleanup.forEach((cleanup) => cleanup());
2546
- this.cleanup.clear();
2547
- }
2548
- handleKeyDown(event) {
2549
- if (event.key === "Escape") {
2550
- event.preventDefault();
2551
- this.handleCancel();
2552
- }
2553
- }
2554
- handleStart(source, event) {
2555
- var _a;
2556
- const { manager, initialCoordinates } = this;
2557
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2558
- if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2559
- return;
2560
- }
2561
- if (event.defaultPrevented) {
2562
- return;
2563
- }
2564
- this.started = true;
2565
- event.preventDefault();
2566
- (0, import_state.batch)(() => {
2567
- manager.actions.setDragSource(source.id);
2568
- manager.actions.start({ coordinates: initialCoordinates, event });
2569
- });
2570
- const ownerDocument = (0, import_utilities.getDocument)(event.target);
2571
- const unbind = this.listeners.bind(ownerDocument, [
2572
- {
2573
- // Prevent scrolling on touch devices
2574
- type: "touchmove",
2575
- listener: preventDefault,
2576
- options: {
2577
- passive: false
2578
- }
2579
- },
2580
- {
2581
- // Prevent click events
2582
- type: "click",
2583
- listener: preventDefault
2584
- },
2585
- {
2586
- type: "keydown",
2587
- listener: this.handleKeyDown
2588
- }
2589
- ]);
2590
- ownerDocument.body.setPointerCapture(event.pointerId);
2591
- this.cleanup.add(unbind);
2592
- this.cleanup.add(() => {
2593
- this.started = false;
2594
- });
2595
- }
2596
- handleDragStart(event) {
2597
- const { target } = event;
2598
- if (!(0, import_utilities.isElement)(target)) {
2599
- return;
2600
- }
2601
- const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
2602
- if (isNativeDraggable) {
2603
- this.handleCancel();
2604
- } else {
2605
- preventDefault(event);
2606
- }
2607
- }
2608
- handleCancel() {
2609
- const { dragOperation } = this.manager;
2610
- if (dragOperation.status.initialized) {
2611
- this.manager.actions.stop({ canceled: true });
2612
- }
2613
- this.cleanup.forEach((cleanup) => cleanup());
2614
- this.cleanup.clear();
2615
- }
2616
- destroy() {
2617
- this.listeners.clear();
2618
- }
2619
- };
2620
- _clearTimeout = new WeakMap();
2621
- _PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
2622
- var PointerSensor = _PointerSensor;
2623
- function preventDefault(event) {
2624
- event.preventDefault();
2625
- }
2626
- function noop() {
2627
- }
2628
- var windows = /* @__PURE__ */ new WeakSet();
2629
- function patchWindow(window2) {
2630
- if (!window2 || windows.has(window2)) {
2631
- return;
2632
- }
2633
- window2.addEventListener("touchmove", noop, {
2634
- capture: false,
2635
- passive: false
2636
- });
2637
- windows.add(window2);
2638
- }
2639
-
2640
- // lib/dnd/use-sensors.ts
2641
- var import_utilities2 = require("@dnd-kit/dom/utilities");
2642
2409
  var useSensors = ({
2643
2410
  other,
2644
2411
  mouse,
@@ -2647,12 +2414,12 @@ var useSensors = ({
2647
2414
  touch: { delay: { value: 200, tolerance: 10 } },
2648
2415
  other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
2649
2416
  }) => {
2650
- const [sensors] = (0, import_react11.useState)(() => [
2651
- PointerSensor.configure({
2417
+ const [sensors] = (0, import_react10.useState)(() => [
2418
+ import_react11.PointerSensor.configure({
2652
2419
  activationConstraints(event, source) {
2653
2420
  var _a;
2654
2421
  const { pointerType, target } = event;
2655
- if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2422
+ if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2656
2423
  return mouse;
2657
2424
  }
2658
2425
  if (pointerType === "touch") {
@@ -2667,11 +2434,11 @@ var useSensors = ({
2667
2434
 
2668
2435
  // lib/dnd/collision/dynamic/index.ts
2669
2436
  init_react_import();
2670
- var import_abstract9 = require("@dnd-kit/abstract");
2437
+ var import_abstract8 = require("@dnd-kit/abstract");
2671
2438
 
2672
2439
  // lib/dnd/collision/directional/index.ts
2673
2440
  init_react_import();
2674
- var import_abstract2 = require("@dnd-kit/abstract");
2441
+ var import_abstract = require("@dnd-kit/abstract");
2675
2442
 
2676
2443
  // lib/dnd/collision/collision-debug.ts
2677
2444
  init_react_import();
@@ -2749,7 +2516,7 @@ var directionalCollision = (input, previous) => {
2749
2516
  return {
2750
2517
  id: droppable.id,
2751
2518
  value: 1,
2752
- type: import_abstract2.CollisionType.Collision
2519
+ type: import_abstract.CollisionType.Collision
2753
2520
  };
2754
2521
  }
2755
2522
  return null;
@@ -2791,7 +2558,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2791
2558
 
2792
2559
  // lib/dnd/collision/dynamic/track-movement-interval.ts
2793
2560
  init_react_import();
2794
- var import_geometry2 = require("@dnd-kit/geometry");
2561
+ var import_geometry = require("@dnd-kit/geometry");
2795
2562
  var INTERVAL_SENSITIVITY = 10;
2796
2563
  var intervalCache = {
2797
2564
  current: { x: 0, y: 0 },
@@ -2807,13 +2574,15 @@ var trackMovementInterval = (point, dragAxis = "dynamic") => {
2807
2574
  };
2808
2575
  intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
2809
2576
  if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
2810
- intervalCache.previous = import_geometry2.Point.from(point);
2577
+ intervalCache.previous = import_geometry.Point.from(point);
2811
2578
  }
2812
2579
  return intervalCache;
2813
2580
  };
2814
2581
 
2815
2582
  // ../../node_modules/@dnd-kit/collision/dist/index.js
2816
2583
  init_react_import();
2584
+ var import_abstract2 = require("@dnd-kit/abstract");
2585
+ var import_geometry2 = require("@dnd-kit/geometry");
2817
2586
  var import_abstract3 = require("@dnd-kit/abstract");
2818
2587
  var import_geometry3 = require("@dnd-kit/geometry");
2819
2588
  var import_abstract4 = require("@dnd-kit/abstract");
@@ -2824,8 +2593,6 @@ var import_abstract6 = require("@dnd-kit/abstract");
2824
2593
  var import_geometry6 = require("@dnd-kit/geometry");
2825
2594
  var import_abstract7 = require("@dnd-kit/abstract");
2826
2595
  var import_geometry7 = require("@dnd-kit/geometry");
2827
- var import_abstract8 = require("@dnd-kit/abstract");
2828
- var import_geometry8 = require("@dnd-kit/geometry");
2829
2596
  var pointerIntersection = ({
2830
2597
  dragOperation,
2831
2598
  droppable
@@ -2839,12 +2606,12 @@ var pointerIntersection = ({
2839
2606
  return null;
2840
2607
  }
2841
2608
  if (droppable.shape.containsPoint(pointerCoordinates)) {
2842
- const distance = import_geometry3.Point.distance(droppable.shape.center, pointerCoordinates);
2609
+ const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
2843
2610
  return {
2844
2611
  id,
2845
2612
  value: 1 / distance,
2846
- type: import_abstract3.CollisionType.PointerIntersection,
2847
- priority: import_abstract3.CollisionPriority.High
2613
+ type: import_abstract2.CollisionType.PointerIntersection,
2614
+ priority: import_abstract2.CollisionPriority.High
2848
2615
  };
2849
2616
  }
2850
2617
  return null;
@@ -2855,31 +2622,15 @@ var closestCorners = (input) => {
2855
2622
  if (!droppable.shape) {
2856
2623
  return null;
2857
2624
  }
2858
- const { left, top, right, bottom } = droppable.shape.boundingRectangle;
2859
- const corners = [
2860
- {
2861
- x: left,
2862
- y: top
2863
- },
2864
- {
2865
- x: right,
2866
- y: top
2867
- },
2868
- {
2869
- x: left,
2870
- y: bottom
2871
- },
2872
- {
2873
- x: right,
2874
- y: bottom
2875
- }
2876
- ];
2877
- const distance = corners.reduce(
2878
- (acc, corner) => {
2625
+ const shapeCorners = shape ? import_geometry4.Rectangle.from(shape.current.boundingRectangle).corners : void 0;
2626
+ const distance = import_geometry4.Rectangle.from(
2627
+ droppable.shape.boundingRectangle
2628
+ ).corners.reduce(
2629
+ (acc, corner, index) => {
2879
2630
  var _a;
2880
- return acc + import_geometry5.Point.distance(
2881
- import_geometry5.Point.from(corner),
2882
- (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
2631
+ return acc + import_geometry4.Point.distance(
2632
+ import_geometry4.Point.from(corner),
2633
+ (_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
2883
2634
  );
2884
2635
  },
2885
2636
  0
@@ -2888,8 +2639,8 @@ var closestCorners = (input) => {
2888
2639
  return {
2889
2640
  id: droppable.id,
2890
2641
  value: 1 / value,
2891
- type: import_abstract5.CollisionType.Collision,
2892
- priority: import_abstract5.CollisionPriority.Normal
2642
+ type: import_abstract4.CollisionType.Collision,
2643
+ priority: import_abstract4.CollisionPriority.Normal
2893
2644
  };
2894
2645
  };
2895
2646
 
@@ -2914,12 +2665,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2914
2665
  const { center: dragCenter } = dragShape;
2915
2666
  const { fallbackEnabled } = collisionStore.getState();
2916
2667
  const interval = trackMovementInterval(position.current, dragAxis);
2917
- dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2918
- direction: interval.direction
2919
- });
2920
- const collisionMap = dragOperation.data.collisionMap || {};
2921
- dragOperation.data.collisionMap = collisionMap;
2922
- collisionMap[droppable.id] = {
2668
+ const data = {
2923
2669
  direction: interval.direction
2924
2670
  };
2925
2671
  const { center: dropCenter } = dropShape;
@@ -2934,7 +2680,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2934
2680
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
2935
2681
  if (collision) {
2936
2682
  return __spreadProps(__spreadValues({}, collision), {
2937
- priority: import_abstract9.CollisionPriority.Highest
2683
+ priority: import_abstract8.CollisionPriority.Highest,
2684
+ data
2938
2685
  });
2939
2686
  }
2940
2687
  }
@@ -2951,12 +2698,12 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2951
2698
  const collision = {
2952
2699
  id: droppable.id,
2953
2700
  value: intersectionRatio,
2954
- priority: import_abstract9.CollisionPriority.High,
2955
- type: import_abstract9.CollisionType.Collision
2701
+ priority: import_abstract8.CollisionPriority.High,
2702
+ type: import_abstract8.CollisionType.Collision
2956
2703
  };
2957
2704
  const shouldFlushId = flushNext === droppable.id;
2958
2705
  flushNext = "";
2959
- return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2706
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
2960
2707
  }
2961
2708
  if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2962
2709
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
@@ -2968,9 +2715,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2968
2715
  x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
2969
2716
  y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
2970
2717
  });
2971
- collisionMap[droppable.id] = {
2972
- direction
2973
- };
2718
+ data.direction = direction;
2974
2719
  if (intersectionArea) {
2975
2720
  collisionDebug(
2976
2721
  dragCenter,
@@ -2981,7 +2726,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2981
2726
  );
2982
2727
  flushNext = droppable.id;
2983
2728
  return __spreadProps(__spreadValues({}, fallbackCollision), {
2984
- priority: import_abstract9.CollisionPriority.Low
2729
+ priority: import_abstract8.CollisionPriority.Low,
2730
+ data
2985
2731
  });
2986
2732
  }
2987
2733
  collisionDebug(
@@ -2991,16 +2737,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2991
2737
  "orange",
2992
2738
  direction || ""
2993
2739
  );
2994
- return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract9.CollisionPriority.Lowest });
2740
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2741
+ priority: import_abstract8.CollisionPriority.Lowest,
2742
+ data
2743
+ });
2995
2744
  }
2996
2745
  }
2997
2746
  }
2998
2747
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2999
- delete collisionMap[droppable.id];
3000
2748
  return null;
3001
2749
  };
3002
2750
 
3003
2751
  // components/Sortable/index.tsx
2752
+ var import_sortable = require("@dnd-kit/react/sortable");
3004
2753
  var import_jsx_runtime5 = require("react/jsx-runtime");
3005
2754
  var SortableProvider = ({
3006
2755
  children,
@@ -3020,16 +2769,16 @@ var SortableProvider = ({
3020
2769
  return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
3021
2770
  },
3022
2771
  onDragOver: (event, manager) => {
3023
- var _a, _b;
2772
+ var _a;
3024
2773
  event.preventDefault();
3025
2774
  const { operation } = event;
3026
2775
  const { source, target } = operation;
3027
2776
  if (!source || !target) return;
3028
2777
  let sourceIndex = source.data.index;
3029
2778
  let targetIndex = target.data.index;
3030
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2779
+ const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
3031
2780
  if (sourceIndex !== targetIndex && source.id !== target.id) {
3032
- const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2781
+ const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
3033
2782
  if (targetIndex >= sourceIndex) {
3034
2783
  targetIndex = targetIndex - 1;
3035
2784
  }
@@ -3060,9 +2809,10 @@ var Sortable = ({
3060
2809
  }) => {
3061
2810
  const {
3062
2811
  ref: sortableRef,
3063
- status,
2812
+ isDragging,
2813
+ isDropping,
3064
2814
  handleRef
3065
- } = useSortableSafe({
2815
+ } = (0, import_sortable.useSortable)({
3066
2816
  id,
3067
2817
  type,
3068
2818
  index,
@@ -3070,7 +2820,7 @@ var Sortable = ({
3070
2820
  data: { index },
3071
2821
  collisionDetector: createDynamicCollisionDetector("y")
3072
2822
  });
3073
- return children({ status, ref: sortableRef, handleRef });
2823
+ return children({ isDragging, isDropping, ref: sortableRef, handleRef });
3074
2824
  };
3075
2825
 
3076
2826
  // components/AutoField/context.tsx
@@ -3195,7 +2945,7 @@ var ArrayField = ({
3195
2945
  }
3196
2946
  }, []);
3197
2947
  const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
3198
- const isDragging = !!draggedItem;
2948
+ const isDraggingAny = !!draggedItem;
3199
2949
  const canEdit = useAppStore(
3200
2950
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
3201
2951
  );
@@ -3260,13 +3010,13 @@ var ArrayField = ({
3260
3010
  id: _arrayId,
3261
3011
  index: i,
3262
3012
  disabled: readOnly,
3263
- children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3013
+ children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3264
3014
  "div",
3265
3015
  {
3266
3016
  ref,
3267
3017
  className: getClassNameItem({
3268
3018
  isExpanded: arrayState.openId === _arrayId,
3269
- isDragging: status === "dragging",
3019
+ isDragging,
3270
3020
  readOnly
3271
3021
  }),
3272
3022
  children: [
@@ -3407,7 +3157,7 @@ var ArrayField = ({
3407
3157
  type: "button",
3408
3158
  className: getClassName5("addButton"),
3409
3159
  onClick: () => {
3410
- if (isDragging) return;
3160
+ if (isDraggingAny) return;
3411
3161
  const existingValue = value || [];
3412
3162
  const newValue = [
3413
3163
  ...existingValue,
@@ -4390,28 +4140,28 @@ init_react_import();
4390
4140
 
4391
4141
  // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
4392
4142
  init_react_import();
4393
- var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
4143
+ var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
4394
4144
 
4395
4145
  // components/Drawer/index.tsx
4396
- var import_react37 = require("react");
4146
+ var import_react39 = require("react");
4397
4147
 
4398
4148
  // components/DragDropContext/index.tsx
4399
4149
  init_react_import();
4400
- var import_react35 = require("@dnd-kit/react");
4401
- var import_react36 = require("react");
4150
+ var import_react37 = require("@dnd-kit/react");
4151
+ var import_react38 = require("react");
4402
4152
  var import_dom = require("@dnd-kit/dom");
4403
4153
 
4404
4154
  // components/DropZone/index.tsx
4405
4155
  init_react_import();
4406
- var import_react34 = require("react");
4156
+ var import_react35 = require("react");
4407
4157
 
4408
4158
  // components/DraggableComponent/index.tsx
4409
4159
  init_react_import();
4410
- var import_react25 = require("react");
4160
+ var import_react26 = require("react");
4411
4161
 
4412
4162
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4413
4163
  init_react_import();
4414
- var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
4164
+ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_qzbgx_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_qzbgx_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_qzbgx_29", "DraggableComponent--hover": "_DraggableComponent--hover_qzbgx_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_qzbgx_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_qzbgx_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_qzbgx_66", "DraggableComponent-actions": "_DraggableComponent-actions_qzbgx_66" };
4415
4165
 
4416
4166
  // components/DraggableComponent/index.tsx
4417
4167
  var import_react_dom2 = require("react-dom");
@@ -4448,7 +4198,9 @@ var ZoneStoreContext = (0, import_react23.createContext)(
4448
4198
  areaDepthIndex: {},
4449
4199
  nextAreaDepthIndex: {},
4450
4200
  draggedItem: null,
4451
- previewIndex: {}
4201
+ previewIndex: {},
4202
+ enabledIndex: {},
4203
+ hoveringComponent: null
4452
4204
  }))
4453
4205
  );
4454
4206
  var ZoneStoreProvider = ({
@@ -4461,7 +4213,6 @@ var DropZoneProvider = ({
4461
4213
  children,
4462
4214
  value
4463
4215
  }) => {
4464
- const [hoveringComponent, setHoveringComponent] = (0, import_react23.useState)();
4465
4216
  const dispatch = useAppStore((s) => s.dispatch);
4466
4217
  const registerZone = (0, import_react23.useCallback)(
4467
4218
  (zoneCompound) => {
@@ -4483,19 +4234,36 @@ var DropZoneProvider = ({
4483
4234
  );
4484
4235
  const memoValue = (0, import_react23.useMemo)(
4485
4236
  () => __spreadValues({
4486
- hoveringComponent,
4487
- setHoveringComponent,
4488
4237
  registerZone,
4489
4238
  unregisterZone
4490
4239
  }, value),
4491
- [value, hoveringComponent]
4240
+ [value]
4492
4241
  );
4493
4242
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4494
4243
  };
4495
4244
 
4496
- // lib/use-context-store.ts
4245
+ // components/DraggableComponent/index.tsx
4246
+ var import_shallow2 = require("zustand/react/shallow");
4247
+ var import_sortable2 = require("@dnd-kit/react/sortable");
4248
+
4249
+ // lib/accumulate-transform.ts
4497
4250
  init_react_import();
4498
- var import_react24 = require("react");
4251
+ function accumulateTransform(el) {
4252
+ let matrix = new DOMMatrixReadOnly();
4253
+ let n = el.parentElement;
4254
+ while (n && n !== document.documentElement) {
4255
+ const t = getComputedStyle(n).transform;
4256
+ if (t && t !== "none") {
4257
+ matrix = new DOMMatrixReadOnly(t).multiply(matrix);
4258
+ }
4259
+ n = n.parentElement;
4260
+ }
4261
+ return { scaleX: matrix.a, scaleY: matrix.d };
4262
+ }
4263
+
4264
+ // lib/use-context-store.ts
4265
+ init_react_import();
4266
+ var import_react24 = require("react");
4499
4267
  var import_zustand4 = require("zustand");
4500
4268
  var import_shallow = require("zustand/react/shallow");
4501
4269
  function useContextStore(context, selector) {
@@ -4506,8 +4274,39 @@ function useContextStore(context, selector) {
4506
4274
  return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
4507
4275
  }
4508
4276
 
4277
+ // lib/dnd/use-on-drag-finished.ts
4278
+ init_react_import();
4279
+ var import_react25 = require("react");
4280
+ var useOnDragFinished = (cb, deps = []) => {
4281
+ const appStore = useAppStoreApi();
4282
+ return (0, import_react25.useCallback)(() => {
4283
+ let dispose = () => {
4284
+ };
4285
+ const processDragging = (isDragging2) => {
4286
+ if (isDragging2) {
4287
+ cb(false);
4288
+ } else {
4289
+ setTimeout(() => {
4290
+ cb(true);
4291
+ }, 0);
4292
+ if (dispose) dispose();
4293
+ }
4294
+ };
4295
+ const isDragging = appStore.getState().state.ui.isDragging;
4296
+ processDragging(isDragging);
4297
+ if (isDragging) {
4298
+ dispose = appStore.subscribe(
4299
+ (s) => s.state.ui.isDragging,
4300
+ (isDragging2) => {
4301
+ processDragging(isDragging2);
4302
+ }
4303
+ );
4304
+ }
4305
+ return dispose;
4306
+ }, [appStore, ...deps]);
4307
+ };
4308
+
4509
4309
  // components/DraggableComponent/index.tsx
4510
- var import_shallow2 = require("zustand/react/shallow");
4511
4310
  var import_jsx_runtime20 = require("react/jsx-runtime");
4512
4311
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
4513
4312
  var DEBUG2 = false;
@@ -4537,7 +4336,6 @@ var DraggableComponent = ({
4537
4336
  isSelected = false,
4538
4337
  debug,
4539
4338
  label,
4540
- isEnabled,
4541
4339
  autoDragAxis,
4542
4340
  userDragAxis,
4543
4341
  inDroppableZone = true
@@ -4551,9 +4349,9 @@ var DraggableComponent = ({
4551
4349
  const overrides = useAppStore((s) => s.overrides);
4552
4350
  const dispatch = useAppStore((s) => s.dispatch);
4553
4351
  const iframe = useAppStore((s) => s.iframe);
4554
- const ctx = (0, import_react25.useContext)(dropZoneContext);
4555
- const [localZones, setLocalZones] = (0, import_react25.useState)({});
4556
- const registerLocalZone = (0, import_react25.useCallback)(
4352
+ const ctx = (0, import_react26.useContext)(dropZoneContext);
4353
+ const [localZones, setLocalZones] = (0, import_react26.useState)({});
4354
+ const registerLocalZone = (0, import_react26.useCallback)(
4557
4355
  (zoneCompound2, active) => {
4558
4356
  var _a;
4559
4357
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4563,7 +4361,7 @@ var DraggableComponent = ({
4563
4361
  },
4564
4362
  [setLocalZones]
4565
4363
  );
4566
- const unregisterLocalZone = (0, import_react25.useCallback)(
4364
+ const unregisterLocalZone = (0, import_react26.useCallback)(
4567
4365
  (zoneCompound2) => {
4568
4366
  var _a;
4569
4367
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4586,14 +4384,17 @@ var DraggableComponent = ({
4586
4384
  return s.permissions.getPermissions({ item });
4587
4385
  })
4588
4386
  );
4589
- const userIsDragging = useContextStore(
4590
- ZoneStoreContext,
4591
- (s) => !!s.draggedItem
4387
+ const zoneStore = (0, import_react26.useContext)(ZoneStoreContext);
4388
+ const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
4389
+ const dynamicCollisionDetector = (0, import_react26.useMemo)(
4390
+ () => createDynamicCollisionDetector(dragAxis),
4391
+ [dragAxis]
4592
4392
  );
4593
- const canCollide = permissions.drag || userIsDragging;
4594
- const disabled = !isEnabled || !canCollide;
4595
- const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
4596
- const { ref: sortableRef, status } = useSortableSafe({
4393
+ const {
4394
+ ref: sortableRef,
4395
+ isDragging: thisIsDragging,
4396
+ sortable
4397
+ } = (0, import_sortable2.useSortable)({
4597
4398
  id,
4598
4399
  index,
4599
4400
  group: zoneCompound,
@@ -4608,18 +4409,34 @@ var DraggableComponent = ({
4608
4409
  path: path || [],
4609
4410
  inDroppableZone
4610
4411
  },
4611
- collisionPriority: isEnabled ? depth : 0,
4612
- collisionDetector: createDynamicCollisionDetector(dragAxis),
4613
- disabled,
4412
+ collisionPriority: depth,
4413
+ collisionDetector: dynamicCollisionDetector,
4614
4414
  // "Out of the way" transition from react-beautiful-dnd
4615
4415
  transition: {
4616
4416
  duration: 200,
4617
4417
  easing: "cubic-bezier(0.2, 0, 0, 1)"
4618
- }
4418
+ },
4419
+ feedback: "clone"
4619
4420
  });
4620
- const thisIsDragging = status === "dragging";
4621
- const ref = (0, import_react25.useRef)(null);
4622
- const refSetter = (0, import_react25.useCallback)(
4421
+ (0, import_react26.useEffect)(() => {
4422
+ const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
4423
+ sortable.droppable.disabled = !isEnabled;
4424
+ sortable.draggable.disabled = !permissions.drag;
4425
+ const cleanup = zoneStore.subscribe((s) => {
4426
+ sortable.droppable.disabled = !s.enabledIndex[zoneCompound];
4427
+ });
4428
+ if (ref.current && !permissions.drag) {
4429
+ ref.current.setAttribute("data-puck-disabled", "");
4430
+ return () => {
4431
+ var _a;
4432
+ (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4433
+ cleanup();
4434
+ };
4435
+ }
4436
+ return cleanup;
4437
+ }, [permissions.drag, zoneCompound]);
4438
+ const ref = (0, import_react26.useRef)(null);
4439
+ const refSetter = (0, import_react26.useCallback)(
4623
4440
  (el) => {
4624
4441
  sortableRef(el);
4625
4442
  if (el) {
@@ -4628,14 +4445,14 @@ var DraggableComponent = ({
4628
4445
  },
4629
4446
  [sortableRef]
4630
4447
  );
4631
- const [portalEl, setPortalEl] = (0, import_react25.useState)();
4632
- (0, import_react25.useEffect)(() => {
4448
+ const [portalEl, setPortalEl] = (0, import_react26.useState)();
4449
+ (0, import_react26.useEffect)(() => {
4633
4450
  var _a, _b, _c;
4634
4451
  setPortalEl(
4635
4452
  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
4636
4453
  );
4637
4454
  }, [iframe.enabled, ref.current]);
4638
- const getStyle = (0, import_react25.useCallback)(() => {
4455
+ const getStyle = (0, import_react26.useCallback)(() => {
4639
4456
  var _a, _b, _c;
4640
4457
  if (!ref.current) return;
4641
4458
  const rect = ref.current.getBoundingClientRect();
@@ -4647,40 +4464,61 @@ var DraggableComponent = ({
4647
4464
  x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
4648
4465
  y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
4649
4466
  };
4467
+ const untransformed = {
4468
+ height: ref.current.offsetHeight,
4469
+ width: ref.current.offsetWidth
4470
+ };
4471
+ const transform = accumulateTransform(ref.current);
4650
4472
  const style2 = {
4651
- left: `${rect.left + scroll.x}px`,
4652
- top: `${rect.top + scroll.y}px`,
4653
- height: `${rect.height}px`,
4654
- width: `${rect.width}px`
4473
+ left: `${(rect.left + scroll.x) / transform.scaleX}px`,
4474
+ top: `${(rect.top + scroll.y) / transform.scaleY}px`,
4475
+ height: `${untransformed.height}px`,
4476
+ width: `${untransformed.width}px`
4655
4477
  };
4656
4478
  return style2;
4657
4479
  }, [ref.current]);
4658
- const [style, setStyle] = (0, import_react25.useState)();
4659
- const sync = (0, import_react25.useCallback)(() => {
4480
+ const [style, setStyle] = (0, import_react26.useState)();
4481
+ const sync = (0, import_react26.useCallback)(() => {
4660
4482
  setStyle(getStyle());
4661
4483
  }, [ref.current, iframe]);
4662
- (0, import_react25.useEffect)(() => {
4663
- if (ref.current && !userIsDragging) {
4484
+ (0, import_react26.useEffect)(() => {
4485
+ if (ref.current) {
4664
4486
  const observer = new ResizeObserver(sync);
4665
4487
  observer.observe(ref.current);
4666
4488
  return () => {
4667
4489
  observer.disconnect();
4668
4490
  };
4669
4491
  }
4670
- }, [ref.current, userIsDragging]);
4492
+ }, [ref.current]);
4671
4493
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4672
- (0, import_react25.useEffect)(() => {
4494
+ const hideOverlay = (0, import_react26.useCallback)(() => {
4495
+ setIsVisible(false);
4496
+ }, []);
4497
+ const showOverlay = (0, import_react26.useCallback)(() => {
4498
+ setIsVisible(true);
4499
+ }, []);
4500
+ (0, import_react26.useEffect)(() => {
4673
4501
  var _a;
4674
- registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4502
+ registerNode(id, {
4503
+ methods: { sync, showOverlay, hideOverlay },
4504
+ element: (_a = ref.current) != null ? _a : null
4505
+ });
4675
4506
  return () => {
4676
- registerNode(id, { methods: { sync: () => null }, element: null });
4507
+ registerNode(id, {
4508
+ methods: {
4509
+ sync: () => null,
4510
+ hideOverlay: () => null,
4511
+ showOverlay: () => null
4512
+ },
4513
+ element: null
4514
+ });
4677
4515
  };
4678
4516
  }, [id, zoneCompound, index, componentType, sync]);
4679
- const CustomActionBar = (0, import_react25.useMemo)(
4517
+ const CustomActionBar = (0, import_react26.useMemo)(
4680
4518
  () => overrides.actionBar || DefaultActionBar,
4681
4519
  [overrides.actionBar]
4682
4520
  );
4683
- const onClick = (0, import_react25.useCallback)(
4521
+ const onClick = (0, import_react26.useCallback)(
4684
4522
  (e) => {
4685
4523
  e.stopPropagation();
4686
4524
  dispatch({
@@ -4693,7 +4531,7 @@ var DraggableComponent = ({
4693
4531
  [index, zoneCompound, id]
4694
4532
  );
4695
4533
  const appStore = useAppStoreApi();
4696
- const onSelectParent = (0, import_react25.useCallback)(() => {
4534
+ const onSelectParent = (0, import_react26.useCallback)(() => {
4697
4535
  const { nodes, zones } = appStore.getState().state.indexes;
4698
4536
  const node = nodes[id];
4699
4537
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4714,28 +4552,32 @@ var DraggableComponent = ({
4714
4552
  }
4715
4553
  });
4716
4554
  }, [ctx, path]);
4717
- const onDuplicate = (0, import_react25.useCallback)(() => {
4555
+ const onDuplicate = (0, import_react26.useCallback)(() => {
4718
4556
  dispatch({
4719
4557
  type: "duplicate",
4720
4558
  sourceIndex: index,
4721
4559
  sourceZone: zoneCompound
4722
4560
  });
4723
4561
  }, [index, zoneCompound]);
4724
- const onDelete = (0, import_react25.useCallback)(() => {
4562
+ const onDelete = (0, import_react26.useCallback)(() => {
4725
4563
  dispatch({
4726
4564
  type: "remove",
4727
4565
  index,
4728
4566
  zone: zoneCompound
4729
4567
  });
4730
4568
  }, [index, zoneCompound]);
4731
- const [hover, setHover] = (0, import_react25.useState)(false);
4732
- const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4733
- (0, import_react25.useEffect)(() => {
4569
+ const [hover, setHover] = (0, import_react26.useState)(false);
4570
+ const indicativeHover = useContextStore(
4571
+ ZoneStoreContext,
4572
+ (s) => s.hoveringComponent === id
4573
+ );
4574
+ (0, import_react26.useEffect)(() => {
4734
4575
  if (!ref.current) {
4735
4576
  return;
4736
4577
  }
4737
4578
  const el = ref.current;
4738
4579
  const _onMouseOver = (e) => {
4580
+ const userIsDragging = !!zoneStore.getState().draggedItem;
4739
4581
  if (userIsDragging) {
4740
4582
  if (thisIsDragging) {
4741
4583
  setHover(true);
@@ -4757,18 +4599,12 @@ var DraggableComponent = ({
4757
4599
  el.addEventListener("click", onClick);
4758
4600
  el.addEventListener("mouseover", _onMouseOver);
4759
4601
  el.addEventListener("mouseout", _onMouseOut);
4760
- if (thisIsDragging) {
4761
- el.setAttribute("data-puck-dragging", "");
4762
- } else {
4763
- el.removeAttribute("data-puck-dragging");
4764
- }
4765
4602
  return () => {
4766
4603
  el.removeAttribute("data-puck-component");
4767
4604
  el.removeAttribute("data-puck-dnd");
4768
4605
  el.removeEventListener("click", onClick);
4769
4606
  el.removeEventListener("mouseover", _onMouseOver);
4770
4607
  el.removeEventListener("mouseout", _onMouseOut);
4771
- el.removeAttribute("data-puck-dragging");
4772
4608
  };
4773
4609
  }, [
4774
4610
  ref,
@@ -4776,29 +4612,43 @@ var DraggableComponent = ({
4776
4612
  containsActiveZone,
4777
4613
  zoneCompound,
4778
4614
  id,
4779
- userIsDragging,
4780
4615
  thisIsDragging,
4781
4616
  inDroppableZone
4782
4617
  ]);
4783
- (0, import_react25.useEffect)(() => {
4784
- if (ref.current && disabled) {
4785
- ref.current.setAttribute("data-puck-disabled", "");
4786
- return () => {
4787
- var _a;
4788
- (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4789
- };
4790
- }
4791
- }, [disabled, ref]);
4792
- const [isVisible, setIsVisible] = (0, import_react25.useState)(false);
4793
- (0, import_react25.useEffect)(() => {
4794
- sync();
4795
- if ((isSelected || hover || indicativeHover) && !userIsDragging) {
4796
- setIsVisible(true);
4618
+ const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
4619
+ const [dragFinished, setDragFinished] = (0, import_react26.useState)(true);
4620
+ const [_, startTransition] = (0, import_react26.useTransition)();
4621
+ (0, import_react26.useEffect)(() => {
4622
+ startTransition(() => {
4623
+ if (hover || indicativeHover || isSelected) {
4624
+ sync();
4625
+ setIsVisible(true);
4626
+ setThisWasDragging(false);
4627
+ } else {
4628
+ setIsVisible(false);
4629
+ }
4630
+ });
4631
+ }, [hover, indicativeHover, isSelected, iframe]);
4632
+ const [thisWasDragging, setThisWasDragging] = (0, import_react26.useState)(false);
4633
+ const onDragFinished = useOnDragFinished((finished) => {
4634
+ if (finished) {
4635
+ startTransition(() => {
4636
+ sync();
4637
+ setDragFinished(true);
4638
+ });
4797
4639
  } else {
4798
- setIsVisible(false);
4640
+ setDragFinished(false);
4641
+ }
4642
+ });
4643
+ (0, import_react26.useEffect)(() => {
4644
+ if (thisIsDragging) {
4645
+ setThisWasDragging(true);
4799
4646
  }
4800
- }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
4801
- const syncActionsPosition = (0, import_react25.useCallback)(
4647
+ }, [thisIsDragging]);
4648
+ (0, import_react26.useEffect)(() => {
4649
+ if (thisWasDragging) return onDragFinished();
4650
+ }, [thisWasDragging, onDragFinished]);
4651
+ const syncActionsPosition = (0, import_react26.useCallback)(
4802
4652
  (el) => {
4803
4653
  if (el) {
4804
4654
  const view = el.ownerDocument.defaultView;
@@ -4823,7 +4673,7 @@ var DraggableComponent = ({
4823
4673
  },
4824
4674
  [zoom]
4825
4675
  );
4826
- (0, import_react25.useEffect)(() => {
4676
+ (0, import_react26.useEffect)(() => {
4827
4677
  if (userDragAxis) {
4828
4678
  setDragAxis(userDragAxis);
4829
4679
  return;
@@ -4837,8 +4687,11 @@ var DraggableComponent = ({
4837
4687
  }
4838
4688
  setDragAxis(autoDragAxis);
4839
4689
  }, [ref, userDragAxis, autoDragAxis]);
4840
- const parentAction = (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 }) });
4841
- const nextContextValue = (0, import_react25.useMemo)(
4690
+ const parentAction = (0, import_react26.useMemo)(
4691
+ () => (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 }) }),
4692
+ [ctx == null ? void 0 : ctx.areaId]
4693
+ );
4694
+ const nextContextValue = (0, import_react26.useMemo)(
4842
4695
  () => __spreadProps(__spreadValues({}, ctx), {
4843
4696
  areaId: id,
4844
4697
  zoneCompound,
@@ -4858,7 +4711,7 @@ var DraggableComponent = ({
4858
4711
  ]
4859
4712
  );
4860
4713
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
4861
- isVisible && (0, import_react_dom2.createPortal)(
4714
+ dragFinished && isVisible && (0, import_react_dom2.createPortal)(
4862
4715
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4863
4716
  "div",
4864
4717
  {
@@ -4918,19 +4771,23 @@ var DraggableComponent = ({
4918
4771
 
4919
4772
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
4920
4773
  init_react_import();
4921
- var styles_module_default12 = { "DropZone": "_DropZone_3dmev_1", "DropZone--hasChildren": "_DropZone--hasChildren_3dmev_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_3dmev_19", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_3dmev_23", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_3dmev_24", "DropZone--isRootZone": "_DropZone--isRootZone_3dmev_24", "DropZone--isDestination": "_DropZone--isDestination_3dmev_34", "DropZone-item": "_DropZone-item_3dmev_46", "DropZone-hitbox": "_DropZone-hitbox_3dmev_50", "DropZone--isEnabled": "_DropZone--isEnabled_3dmev_58", "DropZone--isAnimating": "_DropZone--isAnimating_3dmev_67" };
4774
+ var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
4775
+
4776
+ // components/DropZone/index.tsx
4777
+ var import_react36 = require("@dnd-kit/react");
4922
4778
 
4923
4779
  // components/DropZone/lib/use-min-empty-height.ts
4924
4780
  init_react_import();
4925
- var import_react26 = require("react");
4781
+ var import_react27 = require("react");
4782
+ var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
4926
4783
  var useMinEmptyHeight = ({
4927
4784
  zoneCompound,
4928
4785
  userMinEmptyHeight,
4929
4786
  ref
4930
4787
  }) => {
4931
4788
  const appStore = useAppStoreApi();
4932
- const [prevHeight, setPrevHeight] = (0, import_react26.useState)(0);
4933
- const [isAnimating, setIsAnimating] = (0, import_react26.useState)(false);
4789
+ const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
4790
+ const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
4934
4791
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
4935
4792
  var _a, _b;
4936
4793
  return {
@@ -4938,32 +4795,52 @@ var useMinEmptyHeight = ({
4938
4795
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4939
4796
  };
4940
4797
  });
4941
- (0, import_react26.useEffect)(() => {
4798
+ const numItems = (0, import_react27.useRef)(0);
4799
+ const onDragFinished = useOnDragFinished(
4800
+ (finished) => {
4801
+ var _a;
4802
+ if (finished) {
4803
+ const newNumItems = getNumItems(appStore, zoneCompound);
4804
+ setPrevHeight(0);
4805
+ if (newNumItems || numItems.current === 0) {
4806
+ setIsAnimating(false);
4807
+ return;
4808
+ }
4809
+ const selectedItem = appStore.getState().selectedItem;
4810
+ const zones = appStore.getState().state.indexes.zones;
4811
+ const nodes = appStore.getState().nodes;
4812
+ (_a = nodes.nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.methods.hideOverlay();
4813
+ setTimeout(() => {
4814
+ var _a2;
4815
+ const contentIds = ((_a2 = zones[zoneCompound]) == null ? void 0 : _a2.contentIds) || [];
4816
+ contentIds.forEach((contentId) => {
4817
+ const node = nodes.nodes[contentId];
4818
+ node == null ? void 0 : node.methods.sync();
4819
+ });
4820
+ if (selectedItem) {
4821
+ setTimeout(() => {
4822
+ var _a3, _b;
4823
+ (_a3 = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _a3.methods.sync();
4824
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.showOverlay();
4825
+ }, 200);
4826
+ }
4827
+ setIsAnimating(false);
4828
+ }, 100);
4829
+ }
4830
+ },
4831
+ [appStore, prevHeight, zoneCompound]
4832
+ );
4833
+ (0, import_react27.useEffect)(() => {
4942
4834
  if (draggedItem && ref.current) {
4943
4835
  if (isZone) {
4944
4836
  const rect = ref.current.getBoundingClientRect();
4837
+ numItems.current = getNumItems(appStore, zoneCompound);
4945
4838
  setPrevHeight(rect.height);
4946
4839
  setIsAnimating(true);
4947
- return;
4840
+ return onDragFinished();
4948
4841
  }
4949
4842
  }
4950
- setPrevHeight(0);
4951
- setTimeout(() => {
4952
- var _a, _b;
4953
- const zones = appStore.getState().state.indexes.zones;
4954
- const nodes = appStore.getState().nodes;
4955
- const selectedItem = appStore.getState().selectedItem;
4956
- const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
4957
- contentIds.forEach((contentId) => {
4958
- const node = nodes.nodes[contentId];
4959
- node == null ? void 0 : node.methods.sync();
4960
- });
4961
- if (selectedItem) {
4962
- (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
4963
- }
4964
- setIsAnimating(false);
4965
- }, 400);
4966
- }, [ref.current, draggedItem, zoneCompound]);
4843
+ }, [ref.current, draggedItem, onDragFinished]);
4967
4844
  return [prevHeight || userMinEmptyHeight, isAnimating];
4968
4845
  };
4969
4846
 
@@ -4984,15 +4861,15 @@ function assignRefs(refs, node) {
4984
4861
 
4985
4862
  // components/DropZone/lib/use-content-with-preview.ts
4986
4863
  init_react_import();
4987
- var import_react29 = require("react");
4864
+ var import_react30 = require("react");
4988
4865
 
4989
4866
  // lib/dnd/use-rendered-callback.ts
4990
4867
  init_react_import();
4991
- var import_react27 = require("@dnd-kit/react");
4992
- var import_react28 = require("react");
4868
+ var import_react28 = require("@dnd-kit/react");
4869
+ var import_react29 = require("react");
4993
4870
  function useRenderedCallback(callback, deps) {
4994
- const manager = (0, import_react27.useDragDropManager)();
4995
- return (0, import_react28.useCallback)(
4871
+ const manager = (0, import_react28.useDragDropManager)();
4872
+ return (0, import_react29.useCallback)(
4996
4873
  (...args) => __async(this, null, function* () {
4997
4874
  yield manager == null ? void 0 : manager.renderer.rendering;
4998
4875
  return callback(...args);
@@ -5003,27 +4880,21 @@ function useRenderedCallback(callback, deps) {
5003
4880
 
5004
4881
  // components/DropZone/lib/use-content-with-preview.ts
5005
4882
  var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5006
- const { draggedItemId, preview, previewExists } = useContextStore(
4883
+ const zoneStore = (0, import_react30.useContext)(ZoneStoreContext);
4884
+ const preview = useContextStore(
5007
4885
  ZoneStoreContext,
5008
- (s) => {
5009
- var _a;
5010
- return {
5011
- draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
5012
- preview: s.previewIndex[zoneCompound],
5013
- previewExists: Object.keys(s.previewIndex || {}).length > 0
5014
- };
5015
- }
4886
+ (s) => s.previewIndex[zoneCompound]
5016
4887
  );
5017
4888
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
5018
- const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react29.useState)(contentIds);
5019
- const [localPreview, setLocalPreview] = (0, import_react29.useState)(
4889
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
4890
+ const [localPreview, setLocalPreview] = (0, import_react30.useState)(
5020
4891
  preview
5021
4892
  );
5022
4893
  const updateContent = useRenderedCallback(
5023
- (contentIds2, preview2, isDragging2) => {
5024
- if (isDragging2 && !previewExists) {
5025
- return;
5026
- }
4894
+ (contentIds2, preview2) => {
4895
+ var _a;
4896
+ const s = zoneStore.getState();
4897
+ const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
5027
4898
  if (preview2) {
5028
4899
  if (preview2.type === "insert") {
5029
4900
  setContentIdsWithPreview(
@@ -5044,14 +4915,14 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5044
4915
  }
5045
4916
  } else {
5046
4917
  setContentIdsWithPreview(
5047
- previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
4918
+ contentIds2.filter((id) => id !== draggedItemId)
5048
4919
  );
5049
4920
  }
5050
4921
  setLocalPreview(preview2);
5051
4922
  },
5052
- [draggedItemId, previewExists]
4923
+ []
5053
4924
  );
5054
- (0, import_react29.useEffect)(() => {
4925
+ (0, import_react30.useEffect)(() => {
5055
4926
  updateContent(contentIds, preview, isDragging);
5056
4927
  }, [contentIds, preview, isDragging]);
5057
4928
  return [contentIdsWithPreview, localPreview];
@@ -5059,16 +4930,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5059
4930
 
5060
4931
  // components/DropZone/lib/use-drag-axis.ts
5061
4932
  init_react_import();
5062
- var import_react30 = require("react");
4933
+ var import_react31 = require("react");
5063
4934
  var GRID_DRAG_AXIS = "dynamic";
5064
4935
  var FLEX_ROW_DRAG_AXIS = "x";
5065
4936
  var DEFAULT_DRAG_AXIS = "y";
5066
4937
  var useDragAxis = (ref, collisionAxis) => {
5067
4938
  const status = useAppStore((s) => s.status);
5068
- const [dragAxis, setDragAxis] = (0, import_react30.useState)(
4939
+ const [dragAxis, setDragAxis] = (0, import_react31.useState)(
5069
4940
  collisionAxis || DEFAULT_DRAG_AXIS
5070
4941
  );
5071
- const calculateDragAxis = (0, import_react30.useCallback)(() => {
4942
+ const calculateDragAxis = (0, import_react31.useCallback)(() => {
5072
4943
  if (ref.current) {
5073
4944
  const computedStyle = window.getComputedStyle(ref.current);
5074
4945
  if (computedStyle.display === "grid") {
@@ -5080,7 +4951,7 @@ var useDragAxis = (ref, collisionAxis) => {
5080
4951
  }
5081
4952
  }
5082
4953
  }, [ref.current]);
5083
- (0, import_react30.useEffect)(() => {
4954
+ (0, import_react31.useEffect)(() => {
5084
4955
  const onViewportChange = () => {
5085
4956
  calculateDragAxis();
5086
4957
  };
@@ -5089,7 +4960,7 @@ var useDragAxis = (ref, collisionAxis) => {
5089
4960
  window.removeEventListener("viewportchange", onViewportChange);
5090
4961
  };
5091
4962
  }, []);
5092
- (0, import_react30.useEffect)(calculateDragAxis, [status, collisionAxis]);
4963
+ (0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
5093
4964
  return [dragAxis, calculateDragAxis];
5094
4965
  };
5095
4966
 
@@ -5101,9 +4972,9 @@ init_react_import();
5101
4972
 
5102
4973
  // lib/use-slots.tsx
5103
4974
  init_react_import();
5104
- var import_react31 = require("react");
5105
- function useSlots(config, props, renderSlot) {
5106
- const slotProps = (0, import_react31.useMemo)(() => {
4975
+ var import_react32 = require("react");
4976
+ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
4977
+ const slotProps = (0, import_react32.useMemo)(() => {
5107
4978
  if (!(config == null ? void 0 : config.fields)) return props;
5108
4979
  const slotProps2 = {};
5109
4980
  const fieldKeys = Object.keys(config.fields);
@@ -5112,7 +4983,11 @@ function useSlots(config, props, renderSlot) {
5112
4983
  const field = config.fields[fieldKey];
5113
4984
  if ((field == null ? void 0 : field.type) === "slot") {
5114
4985
  const content = props[fieldKey] || [];
5115
- const Slot = (dzProps) => renderSlot(__spreadProps(__spreadValues({}, dzProps), {
4986
+ const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
4987
+ const Slot = (dzProps) => render(__spreadProps(__spreadValues({
4988
+ allow: field.allow,
4989
+ disallow: field.disallow
4990
+ }, dzProps), {
5116
4991
  zone: fieldKey,
5117
4992
  content
5118
4993
  }));
@@ -5120,49 +4995,135 @@ function useSlots(config, props, renderSlot) {
5120
4995
  }
5121
4996
  }
5122
4997
  return slotProps2;
5123
- }, [config]);
5124
- return __spreadValues(__spreadValues({}, props), slotProps);
4998
+ }, [config, readOnly, forceReadOnly]);
4999
+ const mergedProps = (0, import_react32.useMemo)(
5000
+ () => __spreadValues(__spreadValues({}, props), slotProps),
5001
+ [props, slotProps]
5002
+ );
5003
+ return mergedProps;
5125
5004
  }
5126
5005
 
5127
5006
  // components/Render/index.tsx
5128
- var import_react33 = __toESM(require("react"));
5007
+ var import_react34 = __toESM(require("react"));
5129
5008
 
5130
5009
  // components/SlotRender/index.tsx
5131
5010
  init_react_import();
5132
- var import_react32 = require("react");
5011
+
5012
+ // components/SlotRender/server.tsx
5013
+ init_react_import();
5014
+ var import_react33 = require("react");
5015
+
5016
+ // components/ServerRender/index.tsx
5017
+ init_react_import();
5133
5018
  var import_jsx_runtime21 = require("react/jsx-runtime");
5134
- var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRender, __spreadValues({}, props));
5135
- var SlotRender = (0, import_react32.forwardRef)(
5136
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5137
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
5138
- const Component = config.components[item.type];
5139
- if (Component) {
5140
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
5141
- SlotRenderPure,
5142
- __spreadProps(__spreadValues({}, slotProps), {
5019
+ function DropZoneRender({
5020
+ zone,
5021
+ data,
5022
+ areaId = "root",
5023
+ config,
5024
+ metadata = {}
5025
+ }) {
5026
+ let zoneCompound = rootDroppableId;
5027
+ let content = (data == null ? void 0 : data.content) || [];
5028
+ if (!data || !config) {
5029
+ return null;
5030
+ }
5031
+ if (areaId !== rootAreaId && zone !== rootZone) {
5032
+ zoneCompound = `${areaId}:${zone}`;
5033
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
5034
+ }
5035
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
5036
+ const Component = config.components[item.type];
5037
+ const props = __spreadProps(__spreadValues({}, item.props), {
5038
+ puck: {
5039
+ renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
5040
+ DropZoneRender,
5041
+ {
5042
+ zone: zone2,
5043
+ data,
5044
+ areaId: item.props.id,
5143
5045
  config,
5144
5046
  metadata
5145
- })
5146
- ));
5147
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
5148
- Component.render,
5149
- __spreadProps(__spreadValues({}, props), {
5150
- puck: {
5151
- renderDropZone: DropZoneRenderPure,
5152
- metadata: metadata || {}
5153
- }
5154
- }),
5155
- props.id
5156
- );
5047
+ }
5048
+ ),
5049
+ metadata
5157
5050
  }
5158
- return null;
5051
+ });
5052
+ const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
5053
+ if (Component) {
5054
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
5055
+ }
5056
+ return null;
5057
+ }) });
5058
+ }
5059
+
5060
+ // components/SlotRender/server.tsx
5061
+ var import_jsx_runtime22 = require("react/jsx-runtime");
5062
+ var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
5063
+ var Item = ({
5064
+ config,
5065
+ item,
5066
+ metadata
5067
+ }) => {
5068
+ const Component = config.components[item.type];
5069
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5070
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5071
+ Component.render,
5072
+ __spreadProps(__spreadValues({}, props), {
5073
+ puck: __spreadProps(__spreadValues({}, props.puck), {
5074
+ renderDropZone: DropZoneRender,
5075
+ metadata: metadata || {}
5076
+ })
5077
+ })
5078
+ );
5079
+ };
5080
+ var SlotRender = (0, import_react33.forwardRef)(
5081
+ function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5082
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
5083
+ if (!config.components[item.type]) {
5084
+ return null;
5085
+ }
5086
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5087
+ Item,
5088
+ {
5089
+ config,
5090
+ item,
5091
+ metadata
5092
+ },
5093
+ item.props.id
5094
+ );
5159
5095
  }) });
5160
5096
  }
5161
5097
  );
5162
5098
 
5099
+ // components/SlotRender/index.tsx
5100
+ var import_jsx_runtime23 = require("react/jsx-runtime");
5101
+ var ContextSlotRender = ({
5102
+ componentId,
5103
+ zone
5104
+ }) => {
5105
+ const config = useAppStore((s) => s.config);
5106
+ const metadata = useAppStore((s) => s.metadata);
5107
+ const slotContent = useAppStore(
5108
+ (s) => {
5109
+ var _a, _b;
5110
+ return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
5111
+ }
5112
+ );
5113
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5114
+ SlotRenderPure,
5115
+ {
5116
+ content: slotContent,
5117
+ zone,
5118
+ config,
5119
+ metadata
5120
+ }
5121
+ );
5122
+ };
5123
+
5163
5124
  // components/Render/index.tsx
5164
- var import_jsx_runtime22 = require("react/jsx-runtime");
5165
- var renderContext = import_react33.default.createContext({
5125
+ var import_jsx_runtime24 = require("react/jsx-runtime");
5126
+ var renderContext = import_react34.default.createContext({
5166
5127
  config: { components: {} },
5167
5128
  data: { root: {}, content: [] },
5168
5129
  metadata: {}
@@ -5190,8 +5151,8 @@ function Render({
5190
5151
  editMode: false,
5191
5152
  id: "puck-root"
5192
5153
  });
5193
- const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
5194
- const nextContextValue = (0, import_react33.useMemo)(
5154
+ const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
5155
+ const nextContextValue = (0, import_react34.useMemo)(
5195
5156
  () => ({
5196
5157
  mode: "render",
5197
5158
  depth: 0
@@ -5199,37 +5160,30 @@ function Render({
5199
5160
  []
5200
5161
  );
5201
5162
  if ((_a = config.root) == null ? void 0 : _a.render) {
5202
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone }) })) }) });
5163
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneRenderPure, { zone: rootZone }) })) }) });
5203
5164
  }
5204
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone }) }) });
5165
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneRenderPure, { zone: rootZone }) }) });
5205
5166
  }
5206
5167
 
5207
5168
  // components/DropZone/index.tsx
5208
- var import_jsx_runtime23 = require("react/jsx-runtime");
5169
+ var import_jsx_runtime25 = require("react/jsx-runtime");
5209
5170
  var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
5210
5171
  var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
5211
5172
  var RENDER_DEBUG = false;
5212
- var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneEdit, __spreadValues({}, props));
5173
+ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadValues({}, props));
5213
5174
  var DropZoneChild = ({
5214
5175
  zoneCompound,
5215
5176
  componentId,
5216
- preview,
5217
5177
  index,
5218
- isEnabled,
5219
5178
  dragAxis,
5220
5179
  collisionAxis,
5221
5180
  inDroppableZone
5222
5181
  }) => {
5223
5182
  var _a, _b;
5224
5183
  const metadata = useAppStore((s) => s.metadata);
5225
- const puckProps = {
5226
- renderDropZone: DropZoneEditPure,
5227
- isEditing: true,
5228
- dragRef: null,
5229
- metadata
5230
- };
5231
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5184
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5232
5185
  const { depth = 1 } = ctx != null ? ctx : {};
5186
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5233
5187
  const nodeProps = useAppStore(
5234
5188
  (0, import_shallow3.useShallow)((s) => {
5235
5189
  var _a2;
@@ -5242,11 +5196,38 @@ var DropZoneChild = ({
5242
5196
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
5243
5197
  }
5244
5198
  );
5245
- const node = { type: nodeType, props: nodeProps };
5246
- const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
5199
+ const nodeReadOnly = useAppStore(
5200
+ (0, import_shallow3.useShallow)((s) => {
5201
+ var _a2;
5202
+ return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
5203
+ })
5204
+ );
5205
+ const item = (0, import_react35.useMemo)(() => {
5206
+ if (nodeProps) {
5207
+ return { type: nodeType, props: nodeProps };
5208
+ }
5209
+ const preview = zoneStore.getState().previewIndex[zoneCompound];
5210
+ if (componentId === (preview == null ? void 0 : preview.props.id)) {
5211
+ return {
5212
+ type: preview.componentType,
5213
+ props: preview.props,
5214
+ previewType: preview.type
5215
+ };
5216
+ }
5217
+ return null;
5218
+ }, [componentId, zoneCompound, nodeType, nodeProps]);
5247
5219
  const componentConfig = useAppStore(
5248
5220
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5249
5221
  );
5222
+ const puckProps = (0, import_react35.useMemo)(
5223
+ () => ({
5224
+ renderDropZone: DropZoneEditPure,
5225
+ isEditing: true,
5226
+ dragRef: null,
5227
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5228
+ }),
5229
+ [metadata, componentConfig == null ? void 0 : componentConfig.metadata]
5230
+ );
5250
5231
  const overrides = useAppStore((s) => s.overrides);
5251
5232
  const isLoading = useAppStore(
5252
5233
  (s) => {
@@ -5261,13 +5242,13 @@ var DropZoneChild = ({
5261
5242
  }
5262
5243
  );
5263
5244
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5264
- const renderPreview = (0, import_react34.useMemo)(
5265
- () => function Preview4() {
5266
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5245
+ const renderPreview = (0, import_react35.useMemo)(
5246
+ () => function Preview3() {
5247
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5267
5248
  },
5268
5249
  [componentId, label, overrides]
5269
5250
  );
5270
- const defaultsProps = (0, import_react34.useMemo)(
5251
+ const defaultsProps = (0, import_react35.useMemo)(
5271
5252
  () => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
5272
5253
  puck: puckProps,
5273
5254
  editMode: true
@@ -5278,19 +5259,22 @@ var DropZoneChild = ({
5278
5259
  const defaultedPropsWithSlots = useSlots(
5279
5260
  componentConfig,
5280
5261
  defaultsProps,
5281
- DropZoneEditPure
5262
+ DropZoneEditPure,
5263
+ (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
5264
+ nodeReadOnly,
5265
+ isLoading
5282
5266
  );
5283
5267
  if (!item) return;
5284
- let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
5268
+ let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
5285
5269
  "No configuration for ",
5286
5270
  item.type
5287
5271
  ] });
5288
5272
  let componentType = item.type;
5289
- const isPreview = componentId === (preview == null ? void 0 : preview.props.id) && preview.type === "insert";
5290
- if (isPreview) {
5273
+ const isInserting = item.previewType === "insert";
5274
+ if (isInserting) {
5291
5275
  Render2 = renderPreview;
5292
5276
  }
5293
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5277
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5294
5278
  DraggableComponent,
5295
5279
  {
5296
5280
  id: componentId,
@@ -5301,23 +5285,22 @@ var DropZoneChild = ({
5301
5285
  isLoading,
5302
5286
  isSelected,
5303
5287
  label,
5304
- isEnabled,
5305
5288
  autoDragAxis: dragAxis,
5306
5289
  userDragAxis: collisionAxis,
5307
5290
  inDroppableZone,
5308
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5291
+ 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)(
5309
5292
  Render2,
5310
5293
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5311
5294
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
5312
5295
  dragRef
5313
5296
  })
5314
5297
  })
5315
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
5298
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
5316
5299
  }
5317
5300
  );
5318
5301
  };
5319
- var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
5320
- var DropZoneEdit = (0, import_react34.forwardRef)(
5302
+ var DropZoneChildMemo = (0, import_react35.memo)(DropZoneChild);
5303
+ var DropZoneEdit = (0, import_react35.forwardRef)(
5321
5304
  function DropZoneEditInternal({
5322
5305
  zone,
5323
5306
  allow,
@@ -5327,7 +5310,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5327
5310
  minEmptyHeight: userMinEmptyHeight = 128,
5328
5311
  collisionAxis
5329
5312
  }, userRef) {
5330
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5313
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5331
5314
  const {
5332
5315
  // These all need setting via context
5333
5316
  areaId,
@@ -5348,20 +5331,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5348
5331
  }
5349
5332
  }
5350
5333
  const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
5351
- const {
5352
- isDeepestZone,
5353
- inNextDeepestArea,
5354
- draggedComponentType,
5355
- userIsDragging
5356
- } = useContextStore(ZoneStoreContext, (s) => {
5357
- var _a, _b;
5358
- return {
5359
- isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
5360
- inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
5361
- draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
5362
- userIsDragging: !!s.draggedItem
5363
- };
5364
- });
5334
+ const inNextDeepestArea = useContextStore(
5335
+ ZoneStoreContext,
5336
+ (s) => s.nextAreaDepthIndex[areaId || ""]
5337
+ );
5365
5338
  const zoneContentIds = useAppStore(
5366
5339
  (0, import_shallow3.useShallow)((s) => {
5367
5340
  var _a;
@@ -5374,7 +5347,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5374
5347
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
5375
5348
  })
5376
5349
  );
5377
- (0, import_react34.useEffect)(() => {
5350
+ (0, import_react35.useEffect)(() => {
5378
5351
  if (!zoneType || zoneType === "dropzone") {
5379
5352
  if (ctx == null ? void 0 : ctx.registerZone) {
5380
5353
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5386,11 +5359,20 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5386
5359
  };
5387
5360
  }
5388
5361
  }, [zoneType]);
5389
- const contentIds = (0, import_react34.useMemo)(() => {
5362
+ (0, import_react35.useEffect)(() => {
5363
+ if (zoneType === "dropzone") {
5364
+ if (zoneCompound !== rootDroppableId) {
5365
+ console.warn(
5366
+ "DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
5367
+ );
5368
+ }
5369
+ }
5370
+ }, [zoneType]);
5371
+ const contentIds = (0, import_react35.useMemo)(() => {
5390
5372
  return zoneContentIds || [];
5391
5373
  }, [zoneContentIds]);
5392
- const ref = (0, import_react34.useRef)(null);
5393
- const acceptsTarget = (0, import_react34.useCallback)(
5374
+ const ref = (0, import_react35.useRef)(null);
5375
+ const acceptsTarget = (0, import_react35.useCallback)(
5394
5376
  (componentType) => {
5395
5377
  if (!componentType) {
5396
5378
  return true;
@@ -5412,29 +5394,44 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5412
5394
  },
5413
5395
  [allow, disallow]
5414
5396
  );
5415
- (0, import_react34.useEffect)(() => {
5397
+ const targetAccepted = useContextStore(ZoneStoreContext, (s) => {
5398
+ var _a;
5399
+ const draggedComponentType = (_a = s.draggedItem) == null ? void 0 : _a.data.componentType;
5400
+ return acceptsTarget(draggedComponentType);
5401
+ });
5402
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
5403
+ const isEnabled = useContextStore(ZoneStoreContext, (s) => {
5404
+ var _a;
5405
+ let _isEnabled = true;
5406
+ const isDeepestZone = (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false;
5407
+ _isEnabled = isDeepestZone;
5408
+ if (_isEnabled) {
5409
+ _isEnabled = targetAccepted;
5410
+ }
5411
+ return _isEnabled;
5412
+ });
5413
+ (0, import_react35.useEffect)(() => {
5416
5414
  if (registerLocalZone) {
5417
- registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
5415
+ registerLocalZone(zoneCompound, isEnabled);
5418
5416
  }
5419
5417
  return () => {
5420
5418
  if (unregisterLocalZone) {
5421
5419
  unregisterLocalZone(zoneCompound);
5422
5420
  }
5423
5421
  };
5424
- }, [draggedComponentType, zoneCompound]);
5425
- const hoveringOverArea = inNextDeepestArea || isRootZone;
5426
- let isEnabled = true;
5427
- if (userIsDragging) {
5428
- isEnabled = isDeepestZone;
5429
- }
5430
- if (isEnabled) {
5431
- isEnabled = acceptsTarget(draggedComponentType);
5432
- }
5422
+ }, [isEnabled, zoneCompound]);
5433
5423
  const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
5434
5424
  contentIds,
5435
5425
  zoneCompound
5436
5426
  );
5437
5427
  const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
5428
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5429
+ (0, import_react35.useEffect)(() => {
5430
+ const { enabledIndex } = zoneStore.getState();
5431
+ zoneStore.setState({
5432
+ enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
5433
+ });
5434
+ }, [isEnabled, zoneStore, zoneCompound]);
5438
5435
  const droppableConfig = {
5439
5436
  id: zoneCompound,
5440
5437
  collisionPriority: isEnabled ? depth : 0,
@@ -5444,11 +5441,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5444
5441
  data: {
5445
5442
  areaId,
5446
5443
  depth,
5447
- isDroppableTarget: acceptsTarget(draggedComponentType),
5444
+ isDroppableTarget: targetAccepted,
5448
5445
  path: path || []
5449
5446
  }
5450
5447
  };
5451
- const { ref: dropRef } = useDroppableSafe(droppableConfig);
5448
+ const { ref: dropRef } = (0, import_react36.useDroppable)(droppableConfig);
5452
5449
  const isAreaSelected = useAppStore(
5453
5450
  (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
5454
5451
  );
@@ -5458,12 +5455,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5458
5455
  userMinEmptyHeight,
5459
5456
  ref
5460
5457
  });
5461
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5458
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5462
5459
  "div",
5463
5460
  {
5464
5461
  className: `${getClassName17({
5465
5462
  isRootZone,
5466
- userIsDragging,
5467
5463
  hoveringOverArea,
5468
5464
  isEnabled,
5469
5465
  isAreaSelected,
@@ -5480,17 +5476,15 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5480
5476
  backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
5481
5477
  }),
5482
5478
  children: contentIdsWithPreview.map((componentId, i) => {
5483
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5479
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5484
5480
  DropZoneChildMemo,
5485
5481
  {
5486
5482
  zoneCompound,
5487
5483
  componentId,
5488
- preview,
5489
5484
  dragAxis,
5490
- isEnabled,
5491
5485
  index: i,
5492
5486
  collisionAxis,
5493
- inDroppableZone: acceptsTarget(draggedComponentType)
5487
+ inDroppableZone: targetAccepted
5494
5488
  },
5495
5489
  componentId
5496
5490
  );
@@ -5499,15 +5493,39 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5499
5493
  );
5500
5494
  }
5501
5495
  );
5502
- var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneRender, __spreadValues({}, props));
5503
- var DropZoneRender = (0, import_react34.forwardRef)(
5496
+ var DropZoneRenderItem = ({
5497
+ config,
5498
+ item,
5499
+ metadata
5500
+ }) => {
5501
+ const Component = config.components[item.type];
5502
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5503
+ const nextContextValue = (0, import_react35.useMemo)(
5504
+ () => ({
5505
+ areaId: props.id,
5506
+ depth: 1
5507
+ }),
5508
+ [props]
5509
+ );
5510
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5511
+ Component.render,
5512
+ __spreadProps(__spreadValues({}, props), {
5513
+ puck: __spreadProps(__spreadValues({}, props.puck), {
5514
+ renderDropZone: DropZoneRenderPure,
5515
+ metadata: __spreadValues(__spreadValues({}, metadata), Component.metadata)
5516
+ })
5517
+ })
5518
+ ) }, props.id);
5519
+ };
5520
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
5521
+ var DropZoneRender2 = (0, import_react35.forwardRef)(
5504
5522
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5505
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5523
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5506
5524
  const { areaId = "root" } = ctx || {};
5507
- const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
5525
+ const { config, data, metadata } = (0, import_react35.useContext)(renderContext);
5508
5526
  let zoneCompound = rootDroppableId;
5509
5527
  let content = (data == null ? void 0 : data.content) || [];
5510
- (0, import_react34.useEffect)(() => {
5528
+ (0, import_react35.useEffect)(() => {
5511
5529
  if (!content) {
5512
5530
  if (ctx == null ? void 0 : ctx.registerZone) {
5513
5531
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5526,52 +5544,37 @@ var DropZoneRender = (0, import_react34.forwardRef)(
5526
5544
  zoneCompound = `${areaId}:${zone}`;
5527
5545
  content = setupZone(data, zoneCompound).zones[zoneCompound];
5528
5546
  }
5529
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className, style, ref, children: content.map((item) => {
5547
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className, style, ref, children: content.map((item) => {
5530
5548
  const Component = config.components[item.type];
5531
5549
  if (Component) {
5532
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5533
- SlotRenderPure,
5534
- __spreadProps(__spreadValues({}, slotProps), {
5550
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5551
+ DropZoneRenderItem,
5552
+ {
5535
5553
  config,
5554
+ item,
5536
5555
  metadata
5537
- })
5538
- ));
5539
- const nextContextValue = (0, import_react34.useMemo)(
5540
- () => ({
5541
- areaId: props.id,
5542
- depth: 1
5543
- }),
5544
- [props]
5556
+ },
5557
+ item.props.id
5545
5558
  );
5546
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5547
- Component.render,
5548
- __spreadProps(__spreadValues({}, props), {
5549
- puck: {
5550
- renderDropZone: DropZoneRenderPure,
5551
- metadata: metadata || {}
5552
- }
5553
- })
5554
- ) }, props.id);
5555
5559
  }
5556
5560
  return null;
5557
5561
  }) });
5558
5562
  }
5559
5563
  );
5560
- var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZone, __spreadValues({}, props));
5561
- var DropZone = (0, import_react34.forwardRef)(
5564
+ var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
5565
+ var DropZone = (0, import_react35.forwardRef)(
5562
5566
  function DropZone2(props, ref) {
5563
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5567
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5564
5568
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5565
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5569
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5566
5570
  }
5567
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
5571
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadProps(__spreadValues({}, props), { ref })) });
5568
5572
  }
5569
5573
  );
5570
5574
 
5571
5575
  // lib/dnd/NestedDroppablePlugin.ts
5572
5576
  init_react_import();
5573
- var import_abstract10 = require("@dnd-kit/abstract");
5574
- var import_state2 = require("@dnd-kit/state");
5577
+ var import_abstract9 = require("@dnd-kit/abstract");
5575
5578
 
5576
5579
  // lib/throttle.ts
5577
5580
  init_react_import();
@@ -5620,7 +5623,7 @@ var GlobalPosition = class {
5620
5623
  var _a;
5621
5624
  this.target = target;
5622
5625
  this.original = original;
5623
- this.frameEl = document.querySelector("iframe");
5626
+ this.frameEl = document.querySelector("iframe#preview-frame");
5624
5627
  if (this.frameEl) {
5625
5628
  this.frameRect = this.frameEl.getBoundingClientRect();
5626
5629
  this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
@@ -5700,6 +5703,7 @@ var getZoneId2 = (candidate) => {
5700
5703
  }
5701
5704
  return id;
5702
5705
  };
5706
+ var BUFFER = 6;
5703
5707
  var getPointerCollisions = (position, manager) => {
5704
5708
  const candidates = [];
5705
5709
  let elements = position.target.ownerDocument.elementsFromPoint(
@@ -5723,13 +5727,26 @@ var getPointerCollisions = (position, manager) => {
5723
5727
  for (let i = 0; i < elements.length; i++) {
5724
5728
  const element = elements[i];
5725
5729
  const dropzoneId = element.getAttribute("data-puck-dropzone");
5730
+ const id = element.getAttribute("data-puck-dnd");
5731
+ const isVoid = element.hasAttribute("data-puck-dnd-void");
5732
+ if (BUFFER && (dropzoneId || id) && !isVoid) {
5733
+ const box = element.getBoundingClientRect();
5734
+ const contractedBox = {
5735
+ left: box.left + BUFFER,
5736
+ right: box.right - BUFFER,
5737
+ top: box.top + BUFFER,
5738
+ bottom: box.bottom - BUFFER
5739
+ };
5740
+ if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
5741
+ continue;
5742
+ }
5743
+ }
5726
5744
  if (dropzoneId) {
5727
5745
  const droppable = manager.registry.droppables.get(dropzoneId);
5728
5746
  if (droppable) {
5729
5747
  candidates.push(droppable);
5730
5748
  }
5731
5749
  }
5732
- const id = element.getAttribute("data-puck-dnd");
5733
5750
  if (id) {
5734
5751
  const droppable = manager.registry.droppables.get(id);
5735
5752
  if (droppable) {
@@ -5783,17 +5800,17 @@ var findDeepestCandidate = (position, manager) => {
5783
5800
  return { zone, area };
5784
5801
  }
5785
5802
  return {
5786
- zone: "default-zone",
5787
- area: null
5803
+ zone: rootDroppableId,
5804
+ area: rootAreaId
5788
5805
  };
5789
5806
  };
5790
- var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract10.Plugin {
5807
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
5791
5808
  constructor(manager, options) {
5792
5809
  super(manager);
5793
5810
  if (typeof window === "undefined") {
5794
5811
  return;
5795
5812
  }
5796
- const cleanupEffect = (0, import_state2.effects)(() => {
5813
+ this.registerEffect(() => {
5797
5814
  const handleMove = (event) => {
5798
5815
  const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
5799
5816
  const position = new GlobalPosition(target, {
@@ -5817,12 +5834,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
5817
5834
  capture: true
5818
5835
  // dndkit's PointerSensor prevents propagation during drag
5819
5836
  });
5820
- this.destroy = () => {
5837
+ const cleanup = () => {
5821
5838
  document.body.removeEventListener("pointermove", handlePointerMove, {
5822
5839
  capture: true
5823
5840
  });
5824
- cleanupEffect();
5825
5841
  };
5842
+ return cleanup;
5826
5843
  });
5827
5844
  }
5828
5845
  };
@@ -5882,14 +5899,15 @@ function getDeepDir(el) {
5882
5899
  }
5883
5900
 
5884
5901
  // components/DragDropContext/index.tsx
5885
- var import_jsx_runtime24 = require("react/jsx-runtime");
5902
+ var import_state = require("@dnd-kit/state");
5903
+ var import_jsx_runtime26 = require("react/jsx-runtime");
5886
5904
  var DEBUG3 = false;
5887
- var dragListenerContext = (0, import_react36.createContext)({
5905
+ var dragListenerContext = (0, import_react38.createContext)({
5888
5906
  dragListeners: {}
5889
5907
  });
5890
5908
  function useDragListener(type, fn, deps = []) {
5891
- const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
5892
- (0, import_react36.useEffect)(() => {
5909
+ const { setDragListeners } = (0, import_react38.useContext)(dragListenerContext);
5910
+ (0, import_react38.useEffect)(() => {
5893
5911
  if (setDragListeners) {
5894
5912
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
5895
5913
  [type]: [...old[type] || [], fn]
@@ -5899,8 +5917,8 @@ function useDragListener(type, fn, deps = []) {
5899
5917
  }
5900
5918
  var AREA_CHANGE_DEBOUNCE_MS = 100;
5901
5919
  var useTempDisableFallback = (timeout3) => {
5902
- const lastFallbackDisable = (0, import_react36.useRef)(null);
5903
- return (0, import_react36.useCallback)((manager) => {
5920
+ const lastFallbackDisable = (0, import_react38.useRef)(null);
5921
+ return (0, import_react38.useCallback)((manager) => {
5904
5922
  collisionStore.setState({ fallbackEnabled: false });
5905
5923
  const fallbackId = generateId();
5906
5924
  lastFallbackDisable.current = fallbackId;
@@ -5919,19 +5937,21 @@ var DragDropContextClient = ({
5919
5937
  const dispatch = useAppStore((s) => s.dispatch);
5920
5938
  const appStore = useAppStoreApi();
5921
5939
  const id = useSafeId();
5922
- const debouncedParamsRef = (0, import_react36.useRef)(null);
5940
+ const debouncedParamsRef = (0, import_react38.useRef)(null);
5923
5941
  const tempDisableFallback = useTempDisableFallback(100);
5924
- const [zoneStore] = (0, import_react36.useState)(
5942
+ const [zoneStore] = (0, import_react38.useState)(
5925
5943
  () => (0, import_zustand5.createStore)(() => ({
5926
5944
  zoneDepthIndex: {},
5927
5945
  nextZoneDepthIndex: {},
5928
5946
  areaDepthIndex: {},
5929
5947
  nextAreaDepthIndex: {},
5930
5948
  draggedItem: null,
5931
- previewIndex: {}
5949
+ previewIndex: {},
5950
+ enabledIndex: {},
5951
+ hoveringComponent: null
5932
5952
  }))
5933
5953
  );
5934
- const getChanged2 = (0, import_react36.useCallback)(
5954
+ const getChanged2 = (0, import_react38.useCallback)(
5935
5955
  (params, id2) => {
5936
5956
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
5937
5957
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -5952,7 +5972,7 @@ var DragDropContextClient = ({
5952
5972
  },
5953
5973
  [zoneStore]
5954
5974
  );
5955
- const setDeepestAndCollide = (0, import_react36.useCallback)(
5975
+ const setDeepestAndCollide = (0, import_react38.useCallback)(
5956
5976
  (params, manager) => {
5957
5977
  const { zoneChanged, areaChanged } = getChanged2(params, id);
5958
5978
  if (!zoneChanged && !areaChanged) return;
@@ -5976,7 +5996,7 @@ var DragDropContextClient = ({
5976
5996
  setDeepestDb.cancel();
5977
5997
  debouncedParamsRef.current = null;
5978
5998
  };
5979
- (0, import_react36.useEffect)(() => {
5999
+ (0, import_react38.useEffect)(() => {
5980
6000
  if (DEBUG3) {
5981
6001
  zoneStore.subscribe(
5982
6002
  (s) => {
@@ -5990,7 +6010,7 @@ var DragDropContextClient = ({
5990
6010
  );
5991
6011
  }
5992
6012
  }, []);
5993
- const [plugins] = (0, import_react36.useState)(() => [
6013
+ const [plugins] = (0, import_react38.useState)(() => [
5994
6014
  ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
5995
6015
  createNestedDroppablePlugin(
5996
6016
  {
@@ -6038,10 +6058,10 @@ var DragDropContextClient = ({
6038
6058
  )
6039
6059
  ]);
6040
6060
  const sensors = useSensors();
6041
- const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
6042
- const dragMode = (0, import_react36.useRef)(null);
6043
- const initialSelector = (0, import_react36.useRef)(void 0);
6044
- const nextContextValue = (0, import_react36.useMemo)(
6061
+ const [dragListeners, setDragListeners] = (0, import_react38.useState)({});
6062
+ const dragMode = (0, import_react38.useRef)(null);
6063
+ const initialSelector = (0, import_react38.useRef)(void 0);
6064
+ const nextContextValue = (0, import_react38.useMemo)(
6045
6065
  () => ({
6046
6066
  mode: "edit",
6047
6067
  areaId: "root",
@@ -6049,20 +6069,22 @@ var DragDropContextClient = ({
6049
6069
  }),
6050
6070
  []
6051
6071
  );
6052
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
6072
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6053
6073
  dragListenerContext.Provider,
6054
6074
  {
6055
6075
  value: {
6056
6076
  dragListeners,
6057
6077
  setDragListeners
6058
6078
  },
6059
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
6060
- import_react35.DragDropProvider,
6079
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6080
+ import_react37.DragDropProvider,
6061
6081
  {
6062
6082
  plugins,
6063
6083
  sensors,
6064
6084
  onDragEnd: (event, manager) => {
6065
- var _a;
6085
+ var _a, _b;
6086
+ const entryEl = (_a = getFrame()) == null ? void 0 : _a.querySelector("[data-puck-entry]");
6087
+ entryEl == null ? void 0 : entryEl.removeAttribute("data-puck-dragging");
6066
6088
  const { source, target } = event.operation;
6067
6089
  if (!source) {
6068
6090
  zoneStore.setState({ draggedItem: null });
@@ -6070,9 +6092,9 @@ var DragDropContextClient = ({
6070
6092
  }
6071
6093
  const { zone, index } = source.data;
6072
6094
  const { previewIndex = {} } = zoneStore.getState() || {};
6073
- const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
6074
- setTimeout(() => {
6075
- var _a2, _b;
6095
+ const thisPreview = ((_b = previewIndex[zone]) == null ? void 0 : _b.props.id) === source.id ? previewIndex[zone] : null;
6096
+ const onAnimationEnd = () => {
6097
+ var _a2, _b2;
6076
6098
  zoneStore.setState({ draggedItem: null });
6077
6099
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
6078
6100
  zoneStore.setState({ previewIndex: {} });
@@ -6090,7 +6112,6 @@ var DragDropContextClient = ({
6090
6112
  }
6091
6113
  if (thisPreview) {
6092
6114
  zoneStore.setState({ previewIndex: {} });
6093
- const state = appStore.getState().state;
6094
6115
  if (thisPreview.type === "insert") {
6095
6116
  insertComponent(
6096
6117
  thisPreview.componentType,
@@ -6109,23 +6130,28 @@ var DragDropContextClient = ({
6109
6130
  });
6110
6131
  }
6111
6132
  }
6112
- setTimeout(() => {
6113
- dispatch({
6114
- type: "setUi",
6115
- ui: {
6116
- itemSelector: { index, zone },
6117
- isDragging: false
6118
- },
6119
- recordHistory: true
6120
- });
6121
- }, 50);
6122
- (_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
6133
+ dispatch({
6134
+ type: "setUi",
6135
+ ui: {
6136
+ itemSelector: { index, zone },
6137
+ isDragging: false
6138
+ },
6139
+ recordHistory: true
6140
+ });
6141
+ (_b2 = dragListeners.dragend) == null ? void 0 : _b2.forEach((fn) => {
6123
6142
  fn(event, manager);
6124
6143
  });
6125
- }, 250);
6144
+ };
6145
+ let dispose;
6146
+ dispose = (0, import_state.effect)(() => {
6147
+ if (source.status === "idle") {
6148
+ onAnimationEnd();
6149
+ dispose == null ? void 0 : dispose();
6150
+ }
6151
+ });
6126
6152
  },
6127
6153
  onDragOver: (event, manager) => {
6128
- var _a, _b, _c, _d, _e;
6154
+ var _a, _b, _c, _d;
6129
6155
  event.preventDefault();
6130
6156
  const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
6131
6157
  if (!draggedItem) return;
@@ -6143,7 +6169,7 @@ var DragDropContextClient = ({
6143
6169
  const targetData = target.data;
6144
6170
  targetZone = targetData.zone;
6145
6171
  targetIndex = targetData.index;
6146
- const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
6172
+ const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
6147
6173
  const dir = getDeepDir(target.element);
6148
6174
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
6149
6175
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
@@ -6156,7 +6182,7 @@ var DragDropContextClient = ({
6156
6182
  targetZone = target.id.toString();
6157
6183
  targetIndex = 0;
6158
6184
  }
6159
- const path = ((_d = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _d.path) || [];
6185
+ const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
6160
6186
  if (targetId === sourceId || path.find((path2) => {
6161
6187
  const [pathId] = path2.split(":");
6162
6188
  return pathId === sourceId;
@@ -6202,16 +6228,12 @@ var DragDropContextClient = ({
6202
6228
  });
6203
6229
  }
6204
6230
  }
6205
- (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
6231
+ (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
6206
6232
  fn(event, manager);
6207
6233
  });
6208
6234
  },
6209
6235
  onDragStart: (event, manager) => {
6210
6236
  var _a;
6211
- dispatch({
6212
- type: "setUi",
6213
- ui: { itemSelector: null, isDragging: true }
6214
- });
6215
6237
  const { source } = event.operation;
6216
6238
  if (source && source.type !== "void") {
6217
6239
  const sourceData = source.data;
@@ -6241,13 +6263,33 @@ var DragDropContextClient = ({
6241
6263
  });
6242
6264
  },
6243
6265
  onBeforeDragStart: (event) => {
6244
- var _a;
6245
- const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
6266
+ var _a, _b, _c, _d;
6267
+ const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
6246
6268
  dragMode.current = isNewComponent ? "new" : "existing";
6247
6269
  initialSelector.current = void 0;
6248
6270
  zoneStore.setState({ draggedItem: event.operation.source });
6271
+ if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== ((_c = event.operation.source) == null ? void 0 : _c.id)) {
6272
+ dispatch({
6273
+ type: "setUi",
6274
+ ui: {
6275
+ itemSelector: null,
6276
+ isDragging: true
6277
+ },
6278
+ recordHistory: false
6279
+ });
6280
+ } else {
6281
+ dispatch({
6282
+ type: "setUi",
6283
+ ui: {
6284
+ isDragging: true
6285
+ },
6286
+ recordHistory: false
6287
+ });
6288
+ }
6289
+ const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
6290
+ entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
6249
6291
  },
6250
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
6292
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
6251
6293
  }
6252
6294
  )
6253
6295
  }
@@ -6261,11 +6303,12 @@ var DragDropContext = ({
6261
6303
  if (status === "LOADING") {
6262
6304
  return children;
6263
6305
  }
6264
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragDropContextClient, { disableAutoScroll, children });
6306
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DragDropContextClient, { disableAutoScroll, children });
6265
6307
  };
6266
6308
 
6267
6309
  // components/Drawer/index.tsx
6268
- var import_jsx_runtime25 = require("react/jsx-runtime");
6310
+ var import_react40 = require("@dnd-kit/react");
6311
+ var import_jsx_runtime27 = require("react/jsx-runtime");
6269
6312
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
6270
6313
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
6271
6314
  var DrawerItemInner = ({
@@ -6275,11 +6318,11 @@ var DrawerItemInner = ({
6275
6318
  dragRef,
6276
6319
  isDragDisabled
6277
6320
  }) => {
6278
- const CustomInner = (0, import_react37.useMemo)(
6279
- () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
6321
+ const CustomInner = (0, import_react39.useMemo)(
6322
+ () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
6280
6323
  [children]
6281
6324
  );
6282
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6325
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6283
6326
  "div",
6284
6327
  {
6285
6328
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -6287,9 +6330,9 @@ var DrawerItemInner = ({
6287
6330
  onMouseDown: (e) => e.preventDefault(),
6288
6331
  "data-testid": dragRef ? `drawer-item:${name}` : "",
6289
6332
  "data-puck-drawer-item": true,
6290
- children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
6291
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
6292
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DragIcon, {}) })
6333
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
6334
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
6335
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DragIcon, {}) })
6293
6336
  ] }) }) })
6294
6337
  }
6295
6338
  );
@@ -6301,14 +6344,15 @@ var DrawerItemDraggable = ({
6301
6344
  id,
6302
6345
  isDragDisabled
6303
6346
  }) => {
6304
- const { ref } = useDraggableSafe({
6347
+ const { ref } = (0, import_react40.useDraggable)({
6305
6348
  id,
6306
- data: { type: "drawer", componentType: name },
6307
- disabled: isDragDisabled
6349
+ data: { componentType: name },
6350
+ disabled: isDragDisabled,
6351
+ type: "drawer"
6308
6352
  });
6309
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName18("draggable"), children: [
6310
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name, label, children }) }),
6311
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6353
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
6354
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
6355
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6312
6356
  DrawerItemInner,
6313
6357
  {
6314
6358
  name,
@@ -6329,7 +6373,7 @@ var DrawerItem = ({
6329
6373
  isDragDisabled
6330
6374
  }) => {
6331
6375
  const resolvedId = id || name;
6332
- const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
6376
+ const [dynamicId, setDynamicId] = (0, import_react39.useState)(generateId(resolvedId));
6333
6377
  if (typeof index !== "undefined") {
6334
6378
  console.error(
6335
6379
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -6342,7 +6386,7 @@ var DrawerItem = ({
6342
6386
  },
6343
6387
  [resolvedId]
6344
6388
  );
6345
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6389
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6346
6390
  DrawerItemDraggable,
6347
6391
  {
6348
6392
  name,
@@ -6369,19 +6413,20 @@ var Drawer = ({
6369
6413
  );
6370
6414
  }
6371
6415
  const id = useSafeId();
6372
- const { ref } = useDroppableSafe({
6416
+ const { ref } = (0, import_react40.useDroppable)({
6373
6417
  id,
6374
6418
  type: "void",
6375
6419
  collisionPriority: 0
6376
6420
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
6377
6421
  });
6378
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6422
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6379
6423
  "div",
6380
6424
  {
6381
6425
  className: getClassName18(),
6382
6426
  ref,
6383
6427
  "data-puck-dnd": id,
6384
6428
  "data-puck-drawer": true,
6429
+ "data-puck-dnd-void": true,
6385
6430
  children
6386
6431
  }
6387
6432
  );
@@ -6390,7 +6435,7 @@ Drawer.Item = DrawerItem;
6390
6435
 
6391
6436
  // components/Puck/index.tsx
6392
6437
  init_react_import();
6393
- var import_react52 = require("react");
6438
+ var import_react56 = require("react");
6394
6439
 
6395
6440
  // components/SidebarSection/index.tsx
6396
6441
  init_react_import();
@@ -6401,7 +6446,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
6401
6446
 
6402
6447
  // lib/use-breadcrumbs.ts
6403
6448
  init_react_import();
6404
- var import_react38 = require("react");
6449
+ var import_react41 = require("react");
6405
6450
  var useBreadcrumbs = (renderCount) => {
6406
6451
  const selectedId = useAppStore((s) => {
6407
6452
  var _a;
@@ -6413,7 +6458,7 @@ var useBreadcrumbs = (renderCount) => {
6413
6458
  return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
6414
6459
  });
6415
6460
  const appStore = useAppStoreApi();
6416
- return (0, import_react38.useMemo)(() => {
6461
+ return (0, import_react41.useMemo)(() => {
6417
6462
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6418
6463
  var _a, _b, _c;
6419
6464
  const [componentId] = zoneCompound.split(":");
@@ -6444,7 +6489,7 @@ var useBreadcrumbs = (renderCount) => {
6444
6489
  };
6445
6490
 
6446
6491
  // components/SidebarSection/index.tsx
6447
- var import_jsx_runtime26 = require("react/jsx-runtime");
6492
+ var import_jsx_runtime28 = require("react/jsx-runtime");
6448
6493
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
6449
6494
  var SidebarSection = ({
6450
6495
  children,
@@ -6457,15 +6502,15 @@ var SidebarSection = ({
6457
6502
  }) => {
6458
6503
  const setUi = useAppStore((s) => s.setUi);
6459
6504
  const breadcrumbs = useBreadcrumbs(1);
6460
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
6505
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
6461
6506
  "div",
6462
6507
  {
6463
6508
  className: getClassName19({ noBorderTop, noPadding }),
6464
6509
  style: { background },
6465
6510
  children: [
6466
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
6467
- showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
6468
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6511
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
6512
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
6513
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6469
6514
  "button",
6470
6515
  {
6471
6516
  type: "button",
@@ -6474,81 +6519,37 @@ var SidebarSection = ({
6474
6519
  children: breadcrumb.label
6475
6520
  }
6476
6521
  ),
6477
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChevronRight, { size: 16 })
6522
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronRight, { size: 16 })
6478
6523
  ] }, i)) : null,
6479
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
6524
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
6480
6525
  ] }) }),
6481
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("content"), children }),
6482
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Loader, { size: 32 }) })
6526
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("content"), children }),
6527
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 32 }) })
6483
6528
  ]
6484
6529
  }
6485
6530
  );
6486
6531
  };
6487
6532
 
6488
- // components/MenuBar/index.tsx
6489
- init_react_import();
6490
-
6491
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
6492
- init_react_import();
6493
- var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
6494
-
6495
- // components/MenuBar/index.tsx
6496
- var import_jsx_runtime27 = require("react/jsx-runtime");
6497
- var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
6498
- function MenuBar({
6499
- menuOpen = false,
6500
- renderHeaderActions,
6501
- setMenuOpen
6502
- }) {
6503
- const back = useAppStore((s) => s.history.back);
6504
- const forward = useAppStore((s) => s.history.forward);
6505
- const hasFuture = useAppStore((s) => s.history.hasFuture());
6506
- const hasPast = useAppStore((s) => s.history.hasPast());
6507
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6508
- "div",
6509
- {
6510
- className: getClassName20({ menuOpen }),
6511
- onClick: (event) => {
6512
- var _a;
6513
- const element = event.target;
6514
- if (window.matchMedia("(min-width: 638px)").matches) {
6515
- return;
6516
- }
6517
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
6518
- setMenuOpen(false);
6519
- }
6520
- },
6521
- children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName20("inner"), children: [
6522
- /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName20("history"), children: [
6523
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Undo2, { size: 21 }) }),
6524
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Redo2, { size: 21 }) })
6525
- ] }),
6526
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: renderHeaderActions && renderHeaderActions() })
6527
- ] })
6528
- }
6529
- );
6530
- }
6531
-
6532
6533
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6533
6534
  init_react_import();
6534
- var styles_module_default15 = { "Puck": "_Puck_11o75_19", "Puck-portal": "_Puck-portal_11o75_24", "PuckLayout-inner": "_PuckLayout-inner_11o75_31", "PuckLayout--mounted": "_PuckLayout--mounted_11o75_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_11o75_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_11o75_53", "PuckLayout-mounted": "_PuckLayout-mounted_11o75_67", "PuckLayout": "_PuckLayout_11o75_31", "PuckLayout-header": "_PuckLayout-header_11o75_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_11o75_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_11o75_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_11o75_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_11o75_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_11o75_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_11o75_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_11o75_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_11o75_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_11o75_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_11o75_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_11o75_134" };
6535
+ var styles_module_default14 = { "Puck": "_Puck_mc1k2_19", "Puck-portal": "_Puck-portal_mc1k2_24", "PuckLayout-inner": "_PuckLayout-inner_mc1k2_31", "PuckLayout--mounted": "_PuckLayout--mounted_mc1k2_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_mc1k2_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_mc1k2_53", "PuckLayout-mounted": "_PuckLayout-mounted_mc1k2_67", "PuckLayout": "_PuckLayout_mc1k2_31", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_mc1k2_108", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_mc1k2_117" };
6535
6536
 
6536
6537
  // components/Puck/components/Fields/index.tsx
6537
6538
  init_react_import();
6538
6539
 
6539
6540
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
6540
6541
  init_react_import();
6541
- var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
6542
+ var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
6542
6543
 
6543
6544
  // components/Puck/components/Fields/index.tsx
6544
- var import_react39 = require("react");
6545
+ var import_react42 = require("react");
6545
6546
  var import_shallow4 = require("zustand/react/shallow");
6546
- var import_jsx_runtime28 = require("react/jsx-runtime");
6547
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
6547
+ var import_jsx_runtime29 = require("react/jsx-runtime");
6548
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
6548
6549
  var DefaultFields = ({
6549
6550
  children
6550
6551
  }) => {
6551
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_jsx_runtime28.Fragment, { children });
6552
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
6552
6553
  };
6553
6554
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6554
6555
  let currentProps;
@@ -6614,12 +6615,12 @@ var FieldsChild = ({ fieldName }) => {
6614
6615
  })
6615
6616
  );
6616
6617
  const appStore = useAppStoreApi();
6617
- const onChange = (0, import_react39.useCallback)(createOnChange(fieldName, appStore), [
6618
+ const onChange = (0, import_react42.useCallback)(createOnChange(fieldName, appStore), [
6618
6619
  fieldName
6619
6620
  ]);
6620
6621
  if (!field || !id) return null;
6621
6622
  if (field.type === "slot") return null;
6622
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6623
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("field"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6623
6624
  AutoFieldPrivate,
6624
6625
  {
6625
6626
  field,
@@ -6631,7 +6632,8 @@ var FieldsChild = ({ fieldName }) => {
6631
6632
  }
6632
6633
  ) }, id);
6633
6634
  };
6634
- var Fields = ({ wrapFields = true }) => {
6635
+ var FieldsChildMemo = (0, import_react42.memo)(FieldsChild);
6636
+ var FieldsInternal = ({ wrapFields = true }) => {
6635
6637
  const overrides = useAppStore((s) => s.overrides);
6636
6638
  const componentResolving = useAppStore((s) => {
6637
6639
  var _a, _b;
@@ -6647,42 +6649,48 @@ var Fields = ({ wrapFields = true }) => {
6647
6649
  useRegisterFieldsSlice(appStore, id);
6648
6650
  const fieldsLoading = useAppStore((s) => s.fields.loading);
6649
6651
  const fieldNames = useAppStore(
6650
- (0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
6652
+ (0, import_shallow4.useShallow)((s) => {
6653
+ if (s.fields.id === id) {
6654
+ return Object.keys(s.fields.fields);
6655
+ }
6656
+ return [];
6657
+ })
6651
6658
  );
6652
6659
  const isLoading = fieldsLoading || componentResolving;
6653
- const Wrapper = (0, import_react39.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6654
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
6660
+ const Wrapper = (0, import_react42.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6661
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6655
6662
  "form",
6656
6663
  {
6657
- className: getClassName21({ wrapFields }),
6664
+ className: getClassName20({ wrapFields }),
6658
6665
  onSubmit: (e) => {
6659
6666
  e.preventDefault();
6660
6667
  },
6661
6668
  children: [
6662
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FieldsChild, { fieldName }, fieldName)) }),
6663
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 16 }) }) })
6669
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
6670
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) }) })
6664
6671
  ]
6665
6672
  }
6666
6673
  );
6667
6674
  };
6675
+ var Fields = (0, import_react42.memo)(FieldsInternal);
6668
6676
 
6669
6677
  // components/Puck/components/Components/index.tsx
6670
6678
  init_react_import();
6671
6679
 
6672
6680
  // lib/use-component-list.tsx
6673
6681
  init_react_import();
6674
- var import_react40 = require("react");
6682
+ var import_react43 = require("react");
6675
6683
 
6676
6684
  // components/ComponentList/index.tsx
6677
6685
  init_react_import();
6678
6686
 
6679
6687
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6680
6688
  init_react_import();
6681
- var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
6689
+ var styles_module_default16 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
6682
6690
 
6683
6691
  // components/ComponentList/index.tsx
6684
- var import_jsx_runtime29 = require("react/jsx-runtime");
6685
- var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
6692
+ var import_jsx_runtime30 = require("react/jsx-runtime");
6693
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6686
6694
  var ComponentListItem = ({
6687
6695
  name,
6688
6696
  label
@@ -6693,7 +6701,7 @@ var ComponentListItem = ({
6693
6701
  type: name
6694
6702
  }).insert
6695
6703
  );
6696
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6704
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6697
6705
  };
6698
6706
  var ComponentList = ({
6699
6707
  children,
@@ -6704,12 +6712,12 @@ var ComponentList = ({
6704
6712
  const setUi = useAppStore((s) => s.setUi);
6705
6713
  const componentList = useAppStore((s) => s.state.ui.componentList);
6706
6714
  const { expanded = true } = componentList[id] || {};
6707
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
6708
- title && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6715
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName21({ isExpanded: expanded }), children: [
6716
+ title && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6709
6717
  "button",
6710
6718
  {
6711
6719
  type: "button",
6712
- className: getClassName22("title"),
6720
+ className: getClassName21("title"),
6713
6721
  onClick: () => setUi({
6714
6722
  componentList: __spreadProps(__spreadValues({}, componentList), {
6715
6723
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6719,14 +6727,14 @@ var ComponentList = ({
6719
6727
  }),
6720
6728
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6721
6729
  children: [
6722
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: title }),
6723
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronDown, { size: 12 }) })
6730
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { children: title }),
6731
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronDown, { size: 12 }) })
6724
6732
  ]
6725
6733
  }
6726
6734
  ),
6727
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6735
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("content"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6728
6736
  var _a;
6729
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6737
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6730
6738
  ComponentListItem,
6731
6739
  {
6732
6740
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6740,12 +6748,12 @@ var ComponentList = ({
6740
6748
  ComponentList.Item = ComponentListItem;
6741
6749
 
6742
6750
  // lib/use-component-list.tsx
6743
- var import_jsx_runtime30 = require("react/jsx-runtime");
6751
+ var import_jsx_runtime31 = require("react/jsx-runtime");
6744
6752
  var useComponentList = () => {
6745
- const [componentList, setComponentList] = (0, import_react40.useState)();
6753
+ const [componentList, setComponentList] = (0, import_react43.useState)();
6746
6754
  const config = useAppStore((s) => s.config);
6747
6755
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6748
- (0, import_react40.useEffect)(() => {
6756
+ (0, import_react43.useEffect)(() => {
6749
6757
  var _a, _b, _c;
6750
6758
  if (Object.keys(uiComponentList).length > 0) {
6751
6759
  const matchedComponents = [];
@@ -6755,7 +6763,7 @@ var useComponentList = () => {
6755
6763
  if (category.visible === false || !category.components) {
6756
6764
  return null;
6757
6765
  }
6758
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6766
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6759
6767
  ComponentList,
6760
6768
  {
6761
6769
  id: categoryKey,
@@ -6764,7 +6772,7 @@ var useComponentList = () => {
6764
6772
  var _a2;
6765
6773
  matchedComponents.push(componentName);
6766
6774
  const componentConf = config.components[componentName] || {};
6767
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6775
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6768
6776
  ComponentList.Item,
6769
6777
  {
6770
6778
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6784,7 +6792,7 @@ var useComponentList = () => {
6784
6792
  );
6785
6793
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6786
6794
  _componentList.push(
6787
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6795
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6788
6796
  ComponentList,
6789
6797
  {
6790
6798
  id: "other",
@@ -6792,7 +6800,7 @@ var useComponentList = () => {
6792
6800
  children: remainingComponents.map((componentName, i) => {
6793
6801
  var _a2;
6794
6802
  const componentConf = config.components[componentName] || {};
6795
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6803
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6796
6804
  ComponentList.Item,
6797
6805
  {
6798
6806
  name: componentName,
@@ -6814,25 +6822,25 @@ var useComponentList = () => {
6814
6822
  };
6815
6823
 
6816
6824
  // components/Puck/components/Components/index.tsx
6817
- var import_react41 = require("react");
6818
- var import_jsx_runtime31 = require("react/jsx-runtime");
6825
+ var import_react44 = require("react");
6826
+ var import_jsx_runtime32 = require("react/jsx-runtime");
6819
6827
  var Components = () => {
6820
6828
  const overrides = useAppStore((s) => s.overrides);
6821
6829
  const componentList = useComponentList();
6822
- const Wrapper = (0, import_react41.useMemo)(() => overrides.components || "div", [overrides]);
6823
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComponentList, { id: "all" }) });
6830
+ const Wrapper = (0, import_react44.useMemo)(() => overrides.components || "div", [overrides]);
6831
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
6824
6832
  };
6825
6833
 
6826
6834
  // components/Puck/components/Preview/index.tsx
6827
6835
  init_react_import();
6828
- var import_react43 = require("react");
6836
+ var import_react46 = require("react");
6829
6837
 
6830
6838
  // components/AutoFrame/index.tsx
6831
6839
  init_react_import();
6832
- var import_react42 = require("react");
6840
+ var import_react45 = require("react");
6833
6841
  var import_object_hash = __toESM(require("object-hash"));
6834
6842
  var import_react_dom3 = require("react-dom");
6835
- var import_jsx_runtime32 = require("react/jsx-runtime");
6843
+ var import_jsx_runtime33 = require("react/jsx-runtime");
6836
6844
  var styleSelector = 'style, link[rel="stylesheet"]';
6837
6845
  var collectStyles = (doc) => {
6838
6846
  const collected = [];
@@ -6875,7 +6883,7 @@ var CopyHostStyles = ({
6875
6883
  onStylesLoaded = () => null
6876
6884
  }) => {
6877
6885
  const { document: doc, window: win } = useFrame();
6878
- (0, import_react42.useEffect)(() => {
6886
+ (0, import_react45.useEffect)(() => {
6879
6887
  if (!win || !doc) {
6880
6888
  return () => {
6881
6889
  };
@@ -7032,10 +7040,10 @@ var CopyHostStyles = ({
7032
7040
  observer.disconnect();
7033
7041
  };
7034
7042
  }, []);
7035
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
7043
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
7036
7044
  };
7037
- var autoFrameContext = (0, import_react42.createContext)({});
7038
- var useFrame = () => (0, import_react42.useContext)(autoFrameContext);
7045
+ var autoFrameContext = (0, import_react45.createContext)({});
7046
+ var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
7039
7047
  function AutoFrame(_a) {
7040
7048
  var _b = _a, {
7041
7049
  children,
@@ -7056,11 +7064,11 @@ function AutoFrame(_a) {
7056
7064
  "onNotReady",
7057
7065
  "frameRef"
7058
7066
  ]);
7059
- const [loaded, setLoaded] = (0, import_react42.useState)(false);
7060
- const [ctx, setCtx] = (0, import_react42.useState)({});
7061
- const [mountTarget, setMountTarget] = (0, import_react42.useState)();
7062
- const [stylesLoaded, setStylesLoaded] = (0, import_react42.useState)(false);
7063
- (0, import_react42.useEffect)(() => {
7067
+ const [loaded, setLoaded] = (0, import_react45.useState)(false);
7068
+ const [ctx, setCtx] = (0, import_react45.useState)({});
7069
+ const [mountTarget, setMountTarget] = (0, import_react45.useState)();
7070
+ const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
7071
+ (0, import_react45.useEffect)(() => {
7064
7072
  var _a2;
7065
7073
  if (frameRef.current) {
7066
7074
  const doc = frameRef.current.contentDocument;
@@ -7079,7 +7087,7 @@ function AutoFrame(_a) {
7079
7087
  }
7080
7088
  }
7081
7089
  }, [frameRef, loaded, stylesLoaded]);
7082
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
7090
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7083
7091
  "iframe",
7084
7092
  __spreadProps(__spreadValues({}, props), {
7085
7093
  className,
@@ -7089,7 +7097,7 @@ function AutoFrame(_a) {
7089
7097
  onLoad: () => {
7090
7098
  setLoaded(true);
7091
7099
  },
7092
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
7100
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7093
7101
  CopyHostStyles,
7094
7102
  {
7095
7103
  debug,
@@ -7105,14 +7113,14 @@ var AutoFrame_default = AutoFrame;
7105
7113
 
7106
7114
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
7107
7115
  init_react_import();
7108
- var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7116
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7109
7117
 
7110
7118
  // components/Puck/components/Preview/index.tsx
7111
- var import_jsx_runtime33 = require("react/jsx-runtime");
7112
- var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
7119
+ var import_jsx_runtime34 = require("react/jsx-runtime");
7120
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
7113
7121
  var useBubbleIframeEvents = (ref) => {
7114
7122
  const status = useAppStore((s) => s.status);
7115
- (0, import_react43.useEffect)(() => {
7123
+ (0, import_react46.useEffect)(() => {
7116
7124
  if (ref.current && status === "READY") {
7117
7125
  const iframe = ref.current;
7118
7126
  const handlePointerMove = (event) => {
@@ -7150,7 +7158,7 @@ var useBubbleIframeEvents = (ref) => {
7150
7158
  }
7151
7159
  }, [status]);
7152
7160
  };
7153
- var Preview3 = ({ id = "puck-preview" }) => {
7161
+ var Preview2 = ({ id = "puck-preview" }) => {
7154
7162
  const dispatch = useAppStore((s) => s.dispatch);
7155
7163
  const root = useAppStore((s) => s.state.data.root);
7156
7164
  const config = useAppStore((s) => s.config);
@@ -7161,22 +7169,22 @@ var Preview3 = ({ id = "puck-preview" }) => {
7161
7169
  const renderData = useAppStore(
7162
7170
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7163
7171
  );
7164
- const Page = (0, import_react43.useCallback)(
7172
+ const Page = (0, import_react46.useCallback)(
7165
7173
  (pageProps) => {
7166
7174
  var _a, _b;
7167
7175
  const rootConfig = config.root;
7168
7176
  const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
7169
7177
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7170
7178
  id: "puck-root"
7171
- }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: propsWithSlots.children });
7179
+ }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: propsWithSlots.children });
7172
7180
  },
7173
7181
  [config.root]
7174
7182
  );
7175
- const Frame = (0, import_react43.useMemo)(() => overrides.iframe, [overrides]);
7183
+ const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
7176
7184
  const rootProps = root.props || root;
7177
- const ref = (0, import_react43.useRef)(null);
7185
+ const ref = (0, import_react46.useRef)(null);
7178
7186
  useBubbleIframeEvents(ref);
7179
- const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7187
+ const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7180
7188
  Page,
7181
7189
  __spreadProps(__spreadValues({}, rootProps), {
7182
7190
  puck: {
@@ -7186,28 +7194,28 @@ var Preview3 = ({ id = "puck-preview" }) => {
7186
7194
  metadata
7187
7195
  },
7188
7196
  editMode: true,
7189
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZonePure, { zone: rootDroppableId })
7197
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7190
7198
  })
7191
- ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: renderData, config });
7192
- (0, import_react43.useEffect)(() => {
7199
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config });
7200
+ (0, import_react46.useEffect)(() => {
7193
7201
  if (!iframe.enabled) {
7194
7202
  setStatus("READY");
7195
7203
  }
7196
7204
  }, [iframe.enabled]);
7197
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7205
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7198
7206
  "div",
7199
7207
  {
7200
- className: getClassName23(),
7208
+ className: getClassName22(),
7201
7209
  id,
7202
7210
  "data-puck-preview": true,
7203
7211
  onClick: () => {
7204
7212
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7205
7213
  },
7206
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7214
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7207
7215
  AutoFrame_default,
7208
7216
  {
7209
7217
  id: "preview-frame",
7210
- className: getClassName23("frame"),
7218
+ className: getClassName22("frame"),
7211
7219
  "data-rfd-iframe": true,
7212
7220
  onReady: () => {
7213
7221
  setStatus("READY");
@@ -7216,18 +7224,18 @@ var Preview3 = ({ id = "puck-preview" }) => {
7216
7224
  setStatus("MOUNTED");
7217
7225
  },
7218
7226
  frameRef: ref,
7219
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7227
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7220
7228
  if (Frame) {
7221
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
7229
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Frame, { document: document2, children: inner });
7222
7230
  }
7223
7231
  return inner;
7224
7232
  } })
7225
7233
  }
7226
- ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7234
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7227
7235
  "div",
7228
7236
  {
7229
7237
  id: "preview-frame",
7230
- className: getClassName23("frame"),
7238
+ className: getClassName22("frame"),
7231
7239
  ref,
7232
7240
  "data-puck-entry": true,
7233
7241
  children: inner
@@ -7245,7 +7253,7 @@ init_react_import();
7245
7253
 
7246
7254
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
7247
7255
  init_react_import();
7248
- var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7256
+ var styles_module_default18 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7249
7257
 
7250
7258
  // lib/scroll-into-view.ts
7251
7259
  init_react_import();
@@ -7259,7 +7267,7 @@ var scrollIntoView = (el) => {
7259
7267
  };
7260
7268
 
7261
7269
  // components/LayerTree/index.tsx
7262
- var import_react44 = require("react");
7270
+ var import_react47 = require("react");
7263
7271
 
7264
7272
  // lib/on-scroll-end.ts
7265
7273
  init_react_import();
@@ -7282,20 +7290,20 @@ var onScrollEnd = (frame, cb) => {
7282
7290
 
7283
7291
  // components/LayerTree/index.tsx
7284
7292
  var import_shallow5 = require("zustand/react/shallow");
7285
- var import_jsx_runtime34 = require("react/jsx-runtime");
7286
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7287
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
7293
+ var import_jsx_runtime35 = require("react/jsx-runtime");
7294
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
7295
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
7288
7296
  var Layer = ({
7289
7297
  index,
7290
7298
  itemId,
7291
7299
  zoneCompound
7292
7300
  }) => {
7293
7301
  var _a;
7294
- const ctx = (0, import_react44.useContext)(dropZoneContext);
7302
+ const ctx = (0, import_react47.useContext)(dropZoneContext);
7295
7303
  const config = useAppStore((s) => s.config);
7296
7304
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7297
7305
  const dispatch = useAppStore((s) => s.dispatch);
7298
- const setItemSelector = (0, import_react44.useCallback)(
7306
+ const setItemSelector = (0, import_react47.useCallback)(
7299
7307
  (itemSelector2) => {
7300
7308
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
7301
7309
  },
@@ -7315,9 +7323,11 @@ var Layer = ({
7315
7323
  )
7316
7324
  );
7317
7325
  const containsZone = zonesForItem.length > 0;
7318
- const { setHoveringComponent = () => {
7319
- }, hoveringComponent } = ctx || {};
7320
- const isHovering = hoveringComponent === itemId;
7326
+ const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
7327
+ const isHovering = useContextStore(
7328
+ ZoneStoreContext,
7329
+ (s) => s.hoveringComponent === itemId
7330
+ );
7321
7331
  const childIsSelected = useAppStore((s) => {
7322
7332
  var _a2, _b;
7323
7333
  const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
@@ -7328,7 +7338,7 @@ var Layer = ({
7328
7338
  });
7329
7339
  const componentConfig = config.components[nodeData.data.type];
7330
7340
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7331
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
7341
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7332
7342
  "li",
7333
7343
  {
7334
7344
  className: getClassNameLayer({
@@ -7338,7 +7348,7 @@ var Layer = ({
7338
7348
  childIsSelected
7339
7349
  }),
7340
7350
  children: [
7341
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
7351
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7342
7352
  "button",
7343
7353
  {
7344
7354
  type: "button",
@@ -7364,31 +7374,31 @@ var Layer = ({
7364
7374
  });
7365
7375
  });
7366
7376
  },
7367
- onMouseOver: (e) => {
7377
+ onMouseEnter: (e) => {
7368
7378
  e.stopPropagation();
7369
- setHoveringComponent(itemId);
7379
+ zoneStore.setState({ hoveringComponent: itemId });
7370
7380
  },
7371
- onMouseOut: (e) => {
7381
+ onMouseLeave: (e) => {
7372
7382
  e.stopPropagation();
7373
- setHoveringComponent(null);
7383
+ zoneStore.setState({ hoveringComponent: null });
7374
7384
  },
7375
7385
  children: [
7376
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7386
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7377
7387
  "div",
7378
7388
  {
7379
7389
  className: getClassNameLayer("chevron"),
7380
7390
  title: isSelected ? "Collapse" : "Expand",
7381
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
7391
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { size: "12" })
7382
7392
  }
7383
7393
  ),
7384
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
7385
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(LayoutGrid, { size: "16" }) }),
7386
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label })
7394
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassNameLayer("title"), children: [
7395
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayoutGrid, { size: "16" }) }),
7396
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("name"), children: label })
7387
7397
  ] })
7388
7398
  ]
7389
7399
  }
7390
7400
  ) }),
7391
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7401
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7392
7402
  ]
7393
7403
  }
7394
7404
  );
@@ -7406,15 +7416,15 @@ var LayerTree = ({
7406
7416
  }
7407
7417
  )
7408
7418
  );
7409
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
7410
- label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
7411
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
7419
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
7420
+ label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
7421
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
7412
7422
  label
7413
7423
  ] }),
7414
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
7415
- contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
7424
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
7425
+ contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
7416
7426
  contentIds.map((itemId, i) => {
7417
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7427
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7418
7428
  Layer,
7419
7429
  {
7420
7430
  index: i,
@@ -7429,7 +7439,7 @@ var LayerTree = ({
7429
7439
  };
7430
7440
 
7431
7441
  // components/Puck/components/Outline/index.tsx
7432
- var import_react45 = require("react");
7442
+ var import_react48 = require("react");
7433
7443
 
7434
7444
  // lib/data/find-zones-for-area.ts
7435
7445
  init_react_import();
@@ -7441,14 +7451,14 @@ var findZonesForArea = (state, area) => {
7441
7451
 
7442
7452
  // components/Puck/components/Outline/index.tsx
7443
7453
  var import_shallow6 = require("zustand/react/shallow");
7444
- var import_jsx_runtime35 = require("react/jsx-runtime");
7454
+ var import_jsx_runtime36 = require("react/jsx-runtime");
7445
7455
  var Outline = () => {
7446
7456
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7447
7457
  const rootZones = useAppStore(
7448
7458
  (0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
7449
7459
  );
7450
- const Wrapper = (0, import_react45.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7451
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7460
+ const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7461
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7452
7462
  LayerTree,
7453
7463
  {
7454
7464
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -7581,25 +7591,25 @@ var getBox = function getBox2(el) {
7581
7591
  };
7582
7592
 
7583
7593
  // components/Puck/components/Canvas/index.tsx
7584
- var import_react47 = require("react");
7594
+ var import_react50 = require("react");
7585
7595
 
7586
7596
  // components/ViewportControls/index.tsx
7587
7597
  init_react_import();
7588
- var import_react46 = require("react");
7598
+ var import_react49 = require("react");
7589
7599
 
7590
7600
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7591
7601
  init_react_import();
7592
- var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
7602
+ var styles_module_default19 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
7593
7603
 
7594
7604
  // components/ViewportControls/index.tsx
7595
- var import_jsx_runtime36 = require("react/jsx-runtime");
7605
+ var import_jsx_runtime37 = require("react/jsx-runtime");
7596
7606
  var icons = {
7597
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
7598
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
7599
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
7607
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Smartphone, { size: 16 }),
7608
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Tablet, { size: 16 }),
7609
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Monitor, { size: 16 })
7600
7610
  };
7601
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7602
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
7611
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7612
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7603
7613
  var ViewportButton = ({
7604
7614
  children,
7605
7615
  height = "auto",
@@ -7608,11 +7618,11 @@ var ViewportButton = ({
7608
7618
  onClick
7609
7619
  }) => {
7610
7620
  const viewports = useAppStore((s) => s.state.ui.viewports);
7611
- const [isActive, setIsActive] = (0, import_react46.useState)(false);
7612
- (0, import_react46.useEffect)(() => {
7621
+ const [isActive, setIsActive] = (0, import_react49.useState)(false);
7622
+ (0, import_react49.useEffect)(() => {
7613
7623
  setIsActive(width === viewports.current.width);
7614
7624
  }, [width, viewports.current.width]);
7615
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7625
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7616
7626
  IconButton,
7617
7627
  {
7618
7628
  title,
@@ -7621,7 +7631,7 @@ var ViewportButton = ({
7621
7631
  e.stopPropagation();
7622
7632
  onClick({ width, height });
7623
7633
  },
7624
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
7634
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton("inner"), children })
7625
7635
  }
7626
7636
  ) });
7627
7637
  };
@@ -7645,7 +7655,7 @@ var ViewportControls = ({
7645
7655
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7646
7656
  (option) => option.value === autoZoom
7647
7657
  );
7648
- const zoomOptions = (0, import_react46.useMemo)(
7658
+ const zoomOptions = (0, import_react49.useMemo)(
7649
7659
  () => [
7650
7660
  ...defaultZoomOptions,
7651
7661
  ...defaultsContainAutoZoom ? [] : [
@@ -7657,8 +7667,8 @@ var ViewportControls = ({
7657
7667
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7658
7668
  [autoZoom]
7659
7669
  );
7660
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
7661
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7670
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName24(), children: [
7671
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7662
7672
  ViewportButton,
7663
7673
  {
7664
7674
  height: viewport.height,
@@ -7669,8 +7679,8 @@ var ViewportControls = ({
7669
7679
  },
7670
7680
  i
7671
7681
  )),
7672
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7673
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7682
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7683
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7674
7684
  IconButton,
7675
7685
  {
7676
7686
  title: "Zoom viewport out",
@@ -7684,10 +7694,10 @@ var ViewportControls = ({
7684
7694
  )].value
7685
7695
  );
7686
7696
  },
7687
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
7697
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomOut, { size: 16 })
7688
7698
  }
7689
7699
  ),
7690
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7700
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7691
7701
  IconButton,
7692
7702
  {
7693
7703
  title: "Zoom viewport in",
@@ -7701,19 +7711,19 @@ var ViewportControls = ({
7701
7711
  )].value
7702
7712
  );
7703
7713
  },
7704
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
7714
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomIn, { size: 16 })
7705
7715
  }
7706
7716
  ),
7707
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7708
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7717
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7718
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7709
7719
  "select",
7710
7720
  {
7711
- className: getClassName25("zoomSelect"),
7721
+ className: getClassName24("zoomSelect"),
7712
7722
  value: zoom.toString(),
7713
7723
  onChange: (e) => {
7714
7724
  onZoom(parseFloat(e.currentTarget.value));
7715
7725
  },
7716
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7726
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7717
7727
  "option",
7718
7728
  {
7719
7729
  value: option.value,
@@ -7728,7 +7738,7 @@ var ViewportControls = ({
7728
7738
 
7729
7739
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7730
7740
  init_react_import();
7731
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7741
+ var styles_module_default20 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7732
7742
 
7733
7743
  // lib/get-zoom-config.ts
7734
7744
  init_react_import();
@@ -7762,8 +7772,8 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7762
7772
 
7763
7773
  // components/Puck/components/Canvas/index.tsx
7764
7774
  var import_shallow7 = require("zustand/react/shallow");
7765
- var import_jsx_runtime37 = require("react/jsx-runtime");
7766
- var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
7775
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7776
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7767
7777
  var ZOOM_ON_CHANGE = true;
7768
7778
  var Canvas = () => {
7769
7779
  const {
@@ -7792,17 +7802,17 @@ var Canvas = () => {
7792
7802
  viewports: s.state.ui.viewports
7793
7803
  }))
7794
7804
  );
7795
- const frameRef = (0, import_react47.useRef)(null);
7796
- const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
7797
- const defaultRender = (0, import_react47.useMemo)(() => {
7798
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
7805
+ const frameRef = (0, import_react50.useRef)(null);
7806
+ const [showTransition, setShowTransition] = (0, import_react50.useState)(false);
7807
+ const defaultRender = (0, import_react50.useMemo)(() => {
7808
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
7799
7809
  return PuckDefault;
7800
7810
  }, []);
7801
- const CustomPreview = (0, import_react47.useMemo)(
7811
+ const CustomPreview = (0, import_react50.useMemo)(
7802
7812
  () => overrides.preview || defaultRender,
7803
7813
  [overrides]
7804
7814
  );
7805
- const getFrameDimensions = (0, import_react47.useCallback)(() => {
7815
+ const getFrameDimensions = (0, import_react50.useCallback)(() => {
7806
7816
  if (frameRef.current) {
7807
7817
  const frame = frameRef.current;
7808
7818
  const box = getBox(frame);
@@ -7810,7 +7820,7 @@ var Canvas = () => {
7810
7820
  }
7811
7821
  return { width: 0, height: 0 };
7812
7822
  }, [frameRef]);
7813
- const resetAutoZoom = (0, import_react47.useCallback)(
7823
+ const resetAutoZoom = (0, import_react50.useCallback)(
7814
7824
  (newViewports = viewports) => {
7815
7825
  if (frameRef.current) {
7816
7826
  setZoomConfig(
@@ -7824,11 +7834,11 @@ var Canvas = () => {
7824
7834
  },
7825
7835
  [frameRef, zoomConfig, viewports]
7826
7836
  );
7827
- (0, import_react47.useEffect)(() => {
7837
+ (0, import_react50.useEffect)(() => {
7828
7838
  setShowTransition(false);
7829
7839
  resetAutoZoom(viewports);
7830
7840
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7831
- (0, import_react47.useEffect)(() => {
7841
+ (0, import_react50.useEffect)(() => {
7832
7842
  const { height: frameHeight } = getFrameDimensions();
7833
7843
  if (viewports.current.height === "auto") {
7834
7844
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7836,13 +7846,13 @@ var Canvas = () => {
7836
7846
  }));
7837
7847
  }
7838
7848
  }, [zoomConfig.zoom]);
7839
- (0, import_react47.useEffect)(() => {
7849
+ (0, import_react50.useEffect)(() => {
7840
7850
  if (ZOOM_ON_CHANGE) {
7841
7851
  setShowTransition(true);
7842
7852
  resetAutoZoom(viewports);
7843
7853
  }
7844
7854
  }, [viewports.current.width]);
7845
- (0, import_react47.useEffect)(() => {
7855
+ (0, import_react50.useEffect)(() => {
7846
7856
  const cb = () => {
7847
7857
  setShowTransition(false);
7848
7858
  resetAutoZoom();
@@ -7852,16 +7862,16 @@ var Canvas = () => {
7852
7862
  window.removeEventListener("resize", cb);
7853
7863
  };
7854
7864
  }, []);
7855
- const [showLoader, setShowLoader] = (0, import_react47.useState)(false);
7856
- (0, import_react47.useEffect)(() => {
7865
+ const [showLoader, setShowLoader] = (0, import_react50.useState)(false);
7866
+ (0, import_react50.useEffect)(() => {
7857
7867
  setTimeout(() => {
7858
7868
  setShowLoader(true);
7859
7869
  }, 500);
7860
7870
  }, []);
7861
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
7871
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
7862
7872
  "div",
7863
7873
  {
7864
- className: getClassName26({
7874
+ className: getClassName25({
7865
7875
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7866
7876
  showLoader
7867
7877
  }),
@@ -7871,7 +7881,7 @@ var Canvas = () => {
7871
7881
  recordHistory: true
7872
7882
  }),
7873
7883
  children: [
7874
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7884
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7875
7885
  ViewportControls,
7876
7886
  {
7877
7887
  autoZoom: zoomConfig.autoZoom,
@@ -7897,11 +7907,11 @@ var Canvas = () => {
7897
7907
  }
7898
7908
  }
7899
7909
  ) }),
7900
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
7901
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7910
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
7911
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7902
7912
  "div",
7903
7913
  {
7904
- className: getClassName26("root"),
7914
+ className: getClassName25("root"),
7905
7915
  style: {
7906
7916
  width: iframe.enabled ? viewports.current.width : "100%",
7907
7917
  height: zoomConfig.rootHeight,
@@ -7919,10 +7929,10 @@ var Canvas = () => {
7919
7929
  })
7920
7930
  );
7921
7931
  },
7922
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview3, {}) })
7932
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Preview2, {}) })
7923
7933
  }
7924
7934
  ),
7925
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
7935
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { size: 24 }) })
7926
7936
  ] })
7927
7937
  ]
7928
7938
  }
@@ -7931,7 +7941,7 @@ var Canvas = () => {
7931
7941
 
7932
7942
  // lib/use-loaded-overrides.ts
7933
7943
  init_react_import();
7934
- var import_react48 = require("react");
7944
+ var import_react51 = require("react");
7935
7945
 
7936
7946
  // lib/load-overrides.ts
7937
7947
  init_react_import();
@@ -7970,26 +7980,26 @@ var useLoadedOverrides = ({
7970
7980
  overrides,
7971
7981
  plugins
7972
7982
  }) => {
7973
- return (0, import_react48.useMemo)(() => {
7983
+ return (0, import_react51.useMemo)(() => {
7974
7984
  return loadOverrides({ overrides, plugins });
7975
7985
  }, [plugins, overrides]);
7976
7986
  };
7977
7987
 
7978
7988
  // components/DefaultOverride/index.tsx
7979
7989
  init_react_import();
7980
- var import_jsx_runtime38 = require("react/jsx-runtime");
7981
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
7990
+ var import_jsx_runtime39 = require("react/jsx-runtime");
7991
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
7982
7992
 
7983
7993
  // lib/use-inject-css.ts
7984
7994
  init_react_import();
7985
- var import_react49 = require("react");
7995
+ var import_react52 = require("react");
7986
7996
  var styles = ``;
7987
7997
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7988
- const [el, setEl] = (0, import_react49.useState)();
7989
- (0, import_react49.useEffect)(() => {
7998
+ const [el, setEl] = (0, import_react52.useState)();
7999
+ (0, import_react52.useEffect)(() => {
7990
8000
  setEl(document.createElement("style"));
7991
8001
  }, []);
7992
- (0, import_react49.useEffect)(() => {
8002
+ (0, import_react52.useEffect)(() => {
7993
8003
  var _a;
7994
8004
  if (!el || typeof window === "undefined") {
7995
8005
  return;
@@ -8009,10 +8019,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
8009
8019
 
8010
8020
  // lib/use-preview-mode-hotkeys.ts
8011
8021
  init_react_import();
8012
- var import_react50 = require("react");
8022
+ var import_react53 = require("react");
8013
8023
  var usePreviewModeHotkeys = () => {
8014
8024
  const appStore = useAppStoreApi();
8015
- const toggleInteractive = (0, import_react50.useCallback)(() => {
8025
+ const toggleInteractive = (0, import_react53.useCallback)(() => {
8016
8026
  const dispatch = appStore.getState().dispatch;
8017
8027
  dispatch({
8018
8028
  type: "setUi",
@@ -8027,7 +8037,7 @@ var usePreviewModeHotkeys = () => {
8027
8037
 
8028
8038
  // lib/use-puck.ts
8029
8039
  init_react_import();
8030
- var import_react51 = require("react");
8040
+ var import_react54 = require("react");
8031
8041
  var import_zustand6 = require("zustand");
8032
8042
  var generateUsePuck = (store) => {
8033
8043
  const history = {
@@ -8041,23 +8051,32 @@ var generateUsePuck = (store) => {
8041
8051
  index: store.history.index
8042
8052
  };
8043
8053
  const storeData = {
8044
- appState: store.state,
8054
+ appState: makeStatePublic(store.state),
8045
8055
  config: store.config,
8046
8056
  dispatch: store.dispatch,
8047
8057
  getPermissions: store.permissions.getPermissions,
8048
8058
  refreshPermissions: store.permissions.refreshPermissions,
8049
8059
  history,
8050
- selectedItem: store.selectedItem || null
8060
+ selectedItem: store.selectedItem || null,
8061
+ getItemBySelector: (selector) => getItem(selector, store.state),
8062
+ getItemById: (id) => store.state.indexes.nodes[id].data,
8063
+ getSelectorForId: (id) => {
8064
+ const node = store.state.indexes.nodes[id];
8065
+ if (!node) return;
8066
+ const zoneCompound = `${node.parentId}:${node.zone}`;
8067
+ const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
8068
+ return { zone: zoneCompound, index };
8069
+ }
8051
8070
  };
8052
8071
  const get = () => storeData;
8053
8072
  return __spreadProps(__spreadValues({}, storeData), { get });
8054
8073
  };
8055
- var UsePuckStoreContext = (0, import_react51.createContext)(
8074
+ var UsePuckStoreContext = (0, import_react54.createContext)(
8056
8075
  null
8057
8076
  );
8058
8077
  var convertToPickedStore = (store) => {
8059
8078
  return {
8060
- state: makeStatePublic(store.state),
8079
+ state: store.state,
8061
8080
  config: store.config,
8062
8081
  dispatch: store.dispatch,
8063
8082
  permissions: store.permissions,
@@ -8066,12 +8085,12 @@ var convertToPickedStore = (store) => {
8066
8085
  };
8067
8086
  };
8068
8087
  var useRegisterUsePuckStore = (appStore) => {
8069
- const [usePuckStore] = (0, import_react51.useState)(
8088
+ const [usePuckStore] = (0, import_react54.useState)(
8070
8089
  () => (0, import_zustand6.createStore)(
8071
8090
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
8072
8091
  )
8073
8092
  );
8074
- (0, import_react51.useEffect)(() => {
8093
+ (0, import_react54.useEffect)(() => {
8075
8094
  return appStore.subscribe(
8076
8095
  (store) => convertToPickedStore(store),
8077
8096
  (pickedStore) => {
@@ -8083,7 +8102,7 @@ var useRegisterUsePuckStore = (appStore) => {
8083
8102
  };
8084
8103
  function createUsePuck() {
8085
8104
  return function usePuck2(selector) {
8086
- const usePuckApi = (0, import_react51.useContext)(UsePuckStoreContext);
8105
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8087
8106
  if (!usePuckApi) {
8088
8107
  throw new Error("usePuck must be used inside <Puck>.");
8089
8108
  }
@@ -8095,18 +8114,241 @@ function createUsePuck() {
8095
8114
  };
8096
8115
  }
8097
8116
  function usePuck() {
8098
- (0, import_react51.useEffect)(() => {
8117
+ (0, import_react54.useEffect)(() => {
8099
8118
  console.warn(
8100
8119
  "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
8101
8120
  );
8102
8121
  }, []);
8103
8122
  return createUsePuck()((s) => s);
8104
8123
  }
8124
+ function useGetPuck() {
8125
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8126
+ if (!usePuckApi) {
8127
+ throw new Error("usePuckGet must be used inside <Puck>.");
8128
+ }
8129
+ return usePuckApi.getState;
8130
+ }
8105
8131
 
8106
8132
  // components/Puck/index.tsx
8107
- var import_jsx_runtime39 = require("react/jsx-runtime");
8108
- var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
8109
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
8133
+ var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
8134
+
8135
+ // components/Puck/components/Header/index.tsx
8136
+ init_react_import();
8137
+ var import_react55 = require("react");
8138
+
8139
+ // components/MenuBar/index.tsx
8140
+ init_react_import();
8141
+
8142
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
8143
+ init_react_import();
8144
+ var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
8145
+
8146
+ // components/MenuBar/index.tsx
8147
+ var import_jsx_runtime40 = require("react/jsx-runtime");
8148
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
8149
+ function MenuBar({
8150
+ menuOpen = false,
8151
+ renderHeaderActions,
8152
+ setMenuOpen
8153
+ }) {
8154
+ const back = useAppStore((s) => s.history.back);
8155
+ const forward = useAppStore((s) => s.history.forward);
8156
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
8157
+ const hasPast = useAppStore((s) => s.history.hasPast());
8158
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8159
+ "div",
8160
+ {
8161
+ className: getClassName26({ menuOpen }),
8162
+ onClick: (event) => {
8163
+ var _a;
8164
+ const element = event.target;
8165
+ if (window.matchMedia("(min-width: 638px)").matches) {
8166
+ return;
8167
+ }
8168
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
8169
+ setMenuOpen(false);
8170
+ }
8171
+ },
8172
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("inner"), children: [
8173
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("history"), children: [
8174
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Undo2, { size: 21 }) }),
8175
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Redo2, { size: 21 }) })
8176
+ ] }),
8177
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: renderHeaderActions && renderHeaderActions() })
8178
+ ] })
8179
+ }
8180
+ );
8181
+ }
8182
+
8183
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
8184
+ init_react_import();
8185
+ var styles_module_default22 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
8186
+
8187
+ // components/Puck/components/Header/index.tsx
8188
+ var import_jsx_runtime41 = require("react/jsx-runtime");
8189
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
8190
+ var HeaderInner = () => {
8191
+ const {
8192
+ onPublish,
8193
+ renderHeader,
8194
+ renderHeaderActions,
8195
+ headerTitle,
8196
+ headerPath,
8197
+ iframe: _iframe
8198
+ } = usePropsContext();
8199
+ const dispatch = useAppStore((s) => s.dispatch);
8200
+ const appStore = useAppStoreApi();
8201
+ const defaultHeaderRender = (0, import_react55.useMemo)(() => {
8202
+ if (renderHeader) {
8203
+ console.warn(
8204
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8205
+ );
8206
+ const RenderHeader = (_a) => {
8207
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8208
+ const Comp = renderHeader;
8209
+ const appState = useAppStore((s) => s.state);
8210
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8211
+ };
8212
+ return RenderHeader;
8213
+ }
8214
+ return DefaultOverride;
8215
+ }, [renderHeader]);
8216
+ const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
8217
+ if (renderHeaderActions) {
8218
+ console.warn(
8219
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8220
+ );
8221
+ const RenderHeader = (props) => {
8222
+ const Comp = renderHeaderActions;
8223
+ const appState = useAppStore((s) => s.state);
8224
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8225
+ };
8226
+ return RenderHeader;
8227
+ }
8228
+ return DefaultOverride;
8229
+ }, [renderHeader]);
8230
+ const CustomHeader = useAppStore(
8231
+ (s) => s.overrides.header || defaultHeaderRender
8232
+ );
8233
+ const CustomHeaderActions = useAppStore(
8234
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
8235
+ );
8236
+ const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
8237
+ const rootTitle = useAppStore((s) => {
8238
+ var _a, _b;
8239
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
8240
+ return (_b = rootData.props.title) != null ? _b : "";
8241
+ });
8242
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8243
+ const rightSideBarVisible = useAppStore(
8244
+ (s) => s.state.ui.rightSideBarVisible
8245
+ );
8246
+ const toggleSidebars = (0, import_react55.useCallback)(
8247
+ (sidebar) => {
8248
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8249
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8250
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8251
+ dispatch({
8252
+ type: "setUi",
8253
+ ui: __spreadValues({
8254
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
8255
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
8256
+ });
8257
+ },
8258
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
8259
+ );
8260
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8261
+ CustomHeader,
8262
+ {
8263
+ actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8264
+ Button,
8265
+ {
8266
+ onClick: () => {
8267
+ const data = appStore.getState().state.data;
8268
+ onPublish && onPublish(data);
8269
+ },
8270
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8271
+ children: "Publish"
8272
+ }
8273
+ ) }) }),
8274
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8275
+ "header",
8276
+ {
8277
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
8278
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("inner"), children: [
8279
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("toggle"), children: [
8280
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8281
+ IconButton,
8282
+ {
8283
+ onClick: () => {
8284
+ toggleSidebars("left");
8285
+ },
8286
+ title: "Toggle left sidebar",
8287
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8288
+ }
8289
+ ) }),
8290
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8291
+ IconButton,
8292
+ {
8293
+ onClick: () => {
8294
+ toggleSidebars("right");
8295
+ },
8296
+ title: "Toggle right sidebar",
8297
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8298
+ }
8299
+ ) })
8300
+ ] }),
8301
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8302
+ headerTitle || rootTitle || "Page",
8303
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8304
+ " ",
8305
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("code", { className: getClassName27("path"), children: headerPath })
8306
+ ] })
8307
+ ] }) }),
8308
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("tools"), children: [
8309
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8310
+ IconButton,
8311
+ {
8312
+ onClick: () => {
8313
+ return setMenuOpen(!menuOpen);
8314
+ },
8315
+ title: "Toggle menu bar",
8316
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8317
+ }
8318
+ ) }),
8319
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8320
+ MenuBar,
8321
+ {
8322
+ dispatch,
8323
+ onPublish,
8324
+ menuOpen,
8325
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8326
+ Button,
8327
+ {
8328
+ onClick: () => {
8329
+ const data = appStore.getState().state.data;
8330
+ onPublish && onPublish(data);
8331
+ },
8332
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8333
+ children: "Publish"
8334
+ }
8335
+ ) }),
8336
+ setMenuOpen
8337
+ }
8338
+ )
8339
+ ] })
8340
+ ] })
8341
+ }
8342
+ )
8343
+ }
8344
+ );
8345
+ };
8346
+ var Header = (0, import_react55.memo)(HeaderInner);
8347
+
8348
+ // components/Puck/index.tsx
8349
+ var import_jsx_runtime42 = require("react/jsx-runtime");
8350
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
8351
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
8110
8352
  var FieldSideBar = () => {
8111
8353
  const title = useAppStore(
8112
8354
  (s) => {
@@ -8114,13 +8356,13 @@ var FieldSideBar = () => {
8114
8356
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
8115
8357
  }
8116
8358
  );
8117
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {}) });
8359
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
8118
8360
  };
8119
- var propsContext = (0, import_react52.createContext)({});
8361
+ var propsContext = (0, import_react56.createContext)({});
8120
8362
  function PropsProvider(props) {
8121
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(propsContext.Provider, { value: props, children: props.children });
8363
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
8122
8364
  }
8123
- var usePropsContext = () => (0, import_react52.useContext)(propsContext);
8365
+ var usePropsContext = () => (0, import_react56.useContext)(propsContext);
8124
8366
  function PuckProvider({ children }) {
8125
8367
  const {
8126
8368
  config,
@@ -8136,11 +8378,14 @@ function PuckProvider({ children }) {
8136
8378
  metadata,
8137
8379
  onAction
8138
8380
  } = usePropsContext();
8139
- const iframe = __spreadValues({
8140
- enabled: true,
8141
- waitForStyles: true
8142
- }, _iframe);
8143
- const [generatedAppState] = (0, import_react52.useState)(() => {
8381
+ const iframe = (0, import_react56.useMemo)(
8382
+ () => __spreadValues({
8383
+ enabled: true,
8384
+ waitForStyles: true
8385
+ }, _iframe),
8386
+ [_iframe]
8387
+ );
8388
+ const [generatedAppState] = (0, import_react56.useState)(() => {
8144
8389
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8145
8390
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8146
8391
  let clientUiState = {};
@@ -8197,17 +8442,17 @@ function PuckProvider({ children }) {
8197
8442
  ) : {}
8198
8443
  })
8199
8444
  });
8200
- return walkTree(newAppState, config);
8445
+ return walkAppState(newAppState, config);
8201
8446
  });
8202
8447
  const { appendData = true } = _initialHistory || {};
8203
- const [blendedHistories] = (0, import_react52.useState)(
8448
+ const [blendedHistories] = (0, import_react56.useState)(
8204
8449
  [
8205
8450
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8206
8451
  ...appendData ? [{ state: generatedAppState }] : []
8207
8452
  ].map((history) => {
8208
8453
  let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
8209
8454
  if (!history.state.indexes) {
8210
- newState = walkTree(newState, config);
8455
+ newState = walkAppState(newState, config);
8211
8456
  }
8212
8457
  return __spreadProps(__spreadValues({}, history), {
8213
8458
  state: newState
@@ -8220,7 +8465,7 @@ function PuckProvider({ children }) {
8220
8465
  overrides,
8221
8466
  plugins
8222
8467
  });
8223
- const generateAppStore = (0, import_react52.useCallback)(
8468
+ const generateAppStore = (0, import_react56.useCallback)(
8224
8469
  (state) => {
8225
8470
  return {
8226
8471
  state,
@@ -8244,10 +8489,10 @@ function PuckProvider({ children }) {
8244
8489
  metadata
8245
8490
  ]
8246
8491
  );
8247
- const [appStore] = (0, import_react52.useState)(
8492
+ const [appStore] = (0, import_react56.useState)(
8248
8493
  () => createAppStore(generateAppStore(initialAppState))
8249
8494
  );
8250
- (0, import_react52.useEffect)(() => {
8495
+ (0, import_react56.useEffect)(() => {
8251
8496
  const state = appStore.getState().state;
8252
8497
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8253
8498
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8256,66 +8501,47 @@ function PuckProvider({ children }) {
8256
8501
  index: initialHistoryIndex,
8257
8502
  initialAppState
8258
8503
  });
8259
- (0, import_react52.useEffect)(() => {
8260
- appStore.subscribe((s) => {
8261
- if (onChange) onChange(s.state.data);
8262
- });
8504
+ const previousData = (0, import_react56.useRef)(null);
8505
+ (0, import_react56.useEffect)(() => {
8506
+ appStore.subscribe(
8507
+ (s) => s.state.data,
8508
+ (data) => {
8509
+ if (onChange) {
8510
+ if ((0, import_fast_deep_equal2.default)(data, previousData.current)) return;
8511
+ onChange(data);
8512
+ previousData.current = data;
8513
+ }
8514
+ }
8515
+ );
8263
8516
  }, []);
8264
8517
  useRegisterPermissionsSlice(appStore, permissions);
8265
8518
  const uPuckStore = useRegisterUsePuckStore(appStore);
8266
- (0, import_react52.useEffect)(() => {
8519
+ (0, import_react56.useEffect)(() => {
8267
8520
  const { resolveAndCommitData } = appStore.getState();
8268
8521
  resolveAndCommitData();
8269
8522
  }, []);
8270
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8523
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8271
8524
  }
8272
8525
  function PuckLayout({ children }) {
8273
8526
  const {
8274
- onChange,
8275
- onPublish,
8276
- renderHeader,
8277
- renderHeaderActions,
8278
- headerTitle,
8279
- headerPath,
8280
8527
  iframe: _iframe,
8281
8528
  dnd,
8282
8529
  initialHistory: _initialHistory
8283
8530
  } = usePropsContext();
8284
- const iframe = __spreadValues({
8285
- enabled: true,
8286
- waitForStyles: true
8287
- }, _iframe);
8531
+ const iframe = (0, import_react56.useMemo)(
8532
+ () => __spreadValues({
8533
+ enabled: true,
8534
+ waitForStyles: true
8535
+ }, _iframe),
8536
+ [_iframe]
8537
+ );
8288
8538
  useInjectGlobalCss(iframe.enabled);
8289
8539
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8290
8540
  const rightSideBarVisible = useAppStore(
8291
8541
  (s) => s.state.ui.rightSideBarVisible
8292
8542
  );
8293
- const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
8294
- const appStore = useAppStoreApi();
8295
- (0, import_react52.useEffect)(() => {
8296
- return appStore.subscribe((s) => {
8297
- if (onChange) onChange(s.state.data);
8298
- });
8299
- }, [appStore]);
8300
- const rootProps = useAppStore(
8301
- (s) => s.state.data.root.props || s.state.data.root.props
8302
- );
8303
8543
  const dispatch = useAppStore((s) => s.dispatch);
8304
- const toggleSidebars = (0, import_react52.useCallback)(
8305
- (sidebar) => {
8306
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8307
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8308
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8309
- dispatch({
8310
- type: "setUi",
8311
- ui: __spreadValues({
8312
- [`${sidebar}SideBarVisible`]: !sideBarVisible
8313
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
8314
- });
8315
- },
8316
- [dispatch, leftSideBarVisible, rightSideBarVisible]
8317
- );
8318
- (0, import_react52.useEffect)(() => {
8544
+ (0, import_react56.useEffect)(() => {
8319
8545
  if (!window.matchMedia("(min-width: 638px)").matches) {
8320
8546
  dispatch({
8321
8547
  type: "setUi",
@@ -8338,55 +8564,18 @@ function PuckLayout({ children }) {
8338
8564
  window.removeEventListener("resize", handleResize);
8339
8565
  };
8340
8566
  }, []);
8341
- const defaultHeaderRender = (0, import_react52.useMemo)(() => {
8342
- if (renderHeader) {
8343
- console.warn(
8344
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8345
- );
8346
- const RenderHeader = (_a) => {
8347
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8348
- const Comp = renderHeader;
8349
- const appState = useAppStore((s) => s.state);
8350
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8351
- };
8352
- return RenderHeader;
8353
- }
8354
- return DefaultOverride;
8355
- }, [renderHeader]);
8356
- const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
8357
- if (renderHeaderActions) {
8358
- console.warn(
8359
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8360
- );
8361
- const RenderHeader = (props) => {
8362
- const Comp = renderHeaderActions;
8363
- const appState = useAppStore((s) => s.state);
8364
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8365
- };
8366
- return RenderHeader;
8367
- }
8368
- return DefaultOverride;
8369
- }, [renderHeader]);
8370
8567
  const overrides = useAppStore((s) => s.overrides);
8371
- const CustomPuck = (0, import_react52.useMemo)(
8568
+ const CustomPuck = (0, import_react56.useMemo)(
8372
8569
  () => overrides.puck || DefaultOverride,
8373
8570
  [overrides]
8374
8571
  );
8375
- const CustomHeader = (0, import_react52.useMemo)(
8376
- () => overrides.header || defaultHeaderRender,
8377
- [overrides]
8378
- );
8379
- const CustomHeaderActions = (0, import_react52.useMemo)(
8380
- () => overrides.headerActions || defaultHeaderActionsRender,
8381
- [overrides]
8382
- );
8383
- const [mounted, setMounted] = (0, import_react52.useState)(false);
8384
- (0, import_react52.useEffect)(() => {
8572
+ const [mounted, setMounted] = (0, import_react56.useState)(false);
8573
+ (0, import_react56.useEffect)(() => {
8385
8574
  setMounted(true);
8386
8575
  }, []);
8387
8576
  const ready = useAppStore((s) => s.status === "READY");
8388
8577
  useMonitorHotkeys();
8389
- (0, import_react52.useEffect)(() => {
8578
+ (0, import_react56.useEffect)(() => {
8390
8579
  if (ready && iframe.enabled) {
8391
8580
  const frameDoc = getFrame();
8392
8581
  if (frameDoc) {
@@ -8395,133 +8584,36 @@ function PuckLayout({ children }) {
8395
8584
  }
8396
8585
  }, [ready, iframe.enabled]);
8397
8586
  usePreviewModeHotkeys();
8398
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
8399
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8587
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `Puck ${getClassName28()}`, children: [
8588
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8400
8589
  "div",
8401
8590
  {
8402
8591
  className: getLayoutClassName({
8403
8592
  leftSideBarVisible,
8404
- menuOpen,
8405
8593
  mounted,
8406
8594
  rightSideBarVisible
8407
8595
  }),
8408
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8409
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8410
- CustomHeader,
8411
- {
8412
- actions: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8413
- Button,
8414
- {
8415
- onClick: () => {
8416
- const data = appStore.getState().state.data;
8417
- onPublish && onPublish(data);
8418
- },
8419
- icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
8420
- children: "Publish"
8421
- }
8422
- ) }) }),
8423
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
8424
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
8425
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8426
- "div",
8427
- {
8428
- className: getLayoutClassName("leftSideBarToggle"),
8429
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8430
- IconButton,
8431
- {
8432
- onClick: () => {
8433
- toggleSidebars("left");
8434
- },
8435
- title: "Toggle left sidebar",
8436
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
8437
- }
8438
- )
8439
- }
8440
- ),
8441
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8442
- "div",
8443
- {
8444
- className: getLayoutClassName("rightSideBarToggle"),
8445
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8446
- IconButton,
8447
- {
8448
- onClick: () => {
8449
- toggleSidebars("right");
8450
- },
8451
- title: "Toggle right sidebar",
8452
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
8453
- }
8454
- )
8455
- }
8456
- )
8457
- ] }),
8458
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
8459
- headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
8460
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
8461
- " ",
8462
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8463
- "code",
8464
- {
8465
- className: getLayoutClassName("headerPath"),
8466
- children: headerPath
8467
- }
8468
- )
8469
- ] })
8470
- ] }) }),
8471
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
8472
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8473
- IconButton,
8474
- {
8475
- onClick: () => {
8476
- return setMenuOpen(!menuOpen);
8477
- },
8478
- title: "Toggle menu bar",
8479
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
8480
- }
8481
- ) }),
8482
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8483
- MenuBar,
8484
- {
8485
- dispatch,
8486
- onPublish,
8487
- menuOpen,
8488
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8489
- Button,
8490
- {
8491
- onClick: () => {
8492
- const data = appStore.getState().state.data;
8493
- onPublish && onPublish(data);
8494
- },
8495
- icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
8496
- children: "Publish"
8497
- }
8498
- ) }),
8499
- setMenuOpen
8500
- }
8501
- )
8502
- ] })
8503
- ] }) })
8504
- }
8505
- ),
8506
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8507
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
8508
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
8596
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8597
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Header, {}),
8598
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8599
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Components, {}) }),
8600
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Outline, {}) })
8509
8601
  ] }),
8510
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
8511
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(FieldSideBar, {}) })
8602
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Canvas, {}),
8603
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FieldSideBar, {}) })
8512
8604
  ] })
8513
8605
  }
8514
8606
  ) }) }),
8515
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
8607
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { id: "puck-portal-root", className: getClassName28("portal") })
8516
8608
  ] });
8517
8609
  }
8518
8610
  function Puck(props) {
8519
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
8611
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
8520
8612
  }
8521
8613
  Puck.Components = Components;
8522
8614
  Puck.Fields = Fields;
8523
8615
  Puck.Outline = Outline;
8524
- Puck.Preview = Preview3;
8616
+ Puck.Preview = Preview2;
8525
8617
 
8526
8618
  // lib/migrate.ts
8527
8619
  init_react_import();
@@ -8540,10 +8632,67 @@ var migrations = [
8540
8632
  });
8541
8633
  }
8542
8634
  return data;
8635
+ },
8636
+ // Migrate zones to slots
8637
+ (data, config) => {
8638
+ var _a;
8639
+ if (!config) return data;
8640
+ console.log("Migrating DropZones to slots...");
8641
+ const updatedItems = {};
8642
+ const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
8643
+ const { indexes } = walkAppState(appState, config);
8644
+ const deletedCompounds = [];
8645
+ walkAppState(appState, config, (content, zoneCompound, zoneType) => {
8646
+ var _a2, _b;
8647
+ if (zoneType === "dropzone") {
8648
+ const [id, slotName] = zoneCompound.split(":");
8649
+ const nodeData = indexes.nodes[id].data;
8650
+ const componentType = nodeData.type;
8651
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
8652
+ if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
8653
+ updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8654
+ props: __spreadProps(__spreadValues({}, nodeData.props), {
8655
+ [slotName]: content
8656
+ })
8657
+ });
8658
+ deletedCompounds.push(zoneCompound);
8659
+ }
8660
+ return content;
8661
+ }
8662
+ return content;
8663
+ });
8664
+ const updated = walkAppState(
8665
+ appState,
8666
+ config,
8667
+ (content) => content,
8668
+ (item) => {
8669
+ var _a2;
8670
+ return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
8671
+ }
8672
+ );
8673
+ deletedCompounds.forEach((zoneCompound) => {
8674
+ var _a2;
8675
+ const [_, propName] = zoneCompound.split(":");
8676
+ console.log(
8677
+ `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
8678
+ );
8679
+ (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
8680
+ });
8681
+ Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
8682
+ const [_, propName] = zoneCompound.split(":");
8683
+ throw new Error(
8684
+ `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
8685
+ );
8686
+ });
8687
+ delete updated.data.zones;
8688
+ return updated.data;
8543
8689
  }
8544
8690
  ];
8545
- function migrate(data) {
8546
- return migrations == null ? void 0 : migrations.reduce((acc, migration) => migration(acc), data);
8691
+ function migrate(data, config) {
8692
+ return migrations == null ? void 0 : migrations.reduce(
8693
+ (acc, migration) => migration(acc, config),
8694
+ data
8695
+ );
8547
8696
  }
8548
8697
 
8549
8698
  // lib/transform-props.ts
@@ -8557,11 +8706,13 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
8557
8706
  });
8558
8707
 
8559
8708
  // lib/transform-props.ts
8560
- function transformProps(data, propTransforms) {
8709
+ function transformProps(data, propTransforms, config = { components: {} }) {
8561
8710
  const mapItem = (item) => {
8562
8711
  if (propTransforms[item.type]) {
8563
8712
  return __spreadProps(__spreadValues({}, item), {
8564
- props: propTransforms[item.type](item.props)
8713
+ props: __spreadValues({
8714
+ id: item.props.id
8715
+ }, propTransforms[item.type](item.props))
8565
8716
  });
8566
8717
  }
8567
8718
  return item;
@@ -8570,23 +8721,18 @@ function transformProps(data, propTransforms) {
8570
8721
  const rootProps = defaultedData.root.props || defaultedData.root;
8571
8722
  let newRoot = __spreadValues({}, defaultedData.root);
8572
8723
  if (propTransforms["root"]) {
8573
- if (defaultedData.root.props) {
8574
- newRoot.props = propTransforms["root"](rootProps);
8575
- } else {
8576
- newRoot = propTransforms["root"](rootProps);
8577
- }
8724
+ newRoot.props = propTransforms["root"](rootProps);
8578
8725
  }
8579
- const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
8580
- root: newRoot,
8581
- content: defaultedData.content.map(mapItem),
8582
- zones: Object.keys(data.zones || {}).reduce(
8583
- (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
8584
- [zoneKey]: data.zones[zoneKey].map(mapItem)
8585
- }),
8586
- {}
8587
- )
8588
- });
8589
- return afterPropTransforms;
8726
+ const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
8727
+ const updatedData = walkTree(
8728
+ dataWithUpdatedRoot,
8729
+ config,
8730
+ (content) => content.map(mapItem)
8731
+ );
8732
+ if (!defaultedData.root.props) {
8733
+ updatedData.root = updatedData.root.props;
8734
+ }
8735
+ return updatedData;
8590
8736
  }
8591
8737
 
8592
8738
  // lib/resolve-all-data.ts
@@ -8620,7 +8766,11 @@ function resolveAllData(_0, _1) {
8620
8766
  "force",
8621
8767
  false
8622
8768
  )).node;
8623
- const resolvedDeep = yield mapSlots(resolved, processContent, false);
8769
+ const resolvedDeep = yield mapSlotsAsync(
8770
+ resolved,
8771
+ processContent,
8772
+ false
8773
+ );
8624
8774
  onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
8625
8775
  return resolvedDeep;
8626
8776
  });
@@ -8667,7 +8817,9 @@ function resolveAllData(_0, _1) {
8667
8817
  renderContext,
8668
8818
  resolveAllData,
8669
8819
  transformProps,
8670
- usePuck
8820
+ useGetPuck,
8821
+ usePuck,
8822
+ walkTree
8671
8823
  });
8672
8824
  /*! Bundled license information:
8673
8825