@measured/puck 0.19.0-canary.036267f6 → 0.19.0-canary.046cb9ed

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
@@ -181,7 +181,8 @@ __export(core_exports, {
181
181
  renderContext: () => renderContext,
182
182
  resolveAllData: () => resolveAllData,
183
183
  transformProps: () => transformProps,
184
- usePuck: () => usePuck
184
+ usePuck: () => usePuck,
185
+ walkTree: () => walkTree
185
186
  });
186
187
  module.exports = __toCommonJS(core_exports);
187
188
  init_react_import();
@@ -308,7 +309,7 @@ init_react_import();
308
309
 
309
310
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
310
311
  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" };
312
+ 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
313
 
313
314
  // components/AutoField/index.tsx
314
315
  var import_react22 = require("react");
@@ -670,7 +671,7 @@ init_react_import();
670
671
  // lib/filter.ts
671
672
  init_react_import();
672
673
 
673
- // lib/reorder.ts
674
+ // lib/data/reorder.ts
674
675
  init_react_import();
675
676
  var reorder = (list, startIndex, endIndex) => {
676
677
  const result = Array.from(list);
@@ -679,7 +680,7 @@ var reorder = (list, startIndex, endIndex) => {
679
680
  return result;
680
681
  };
681
682
 
682
- // lib/replace.ts
683
+ // lib/data/replace.ts
683
684
  init_react_import();
684
685
  var replace = (list, index, newItem) => {
685
686
  const result = Array.from(list);
@@ -791,74 +792,30 @@ init_react_import();
791
792
  // reducer/index.ts
792
793
  init_react_import();
793
794
 
794
- // reducer/reduce.ts
795
+ // reducer/actions/set.ts
795
796
  init_react_import();
796
797
 
797
- // lib/insert.ts
798
+ // lib/data/walk-app-state.ts
798
799
  init_react_import();
799
- var insert = (list, index, item) => {
800
- const result = Array.from(list || []);
801
- result.splice(index, 0, item);
802
- return result;
803
- };
804
-
805
- // lib/remove.ts
806
- init_react_import();
807
- var remove = (list, index) => {
808
- const result = Array.from(list);
809
- result.splice(index, 1);
810
- return result;
811
- };
812
-
813
- // lib/setup-zone.ts
814
- init_react_import();
815
-
816
- // lib/root-droppable-id.ts
817
- init_react_import();
818
- var rootAreaId = "root";
819
- var rootZone = "default-zone";
820
- var rootDroppableId = `${rootAreaId}:${rootZone}`;
821
800
 
822
- // lib/setup-zone.ts
823
- var setupZone = (data, zoneKey) => {
824
- if (zoneKey === rootDroppableId) {
825
- return data;
826
- }
827
- const newData = __spreadProps(__spreadValues({}, data), {
828
- zones: data.zones ? __spreadValues({}, data.zones) : {}
829
- });
830
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
831
- return newData;
832
- };
833
-
834
- // lib/get-item.ts
801
+ // lib/data/for-each-slot.ts
835
802
  init_react_import();
836
- function getItem(selector, state) {
837
- var _a, _b;
838
- const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
839
- return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
840
- }
841
803
 
842
- // lib/generate-id.ts
843
- init_react_import();
844
- var import_uuid = require("uuid");
845
- var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, import_uuid.v4)();
846
-
847
- // lib/walk-tree.ts
848
- init_react_import();
849
-
850
- // lib/for-each-slot.ts
851
- init_react_import();
852
-
853
- // lib/is-slot.ts
804
+ // lib/data/is-slot.ts
854
805
  init_react_import();
855
806
  var isSlot = (prop) => {
856
807
  var _a, _b;
857
808
  return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
858
809
  };
810
+ var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
811
+ var _a, _b;
812
+ const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
813
+ if (!configForComponent) return isSlot(propValue);
814
+ return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
815
+ };
859
816
 
860
- // lib/for-each-slot.ts
861
- var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, cb, recursive = false, isSlot2 = isSlot) {
817
+ // lib/data/for-each-slot.ts
818
+ var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
862
819
  const props = item.props || {};
863
820
  const propKeys = Object.keys(props);
864
821
  for (let i = 0; i < propKeys.length; i++) {
@@ -866,23 +823,31 @@ var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function*
866
823
  const itemType = "type" in item ? item.type : "root";
867
824
  if (isSlot2(itemType, propKey, props[propKey])) {
868
825
  const content = props[propKey];
869
- yield cb(props.id, propKey, content);
826
+ cb(props.id, propKey, content);
870
827
  if (recursive) {
871
828
  content.forEach(
872
829
  (childItem) => __async(void 0, null, function* () {
873
- return yield forEachSlot(childItem, cb, true, isSlot2);
830
+ return forEachSlot(childItem, cb, true, isSlot2);
874
831
  })
875
832
  );
876
833
  }
877
834
  }
878
835
  }
879
- });
836
+ };
880
837
 
881
- // lib/for-related-zones.ts
838
+ // lib/data/for-related-zones.ts
882
839
  init_react_import();
883
840
 
884
841
  // lib/get-zone-id.ts
885
842
  init_react_import();
843
+
844
+ // lib/root-droppable-id.ts
845
+ init_react_import();
846
+ var rootAreaId = "root";
847
+ var rootZone = "default-zone";
848
+ var rootDroppableId = `${rootAreaId}:${rootZone}`;
849
+
850
+ // lib/get-zone-id.ts
886
851
  var getZoneId = (zoneCompound) => {
887
852
  if (!zoneCompound) {
888
853
  return [];
@@ -893,19 +858,17 @@ var getZoneId = (zoneCompound) => {
893
858
  return [rootDroppableId, zoneCompound];
894
859
  };
895
860
 
896
- // lib/for-related-zones.ts
861
+ // lib/data/for-related-zones.ts
897
862
  function forRelatedZones(item, data, cb, path = []) {
898
863
  Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
899
864
  const [parentId] = getZoneId(zoneCompound);
900
865
  if (parentId === item.props.id) {
901
- const newPath = [...path, zoneCompound];
902
- content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
903
866
  cb(path, zoneCompound, content);
904
867
  }
905
868
  });
906
869
  }
907
870
 
908
- // lib/strip-slots.ts
871
+ // lib/data/strip-slots.ts
909
872
  init_react_import();
910
873
  var stripSlots = (data) => {
911
874
  return __spreadProps(__spreadValues({}, data), {
@@ -921,8 +884,8 @@ var stripSlots = (data) => {
921
884
  });
922
885
  };
923
886
 
924
- // lib/walk-tree.ts
925
- function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
887
+ // lib/data/walk-app-state.ts
888
+ function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
926
889
  var _a;
927
890
  let newZones = {};
928
891
  const newZoneIndex = {};
@@ -963,7 +926,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
963
926
  const mappedItem = mapNodeOrSkip(item, path, index);
964
927
  if (!mappedItem) return item;
965
928
  const id = mappedItem.props.id;
966
- processRelatedZones(item, id, path);
967
929
  const newProps = __spreadValues({}, mappedItem.props);
968
930
  forEachSlot(
969
931
  mappedItem,
@@ -979,13 +941,9 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
979
941
  newProps[slotId] = newContent2;
980
942
  },
981
943
  false,
982
- (itemType, propName, propValue) => {
983
- var _a2, _b;
984
- const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
985
- if (!configForComponent) return isSlot(propValue);
986
- return ((_b = (_a2 = configForComponent.fields) == null ? void 0 : _a2[propName]) == null ? void 0 : _b.type) === "slot";
987
- }
944
+ createIsSlotConfig(config)
988
945
  );
946
+ processRelatedZones(item, id, path);
989
947
  const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
990
948
  const thisZoneCompound = path[path.length - 1];
991
949
  const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
@@ -996,7 +954,7 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
996
954
  parentId,
997
955
  zone
998
956
  };
999
- const finalData = newItem;
957
+ const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
1000
958
  if (newProps.id === "root") {
1001
959
  delete finalData["type"];
1002
960
  delete finalData.props["id"];
@@ -1011,8 +969,12 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
1011
969
  "root"
1012
970
  );
1013
971
  const processedContent = newContent;
972
+ const zonesAlreadyProcessed = Object.keys(newZones);
1014
973
  Object.keys(zones || {}).forEach((zoneCompound) => {
1015
974
  const [parentId] = zoneCompound.split(":");
975
+ if (zonesAlreadyProcessed.includes(zoneCompound)) {
976
+ return;
977
+ }
1016
978
  const [_2, newContent2] = processContent(
1017
979
  [rootDroppableId],
1018
980
  zoneCompound,
@@ -1036,7 +998,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
1036
998
  return __spreadProps(__spreadValues({}, state), {
1037
999
  data: {
1038
1000
  root,
1039
- // root: state.data.root, // TODO changing root causes it's entire subtree to re-render. Let's keep this disabled until the performance issues are resolved in #644.
1040
1001
  content: processedContent,
1041
1002
  zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
1042
1003
  },
@@ -1047,60 +1008,157 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
1047
1008
  });
1048
1009
  }
1049
1010
 
1050
- // lib/deindex.ts
1051
- init_react_import();
1052
- var deindex = (state, componentData) => {
1053
- let zones = __spreadValues({}, state.indexes.zones);
1054
- let nodes = __spreadValues({}, state.indexes.nodes);
1055
- const dindexRelatedZones = (item) => {
1056
- forRelatedZones(item, state.data, (_path, zoneCompound, content) => {
1057
- content.forEach((subItem) => {
1058
- dindexChildren(subItem);
1059
- delete nodes[subItem.props.id];
1060
- });
1061
- delete zones[zoneCompound];
1062
- });
1063
- };
1064
- const dindexChildren = (item) => {
1065
- forEachSlot(
1066
- item,
1067
- (parentId, slotId, content) => {
1068
- const zoneCompound = `${parentId}:${slotId}`;
1069
- delete zones[zoneCompound];
1070
- content.forEach((item2) => {
1071
- dindexRelatedZones(item2);
1072
- delete nodes[item2.props.id];
1073
- });
1074
- },
1075
- true
1011
+ // reducer/actions/set.ts
1012
+ var setAction = (state, action, appStore) => {
1013
+ if (typeof action.state === "object") {
1014
+ const newState = __spreadValues(__spreadValues({}, state), action.state);
1015
+ if (action.state.indexes) {
1016
+ return newState;
1017
+ }
1018
+ console.warn(
1019
+ "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1076
1020
  );
1077
- };
1078
- dindexRelatedZones(componentData);
1079
- dindexChildren(componentData);
1080
- delete nodes[componentData.props.id];
1081
- return { nodes, zones };
1021
+ return walkAppState(newState, appStore.config);
1022
+ }
1023
+ return __spreadValues(__spreadValues({}, state), action.state(state));
1082
1024
  };
1083
1025
 
1084
- // reducer/reduce.ts
1085
- var zoneCache = {};
1026
+ // reducer/actions/insert.ts
1027
+ init_react_import();
1028
+
1029
+ // lib/data/insert.ts
1030
+ init_react_import();
1031
+ var insert = (list, index, item) => {
1032
+ const result = Array.from(list || []);
1033
+ result.splice(index, 0, item);
1034
+ return result;
1035
+ };
1036
+
1037
+ // lib/generate-id.ts
1038
+ init_react_import();
1039
+ var import_uuid = require("uuid");
1040
+ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, import_uuid.v4)();
1041
+
1042
+ // lib/data/get-ids-for-parent.ts
1043
+ init_react_import();
1086
1044
  var getIdsForParent = (zoneCompound, state) => {
1087
1045
  const [parentId] = zoneCompound.split(":");
1088
1046
  const node = state.indexes.nodes[parentId];
1089
1047
  return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
1090
1048
  };
1091
- function insertAction(state, action, config) {
1092
- const id = action.id || generateId(action.componentType);
1093
- const emptyComponentData = {
1094
- type: action.componentType,
1095
- props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
1096
- id
1097
- })
1049
+
1050
+ // lib/data/populate-ids.ts
1051
+ init_react_import();
1052
+
1053
+ // lib/data/walk-tree.ts
1054
+ init_react_import();
1055
+
1056
+ // lib/data/map-slots.ts
1057
+ init_react_import();
1058
+ function mapSlotsAsync(_0, _1) {
1059
+ return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
1060
+ const props = __spreadValues({}, item.props);
1061
+ const propKeys = Object.keys(props);
1062
+ for (let i = 0; i < propKeys.length; i++) {
1063
+ const propKey = propKeys[i];
1064
+ const itemType = "type" in item ? item.type : "root";
1065
+ if (isSlot2(itemType, propKey, props[propKey])) {
1066
+ const content = props[propKey];
1067
+ const mappedContent = recursive ? yield Promise.all(
1068
+ content.map((item2) => __async(this, null, function* () {
1069
+ return yield mapSlotsAsync(item2, map, recursive, isSlot2);
1070
+ }))
1071
+ ) : content;
1072
+ props[propKey] = yield map(mappedContent, propKey);
1073
+ }
1074
+ }
1075
+ return __spreadProps(__spreadValues({}, item), { props });
1076
+ });
1077
+ }
1078
+ function mapSlotsSync(item, map, isSlot2 = isSlot) {
1079
+ var _a, _b;
1080
+ const props = __spreadValues({}, item.props);
1081
+ const propKeys = Object.keys(props);
1082
+ for (let i = 0; i < propKeys.length; i++) {
1083
+ const propKey = propKeys[i];
1084
+ const itemType = "type" in item ? item.type : "root";
1085
+ if (isSlot2(itemType, propKey, props[propKey])) {
1086
+ const content = props[propKey];
1087
+ const mappedContent = content.map((item2) => {
1088
+ return mapSlotsSync(item2, map, isSlot2);
1089
+ });
1090
+ props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
1091
+ }
1092
+ }
1093
+ return __spreadProps(__spreadValues({}, item), { props });
1094
+ }
1095
+
1096
+ // lib/data/walk-tree.ts
1097
+ function walkTree(data, config, callbackFn) {
1098
+ var _a, _b;
1099
+ const isSlot2 = createIsSlotConfig(config);
1100
+ const walkItem = (item) => {
1101
+ return mapSlotsSync(
1102
+ item,
1103
+ (content, parentId, propName) => callbackFn(content, { parentId, propName }),
1104
+ isSlot2
1105
+ );
1098
1106
  };
1107
+ if ("props" in data) {
1108
+ return walkItem(data);
1109
+ }
1110
+ const _data = data;
1111
+ const zones = (_a = _data.zones) != null ? _a : {};
1112
+ const mappedContent = _data.content.map(walkItem);
1113
+ return {
1114
+ root: walkItem(_data.root),
1115
+ content: (_b = callbackFn(mappedContent, {
1116
+ parentId: "root",
1117
+ propName: "default-zone"
1118
+ })) != null ? _b : mappedContent,
1119
+ zones: Object.keys(zones).reduce(
1120
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
1121
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
1122
+ }),
1123
+ {}
1124
+ )
1125
+ };
1126
+ }
1127
+
1128
+ // lib/data/populate-ids.ts
1129
+ var populateIds = (data, config, override = false) => {
1130
+ const id = generateId(data.type);
1131
+ return walkTree(
1132
+ __spreadProps(__spreadValues({}, data), {
1133
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
1134
+ }),
1135
+ config,
1136
+ (contents) => contents.map((item) => {
1137
+ const id2 = generateId(item.type);
1138
+ return __spreadProps(__spreadValues({}, item), {
1139
+ props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
1140
+ });
1141
+ })
1142
+ );
1143
+ };
1144
+
1145
+ // reducer/actions/insert.ts
1146
+ function insertAction(state, action, appStore) {
1147
+ const id = action.id || generateId(action.componentType);
1148
+ const emptyComponentData = populateIds(
1149
+ {
1150
+ type: action.componentType,
1151
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
1152
+ id
1153
+ })
1154
+ },
1155
+ appStore.config
1156
+ );
1099
1157
  const [parentId] = action.destinationZone.split(":");
1100
1158
  const idsInPath = getIdsForParent(action.destinationZone, state);
1101
- return walkTree(
1159
+ return walkAppState(
1102
1160
  state,
1103
- config,
1161
+ appStore.config,
1104
1162
  (content, zoneCompound) => {
1105
1163
  if (zoneCompound === action.destinationZone) {
1106
1164
  return insert(
@@ -1123,6 +1181,142 @@ function insertAction(state, action, config) {
1123
1181
  }
1124
1182
  );
1125
1183
  }
1184
+
1185
+ // reducer/actions/replace.ts
1186
+ init_react_import();
1187
+ var replaceAction = (state, action, appStore) => {
1188
+ const [parentId] = action.destinationZone.split(":");
1189
+ const idsInPath = getIdsForParent(action.destinationZone, state);
1190
+ const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
1191
+ const idChanged = originalId !== action.data.props.id;
1192
+ if (idChanged) {
1193
+ throw new Error(
1194
+ `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1195
+ );
1196
+ }
1197
+ const data = populateIds(action.data, appStore.config);
1198
+ return walkAppState(
1199
+ state,
1200
+ appStore.config,
1201
+ (content, zoneCompound) => {
1202
+ const newContent = [...content];
1203
+ if (zoneCompound === action.destinationZone) {
1204
+ newContent[action.destinationIndex] = data;
1205
+ }
1206
+ return newContent;
1207
+ },
1208
+ (childItem, path) => {
1209
+ const pathIds = path.map((p) => p.split(":")[0]);
1210
+ if (childItem.props.id === data.props.id) {
1211
+ return data;
1212
+ } else if (childItem.props.id === parentId) {
1213
+ return childItem;
1214
+ } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1215
+ return childItem;
1216
+ } else if (pathIds.indexOf(data.props.id) > -1) {
1217
+ return childItem;
1218
+ }
1219
+ return null;
1220
+ }
1221
+ );
1222
+ };
1223
+
1224
+ // reducer/actions/replace-root.ts
1225
+ init_react_import();
1226
+ var replaceRootAction = (state, action, appStore) => {
1227
+ return walkAppState(
1228
+ state,
1229
+ appStore.config,
1230
+ (content) => content,
1231
+ (childItem) => {
1232
+ if (childItem.props.id === "root") {
1233
+ return __spreadProps(__spreadValues({}, childItem), {
1234
+ props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1235
+ readOnly: action.root.readOnly
1236
+ });
1237
+ }
1238
+ return childItem;
1239
+ }
1240
+ );
1241
+ };
1242
+
1243
+ // reducer/actions/duplicate.ts
1244
+ init_react_import();
1245
+
1246
+ // lib/data/get-item.ts
1247
+ init_react_import();
1248
+ function getItem(selector, state) {
1249
+ var _a, _b;
1250
+ const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
1251
+ return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
1252
+ }
1253
+
1254
+ // reducer/actions/duplicate.ts
1255
+ function duplicateAction(state, action, appStore) {
1256
+ const item = getItem(
1257
+ { index: action.sourceIndex, zone: action.sourceZone },
1258
+ state
1259
+ );
1260
+ const idsInPath = getIdsForParent(action.sourceZone, state);
1261
+ const newItem = __spreadProps(__spreadValues({}, item), {
1262
+ props: __spreadProps(__spreadValues({}, item.props), {
1263
+ id: generateId(item.type)
1264
+ })
1265
+ });
1266
+ const modified = walkAppState(
1267
+ state,
1268
+ appStore.config,
1269
+ (content, zoneCompound) => {
1270
+ if (zoneCompound === action.sourceZone) {
1271
+ return insert(content, action.sourceIndex + 1, item);
1272
+ }
1273
+ return content;
1274
+ },
1275
+ (childItem, path, index) => {
1276
+ const zoneCompound = path[path.length - 1];
1277
+ const parents = path.map((p) => p.split(":")[0]);
1278
+ if (parents.indexOf(newItem.props.id) > -1) {
1279
+ return __spreadProps(__spreadValues({}, childItem), {
1280
+ props: __spreadProps(__spreadValues({}, childItem.props), {
1281
+ id: generateId(childItem.type)
1282
+ })
1283
+ });
1284
+ }
1285
+ if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1286
+ return newItem;
1287
+ }
1288
+ const [sourceZoneParent] = action.sourceZone.split(":");
1289
+ if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1290
+ return childItem;
1291
+ }
1292
+ return null;
1293
+ }
1294
+ );
1295
+ return __spreadProps(__spreadValues({}, modified), {
1296
+ ui: __spreadProps(__spreadValues({}, modified.ui), {
1297
+ itemSelector: {
1298
+ index: action.sourceIndex + 1,
1299
+ zone: action.sourceZone
1300
+ }
1301
+ })
1302
+ });
1303
+ }
1304
+
1305
+ // reducer/actions/reorder.ts
1306
+ init_react_import();
1307
+
1308
+ // reducer/actions/move.ts
1309
+ init_react_import();
1310
+
1311
+ // lib/data/remove.ts
1312
+ init_react_import();
1313
+ var remove = (list, index) => {
1314
+ const result = Array.from(list);
1315
+ result.splice(index, 1);
1316
+ return result;
1317
+ };
1318
+
1319
+ // reducer/actions/move.ts
1126
1320
  var moveAction = (state, action, appStore) => {
1127
1321
  if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
1128
1322
  return state;
@@ -1134,7 +1328,7 @@ var moveAction = (state, action, appStore) => {
1134
1328
  if (!item) return state;
1135
1329
  const idsInSourcePath = getIdsForParent(action.sourceZone, state);
1136
1330
  const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
1137
- return walkTree(
1331
+ return walkAppState(
1138
1332
  state,
1139
1333
  appStore.config,
1140
1334
  (content, zoneCompound) => {
@@ -1159,225 +1353,164 @@ var moveAction = (state, action, appStore) => {
1159
1353
  return childItem;
1160
1354
  }
1161
1355
  return null;
1162
- }
1163
- );
1164
- };
1165
- var replaceAction = (state, action, appStore) => {
1166
- const [parentId] = action.destinationZone.split(":");
1167
- const idsInPath = getIdsForParent(action.destinationZone, state);
1168
- return walkTree(
1169
- state,
1170
- appStore.config,
1171
- (content) => content,
1172
- (childItem, path) => {
1173
- const pathIds = path.map((p) => p.split(":")[0]);
1174
- if (childItem.props.id === action.data.props.id) {
1175
- return action.data;
1176
- } else if (childItem.props.id === parentId) {
1177
- return childItem;
1178
- } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1179
- return childItem;
1180
- } else if (pathIds.indexOf(action.data.props.id) > -1) {
1181
- return childItem;
1182
- }
1183
- return null;
1184
- }
1185
- );
1186
- };
1187
- var setAction = (state, action, appStore) => {
1188
- if (typeof action.state === "object") {
1189
- const newState = __spreadValues(__spreadValues({}, state), action.state);
1190
- if (action.state.indexes) {
1191
- console.warn(
1192
- "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1193
- );
1194
- return newState;
1195
- }
1196
- return walkTree(newState, appStore.config);
1197
- }
1198
- return __spreadValues(__spreadValues({}, state), action.state(state));
1199
- };
1200
- function reduce(state, action, appStore) {
1201
- if (action.type === "set") {
1202
- return setAction(state, action, appStore);
1203
- }
1204
- if (action.type === "insert") {
1205
- return insertAction(state, action, appStore.config);
1206
- }
1207
- if (action.type === "replace") {
1208
- return replaceAction(state, action, appStore);
1209
- }
1210
- if (action.type === "replaceRoot") {
1211
- return walkTree(
1212
- state,
1213
- appStore.config,
1214
- (content) => content,
1215
- (childItem) => {
1216
- if (childItem.props.id === "root") {
1217
- return __spreadProps(__spreadValues({}, childItem), {
1218
- props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1219
- readOnly: action.root.readOnly
1220
- });
1221
- }
1222
- return childItem;
1223
- }
1224
- );
1225
- }
1226
- if (action.type === "duplicate") {
1227
- const item = getItem(
1228
- { index: action.sourceIndex, zone: action.sourceZone },
1229
- state
1230
- );
1231
- const idsInPath = getIdsForParent(action.sourceZone, state);
1232
- const newItem = __spreadProps(__spreadValues({}, item), {
1233
- props: __spreadProps(__spreadValues({}, item.props), {
1234
- id: generateId(item.type)
1235
- })
1236
- });
1237
- const modified = walkTree(
1238
- state,
1239
- appStore.config,
1240
- (content, zoneCompound) => {
1241
- if (zoneCompound === action.sourceZone) {
1242
- return insert(content, action.sourceIndex + 1, item);
1243
- }
1244
- return content;
1245
- },
1246
- (childItem, path, index) => {
1247
- const zoneCompound = path[path.length - 1];
1248
- const parents = path.map((p) => p.split(":")[0]);
1249
- if (parents.indexOf(newItem.props.id) > -1) {
1250
- return __spreadProps(__spreadValues({}, childItem), {
1251
- props: __spreadProps(__spreadValues({}, childItem.props), {
1252
- id: generateId(childItem.type)
1253
- })
1254
- });
1255
- }
1256
- if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1257
- return newItem;
1258
- }
1259
- const [sourceZoneParent] = action.sourceZone.split(":");
1260
- if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1261
- return childItem;
1262
- }
1263
- return null;
1356
+ }
1357
+ );
1358
+ };
1359
+
1360
+ // reducer/actions/reorder.ts
1361
+ var reorderAction = (state, action, appStore) => {
1362
+ return moveAction(
1363
+ state,
1364
+ {
1365
+ type: "move",
1366
+ sourceIndex: action.sourceIndex,
1367
+ sourceZone: action.destinationZone,
1368
+ destinationIndex: action.destinationIndex,
1369
+ destinationZone: action.destinationZone
1370
+ },
1371
+ appStore
1372
+ );
1373
+ };
1374
+
1375
+ // reducer/actions/remove.ts
1376
+ init_react_import();
1377
+ var removeAction = (state, action, appStore) => {
1378
+ const item = getItem({ index: action.index, zone: action.zone }, state);
1379
+ const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
1380
+ (acc, [nodeId, nodeData]) => {
1381
+ const pathIds = nodeData.path.map((p) => p.split(":")[0]);
1382
+ if (pathIds.includes(item.props.id)) {
1383
+ return [...acc, nodeId];
1264
1384
  }
1265
- );
1266
- return __spreadProps(__spreadValues({}, modified), {
1267
- ui: __spreadProps(__spreadValues({}, modified.ui), {
1268
- itemSelector: {
1269
- index: action.sourceIndex + 1,
1270
- zone: action.sourceZone
1271
- }
1272
- })
1273
- });
1274
- }
1275
- if (action.type === "reorder") {
1276
- return moveAction(
1277
- state,
1278
- {
1279
- type: "move",
1280
- sourceIndex: action.sourceIndex,
1281
- sourceZone: action.destinationZone,
1282
- destinationIndex: action.destinationIndex,
1283
- destinationZone: action.destinationZone
1284
- },
1285
- appStore
1286
- );
1287
- }
1288
- if (action.type === "move") {
1289
- return moveAction(state, action, appStore);
1290
- }
1291
- if (action.type === "remove") {
1292
- const item = getItem({ index: action.index, zone: action.zone }, state);
1293
- let deindexed = deindex(state, item);
1294
- const [parentId] = action.zone.split(":");
1295
- return walkTree(
1296
- __spreadProps(__spreadValues({}, state), { indexes: deindexed }),
1297
- appStore.config,
1298
- (content, zoneCompound) => {
1299
- if (zoneCompound === action.zone) {
1300
- return remove(content, action.index);
1301
- }
1302
- return content;
1303
- },
1304
- (childItem, path) => {
1305
- const parentIds = path.map((p) => p.split(":")[0]);
1306
- if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
1307
- return childItem;
1308
- }
1309
- return null;
1385
+ return acc;
1386
+ },
1387
+ [item.props.id]
1388
+ );
1389
+ const newState = walkAppState(
1390
+ state,
1391
+ appStore.config,
1392
+ (content, zoneCompound) => {
1393
+ if (zoneCompound === action.zone) {
1394
+ return remove(content, action.index);
1310
1395
  }
1311
- );
1312
- }
1313
- if (action.type === "registerZone") {
1314
- if (zoneCache[action.zone]) {
1315
- return __spreadProps(__spreadValues({}, state), {
1316
- data: __spreadProps(__spreadValues({}, state.data), {
1317
- zones: __spreadProps(__spreadValues({}, state.data.zones), {
1318
- [action.zone]: zoneCache[action.zone]
1319
- })
1320
- }),
1321
- indexes: __spreadProps(__spreadValues({}, state.indexes), {
1322
- zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
1323
- [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
1324
- contentIds: zoneCache[action.zone].map((item) => item.props.id),
1325
- type: "dropzone"
1326
- })
1327
- })
1328
- })
1329
- });
1396
+ return content;
1397
+ }
1398
+ );
1399
+ Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
1400
+ const parentId = zoneCompound.split(":")[0];
1401
+ if (nodesToDelete.includes(parentId) && newState.data.zones) {
1402
+ delete newState.data.zones[zoneCompound];
1403
+ }
1404
+ });
1405
+ Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
1406
+ const parentId = zoneCompound.split(":")[0];
1407
+ if (nodesToDelete.includes(parentId)) {
1408
+ delete newState.indexes.zones[zoneCompound];
1330
1409
  }
1331
- return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
1410
+ });
1411
+ nodesToDelete.forEach((id) => {
1412
+ delete newState.indexes.nodes[id];
1413
+ });
1414
+ return newState;
1415
+ };
1416
+
1417
+ // reducer/actions/register-zone.ts
1418
+ init_react_import();
1419
+
1420
+ // lib/data/setup-zone.ts
1421
+ init_react_import();
1422
+ var setupZone = (data, zoneKey) => {
1423
+ if (zoneKey === rootDroppableId) {
1424
+ return data;
1332
1425
  }
1333
- if (action.type === "unregisterZone") {
1334
- const _zones = __spreadValues({}, state.data.zones || {});
1335
- const zoneIndex = __spreadValues({}, state.indexes.zones || {});
1336
- if (_zones[action.zone]) {
1337
- zoneCache[action.zone] = _zones[action.zone];
1338
- delete _zones[action.zone];
1339
- }
1340
- delete zoneIndex[action.zone];
1426
+ const newData = __spreadProps(__spreadValues({}, data), {
1427
+ zones: data.zones ? __spreadValues({}, data.zones) : {}
1428
+ });
1429
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1430
+ return newData;
1431
+ };
1432
+
1433
+ // reducer/actions/register-zone.ts
1434
+ var zoneCache = {};
1435
+ function registerZoneAction(state, action) {
1436
+ if (zoneCache[action.zone]) {
1341
1437
  return __spreadProps(__spreadValues({}, state), {
1342
1438
  data: __spreadProps(__spreadValues({}, state.data), {
1343
- zones: _zones
1439
+ zones: __spreadProps(__spreadValues({}, state.data.zones), {
1440
+ [action.zone]: zoneCache[action.zone]
1441
+ })
1344
1442
  }),
1345
1443
  indexes: __spreadProps(__spreadValues({}, state.indexes), {
1346
- zones: zoneIndex
1444
+ zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
1445
+ [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
1446
+ contentIds: zoneCache[action.zone].map((item) => item.props.id),
1447
+ type: "dropzone"
1448
+ })
1449
+ })
1347
1450
  })
1348
1451
  });
1349
1452
  }
1350
- if (action.type === "setData") {
1351
- if (typeof action.data === "object") {
1352
- console.warn(
1353
- "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1354
- );
1355
- return walkTree(
1356
- __spreadProps(__spreadValues({}, state), {
1357
- data: __spreadValues(__spreadValues({}, state.data), action.data)
1358
- }),
1359
- appStore.config
1360
- );
1361
- }
1362
- return walkTree(
1453
+ return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
1454
+ }
1455
+ function unregisterZoneAction(state, action) {
1456
+ const _zones = __spreadValues({}, state.data.zones || {});
1457
+ const zoneIndex = __spreadValues({}, state.indexes.zones || {});
1458
+ if (_zones[action.zone]) {
1459
+ zoneCache[action.zone] = _zones[action.zone];
1460
+ delete _zones[action.zone];
1461
+ }
1462
+ delete zoneIndex[action.zone];
1463
+ return __spreadProps(__spreadValues({}, state), {
1464
+ data: __spreadProps(__spreadValues({}, state.data), {
1465
+ zones: _zones
1466
+ }),
1467
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
1468
+ zones: zoneIndex
1469
+ })
1470
+ });
1471
+ }
1472
+
1473
+ // reducer/actions/set-data.ts
1474
+ init_react_import();
1475
+ var setDataAction = (state, action, appStore) => {
1476
+ if (typeof action.data === "object") {
1477
+ console.warn(
1478
+ "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1479
+ );
1480
+ return walkAppState(
1363
1481
  __spreadProps(__spreadValues({}, state), {
1364
- data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
1482
+ data: __spreadValues(__spreadValues({}, state.data), action.data)
1365
1483
  }),
1366
1484
  appStore.config
1367
1485
  );
1368
1486
  }
1369
- if (action.type === "setUi") {
1370
- if (typeof action.ui === "object") {
1371
- return __spreadProps(__spreadValues({}, state), {
1372
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
1373
- });
1374
- }
1487
+ return walkAppState(
1488
+ __spreadProps(__spreadValues({}, state), {
1489
+ data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
1490
+ }),
1491
+ appStore.config
1492
+ );
1493
+ };
1494
+
1495
+ // reducer/actions/set-ui.ts
1496
+ init_react_import();
1497
+ var setUiAction = (state, action) => {
1498
+ if (typeof action.ui === "object") {
1375
1499
  return __spreadProps(__spreadValues({}, state), {
1376
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
1500
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
1377
1501
  });
1378
1502
  }
1379
- return state;
1380
- }
1503
+ return __spreadProps(__spreadValues({}, state), {
1504
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
1505
+ });
1506
+ };
1507
+
1508
+ // lib/data/make-state-public.ts
1509
+ init_react_import();
1510
+ var makeStatePublic = (state) => {
1511
+ const { data, ui } = state;
1512
+ return { data, ui };
1513
+ };
1381
1514
 
1382
1515
  // reducer/actions.tsx
1383
1516
  init_react_import();
@@ -1396,7 +1529,7 @@ function storeInterceptor(reducer, record, onAction) {
1396
1529
  if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
1397
1530
  if (record) record(newAppState);
1398
1531
  }
1399
- onAction == null ? void 0 : onAction(action, newAppState, state);
1532
+ onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
1400
1533
  return newAppState;
1401
1534
  };
1402
1535
  }
@@ -1407,8 +1540,43 @@ function createReducer({
1407
1540
  }) {
1408
1541
  return storeInterceptor(
1409
1542
  (state, action) => {
1410
- const result = reduce(state, action, appStore);
1411
- return result;
1543
+ if (action.type === "set") {
1544
+ return setAction(state, action, appStore);
1545
+ }
1546
+ if (action.type === "insert") {
1547
+ return insertAction(state, action, appStore);
1548
+ }
1549
+ if (action.type === "replace") {
1550
+ return replaceAction(state, action, appStore);
1551
+ }
1552
+ if (action.type === "replaceRoot") {
1553
+ return replaceRootAction(state, action, appStore);
1554
+ }
1555
+ if (action.type === "duplicate") {
1556
+ return duplicateAction(state, action, appStore);
1557
+ }
1558
+ if (action.type === "reorder") {
1559
+ return reorderAction(state, action, appStore);
1560
+ }
1561
+ if (action.type === "move") {
1562
+ return moveAction(state, action, appStore);
1563
+ }
1564
+ if (action.type === "remove") {
1565
+ return removeAction(state, action, appStore);
1566
+ }
1567
+ if (action.type === "registerZone") {
1568
+ return registerZoneAction(state, action);
1569
+ }
1570
+ if (action.type === "unregisterZone") {
1571
+ return unregisterZoneAction(state, action);
1572
+ }
1573
+ if (action.type === "setData") {
1574
+ return setDataAction(state, action, appStore);
1575
+ }
1576
+ if (action.type === "setUi") {
1577
+ return setUiAction(state, action);
1578
+ }
1579
+ return state;
1412
1580
  },
1413
1581
  record,
1414
1582
  onAction
@@ -1620,7 +1788,7 @@ var createHistorySlice = (set, get) => {
1620
1788
  const { dispatch, history } = get();
1621
1789
  dispatch({
1622
1790
  type: "set",
1623
- state: ((_a = history.histories[history.index]) == null ? void 0 : _a.state) || history.initialAppState
1791
+ state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
1624
1792
  });
1625
1793
  set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1626
1794
  },
@@ -1697,11 +1865,11 @@ var createNodesSlice = (set, get) => ({
1697
1865
  init_react_import();
1698
1866
  var import_react7 = require("react");
1699
1867
 
1700
- // lib/flatten-data.ts
1868
+ // lib/data/flatten-data.ts
1701
1869
  init_react_import();
1702
1870
  var flattenData = (state, config) => {
1703
1871
  const data = [];
1704
- walkTree(
1872
+ walkAppState(
1705
1873
  state,
1706
1874
  config,
1707
1875
  (content) => content,
@@ -1732,12 +1900,7 @@ var createPermissionsSlice = (set, get) => {
1732
1900
  const { cache: cache2, globalPermissions } = permissions;
1733
1901
  const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1734
1902
  var _a, _b, _c;
1735
- const {
1736
- config: config2,
1737
- state: appState,
1738
- setComponentLoading,
1739
- unsetComponentLoading
1740
- } = get();
1903
+ const { config: config2, state: appState, setComponentLoading } = get();
1741
1904
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1742
1905
  if (!componentConfig) {
1743
1906
  return;
@@ -1746,14 +1909,14 @@ var createPermissionsSlice = (set, get) => {
1746
1909
  if (componentConfig.resolvePermissions) {
1747
1910
  const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
1748
1911
  if (Object.values(changed).some((el) => el === true) || force2) {
1749
- setComponentLoading(item2.props.id);
1912
+ const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
1750
1913
  const resolvedPermissions = yield componentConfig.resolvePermissions(
1751
1914
  item2,
1752
1915
  {
1753
1916
  changed,
1754
1917
  lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
1755
1918
  permissions: initialPermissions,
1756
- appState,
1919
+ appState: makeStatePublic(appState),
1757
1920
  lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
1758
1921
  }
1759
1922
  );
@@ -1771,7 +1934,7 @@ var createPermissionsSlice = (set, get) => {
1771
1934
  })
1772
1935
  })
1773
1936
  });
1774
- unsetComponentLoading(item2.props.id);
1937
+ clearTimeout2();
1775
1938
  }
1776
1939
  }
1777
1940
  });
@@ -1781,7 +1944,7 @@ var createPermissionsSlice = (set, get) => {
1781
1944
  // Shim the root data in by conforming to component data shape
1782
1945
  {
1783
1946
  type: "root",
1784
- props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "puck-root" })
1947
+ props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
1785
1948
  },
1786
1949
  force2
1787
1950
  );
@@ -1796,7 +1959,6 @@ var createPermissionsSlice = (set, get) => {
1796
1959
  } else if (root) {
1797
1960
  resolveDataForRoot(force);
1798
1961
  } else {
1799
- resolveDataForRoot(force);
1800
1962
  flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1801
1963
  yield resolveDataForItem(item2, force);
1802
1964
  }));
@@ -1827,7 +1989,7 @@ var createPermissionsSlice = (set, get) => {
1827
1989
  } else if (root) {
1828
1990
  const rootConfig = config.root;
1829
1991
  const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
1830
- const resolvedForItem = resolvedPermissions["puck-root"];
1992
+ const resolvedForItem = resolvedPermissions["root"];
1831
1993
  return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1832
1994
  }
1833
1995
  return globalPermissions;
@@ -1872,7 +2034,8 @@ var createFieldsSlice = (_set, _get) => {
1872
2034
  return {
1873
2035
  fields: {},
1874
2036
  loading: false,
1875
- lastResolvedData: {}
2037
+ lastResolvedData: {},
2038
+ id: void 0
1876
2039
  };
1877
2040
  };
1878
2041
  var useRegisterFieldsSlice = (appStore, id) => {
@@ -1893,7 +2056,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
1893
2056
  let lastFields = fields;
1894
2057
  if (reset) {
1895
2058
  appStore.setState((s) => ({
1896
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2059
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1897
2060
  }));
1898
2061
  lastFields = defaultFields;
1899
2062
  }
@@ -1910,7 +2073,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
1910
2073
  fields: defaultFields,
1911
2074
  lastFields,
1912
2075
  lastData,
1913
- appState: state,
2076
+ appState: makeStatePublic(state),
1914
2077
  parent
1915
2078
  });
1916
2079
  clearTimeout(timeout3);
@@ -1921,12 +2084,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
1921
2084
  fields: {
1922
2085
  fields: newFields,
1923
2086
  loading: false,
1924
- lastResolvedData: componentData
2087
+ lastResolvedData: componentData,
2088
+ id
1925
2089
  }
1926
2090
  });
1927
2091
  } else {
1928
2092
  appStore.setState((s) => ({
1929
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2093
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1930
2094
  }));
1931
2095
  }
1932
2096
  }),
@@ -1943,39 +2107,15 @@ var useRegisterFieldsSlice = (appStore, id) => {
1943
2107
 
1944
2108
  // lib/resolve-component-data.ts
1945
2109
  init_react_import();
1946
-
1947
- // lib/map-slots.ts
1948
- init_react_import();
1949
- function mapSlots(item, map, recursive = true, isSlot2) {
1950
- return __async(this, null, function* () {
1951
- const props = __spreadValues({}, item.props);
1952
- yield forEachSlot(
1953
- item,
1954
- (_parentId, propName, content) => __async(this, null, function* () {
1955
- const mappedContent = recursive ? yield Promise.all(
1956
- content.map((item2) => __async(this, null, function* () {
1957
- return yield mapSlots(item2, map, recursive, isSlot2);
1958
- }))
1959
- ) : content;
1960
- props[propName] = yield map(mappedContent, propName);
1961
- }),
1962
- false,
1963
- isSlot2
1964
- );
1965
- return __spreadProps(__spreadValues({}, item), { props });
1966
- });
1967
- }
1968
-
1969
- // lib/resolve-component-data.ts
1970
2110
  var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1971
2111
  var cache = { lastChange: {} };
1972
2112
  var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
1973
- const configForItem = "type" in item ? config.components[item.type] : config.root;
2113
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1974
2114
  if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
1975
2115
  const id = "id" in item.props ? item.props.id : "root";
1976
2116
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1977
- if (item && item === oldItem) {
1978
- return resolved;
2117
+ if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
2118
+ return { node: resolved, didChange: false };
1979
2119
  }
1980
2120
  const changed = getChanged(item, oldItem);
1981
2121
  if (onResolveStart) {
@@ -1984,30 +2124,35 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
1984
2124
  const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1985
2125
  changed,
1986
2126
  lastData: oldItem,
1987
- metadata,
2127
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1988
2128
  trigger
1989
2129
  });
1990
2130
  let resolvedItem = __spreadProps(__spreadValues({}, item), {
1991
2131
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
1992
2132
  });
1993
2133
  if (recursive) {
1994
- resolvedItem = yield mapSlots(resolvedItem, (content) => __async(void 0, null, function* () {
1995
- return Promise.all(
1996
- content.map(
1997
- (childItem) => __async(void 0, null, function* () {
1998
- return (yield resolveComponentData(
1999
- childItem,
2000
- config,
2001
- metadata,
2002
- onResolveStart,
2003
- onResolveEnd,
2004
- trigger,
2005
- false
2006
- )).node;
2007
- })
2008
- )
2009
- );
2010
- }));
2134
+ resolvedItem = yield mapSlotsAsync(
2135
+ resolvedItem,
2136
+ (content) => __async(void 0, null, function* () {
2137
+ return Promise.all(
2138
+ content.map(
2139
+ (childItem) => __async(void 0, null, function* () {
2140
+ return (yield resolveComponentData(
2141
+ childItem,
2142
+ config,
2143
+ metadata,
2144
+ onResolveStart,
2145
+ onResolveEnd,
2146
+ trigger,
2147
+ false
2148
+ )).node;
2149
+ })
2150
+ )
2151
+ );
2152
+ }),
2153
+ false,
2154
+ createIsSlotConfig(config)
2155
+ );
2011
2156
  }
2012
2157
  if (Object.keys(readOnly).length) {
2013
2158
  resolvedItem.readOnly = readOnly;
@@ -2024,7 +2169,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2024
2169
  return { node: item, didChange: false };
2025
2170
  });
2026
2171
 
2027
- // lib/to-root.ts
2172
+ // lib/data/to-root.ts
2028
2173
  init_react_import();
2029
2174
  var toRoot = (item) => {
2030
2175
  if ("type" in item && item.type !== "root") {
@@ -2071,172 +2216,176 @@ var defaultPageFields = {
2071
2216
  title: { type: "text" }
2072
2217
  };
2073
2218
  var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
2074
- (0, import_middleware2.subscribeWithSelector)((set, get) => __spreadProps(__spreadValues({
2075
- state: defaultAppState,
2076
- config: { components: {} },
2077
- componentState: {},
2078
- plugins: [],
2079
- overrides: {},
2080
- viewports: defaultViewports,
2081
- zoomConfig: {
2082
- autoZoom: 1,
2083
- rootHeight: 0,
2084
- zoom: 1
2085
- },
2086
- status: "LOADING",
2087
- iframe: {},
2088
- metadata: {}
2089
- }, initialAppStore), {
2090
- fields: createFieldsSlice(set, get),
2091
- history: createHistorySlice(set, get),
2092
- nodes: createNodesSlice(set, get),
2093
- permissions: createPermissionsSlice(set, get),
2094
- getComponentConfig: (type) => {
2095
- var _a;
2096
- const { config, selectedItem } = get();
2097
- const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
2098
- return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
2099
- },
2100
- dispatch: (action) => set((s) => {
2101
- var _a, _b;
2102
- const { record } = get().history;
2103
- const dispatch = createReducer({
2104
- record,
2105
- appStore: s
2106
- });
2107
- const state = dispatch(s.state, action);
2108
- const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2109
- (_b = (_a = get()).onAction) == null ? void 0 : _b.call(_a, action, state, get().state);
2110
- return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2111
- }),
2112
- setZoomConfig: (zoomConfig) => set({ zoomConfig }),
2113
- setStatus: (status) => set({ status }),
2114
- setComponentState: (componentState) => set({ componentState }),
2115
- pendingComponentLoads: {},
2116
- setComponentLoading: (id, loading = true, defer2 = 0) => {
2117
- const { setComponentState, pendingComponentLoads } = get();
2118
- const thisPendingComponentLoads = __spreadValues({}, pendingComponentLoads);
2119
- const setLoading = () => {
2120
- var _a;
2121
- const { componentState } = get();
2122
- setComponentState(__spreadProps(__spreadValues({}, componentState), {
2123
- [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2124
- loadingCount: (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) + 1
2125
- })
2126
- }));
2127
- };
2128
- const unsetLoading = () => {
2129
- var _a;
2130
- const { componentState } = get();
2131
- setComponentState(__spreadProps(__spreadValues({}, componentState), {
2132
- [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2133
- loadingCount: Math.max(
2134
- (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) - 1,
2135
- 0
2136
- )
2219
+ (0, import_middleware2.subscribeWithSelector)((set, get) => {
2220
+ var _a, _b;
2221
+ return __spreadProps(__spreadValues({
2222
+ state: defaultAppState,
2223
+ config: { components: {} },
2224
+ componentState: {},
2225
+ plugins: [],
2226
+ overrides: {},
2227
+ viewports: defaultViewports,
2228
+ zoomConfig: {
2229
+ autoZoom: 1,
2230
+ rootHeight: 0,
2231
+ zoom: 1
2232
+ },
2233
+ status: "LOADING",
2234
+ iframe: {},
2235
+ metadata: {}
2236
+ }, initialAppStore), {
2237
+ fields: createFieldsSlice(set, get),
2238
+ history: createHistorySlice(set, get),
2239
+ nodes: createNodesSlice(set, get),
2240
+ permissions: createPermissionsSlice(set, get),
2241
+ getComponentConfig: (type) => {
2242
+ var _a2;
2243
+ const { config, selectedItem } = get();
2244
+ const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
2245
+ return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
2246
+ },
2247
+ selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
2248
+ (_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
2249
+ initialAppStore.state
2250
+ ) : null,
2251
+ dispatch: (action) => set((s) => {
2252
+ var _a2, _b2;
2253
+ const { record } = get().history;
2254
+ const dispatch = createReducer({
2255
+ record,
2256
+ appStore: s
2257
+ });
2258
+ const state = dispatch(s.state, action);
2259
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2260
+ (_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
2261
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2262
+ }),
2263
+ setZoomConfig: (zoomConfig) => set({ zoomConfig }),
2264
+ setStatus: (status) => set({ status }),
2265
+ setComponentState: (componentState) => set({ componentState }),
2266
+ pendingLoadTimeouts: {},
2267
+ setComponentLoading: (id, loading = true, defer2 = 0) => {
2268
+ const { setComponentState, pendingLoadTimeouts } = get();
2269
+ const loadId = generateId();
2270
+ const setLoading = () => {
2271
+ var _a2;
2272
+ const { componentState } = get();
2273
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
2274
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2275
+ loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
2276
+ })
2277
+ }));
2278
+ };
2279
+ const unsetLoading = () => {
2280
+ var _a2;
2281
+ const { componentState } = get();
2282
+ clearTimeout(timeout3);
2283
+ delete pendingLoadTimeouts[loadId];
2284
+ set({ pendingLoadTimeouts });
2285
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
2286
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2287
+ loadingCount: Math.max(
2288
+ (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
2289
+ 0
2290
+ )
2291
+ })
2292
+ }));
2293
+ };
2294
+ const timeout3 = setTimeout(() => {
2295
+ if (loading) {
2296
+ setLoading();
2297
+ } else {
2298
+ unsetLoading();
2299
+ }
2300
+ delete pendingLoadTimeouts[loadId];
2301
+ set({ pendingLoadTimeouts });
2302
+ }, defer2);
2303
+ set({
2304
+ pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
2305
+ [id]: timeout3
2137
2306
  })
2138
- }));
2139
- };
2140
- if (thisPendingComponentLoads[id]) {
2141
- clearTimeout(thisPendingComponentLoads[id]);
2142
- delete thisPendingComponentLoads[id];
2143
- set({ pendingComponentLoads: thisPendingComponentLoads });
2144
- }
2145
- const timeout3 = setTimeout(() => {
2146
- if (loading) {
2147
- setLoading();
2148
- } else {
2149
- unsetLoading();
2150
- }
2151
- delete thisPendingComponentLoads[id];
2152
- set({ pendingComponentLoads: thisPendingComponentLoads });
2153
- }, defer2);
2154
- set({
2155
- pendingComponentLoads: __spreadProps(__spreadValues({}, thisPendingComponentLoads), {
2156
- [id]: timeout3
2157
- })
2158
- });
2159
- },
2160
- unsetComponentLoading: (id) => {
2161
- const { setComponentLoading } = get();
2162
- setComponentLoading(id, false);
2163
- },
2164
- // Helper
2165
- setUi: (ui, recordHistory) => set((s) => {
2166
- const dispatch = createReducer({
2167
- record: () => {
2168
- },
2169
- appStore: s
2170
- });
2171
- const state = dispatch(s.state, {
2172
- type: "setUi",
2173
- ui,
2174
- recordHistory
2175
- });
2176
- const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2177
- return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2178
- }),
2179
- // resolveDataRuns: 0,
2180
- // resolveData: (newAppState) =>
2181
- // set((s) => {
2182
- // resolveData(newAppState, get);
2183
- // return { ...s, resolveDataRuns: s.resolveDataRuns + 1 };
2184
- // }),
2185
- resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
2186
- const { config, metadata, setComponentLoading } = get();
2187
- return yield resolveComponentData(
2188
- componentData,
2189
- config,
2190
- metadata,
2191
- (item) => setComponentLoading(
2192
- "id" in item.props ? item.props.id : "root",
2193
- true,
2194
- 50
2195
- ),
2196
- (item) => setComponentLoading(
2197
- "id" in item.props ? item.props.id : "root",
2198
- false,
2199
- 0
2200
- ),
2201
- trigger
2202
- );
2203
- }),
2204
- resolveAndCommitData: () => __async(void 0, null, function* () {
2205
- const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
2206
- walkTree(
2207
- state,
2208
- config,
2209
- (content) => content,
2210
- (childItem) => {
2211
- resolveComponentData2(childItem, "load").then((resolved) => {
2212
- const { state: state2 } = get();
2213
- const node = state2.indexes.nodes[resolved.node.props.id];
2214
- if (node && resolved.didChange) {
2215
- if (resolved.node.props.id === "root") {
2216
- dispatch({
2217
- type: "replaceRoot",
2218
- root: toRoot(resolved.node)
2219
- });
2220
- } else {
2221
- const zoneCompound = `${node.parentId}:${node.zone}`;
2222
- const parentZone = state2.indexes.zones[zoneCompound];
2223
- const index = parentZone.contentIds.indexOf(
2224
- resolved.node.props.id
2225
- );
2226
- dispatch({
2227
- type: "replace",
2228
- data: resolved.node,
2229
- destinationIndex: index,
2230
- destinationZone: zoneCompound
2231
- });
2232
- }
2307
+ });
2308
+ return unsetLoading;
2309
+ },
2310
+ unsetComponentLoading: (id) => {
2311
+ const { setComponentLoading } = get();
2312
+ setComponentLoading(id, false);
2313
+ },
2314
+ // Helper
2315
+ setUi: (ui, recordHistory) => set((s) => {
2316
+ const dispatch = createReducer({
2317
+ record: () => {
2318
+ },
2319
+ appStore: s
2320
+ });
2321
+ const state = dispatch(s.state, {
2322
+ type: "setUi",
2323
+ ui,
2324
+ recordHistory
2325
+ });
2326
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2327
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2328
+ }),
2329
+ resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
2330
+ const { config, metadata, setComponentLoading, permissions } = get();
2331
+ const timeouts = {};
2332
+ return yield resolveComponentData(
2333
+ componentData,
2334
+ config,
2335
+ metadata,
2336
+ (item) => {
2337
+ const id = "id" in item.props ? item.props.id : "root";
2338
+ timeouts[id] = setComponentLoading(id, true, 50);
2339
+ },
2340
+ (item) => __async(void 0, null, function* () {
2341
+ const id = "id" in item.props ? item.props.id : "root";
2342
+ if ("type" in item) {
2343
+ yield permissions.refreshPermissions({ item });
2344
+ } else {
2345
+ yield permissions.refreshPermissions({ root: true });
2233
2346
  }
2234
- });
2235
- return childItem;
2236
- }
2237
- );
2238
- })
2239
- }))
2347
+ timeouts[id]();
2348
+ }),
2349
+ trigger
2350
+ );
2351
+ }),
2352
+ resolveAndCommitData: () => __async(void 0, null, function* () {
2353
+ const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
2354
+ walkAppState(
2355
+ state,
2356
+ config,
2357
+ (content) => content,
2358
+ (childItem) => {
2359
+ resolveComponentData2(childItem, "load").then((resolved) => {
2360
+ const { state: state2 } = get();
2361
+ const node = state2.indexes.nodes[resolved.node.props.id];
2362
+ if (node && resolved.didChange) {
2363
+ if (resolved.node.props.id === "root") {
2364
+ dispatch({
2365
+ type: "replaceRoot",
2366
+ root: toRoot(resolved.node)
2367
+ });
2368
+ } else {
2369
+ const zoneCompound = `${node.parentId}:${node.zone}`;
2370
+ const parentZone = state2.indexes.zones[zoneCompound];
2371
+ const index = parentZone.contentIds.indexOf(
2372
+ resolved.node.props.id
2373
+ );
2374
+ dispatch({
2375
+ type: "replace",
2376
+ data: resolved.node,
2377
+ destinationIndex: index,
2378
+ destinationZone: zoneCompound
2379
+ });
2380
+ }
2381
+ }
2382
+ });
2383
+ return childItem;
2384
+ }
2385
+ );
2386
+ })
2387
+ });
2388
+ })
2240
2389
  );
2241
2390
  var appStoreContext = (0, import_react9.createContext)(createAppStore());
2242
2391
  function useAppStore(selector) {
@@ -4310,7 +4459,7 @@ init_react_import();
4310
4459
 
4311
4460
  // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
4312
4461
  init_react_import();
4313
- 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" };
4462
+ 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" };
4314
4463
 
4315
4464
  // components/Drawer/index.tsx
4316
4465
  var import_react37 = require("react");
@@ -4331,7 +4480,7 @@ var import_react25 = require("react");
4331
4480
 
4332
4481
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4333
4482
  init_react_import();
4334
- 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" };
4483
+ 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" };
4335
4484
 
4336
4485
  // components/DraggableComponent/index.tsx
4337
4486
  var import_react_dom2 = require("react-dom");
@@ -4382,7 +4531,6 @@ var DropZoneProvider = ({
4382
4531
  value
4383
4532
  }) => {
4384
4533
  const [hoveringComponent, setHoveringComponent] = (0, import_react23.useState)();
4385
- const [activeZones, setActiveZones] = (0, import_react23.useState)({});
4386
4534
  const dispatch = useAppStore((s) => s.dispatch);
4387
4535
  const registerZone = (0, import_react23.useCallback)(
4388
4536
  (zoneCompound) => {
@@ -4391,7 +4539,7 @@ var DropZoneProvider = ({
4391
4539
  zone: zoneCompound
4392
4540
  });
4393
4541
  },
4394
- [setActiveZones, dispatch]
4542
+ [dispatch]
4395
4543
  );
4396
4544
  const unregisterZone = (0, import_react23.useCallback)(
4397
4545
  (zoneCompound) => {
@@ -4400,17 +4548,16 @@ var DropZoneProvider = ({
4400
4548
  zone: zoneCompound
4401
4549
  });
4402
4550
  },
4403
- [setActiveZones, dispatch]
4551
+ [dispatch]
4404
4552
  );
4405
4553
  const memoValue = (0, import_react23.useMemo)(
4406
4554
  () => __spreadValues({
4407
4555
  hoveringComponent,
4408
4556
  setHoveringComponent,
4409
4557
  registerZone,
4410
- unregisterZone,
4411
- activeZones
4558
+ unregisterZone
4412
4559
  }, value),
4413
- [value, hoveringComponent, activeZones]
4560
+ [value, hoveringComponent]
4414
4561
  );
4415
4562
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4416
4563
  };
@@ -4503,8 +4650,10 @@ var DraggableComponent = ({
4503
4650
  return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
4504
4651
  }));
4505
4652
  const permissions = useAppStore(
4506
- (0, import_shallow2.useShallow)((s) => s.permissions.getPermissions())
4507
- // TODO call using id
4653
+ (0, import_shallow2.useShallow)((s) => {
4654
+ const item = getItem({ index, zone: zoneCompound }, s.state);
4655
+ return s.permissions.getPermissions({ item });
4656
+ })
4508
4657
  );
4509
4658
  const userIsDragging = useContextStore(
4510
4659
  ZoneStoreContext,
@@ -4758,76 +4907,82 @@ var DraggableComponent = ({
4758
4907
  setDragAxis(autoDragAxis);
4759
4908
  }, [ref, userDragAxis, autoDragAxis]);
4760
4909
  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 }) });
4761
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4762
- DropZoneProvider,
4763
- {
4764
- value: __spreadProps(__spreadValues({}, ctx), {
4765
- areaId: id,
4766
- zoneCompound,
4767
- index,
4768
- depth: depth + 1,
4769
- registerLocalZone,
4770
- unregisterLocalZone
4771
- }),
4772
- children: [
4773
- isVisible && (0, import_react_dom2.createPortal)(
4774
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4775
- "div",
4776
- {
4777
- className: getClassName16({
4778
- isSelected,
4779
- isDragging: thisIsDragging,
4780
- hover: hover || indicativeHover
4781
- }),
4782
- style: __spreadValues({}, style),
4783
- "data-puck-overlay": true,
4784
- children: [
4785
- debug,
4786
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
4787
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4910
+ const nextContextValue = (0, import_react25.useMemo)(
4911
+ () => __spreadProps(__spreadValues({}, ctx), {
4912
+ areaId: id,
4913
+ zoneCompound,
4914
+ index,
4915
+ depth: depth + 1,
4916
+ registerLocalZone,
4917
+ unregisterLocalZone
4918
+ }),
4919
+ [
4920
+ ctx,
4921
+ id,
4922
+ zoneCompound,
4923
+ index,
4924
+ depth,
4925
+ registerLocalZone,
4926
+ unregisterLocalZone
4927
+ ]
4928
+ );
4929
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
4930
+ isVisible && (0, import_react_dom2.createPortal)(
4931
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4932
+ "div",
4933
+ {
4934
+ className: getClassName16({
4935
+ isSelected,
4936
+ isDragging: thisIsDragging,
4937
+ hover: hover || indicativeHover
4938
+ }),
4939
+ style: __spreadValues({}, style),
4940
+ "data-puck-overlay": true,
4941
+ children: [
4942
+ debug,
4943
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
4944
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4945
+ "div",
4946
+ {
4947
+ className: getClassName16("actionsOverlay"),
4948
+ style: {
4949
+ top: actionsOverlayTop / zoom
4950
+ },
4951
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4788
4952
  "div",
4789
4953
  {
4790
- className: getClassName16("actionsOverlay"),
4954
+ className: getClassName16("actions"),
4791
4955
  style: {
4792
- top: actionsOverlayTop / zoom
4956
+ transform: `scale(${1 / zoom}`,
4957
+ top: actionsTop / zoom,
4958
+ right: 0,
4959
+ paddingLeft: actionsSide,
4960
+ paddingRight: actionsSide
4793
4961
  },
4794
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4795
- "div",
4962
+ ref: syncActionsPosition,
4963
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4964
+ CustomActionBar,
4796
4965
  {
4797
- className: getClassName16("actions"),
4798
- style: {
4799
- transform: `scale(${1 / zoom}`,
4800
- top: actionsTop / zoom,
4801
- right: 0,
4802
- paddingLeft: actionsSide,
4803
- paddingRight: actionsSide
4804
- },
4805
- ref: syncActionsPosition,
4806
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4807
- CustomActionBar,
4808
- {
4809
- parentAction,
4810
- label: DEBUG2 ? id : label,
4811
- children: [
4812
- permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
4813
- permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
4814
- ]
4815
- }
4816
- )
4966
+ parentAction,
4967
+ label: DEBUG2 ? id : label,
4968
+ children: [
4969
+ permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
4970
+ permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
4971
+ ]
4817
4972
  }
4818
4973
  )
4819
4974
  }
4820
- ),
4821
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
4822
- ]
4823
- }
4824
- ),
4825
- portalEl || document.body
4826
- ),
4827
- children(refSetter)
4828
- ]
4829
- }
4830
- );
4975
+ )
4976
+ }
4977
+ ),
4978
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
4979
+ ]
4980
+ }
4981
+ ),
4982
+ portalEl || document.body
4983
+ ),
4984
+ children(refSetter)
4985
+ ] });
4831
4986
  };
4832
4987
 
4833
4988
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
@@ -5013,26 +5168,33 @@ var import_shallow3 = require("zustand/react/shallow");
5013
5168
  // components/Render/index.tsx
5014
5169
  init_react_import();
5015
5170
 
5016
- // lib/use-slots.ts
5171
+ // lib/use-slots.tsx
5017
5172
  init_react_import();
5018
5173
  var import_react31 = require("react");
5019
- function useSlots(config, props, renderSlot) {
5020
- return (0, import_react31.useMemo)(() => {
5174
+ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5175
+ const slotProps = (0, import_react31.useMemo)(() => {
5021
5176
  if (!(config == null ? void 0 : config.fields)) return props;
5022
- const newProps = __spreadValues({}, props);
5177
+ const slotProps2 = {};
5023
5178
  const fieldKeys = Object.keys(config.fields);
5024
5179
  for (let i = 0; i < fieldKeys.length; i++) {
5025
5180
  const fieldKey = fieldKeys[i];
5026
5181
  const field = config.fields[fieldKey];
5027
5182
  if ((field == null ? void 0 : field.type) === "slot") {
5028
- newProps[fieldKey] = (dzProps) => renderSlot(__spreadProps(__spreadValues({}, dzProps), {
5183
+ const content = props[fieldKey] || [];
5184
+ const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
5185
+ const Slot = (dzProps) => render(__spreadProps(__spreadValues({
5186
+ allow: field.allow,
5187
+ disallow: field.disallow
5188
+ }, dzProps), {
5029
5189
  zone: fieldKey,
5030
- content: props[fieldKey] || []
5190
+ content
5031
5191
  }));
5192
+ slotProps2[fieldKey] = Slot;
5032
5193
  }
5033
5194
  }
5034
- return newProps;
5035
- }, [config, props]);
5195
+ return slotProps2;
5196
+ }, [config, readOnly, forceReadOnly]);
5197
+ return __spreadValues(__spreadValues({}, props), slotProps);
5036
5198
  }
5037
5199
 
5038
5200
  // components/Render/index.tsx
@@ -5040,39 +5202,121 @@ var import_react33 = __toESM(require("react"));
5040
5202
 
5041
5203
  // components/SlotRender/index.tsx
5042
5204
  init_react_import();
5205
+
5206
+ // components/SlotRender/server.tsx
5207
+ init_react_import();
5043
5208
  var import_react32 = require("react");
5209
+
5210
+ // components/ServerRender/index.tsx
5211
+ init_react_import();
5044
5212
  var import_jsx_runtime21 = require("react/jsx-runtime");
5045
- var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRender, __spreadValues({}, props));
5046
- var SlotRender = (0, import_react32.forwardRef)(
5047
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5048
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
5049
- const Component = config.components[item.type];
5050
- if (Component) {
5051
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
5052
- SlotRenderPure,
5053
- __spreadProps(__spreadValues({}, slotProps), {
5213
+ function DropZoneRender({
5214
+ zone,
5215
+ data,
5216
+ areaId = "root",
5217
+ config,
5218
+ metadata = {}
5219
+ }) {
5220
+ let zoneCompound = rootDroppableId;
5221
+ let content = (data == null ? void 0 : data.content) || [];
5222
+ if (!data || !config) {
5223
+ return null;
5224
+ }
5225
+ if (areaId !== rootAreaId && zone !== rootZone) {
5226
+ zoneCompound = `${areaId}:${zone}`;
5227
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
5228
+ }
5229
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
5230
+ const Component = config.components[item.type];
5231
+ const props = __spreadProps(__spreadValues({}, item.props), {
5232
+ puck: {
5233
+ renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
5234
+ DropZoneRender,
5235
+ {
5236
+ zone: zone2,
5237
+ data,
5238
+ areaId: item.props.id,
5054
5239
  config,
5055
5240
  metadata
5056
- })
5057
- ));
5058
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
5059
- Component.render,
5060
- __spreadProps(__spreadValues({}, props), {
5061
- puck: {
5062
- renderDropZone: DropZoneRenderPure,
5063
- metadata: metadata || {}
5064
- }
5065
- }),
5066
- props.id
5067
- );
5241
+ }
5242
+ ),
5243
+ metadata
5068
5244
  }
5069
- return null;
5245
+ });
5246
+ const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
5247
+ if (Component) {
5248
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
5249
+ }
5250
+ return null;
5251
+ }) });
5252
+ }
5253
+
5254
+ // components/SlotRender/server.tsx
5255
+ var import_jsx_runtime22 = require("react/jsx-runtime");
5256
+ var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
5257
+ var Item = ({
5258
+ config,
5259
+ item,
5260
+ metadata
5261
+ }) => {
5262
+ const Component = config.components[item.type];
5263
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5264
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5265
+ Component.render,
5266
+ __spreadProps(__spreadValues({}, props), {
5267
+ puck: __spreadProps(__spreadValues({}, props.puck), {
5268
+ renderDropZone: DropZoneRender,
5269
+ metadata: metadata || {}
5270
+ })
5271
+ })
5272
+ );
5273
+ };
5274
+ var SlotRender = (0, import_react32.forwardRef)(
5275
+ function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5276
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
5277
+ if (!config.components[item.type]) {
5278
+ return null;
5279
+ }
5280
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5281
+ Item,
5282
+ {
5283
+ config,
5284
+ item,
5285
+ metadata
5286
+ },
5287
+ item.props.id
5288
+ );
5070
5289
  }) });
5071
5290
  }
5072
5291
  );
5073
5292
 
5293
+ // components/SlotRender/index.tsx
5294
+ var import_jsx_runtime23 = require("react/jsx-runtime");
5295
+ var ContextSlotRender = ({
5296
+ componentId,
5297
+ zone
5298
+ }) => {
5299
+ const config = useAppStore((s) => s.config);
5300
+ const metadata = useAppStore((s) => s.metadata);
5301
+ const slotContent = useAppStore(
5302
+ (s) => {
5303
+ var _a, _b;
5304
+ return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
5305
+ }
5306
+ );
5307
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5308
+ SlotRenderPure,
5309
+ {
5310
+ content: slotContent,
5311
+ zone,
5312
+ config,
5313
+ metadata
5314
+ }
5315
+ );
5316
+ };
5317
+
5074
5318
  // components/Render/index.tsx
5075
- var import_jsx_runtime22 = require("react/jsx-runtime");
5319
+ var import_jsx_runtime24 = require("react/jsx-runtime");
5076
5320
  var renderContext = import_react33.default.createContext({
5077
5321
  config: { components: {} },
5078
5322
  data: { root: {}, content: [] },
@@ -5101,37 +5345,26 @@ function Render({
5101
5345
  editMode: false,
5102
5346
  id: "puck-root"
5103
5347
  });
5104
- const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
5348
+ const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
5349
+ const nextContextValue = (0, import_react33.useMemo)(
5350
+ () => ({
5351
+ mode: "render",
5352
+ depth: 0
5353
+ }),
5354
+ []
5355
+ );
5105
5356
  if ((_a = config.root) == null ? void 0 : _a.render) {
5106
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5107
- DropZoneProvider,
5108
- {
5109
- value: {
5110
- mode: "render",
5111
- depth: 0
5112
- },
5113
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone }) }))
5114
- }
5115
- ) });
5357
+ 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 }) })) }) });
5116
5358
  }
5117
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5118
- DropZoneProvider,
5119
- {
5120
- value: {
5121
- mode: "render",
5122
- depth: 0
5123
- },
5124
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone })
5125
- }
5126
- ) });
5359
+ 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 }) }) });
5127
5360
  }
5128
5361
 
5129
5362
  // components/DropZone/index.tsx
5130
- var import_jsx_runtime23 = require("react/jsx-runtime");
5363
+ var import_jsx_runtime25 = require("react/jsx-runtime");
5131
5364
  var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
5132
5365
  var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
5133
5366
  var RENDER_DEBUG = false;
5134
- var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneEdit, __spreadValues({}, props));
5367
+ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadValues({}, props));
5135
5368
  var DropZoneChild = ({
5136
5369
  zoneCompound,
5137
5370
  componentId,
@@ -5144,14 +5377,8 @@ var DropZoneChild = ({
5144
5377
  }) => {
5145
5378
  var _a, _b;
5146
5379
  const metadata = useAppStore((s) => s.metadata);
5147
- const puckProps = {
5148
- renderDropZone: DropZoneEditPure,
5149
- isEditing: true,
5150
- dragRef: null,
5151
- metadata
5152
- };
5153
5380
  const ctx = (0, import_react34.useContext)(dropZoneContext);
5154
- const { depth } = ctx;
5381
+ const { depth = 1 } = ctx != null ? ctx : {};
5155
5382
  const nodeProps = useAppStore(
5156
5383
  (0, import_shallow3.useShallow)((s) => {
5157
5384
  var _a2;
@@ -5164,11 +5391,23 @@ var DropZoneChild = ({
5164
5391
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
5165
5392
  }
5166
5393
  );
5394
+ const nodeReadOnly = useAppStore(
5395
+ (0, import_shallow3.useShallow)((s) => {
5396
+ var _a2;
5397
+ return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
5398
+ })
5399
+ );
5167
5400
  const node = { type: nodeType, props: nodeProps };
5168
5401
  const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
5169
5402
  const componentConfig = useAppStore(
5170
5403
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5171
5404
  );
5405
+ const puckProps = {
5406
+ renderDropZone: DropZoneEditPure,
5407
+ isEditing: true,
5408
+ dragRef: null,
5409
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5410
+ };
5172
5411
  const overrides = useAppStore((s) => s.overrides);
5173
5412
  const isLoading = useAppStore(
5174
5413
  (s) => {
@@ -5185,7 +5424,7 @@ var DropZoneChild = ({
5185
5424
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5186
5425
  const renderPreview = (0, import_react34.useMemo)(
5187
5426
  () => function Preview4() {
5188
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5427
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5189
5428
  },
5190
5429
  [componentId, label, overrides]
5191
5430
  );
@@ -5200,10 +5439,13 @@ var DropZoneChild = ({
5200
5439
  const defaultedPropsWithSlots = useSlots(
5201
5440
  componentConfig,
5202
5441
  defaultsProps,
5203
- DropZoneEditPure
5442
+ DropZoneEditPure,
5443
+ (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
5444
+ nodeReadOnly,
5445
+ isLoading
5204
5446
  );
5205
5447
  if (!item) return;
5206
- let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
5448
+ let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
5207
5449
  "No configuration for ",
5208
5450
  item.type
5209
5451
  ] });
@@ -5212,7 +5454,7 @@ var DropZoneChild = ({
5212
5454
  if (isPreview) {
5213
5455
  Render2 = renderPreview;
5214
5456
  }
5215
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5457
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5216
5458
  DraggableComponent,
5217
5459
  {
5218
5460
  id: componentId,
@@ -5227,17 +5469,18 @@ var DropZoneChild = ({
5227
5469
  autoDragAxis: dragAxis,
5228
5470
  userDragAxis: collisionAxis,
5229
5471
  inDroppableZone,
5230
- 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)(
5472
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5231
5473
  Render2,
5232
5474
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5233
5475
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
5234
5476
  dragRef
5235
5477
  })
5236
5478
  })
5237
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
5479
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
5238
5480
  }
5239
5481
  );
5240
5482
  };
5483
+ var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
5241
5484
  var DropZoneEdit = (0, import_react34.forwardRef)(
5242
5485
  function DropZoneEditInternal({
5243
5486
  zone,
@@ -5252,10 +5495,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5252
5495
  const {
5253
5496
  // These all need setting via context
5254
5497
  areaId,
5255
- depth,
5498
+ depth = 0,
5256
5499
  registerLocalZone,
5257
5500
  unregisterLocalZone
5258
- } = ctx;
5501
+ } = ctx != null ? ctx : {};
5259
5502
  const path = useAppStore(
5260
5503
  (0, import_shallow3.useShallow)((s) => {
5261
5504
  var _a;
@@ -5307,6 +5550,15 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5307
5550
  };
5308
5551
  }
5309
5552
  }, [zoneType]);
5553
+ (0, import_react34.useEffect)(() => {
5554
+ if (zoneType === "dropzone") {
5555
+ if (zoneCompound !== rootDroppableId) {
5556
+ console.warn(
5557
+ "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"
5558
+ );
5559
+ }
5560
+ }
5561
+ }, [zoneType]);
5310
5562
  const contentIds = (0, import_react34.useMemo)(() => {
5311
5563
  return zoneContentIds || [];
5312
5564
  }, [zoneContentIds]);
@@ -5379,7 +5631,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5379
5631
  userMinEmptyHeight,
5380
5632
  ref
5381
5633
  });
5382
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5634
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5383
5635
  "div",
5384
5636
  {
5385
5637
  className: `${getClassName17({
@@ -5401,8 +5653,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5401
5653
  backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
5402
5654
  }),
5403
5655
  children: contentIdsWithPreview.map((componentId, i) => {
5404
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5405
- DropZoneChild,
5656
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5657
+ DropZoneChildMemo,
5406
5658
  {
5407
5659
  zoneCompound,
5408
5660
  componentId,
@@ -5420,8 +5672,32 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5420
5672
  );
5421
5673
  }
5422
5674
  );
5423
- var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneRender, __spreadValues({}, props));
5424
- var DropZoneRender = (0, import_react34.forwardRef)(
5675
+ var DropZoneRenderItem = ({
5676
+ config,
5677
+ item,
5678
+ metadata
5679
+ }) => {
5680
+ const Component = config.components[item.type];
5681
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5682
+ const nextContextValue = (0, import_react34.useMemo)(
5683
+ () => ({
5684
+ areaId: props.id,
5685
+ depth: 1
5686
+ }),
5687
+ [props]
5688
+ );
5689
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5690
+ Component.render,
5691
+ __spreadProps(__spreadValues({}, props), {
5692
+ puck: __spreadProps(__spreadValues({}, props.puck), {
5693
+ renderDropZone: DropZoneRenderPure,
5694
+ metadata: __spreadValues(__spreadValues({}, metadata), Component.metadata)
5695
+ })
5696
+ })
5697
+ ) }, props.id);
5698
+ };
5699
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
5700
+ var DropZoneRender2 = (0, import_react34.forwardRef)(
5425
5701
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5426
5702
  const ctx = (0, import_react34.useContext)(dropZoneContext);
5427
5703
  const { areaId = "root" } = ctx || {};
@@ -5447,48 +5723,31 @@ var DropZoneRender = (0, import_react34.forwardRef)(
5447
5723
  zoneCompound = `${areaId}:${zone}`;
5448
5724
  content = setupZone(data, zoneCompound).zones[zoneCompound];
5449
5725
  }
5450
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className, style, ref, children: content.map((item) => {
5726
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className, style, ref, children: content.map((item) => {
5451
5727
  const Component = config.components[item.type];
5452
5728
  if (Component) {
5453
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5454
- SlotRenderPure,
5455
- __spreadProps(__spreadValues({}, slotProps), {
5729
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5730
+ DropZoneRenderItem,
5731
+ {
5456
5732
  config,
5733
+ item,
5457
5734
  metadata
5458
- })
5459
- ));
5460
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5461
- DropZoneProvider,
5462
- {
5463
- value: {
5464
- areaId: props.id,
5465
- depth: 1
5466
- },
5467
- children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5468
- Component.render,
5469
- __spreadProps(__spreadValues({}, props), {
5470
- puck: {
5471
- renderDropZone: DropZoneRenderPure,
5472
- metadata: metadata || {}
5473
- }
5474
- })
5475
- )
5476
5735
  },
5477
- props.id
5736
+ item.props.id
5478
5737
  );
5479
5738
  }
5480
5739
  return null;
5481
5740
  }) });
5482
5741
  }
5483
5742
  );
5484
- var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZone, __spreadValues({}, props));
5743
+ var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
5485
5744
  var DropZone = (0, import_react34.forwardRef)(
5486
5745
  function DropZone2(props, ref) {
5487
5746
  const ctx = (0, import_react34.useContext)(dropZoneContext);
5488
5747
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5489
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5748
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5490
5749
  }
5491
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
5750
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadProps(__spreadValues({}, props), { ref })) });
5492
5751
  }
5493
5752
  );
5494
5753
 
@@ -5544,7 +5803,7 @@ var GlobalPosition = class {
5544
5803
  var _a;
5545
5804
  this.target = target;
5546
5805
  this.original = original;
5547
- this.frameEl = document.querySelector("iframe");
5806
+ this.frameEl = document.querySelector("iframe#preview-frame");
5548
5807
  if (this.frameEl) {
5549
5808
  this.frameRect = this.frameEl.getBoundingClientRect();
5550
5809
  this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
@@ -5624,6 +5883,7 @@ var getZoneId2 = (candidate) => {
5624
5883
  }
5625
5884
  return id;
5626
5885
  };
5886
+ var BUFFER = 6;
5627
5887
  var getPointerCollisions = (position, manager) => {
5628
5888
  const candidates = [];
5629
5889
  let elements = position.target.ownerDocument.elementsFromPoint(
@@ -5647,13 +5907,25 @@ var getPointerCollisions = (position, manager) => {
5647
5907
  for (let i = 0; i < elements.length; i++) {
5648
5908
  const element = elements[i];
5649
5909
  const dropzoneId = element.getAttribute("data-puck-dropzone");
5910
+ const id = element.getAttribute("data-puck-dnd");
5911
+ if (BUFFER && (dropzoneId || id)) {
5912
+ const box = element.getBoundingClientRect();
5913
+ const contractedBox = {
5914
+ left: box.left + BUFFER,
5915
+ right: box.right - BUFFER,
5916
+ top: box.top + BUFFER,
5917
+ bottom: box.bottom - BUFFER
5918
+ };
5919
+ if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
5920
+ continue;
5921
+ }
5922
+ }
5650
5923
  if (dropzoneId) {
5651
5924
  const droppable = manager.registry.droppables.get(dropzoneId);
5652
5925
  if (droppable) {
5653
5926
  candidates.push(droppable);
5654
5927
  }
5655
5928
  }
5656
- const id = element.getAttribute("data-puck-dnd");
5657
5929
  if (id) {
5658
5930
  const droppable = manager.registry.droppables.get(id);
5659
5931
  if (droppable) {
@@ -5707,8 +5979,8 @@ var findDeepestCandidate = (position, manager) => {
5707
5979
  return { zone, area };
5708
5980
  }
5709
5981
  return {
5710
- zone: "default-zone",
5711
- area: null
5982
+ zone: rootDroppableId,
5983
+ area: rootAreaId
5712
5984
  };
5713
5985
  };
5714
5986
  var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract10.Plugin {
@@ -5762,8 +6034,8 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
5762
6034
  destinationZone: zone,
5763
6035
  id
5764
6036
  };
5765
- const { state, config, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
5766
- const insertedState = insertAction(state, insertActionData, config);
6037
+ const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
6038
+ const insertedState = insertAction(state, insertActionData, appStore);
5767
6039
  dispatch(__spreadProps(__spreadValues({}, insertActionData), {
5768
6040
  // Dispatch insert rather set, as user's may rely on this via onAction
5769
6041
  // We must always record history here so the insert is added to user history
@@ -5806,7 +6078,7 @@ function getDeepDir(el) {
5806
6078
  }
5807
6079
 
5808
6080
  // components/DragDropContext/index.tsx
5809
- var import_jsx_runtime24 = require("react/jsx-runtime");
6081
+ var import_jsx_runtime26 = require("react/jsx-runtime");
5810
6082
  var DEBUG3 = false;
5811
6083
  var dragListenerContext = (0, import_react36.createContext)({
5812
6084
  dragListeners: {}
@@ -5965,14 +6237,22 @@ var DragDropContextClient = ({
5965
6237
  const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
5966
6238
  const dragMode = (0, import_react36.useRef)(null);
5967
6239
  const initialSelector = (0, import_react36.useRef)(void 0);
5968
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
6240
+ const nextContextValue = (0, import_react36.useMemo)(
6241
+ () => ({
6242
+ mode: "edit",
6243
+ areaId: "root",
6244
+ depth: 0
6245
+ }),
6246
+ []
6247
+ );
6248
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5969
6249
  dragListenerContext.Provider,
5970
6250
  {
5971
6251
  value: {
5972
6252
  dragListeners,
5973
6253
  setDragListeners
5974
6254
  },
5975
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
6255
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5976
6256
  import_react35.DragDropProvider,
5977
6257
  {
5978
6258
  plugins,
@@ -6006,7 +6286,6 @@ var DragDropContextClient = ({
6006
6286
  }
6007
6287
  if (thisPreview) {
6008
6288
  zoneStore.setState({ previewIndex: {} });
6009
- const state = appStore.getState().state;
6010
6289
  if (thisPreview.type === "insert") {
6011
6290
  insertComponent(
6012
6291
  thisPreview.componentType,
@@ -6163,17 +6442,7 @@ var DragDropContextClient = ({
6163
6442
  initialSelector.current = void 0;
6164
6443
  zoneStore.setState({ draggedItem: event.operation.source });
6165
6444
  },
6166
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
6167
- DropZoneProvider,
6168
- {
6169
- value: {
6170
- mode: "edit",
6171
- areaId: "root",
6172
- depth: 0
6173
- },
6174
- children
6175
- }
6176
- ) })
6445
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
6177
6446
  }
6178
6447
  )
6179
6448
  }
@@ -6187,11 +6456,11 @@ var DragDropContext = ({
6187
6456
  if (status === "LOADING") {
6188
6457
  return children;
6189
6458
  }
6190
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DragDropContextClient, { disableAutoScroll, children });
6459
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DragDropContextClient, { disableAutoScroll, children });
6191
6460
  };
6192
6461
 
6193
6462
  // components/Drawer/index.tsx
6194
- var import_jsx_runtime25 = require("react/jsx-runtime");
6463
+ var import_jsx_runtime27 = require("react/jsx-runtime");
6195
6464
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
6196
6465
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
6197
6466
  var DrawerItemInner = ({
@@ -6202,10 +6471,10 @@ var DrawerItemInner = ({
6202
6471
  isDragDisabled
6203
6472
  }) => {
6204
6473
  const CustomInner = (0, import_react37.useMemo)(
6205
- () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
6474
+ () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
6206
6475
  [children]
6207
6476
  );
6208
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6477
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6209
6478
  "div",
6210
6479
  {
6211
6480
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -6213,9 +6482,9 @@ var DrawerItemInner = ({
6213
6482
  onMouseDown: (e) => e.preventDefault(),
6214
6483
  "data-testid": dragRef ? `drawer-item:${name}` : "",
6215
6484
  "data-puck-drawer-item": true,
6216
- 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: [
6217
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
6218
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DragIcon, {}) })
6485
+ 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: [
6486
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
6487
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DragIcon, {}) })
6219
6488
  ] }) }) })
6220
6489
  }
6221
6490
  );
@@ -6232,9 +6501,9 @@ var DrawerItemDraggable = ({
6232
6501
  data: { type: "drawer", componentType: name },
6233
6502
  disabled: isDragDisabled
6234
6503
  });
6235
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName18("draggable"), children: [
6236
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name, label, children }) }),
6237
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6504
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
6505
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
6506
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6238
6507
  DrawerItemInner,
6239
6508
  {
6240
6509
  name,
@@ -6268,7 +6537,7 @@ var DrawerItem = ({
6268
6537
  },
6269
6538
  [resolvedId]
6270
6539
  );
6271
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6540
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6272
6541
  DrawerItemDraggable,
6273
6542
  {
6274
6543
  name,
@@ -6301,7 +6570,7 @@ var Drawer = ({
6301
6570
  collisionPriority: 0
6302
6571
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
6303
6572
  });
6304
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6573
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6305
6574
  "div",
6306
6575
  {
6307
6576
  className: getClassName18(),
@@ -6370,7 +6639,7 @@ var useBreadcrumbs = (renderCount) => {
6370
6639
  };
6371
6640
 
6372
6641
  // components/SidebarSection/index.tsx
6373
- var import_jsx_runtime26 = require("react/jsx-runtime");
6642
+ var import_jsx_runtime28 = require("react/jsx-runtime");
6374
6643
  var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
6375
6644
  var SidebarSection = ({
6376
6645
  children,
@@ -6383,15 +6652,15 @@ var SidebarSection = ({
6383
6652
  }) => {
6384
6653
  const setUi = useAppStore((s) => s.setUi);
6385
6654
  const breadcrumbs = useBreadcrumbs(1);
6386
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
6655
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
6387
6656
  "div",
6388
6657
  {
6389
6658
  className: getClassName19({ noBorderTop, noPadding }),
6390
6659
  style: { background },
6391
6660
  children: [
6392
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
6393
- showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
6394
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6661
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
6662
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
6663
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6395
6664
  "button",
6396
6665
  {
6397
6666
  type: "button",
@@ -6400,12 +6669,12 @@ var SidebarSection = ({
6400
6669
  children: breadcrumb.label
6401
6670
  }
6402
6671
  ),
6403
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChevronRight, { size: 16 })
6672
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronRight, { size: 16 })
6404
6673
  ] }, i)) : null,
6405
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
6674
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
6406
6675
  ] }) }),
6407
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("content"), children }),
6408
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Loader, { size: 32 }) })
6676
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("content"), children }),
6677
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 32 }) })
6409
6678
  ]
6410
6679
  }
6411
6680
  );
@@ -6419,7 +6688,7 @@ init_react_import();
6419
6688
  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" };
6420
6689
 
6421
6690
  // components/MenuBar/index.tsx
6422
- var import_jsx_runtime27 = require("react/jsx-runtime");
6691
+ var import_jsx_runtime29 = require("react/jsx-runtime");
6423
6692
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
6424
6693
  function MenuBar({
6425
6694
  menuOpen = false,
@@ -6430,7 +6699,7 @@ function MenuBar({
6430
6699
  const forward = useAppStore((s) => s.history.forward);
6431
6700
  const hasFuture = useAppStore((s) => s.history.hasFuture());
6432
6701
  const hasPast = useAppStore((s) => s.history.hasPast());
6433
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6702
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6434
6703
  "div",
6435
6704
  {
6436
6705
  className: getClassName20({ menuOpen }),
@@ -6444,12 +6713,12 @@ function MenuBar({
6444
6713
  setMenuOpen(false);
6445
6714
  }
6446
6715
  },
6447
- children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName20("inner"), children: [
6448
- /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName20("history"), children: [
6449
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Undo2, { size: 21 }) }),
6450
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Redo2, { size: 21 }) })
6716
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("inner"), children: [
6717
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("history"), children: [
6718
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Undo2, { size: 21 }) }),
6719
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Redo2, { size: 21 }) })
6451
6720
  ] }),
6452
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: renderHeaderActions && renderHeaderActions() })
6721
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: renderHeaderActions && renderHeaderActions() })
6453
6722
  ] })
6454
6723
  }
6455
6724
  );
@@ -6469,12 +6738,12 @@ var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields
6469
6738
  // components/Puck/components/Fields/index.tsx
6470
6739
  var import_react39 = require("react");
6471
6740
  var import_shallow4 = require("zustand/react/shallow");
6472
- var import_jsx_runtime28 = require("react/jsx-runtime");
6741
+ var import_jsx_runtime30 = require("react/jsx-runtime");
6473
6742
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
6474
6743
  var DefaultFields = ({
6475
6744
  children
6476
6745
  }) => {
6477
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_jsx_runtime28.Fragment, { children });
6746
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
6478
6747
  };
6479
6748
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6480
6749
  let currentProps;
@@ -6545,7 +6814,7 @@ var FieldsChild = ({ fieldName }) => {
6545
6814
  ]);
6546
6815
  if (!field || !id) return null;
6547
6816
  if (field.type === "slot") return null;
6548
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6817
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6549
6818
  AutoFieldPrivate,
6550
6819
  {
6551
6820
  field,
@@ -6573,11 +6842,16 @@ var Fields = ({ wrapFields = true }) => {
6573
6842
  useRegisterFieldsSlice(appStore, id);
6574
6843
  const fieldsLoading = useAppStore((s) => s.fields.loading);
6575
6844
  const fieldNames = useAppStore(
6576
- (0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
6845
+ (0, import_shallow4.useShallow)((s) => {
6846
+ if (s.fields.id === id) {
6847
+ return Object.keys(s.fields.fields);
6848
+ }
6849
+ return [];
6850
+ })
6577
6851
  );
6578
6852
  const isLoading = fieldsLoading || componentResolving;
6579
6853
  const Wrapper = (0, import_react39.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6580
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
6854
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6581
6855
  "form",
6582
6856
  {
6583
6857
  className: getClassName21({ wrapFields }),
@@ -6585,8 +6859,8 @@ var Fields = ({ wrapFields = true }) => {
6585
6859
  e.preventDefault();
6586
6860
  },
6587
6861
  children: [
6588
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FieldsChild, { fieldName }, fieldName)) }),
6589
- 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 }) }) })
6862
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChild, { fieldName }, fieldName)) }),
6863
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 16 }) }) })
6590
6864
  ]
6591
6865
  }
6592
6866
  );
@@ -6607,7 +6881,7 @@ init_react_import();
6607
6881
  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" };
6608
6882
 
6609
6883
  // components/ComponentList/index.tsx
6610
- var import_jsx_runtime29 = require("react/jsx-runtime");
6884
+ var import_jsx_runtime31 = require("react/jsx-runtime");
6611
6885
  var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
6612
6886
  var ComponentListItem = ({
6613
6887
  name,
@@ -6619,7 +6893,7 @@ var ComponentListItem = ({
6619
6893
  type: name
6620
6894
  }).insert
6621
6895
  );
6622
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6896
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6623
6897
  };
6624
6898
  var ComponentList = ({
6625
6899
  children,
@@ -6630,8 +6904,8 @@ var ComponentList = ({
6630
6904
  const setUi = useAppStore((s) => s.setUi);
6631
6905
  const componentList = useAppStore((s) => s.state.ui.componentList);
6632
6906
  const { expanded = true } = componentList[id] || {};
6633
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
6634
- title && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6907
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
6908
+ title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
6635
6909
  "button",
6636
6910
  {
6637
6911
  type: "button",
@@ -6645,14 +6919,14 @@ var ComponentList = ({
6645
6919
  }),
6646
6920
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6647
6921
  children: [
6648
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: title }),
6649
- /* @__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 }) })
6922
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
6923
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: 12 }) })
6650
6924
  ]
6651
6925
  }
6652
6926
  ),
6653
- /* @__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) => {
6927
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6654
6928
  var _a;
6655
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6929
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6656
6930
  ComponentListItem,
6657
6931
  {
6658
6932
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6666,7 +6940,7 @@ var ComponentList = ({
6666
6940
  ComponentList.Item = ComponentListItem;
6667
6941
 
6668
6942
  // lib/use-component-list.tsx
6669
- var import_jsx_runtime30 = require("react/jsx-runtime");
6943
+ var import_jsx_runtime32 = require("react/jsx-runtime");
6670
6944
  var useComponentList = () => {
6671
6945
  const [componentList, setComponentList] = (0, import_react40.useState)();
6672
6946
  const config = useAppStore((s) => s.config);
@@ -6681,7 +6955,7 @@ var useComponentList = () => {
6681
6955
  if (category.visible === false || !category.components) {
6682
6956
  return null;
6683
6957
  }
6684
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6958
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6685
6959
  ComponentList,
6686
6960
  {
6687
6961
  id: categoryKey,
@@ -6690,7 +6964,7 @@ var useComponentList = () => {
6690
6964
  var _a2;
6691
6965
  matchedComponents.push(componentName);
6692
6966
  const componentConf = config.components[componentName] || {};
6693
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6967
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6694
6968
  ComponentList.Item,
6695
6969
  {
6696
6970
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6710,7 +6984,7 @@ var useComponentList = () => {
6710
6984
  );
6711
6985
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6712
6986
  _componentList.push(
6713
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6987
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6714
6988
  ComponentList,
6715
6989
  {
6716
6990
  id: "other",
@@ -6718,7 +6992,7 @@ var useComponentList = () => {
6718
6992
  children: remainingComponents.map((componentName, i) => {
6719
6993
  var _a2;
6720
6994
  const componentConf = config.components[componentName] || {};
6721
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6995
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6722
6996
  ComponentList.Item,
6723
6997
  {
6724
6998
  name: componentName,
@@ -6741,12 +7015,12 @@ var useComponentList = () => {
6741
7015
 
6742
7016
  // components/Puck/components/Components/index.tsx
6743
7017
  var import_react41 = require("react");
6744
- var import_jsx_runtime31 = require("react/jsx-runtime");
7018
+ var import_jsx_runtime33 = require("react/jsx-runtime");
6745
7019
  var Components = () => {
6746
7020
  const overrides = useAppStore((s) => s.overrides);
6747
7021
  const componentList = useComponentList();
6748
7022
  const Wrapper = (0, import_react41.useMemo)(() => overrides.components || "div", [overrides]);
6749
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComponentList, { id: "all" }) });
7023
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
6750
7024
  };
6751
7025
 
6752
7026
  // components/Puck/components/Preview/index.tsx
@@ -6758,7 +7032,7 @@ init_react_import();
6758
7032
  var import_react42 = require("react");
6759
7033
  var import_object_hash = __toESM(require("object-hash"));
6760
7034
  var import_react_dom3 = require("react-dom");
6761
- var import_jsx_runtime32 = require("react/jsx-runtime");
7035
+ var import_jsx_runtime34 = require("react/jsx-runtime");
6762
7036
  var styleSelector = 'style, link[rel="stylesheet"]';
6763
7037
  var collectStyles = (doc) => {
6764
7038
  const collected = [];
@@ -6958,7 +7232,7 @@ var CopyHostStyles = ({
6958
7232
  observer.disconnect();
6959
7233
  };
6960
7234
  }, []);
6961
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
7235
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
6962
7236
  };
6963
7237
  var autoFrameContext = (0, import_react42.createContext)({});
6964
7238
  var useFrame = () => (0, import_react42.useContext)(autoFrameContext);
@@ -7005,7 +7279,7 @@ function AutoFrame(_a) {
7005
7279
  }
7006
7280
  }
7007
7281
  }, [frameRef, loaded, stylesLoaded]);
7008
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
7282
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7009
7283
  "iframe",
7010
7284
  __spreadProps(__spreadValues({}, props), {
7011
7285
  className,
@@ -7015,7 +7289,7 @@ function AutoFrame(_a) {
7015
7289
  onLoad: () => {
7016
7290
  setLoaded(true);
7017
7291
  },
7018
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
7292
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7019
7293
  CopyHostStyles,
7020
7294
  {
7021
7295
  debug,
@@ -7034,7 +7308,7 @@ init_react_import();
7034
7308
  var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7035
7309
 
7036
7310
  // components/Puck/components/Preview/index.tsx
7037
- var import_jsx_runtime33 = require("react/jsx-runtime");
7311
+ var import_jsx_runtime35 = require("react/jsx-runtime");
7038
7312
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
7039
7313
  var useBubbleIframeEvents = (ref) => {
7040
7314
  const status = useAppStore((s) => s.status);
@@ -7094,7 +7368,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
7094
7368
  const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
7095
7369
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7096
7370
  id: "puck-root"
7097
- }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: propsWithSlots.children });
7371
+ }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
7098
7372
  },
7099
7373
  [config.root]
7100
7374
  );
@@ -7102,7 +7376,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
7102
7376
  const rootProps = root.props || root;
7103
7377
  const ref = (0, import_react43.useRef)(null);
7104
7378
  useBubbleIframeEvents(ref);
7105
- const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7379
+ const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7106
7380
  Page,
7107
7381
  __spreadProps(__spreadValues({}, rootProps), {
7108
7382
  puck: {
@@ -7112,15 +7386,15 @@ var Preview3 = ({ id = "puck-preview" }) => {
7112
7386
  metadata
7113
7387
  },
7114
7388
  editMode: true,
7115
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZonePure, { zone: rootDroppableId })
7389
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
7116
7390
  })
7117
- ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: renderData, config });
7391
+ ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
7118
7392
  (0, import_react43.useEffect)(() => {
7119
7393
  if (!iframe.enabled) {
7120
7394
  setStatus("READY");
7121
7395
  }
7122
7396
  }, [iframe.enabled]);
7123
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7397
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7124
7398
  "div",
7125
7399
  {
7126
7400
  className: getClassName23(),
@@ -7129,7 +7403,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
7129
7403
  onClick: () => {
7130
7404
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7131
7405
  },
7132
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7406
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7133
7407
  AutoFrame_default,
7134
7408
  {
7135
7409
  id: "preview-frame",
@@ -7142,14 +7416,14 @@ var Preview3 = ({ id = "puck-preview" }) => {
7142
7416
  setStatus("MOUNTED");
7143
7417
  },
7144
7418
  frameRef: ref,
7145
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7419
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7146
7420
  if (Frame) {
7147
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
7421
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
7148
7422
  }
7149
7423
  return inner;
7150
7424
  } })
7151
7425
  }
7152
- ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7426
+ ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7153
7427
  "div",
7154
7428
  {
7155
7429
  id: "preview-frame",
@@ -7208,7 +7482,7 @@ var onScrollEnd = (frame, cb) => {
7208
7482
 
7209
7483
  // components/LayerTree/index.tsx
7210
7484
  var import_shallow5 = require("zustand/react/shallow");
7211
- var import_jsx_runtime34 = require("react/jsx-runtime");
7485
+ var import_jsx_runtime36 = require("react/jsx-runtime");
7212
7486
  var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7213
7487
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
7214
7488
  var Layer = ({
@@ -7254,7 +7528,7 @@ var Layer = ({
7254
7528
  });
7255
7529
  const componentConfig = config.components[nodeData.data.type];
7256
7530
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7257
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
7531
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7258
7532
  "li",
7259
7533
  {
7260
7534
  className: getClassNameLayer({
@@ -7264,7 +7538,7 @@ var Layer = ({
7264
7538
  childIsSelected
7265
7539
  }),
7266
7540
  children: [
7267
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
7541
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7268
7542
  "button",
7269
7543
  {
7270
7544
  type: "button",
@@ -7299,22 +7573,22 @@ var Layer = ({
7299
7573
  setHoveringComponent(null);
7300
7574
  },
7301
7575
  children: [
7302
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7576
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7303
7577
  "div",
7304
7578
  {
7305
7579
  className: getClassNameLayer("chevron"),
7306
7580
  title: isSelected ? "Collapse" : "Expand",
7307
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
7581
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
7308
7582
  }
7309
7583
  ),
7310
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
7311
- /* @__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" }) }),
7312
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label })
7584
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
7585
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayoutGrid, { size: "16" }) }),
7586
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
7313
7587
  ] })
7314
7588
  ]
7315
7589
  }
7316
7590
  ) }),
7317
- 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))
7591
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7318
7592
  ]
7319
7593
  }
7320
7594
  );
@@ -7332,15 +7606,15 @@ var LayerTree = ({
7332
7606
  }
7333
7607
  )
7334
7608
  );
7335
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
7336
- label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
7337
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
7609
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
7610
+ label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
7611
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
7338
7612
  label
7339
7613
  ] }),
7340
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName24(), children: [
7341
- contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
7614
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
7615
+ contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
7342
7616
  contentIds.map((itemId, i) => {
7343
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7617
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7344
7618
  Layer,
7345
7619
  {
7346
7620
  index: i,
@@ -7357,7 +7631,7 @@ var LayerTree = ({
7357
7631
  // components/Puck/components/Outline/index.tsx
7358
7632
  var import_react45 = require("react");
7359
7633
 
7360
- // lib/find-zones-for-area.ts
7634
+ // lib/data/find-zones-for-area.ts
7361
7635
  init_react_import();
7362
7636
  var findZonesForArea = (state, area) => {
7363
7637
  return Object.keys(state.indexes.zones).filter(
@@ -7367,14 +7641,14 @@ var findZonesForArea = (state, area) => {
7367
7641
 
7368
7642
  // components/Puck/components/Outline/index.tsx
7369
7643
  var import_shallow6 = require("zustand/react/shallow");
7370
- var import_jsx_runtime35 = require("react/jsx-runtime");
7644
+ var import_jsx_runtime37 = require("react/jsx-runtime");
7371
7645
  var Outline = () => {
7372
7646
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7373
7647
  const rootZones = useAppStore(
7374
7648
  (0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
7375
7649
  );
7376
7650
  const Wrapper = (0, import_react45.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7377
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7651
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7378
7652
  LayerTree,
7379
7653
  {
7380
7654
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -7518,11 +7792,11 @@ init_react_import();
7518
7792
  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" };
7519
7793
 
7520
7794
  // components/ViewportControls/index.tsx
7521
- var import_jsx_runtime36 = require("react/jsx-runtime");
7795
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7522
7796
  var icons = {
7523
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Smartphone, { size: 16 }),
7524
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Tablet, { size: 16 }),
7525
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Monitor, { size: 16 })
7797
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
7798
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
7799
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
7526
7800
  };
7527
7801
  var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7528
7802
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
@@ -7538,7 +7812,7 @@ var ViewportButton = ({
7538
7812
  (0, import_react46.useEffect)(() => {
7539
7813
  setIsActive(width === viewports.current.width);
7540
7814
  }, [width, viewports.current.width]);
7541
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7815
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7542
7816
  IconButton,
7543
7817
  {
7544
7818
  title,
@@ -7547,7 +7821,7 @@ var ViewportButton = ({
7547
7821
  e.stopPropagation();
7548
7822
  onClick({ width, height });
7549
7823
  },
7550
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton("inner"), children })
7824
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
7551
7825
  }
7552
7826
  ) });
7553
7827
  };
@@ -7583,8 +7857,8 @@ var ViewportControls = ({
7583
7857
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7584
7858
  [autoZoom]
7585
7859
  );
7586
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName25(), children: [
7587
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7860
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
7861
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7588
7862
  ViewportButton,
7589
7863
  {
7590
7864
  height: viewport.height,
@@ -7595,8 +7869,8 @@ var ViewportControls = ({
7595
7869
  },
7596
7870
  i
7597
7871
  )),
7598
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7599
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7872
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7873
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7600
7874
  IconButton,
7601
7875
  {
7602
7876
  title: "Zoom viewport out",
@@ -7610,10 +7884,10 @@ var ViewportControls = ({
7610
7884
  )].value
7611
7885
  );
7612
7886
  },
7613
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomOut, { size: 16 })
7887
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
7614
7888
  }
7615
7889
  ),
7616
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7890
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7617
7891
  IconButton,
7618
7892
  {
7619
7893
  title: "Zoom viewport in",
@@ -7627,11 +7901,11 @@ var ViewportControls = ({
7627
7901
  )].value
7628
7902
  );
7629
7903
  },
7630
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ZoomIn, { size: 16 })
7904
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
7631
7905
  }
7632
7906
  ),
7633
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25("divider") }),
7634
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7907
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7908
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7635
7909
  "select",
7636
7910
  {
7637
7911
  className: getClassName25("zoomSelect"),
@@ -7639,7 +7913,7 @@ var ViewportControls = ({
7639
7913
  onChange: (e) => {
7640
7914
  onZoom(parseFloat(e.currentTarget.value));
7641
7915
  },
7642
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7916
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7643
7917
  "option",
7644
7918
  {
7645
7919
  value: option.value,
@@ -7688,7 +7962,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7688
7962
 
7689
7963
  // components/Puck/components/Canvas/index.tsx
7690
7964
  var import_shallow7 = require("zustand/react/shallow");
7691
- var import_jsx_runtime37 = require("react/jsx-runtime");
7965
+ var import_jsx_runtime39 = require("react/jsx-runtime");
7692
7966
  var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
7693
7967
  var ZOOM_ON_CHANGE = true;
7694
7968
  var Canvas = () => {
@@ -7721,7 +7995,7 @@ var Canvas = () => {
7721
7995
  const frameRef = (0, import_react47.useRef)(null);
7722
7996
  const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
7723
7997
  const defaultRender = (0, import_react47.useMemo)(() => {
7724
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
7998
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
7725
7999
  return PuckDefault;
7726
8000
  }, []);
7727
8001
  const CustomPreview = (0, import_react47.useMemo)(
@@ -7784,7 +8058,7 @@ var Canvas = () => {
7784
8058
  setShowLoader(true);
7785
8059
  }, 500);
7786
8060
  }, []);
7787
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
8061
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
7788
8062
  "div",
7789
8063
  {
7790
8064
  className: getClassName26({
@@ -7797,7 +8071,7 @@ var Canvas = () => {
7797
8071
  recordHistory: true
7798
8072
  }),
7799
8073
  children: [
7800
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
8074
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7801
8075
  ViewportControls,
7802
8076
  {
7803
8077
  autoZoom: zoomConfig.autoZoom,
@@ -7823,8 +8097,8 @@ var Canvas = () => {
7823
8097
  }
7824
8098
  }
7825
8099
  ) }),
7826
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
7827
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
8100
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
8101
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7828
8102
  "div",
7829
8103
  {
7830
8104
  className: getClassName26("root"),
@@ -7845,10 +8119,10 @@ var Canvas = () => {
7845
8119
  })
7846
8120
  );
7847
8121
  },
7848
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview3, {}) })
8122
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview3, {}) })
7849
8123
  }
7850
8124
  ),
7851
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
8125
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
7852
8126
  ] })
7853
8127
  ]
7854
8128
  }
@@ -7903,8 +8177,8 @@ var useLoadedOverrides = ({
7903
8177
 
7904
8178
  // components/DefaultOverride/index.tsx
7905
8179
  init_react_import();
7906
- var import_jsx_runtime38 = require("react/jsx-runtime");
7907
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
8180
+ var import_jsx_runtime40 = require("react/jsx-runtime");
8181
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
7908
8182
 
7909
8183
  // lib/use-inject-css.ts
7910
8184
  init_react_import();
@@ -7967,13 +8241,22 @@ var generateUsePuck = (store) => {
7967
8241
  index: store.history.index
7968
8242
  };
7969
8243
  const storeData = {
7970
- appState: store.state,
8244
+ appState: makeStatePublic(store.state),
7971
8245
  config: store.config,
7972
8246
  dispatch: store.dispatch,
7973
8247
  getPermissions: store.permissions.getPermissions,
7974
8248
  refreshPermissions: store.permissions.refreshPermissions,
7975
8249
  history,
7976
- selectedItem: store.selectedItem || null
8250
+ selectedItem: store.selectedItem || null,
8251
+ getItemBySelector: (selector) => getItem(selector, store.state),
8252
+ getItemById: (id) => store.state.indexes.nodes[id].data,
8253
+ getSelectorForId: (id) => {
8254
+ const node = store.state.indexes.nodes[id];
8255
+ if (!node) return;
8256
+ const zoneCompound = `${node.parentId}:${node.zone}`;
8257
+ const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
8258
+ return { zone: zoneCompound, index };
8259
+ }
7977
8260
  };
7978
8261
  const get = () => storeData;
7979
8262
  return __spreadProps(__spreadValues({}, storeData), { get });
@@ -7981,23 +8264,25 @@ var generateUsePuck = (store) => {
7981
8264
  var UsePuckStoreContext = (0, import_react51.createContext)(
7982
8265
  null
7983
8266
  );
8267
+ var convertToPickedStore = (store) => {
8268
+ return {
8269
+ state: store.state,
8270
+ config: store.config,
8271
+ dispatch: store.dispatch,
8272
+ permissions: store.permissions,
8273
+ history: store.history,
8274
+ selectedItem: store.selectedItem
8275
+ };
8276
+ };
7984
8277
  var useRegisterUsePuckStore = (appStore) => {
7985
8278
  const [usePuckStore] = (0, import_react51.useState)(
7986
- () => (0, import_zustand6.createStore)(() => generateUsePuck(appStore.getState()))
8279
+ () => (0, import_zustand6.createStore)(
8280
+ () => generateUsePuck(convertToPickedStore(appStore.getState()))
8281
+ )
7987
8282
  );
7988
8283
  (0, import_react51.useEffect)(() => {
7989
8284
  return appStore.subscribe(
7990
- (store) => {
7991
- const pickedStore = {
7992
- state: store.state,
7993
- config: store.config,
7994
- dispatch: store.dispatch,
7995
- permissions: store.permissions,
7996
- history: store.history,
7997
- selectedItem: store.selectedItem
7998
- };
7999
- return pickedStore;
8000
- },
8285
+ (store) => convertToPickedStore(store),
8001
8286
  (pickedStore) => {
8002
8287
  usePuckStore.setState(generateUsePuck(pickedStore));
8003
8288
  }
@@ -8028,7 +8313,8 @@ function usePuck() {
8028
8313
  }
8029
8314
 
8030
8315
  // components/Puck/index.tsx
8031
- var import_jsx_runtime39 = require("react/jsx-runtime");
8316
+ var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
8317
+ var import_jsx_runtime41 = require("react/jsx-runtime");
8032
8318
  var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
8033
8319
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
8034
8320
  var FieldSideBar = () => {
@@ -8038,31 +8324,13 @@ var FieldSideBar = () => {
8038
8324
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
8039
8325
  }
8040
8326
  );
8041
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {}) });
8327
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
8042
8328
  };
8043
- var DEBUG4 = false;
8044
8329
  var propsContext = (0, import_react52.createContext)({});
8045
8330
  function PropsProvider(props) {
8046
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(propsContext.Provider, { value: props, children: props.children });
8331
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
8047
8332
  }
8048
8333
  var usePropsContext = () => (0, import_react52.useContext)(propsContext);
8049
- var debugPlugin = {
8050
- overrides: {
8051
- fields: ({ children }) => {
8052
- const state = useAppStore((s) => s.state);
8053
- const selectedItem = useAppStore((s) => s.selectedItem);
8054
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
8055
- children,
8056
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Debug: Data", children: JSON.stringify(state.data) }),
8057
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Debug: UI", children: JSON.stringify(state.ui) }),
8058
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Debug: Other", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("ul", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("li", { children: [
8059
- "Selected Item: ",
8060
- JSON.stringify(selectedItem)
8061
- ] }) }) })
8062
- ] });
8063
- }
8064
- }
8065
- };
8066
8334
  function PuckProvider({ children }) {
8067
8335
  const {
8068
8336
  config,
@@ -8070,7 +8338,7 @@ function PuckProvider({ children }) {
8070
8338
  ui: initialUi,
8071
8339
  onChange,
8072
8340
  permissions = {},
8073
- plugins: _plugins,
8341
+ plugins,
8074
8342
  overrides,
8075
8343
  viewports = defaultViewports,
8076
8344
  iframe: _iframe,
@@ -8139,69 +8407,77 @@ function PuckProvider({ children }) {
8139
8407
  ) : {}
8140
8408
  })
8141
8409
  });
8142
- return walkTree(newAppState, config);
8410
+ return walkAppState(newAppState, config);
8143
8411
  });
8144
8412
  const { appendData = true } = _initialHistory || {};
8145
- const blendedHistories = [
8146
- ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8147
- ...appendData ? [{ state: generatedAppState }] : []
8148
- ].map((history) => __spreadProps(__spreadValues({}, history), {
8149
- // Inject default data to enable partial history injections
8150
- state: __spreadValues(__spreadValues({}, generatedAppState), history.state)
8151
- }));
8413
+ const [blendedHistories] = (0, import_react52.useState)(
8414
+ [
8415
+ ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8416
+ ...appendData ? [{ state: generatedAppState }] : []
8417
+ ].map((history) => {
8418
+ let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
8419
+ if (!history.state.indexes) {
8420
+ newState = walkAppState(newState, config);
8421
+ }
8422
+ return __spreadProps(__spreadValues({}, history), {
8423
+ state: newState
8424
+ });
8425
+ })
8426
+ );
8152
8427
  const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
8153
8428
  const initialAppState = blendedHistories[initialHistoryIndex].state;
8154
- const plugins = (0, import_react52.useMemo)(
8155
- () => DEBUG4 ? [..._plugins || [], debugPlugin] : _plugins,
8156
- [_plugins]
8157
- );
8158
8429
  const loadedOverrides = useLoadedOverrides({
8159
8430
  overrides,
8160
8431
  plugins
8161
8432
  });
8162
- const generateAppStore = (0, import_react52.useCallback)(() => {
8163
- return {
8164
- state: initialAppState,
8433
+ const generateAppStore = (0, import_react52.useCallback)(
8434
+ (state) => {
8435
+ return {
8436
+ state,
8437
+ config,
8438
+ plugins: plugins || [],
8439
+ overrides: loadedOverrides,
8440
+ viewports,
8441
+ iframe,
8442
+ onAction,
8443
+ metadata
8444
+ };
8445
+ },
8446
+ [
8447
+ initialAppState,
8165
8448
  config,
8166
- plugins: plugins || [],
8167
- overrides: loadedOverrides,
8449
+ plugins,
8450
+ loadedOverrides,
8168
8451
  viewports,
8169
8452
  iframe,
8170
8453
  onAction,
8171
8454
  metadata
8172
- };
8173
- }, [
8174
- initialAppState,
8175
- config,
8176
- plugins,
8177
- loadedOverrides,
8178
- viewports,
8179
- iframe,
8180
- onAction,
8181
- metadata
8182
- ]);
8183
- const [appStore] = (0, import_react52.useState)(() => createAppStore(generateAppStore()));
8455
+ ]
8456
+ );
8457
+ const [appStore] = (0, import_react52.useState)(
8458
+ () => createAppStore(generateAppStore(initialAppState))
8459
+ );
8184
8460
  (0, import_react52.useEffect)(() => {
8185
- appStore.setState(__spreadValues({}, generateAppStore()));
8186
- }, [
8187
- initialAppState,
8188
- config,
8189
- plugins,
8190
- loadedOverrides,
8191
- viewports,
8192
- iframe,
8193
- onAction,
8194
- metadata
8195
- ]);
8461
+ const state = appStore.getState().state;
8462
+ appStore.setState(__spreadValues({}, generateAppStore(state)));
8463
+ }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
8196
8464
  useRegisterHistorySlice(appStore, {
8197
8465
  histories: blendedHistories,
8198
8466
  index: initialHistoryIndex,
8199
8467
  initialAppState
8200
8468
  });
8469
+ const previousData = (0, import_react52.useRef)(null);
8201
8470
  (0, import_react52.useEffect)(() => {
8202
- appStore.subscribe((s) => {
8203
- if (onChange) onChange(s.state.data);
8204
- });
8471
+ appStore.subscribe(
8472
+ (s) => s.state.data,
8473
+ (data) => {
8474
+ if (onChange) {
8475
+ if ((0, import_fast_deep_equal2.default)(data, previousData.current)) return;
8476
+ onChange(data);
8477
+ previousData.current = data;
8478
+ }
8479
+ }
8480
+ );
8205
8481
  }, []);
8206
8482
  useRegisterPermissionsSlice(appStore, permissions);
8207
8483
  const uPuckStore = useRegisterUsePuckStore(appStore);
@@ -8209,11 +8485,10 @@ function PuckProvider({ children }) {
8209
8485
  const { resolveAndCommitData } = appStore.getState();
8210
8486
  resolveAndCommitData();
8211
8487
  }, []);
8212
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8488
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8213
8489
  }
8214
8490
  function PuckLayout({ children }) {
8215
8491
  const {
8216
- onChange,
8217
8492
  onPublish,
8218
8493
  renderHeader,
8219
8494
  renderHeaderActions,
@@ -8234,11 +8509,6 @@ function PuckLayout({ children }) {
8234
8509
  );
8235
8510
  const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
8236
8511
  const appStore = useAppStoreApi();
8237
- (0, import_react52.useEffect)(() => {
8238
- return appStore.subscribe((s) => {
8239
- if (onChange) onChange(s.state.data);
8240
- });
8241
- }, [appStore]);
8242
8512
  const rootProps = useAppStore(
8243
8513
  (s) => s.state.data.root.props || s.state.data.root.props
8244
8514
  );
@@ -8289,7 +8559,7 @@ function PuckLayout({ children }) {
8289
8559
  var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8290
8560
  const Comp = renderHeader;
8291
8561
  const appState = useAppStore((s) => s.state);
8292
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8562
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8293
8563
  };
8294
8564
  return RenderHeader;
8295
8565
  }
@@ -8303,7 +8573,7 @@ function PuckLayout({ children }) {
8303
8573
  const RenderHeader = (props) => {
8304
8574
  const Comp = renderHeaderActions;
8305
8575
  const appState = useAppStore((s) => s.state);
8306
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8576
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8307
8577
  };
8308
8578
  return RenderHeader;
8309
8579
  }
@@ -8337,8 +8607,8 @@ function PuckLayout({ children }) {
8337
8607
  }
8338
8608
  }, [ready, iframe.enabled]);
8339
8609
  usePreviewModeHotkeys();
8340
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
8341
- /* @__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)(
8610
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
8611
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8342
8612
  "div",
8343
8613
  {
8344
8614
  className: getLayoutClassName({
@@ -8347,61 +8617,61 @@ function PuckLayout({ children }) {
8347
8617
  mounted,
8348
8618
  rightSideBarVisible
8349
8619
  }),
8350
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8351
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8620
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8621
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8352
8622
  CustomHeader,
8353
8623
  {
8354
- 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)(
8624
+ 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)(
8355
8625
  Button,
8356
8626
  {
8357
8627
  onClick: () => {
8358
8628
  const data = appStore.getState().state.data;
8359
8629
  onPublish && onPublish(data);
8360
8630
  },
8361
- icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
8631
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8362
8632
  children: "Publish"
8363
8633
  }
8364
8634
  ) }) }),
8365
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
8366
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
8367
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8635
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
8636
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
8637
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8368
8638
  "div",
8369
8639
  {
8370
8640
  className: getLayoutClassName("leftSideBarToggle"),
8371
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8641
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8372
8642
  IconButton,
8373
8643
  {
8374
8644
  onClick: () => {
8375
8645
  toggleSidebars("left");
8376
8646
  },
8377
8647
  title: "Toggle left sidebar",
8378
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
8648
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8379
8649
  }
8380
8650
  )
8381
8651
  }
8382
8652
  ),
8383
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8653
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8384
8654
  "div",
8385
8655
  {
8386
8656
  className: getLayoutClassName("rightSideBarToggle"),
8387
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8657
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8388
8658
  IconButton,
8389
8659
  {
8390
8660
  onClick: () => {
8391
8661
  toggleSidebars("right");
8392
8662
  },
8393
8663
  title: "Toggle right sidebar",
8394
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
8664
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8395
8665
  }
8396
8666
  )
8397
8667
  }
8398
8668
  )
8399
8669
  ] }),
8400
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
8670
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8401
8671
  headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
8402
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
8672
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8403
8673
  " ",
8404
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8674
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8405
8675
  "code",
8406
8676
  {
8407
8677
  className: getLayoutClassName("headerPath"),
@@ -8410,31 +8680,31 @@ function PuckLayout({ children }) {
8410
8680
  )
8411
8681
  ] })
8412
8682
  ] }) }),
8413
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
8414
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8683
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
8684
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8415
8685
  IconButton,
8416
8686
  {
8417
8687
  onClick: () => {
8418
8688
  return setMenuOpen(!menuOpen);
8419
8689
  },
8420
8690
  title: "Toggle menu bar",
8421
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
8691
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8422
8692
  }
8423
8693
  ) }),
8424
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8694
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8425
8695
  MenuBar,
8426
8696
  {
8427
8697
  dispatch,
8428
8698
  onPublish,
8429
8699
  menuOpen,
8430
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8700
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8431
8701
  Button,
8432
8702
  {
8433
8703
  onClick: () => {
8434
8704
  const data = appStore.getState().state.data;
8435
8705
  onPublish && onPublish(data);
8436
8706
  },
8437
- icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
8707
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8438
8708
  children: "Publish"
8439
8709
  }
8440
8710
  ) }),
@@ -8445,20 +8715,20 @@ function PuckLayout({ children }) {
8445
8715
  ] }) })
8446
8716
  }
8447
8717
  ),
8448
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8449
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Components, {}) }),
8450
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Outline, {}) })
8718
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8719
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Components, {}) }),
8720
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Outline, {}) })
8451
8721
  ] }),
8452
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Canvas, {}),
8453
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(FieldSideBar, {}) })
8722
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Canvas, {}),
8723
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FieldSideBar, {}) })
8454
8724
  ] })
8455
8725
  }
8456
8726
  ) }) }),
8457
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
8727
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
8458
8728
  ] });
8459
8729
  }
8460
8730
  function Puck(props) {
8461
- 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)) })) }));
8731
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
8462
8732
  }
8463
8733
  Puck.Components = Components;
8464
8734
  Puck.Fields = Fields;
@@ -8482,16 +8752,73 @@ var migrations = [
8482
8752
  });
8483
8753
  }
8484
8754
  return data;
8755
+ },
8756
+ // Migrate zones to slots
8757
+ (data, config) => {
8758
+ var _a;
8759
+ if (!config) return data;
8760
+ console.log("Migrating DropZones to slots...");
8761
+ const updatedItems = {};
8762
+ const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
8763
+ const { indexes } = walkAppState(appState, config);
8764
+ const deletedCompounds = [];
8765
+ walkAppState(appState, config, (content, zoneCompound, zoneType) => {
8766
+ var _a2, _b;
8767
+ if (zoneType === "dropzone") {
8768
+ const [id, slotName] = zoneCompound.split(":");
8769
+ const nodeData = indexes.nodes[id].data;
8770
+ const componentType = nodeData.type;
8771
+ const configForComponent = config.components[componentType];
8772
+ if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
8773
+ updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8774
+ props: __spreadProps(__spreadValues({}, nodeData.props), {
8775
+ [slotName]: content
8776
+ })
8777
+ });
8778
+ deletedCompounds.push(zoneCompound);
8779
+ }
8780
+ return content;
8781
+ }
8782
+ return content;
8783
+ });
8784
+ const updated = walkAppState(
8785
+ appState,
8786
+ config,
8787
+ (content) => content,
8788
+ (item) => {
8789
+ var _a2;
8790
+ return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
8791
+ }
8792
+ );
8793
+ deletedCompounds.forEach((zoneCompound) => {
8794
+ var _a2;
8795
+ const [_, propName] = zoneCompound.split(":");
8796
+ console.log(
8797
+ `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
8798
+ );
8799
+ (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
8800
+ });
8801
+ Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
8802
+ const [_, propName] = zoneCompound.split(":");
8803
+ throw new Error(
8804
+ `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
8805
+ );
8806
+ });
8807
+ delete updated.data.zones;
8808
+ return updated.data;
8485
8809
  }
8486
8810
  ];
8487
- function migrate(data) {
8488
- return migrations == null ? void 0 : migrations.reduce((acc, migration) => migration(acc), data);
8811
+ function migrate(data, config) {
8812
+ return migrations == null ? void 0 : migrations.reduce(
8813
+ (acc, migration) => migration(acc, config),
8814
+ data
8815
+ );
8489
8816
  }
8490
8817
 
8491
8818
  // lib/transform-props.ts
8492
8819
  init_react_import();
8493
8820
 
8494
- // lib/default-data.ts
8821
+ // lib/data/default-data.ts
8495
8822
  init_react_import();
8496
8823
  var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
8497
8824
  root: data.root || {},
@@ -8534,7 +8861,7 @@ function transformProps(data, propTransforms) {
8534
8861
  // lib/resolve-all-data.ts
8535
8862
  init_react_import();
8536
8863
 
8537
- // lib/to-component.ts
8864
+ // lib/data/to-component.ts
8538
8865
  init_react_import();
8539
8866
  var toComponent = (item) => {
8540
8867
  return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
@@ -8562,17 +8889,29 @@ function resolveAllData(_0, _1) {
8562
8889
  "force",
8563
8890
  false
8564
8891
  )).node;
8565
- const resolvedDeep = yield mapSlots(resolved, processContent, false);
8892
+ const resolvedDeep = yield mapSlotsAsync(
8893
+ resolved,
8894
+ processContent,
8895
+ false
8896
+ );
8566
8897
  onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
8567
8898
  return resolvedDeep;
8568
8899
  });
8569
8900
  const processContent = (content) => __async(this, null, function* () {
8570
8901
  return Promise.all(content.map(resolveNode));
8571
8902
  });
8903
+ const processZones = () => __async(this, null, function* () {
8904
+ var _a2;
8905
+ const zones = (_a2 = data.zones) != null ? _a2 : {};
8906
+ Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
8907
+ zones[zoneKey] = yield Promise.all(content.map(resolveNode));
8908
+ }));
8909
+ return zones;
8910
+ });
8572
8911
  const dynamic = {
8573
8912
  root: yield resolveNode(defaultedData.root),
8574
8913
  content: yield processContent(defaultedData.content),
8575
- zones: {}
8914
+ zones: yield processZones()
8576
8915
  };
8577
8916
  Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
8578
8917
  const content = defaultedData.zones[zoneKey];
@@ -8601,7 +8940,8 @@ function resolveAllData(_0, _1) {
8601
8940
  renderContext,
8602
8941
  resolveAllData,
8603
8942
  transformProps,
8604
- usePuck
8943
+ usePuck,
8944
+ walkTree
8605
8945
  });
8606
8946
  /*! Bundled license information:
8607
8947