@measured/puck 0.19.0-canary.8d459e4e → 0.19.0-canary.8e1d7223

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,9 +9,6 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __typeError = (msg) => {
13
- throw TypeError(msg);
14
- };
15
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
13
  var __spreadValues = (a, b) => {
17
14
  for (var prop in b || (b = {}))
@@ -64,10 +61,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
64
61
  mod
65
62
  ));
66
63
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
67
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
68
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
69
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
70
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
71
64
  var __async = (__this, __arguments, generator) => {
72
65
  return new Promise((resolve, reject) => {
73
66
  var fulfilled = (value) => {
@@ -181,6 +174,7 @@ __export(core_exports, {
181
174
  renderContext: () => renderContext,
182
175
  resolveAllData: () => resolveAllData,
183
176
  transformProps: () => transformProps,
177
+ useGetPuck: () => useGetPuck,
184
178
  usePuck: () => usePuck,
185
179
  walkTree: () => walkTree
186
180
  });
@@ -798,43 +792,6 @@ init_react_import();
798
792
  // lib/data/walk-app-state.ts
799
793
  init_react_import();
800
794
 
801
- // lib/data/for-each-slot.ts
802
- init_react_import();
803
-
804
- // lib/data/is-slot.ts
805
- init_react_import();
806
- var isSlot = (prop) => {
807
- var _a, _b;
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";
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
- };
816
-
817
- // lib/data/for-each-slot.ts
818
- var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
819
- const props = item.props || {};
820
- const propKeys = Object.keys(props);
821
- for (let i = 0; i < propKeys.length; i++) {
822
- const propKey = propKeys[i];
823
- const itemType = "type" in item ? item.type : "root";
824
- if (isSlot2(itemType, propKey, props[propKey])) {
825
- const content = props[propKey];
826
- cb(props.id, propKey, content);
827
- if (recursive) {
828
- content.forEach(
829
- (childItem) => __async(void 0, null, function* () {
830
- return forEachSlot(childItem, cb, true, isSlot2);
831
- })
832
- );
833
- }
834
- }
835
- }
836
- };
837
-
838
795
  // lib/data/for-related-zones.ts
839
796
  init_react_import();
840
797
 
@@ -868,19 +825,160 @@ function forRelatedZones(item, data, cb, path = []) {
868
825
  });
869
826
  }
870
827
 
828
+ // lib/data/map-slots.ts
829
+ init_react_import();
830
+ var isPromise = (v) => !!v && typeof v.then === "function";
831
+ var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
832
+ var containsPromise = (arr) => arr.some(isPromise);
833
+ var walkField = ({
834
+ value,
835
+ fields,
836
+ map,
837
+ propKey = "",
838
+ propPath = "",
839
+ id = "",
840
+ config,
841
+ recurseSlots = false
842
+ }) => {
843
+ var _a, _b, _c;
844
+ if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
845
+ const content = value || [];
846
+ const mappedContent = recurseSlots ? content.map((el) => {
847
+ var _a2;
848
+ const componentConfig = config.components[el.type];
849
+ if (!componentConfig) {
850
+ throw new Error(`Could not find component config for ${el.type}`);
851
+ }
852
+ const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
853
+ return walkField({
854
+ value: el,
855
+ fields: fields2,
856
+ map,
857
+ id: el.props.id,
858
+ config,
859
+ recurseSlots
860
+ });
861
+ }) : content;
862
+ if (containsPromise(mappedContent)) {
863
+ return Promise.all(mappedContent);
864
+ }
865
+ return map(mappedContent, id, propPath, fields[propKey], propPath);
866
+ }
867
+ if (value && typeof value === "object") {
868
+ if (Array.isArray(value)) {
869
+ const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
870
+ if (!arrayFields) return value;
871
+ const newValue = value.map(
872
+ (el, idx) => walkField({
873
+ value: el,
874
+ fields: arrayFields,
875
+ map,
876
+ propKey,
877
+ propPath: `${propPath}[${idx}]`,
878
+ id,
879
+ config,
880
+ recurseSlots
881
+ })
882
+ );
883
+ if (containsPromise(newValue)) {
884
+ return Promise.all(newValue);
885
+ }
886
+ return newValue;
887
+ } else if ("$$typeof" in value) {
888
+ return value;
889
+ } else {
890
+ const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
891
+ return walkObject({
892
+ value,
893
+ fields: objectFields,
894
+ map,
895
+ id,
896
+ getPropPath: (k) => `${propPath}.${k}`,
897
+ config,
898
+ recurseSlots
899
+ });
900
+ }
901
+ }
902
+ return value;
903
+ };
904
+ var walkObject = ({
905
+ value,
906
+ fields,
907
+ map,
908
+ id,
909
+ getPropPath,
910
+ config,
911
+ recurseSlots
912
+ }) => {
913
+ const newProps = Object.entries(value).map(([k, v]) => {
914
+ const opts = {
915
+ value: v,
916
+ fields,
917
+ map,
918
+ propKey: k,
919
+ propPath: getPropPath(k),
920
+ id,
921
+ config,
922
+ recurseSlots
923
+ };
924
+ const newValue = walkField(opts);
925
+ if (isPromise(newValue)) {
926
+ return newValue.then((resolvedValue) => ({
927
+ [k]: resolvedValue
928
+ }));
929
+ }
930
+ return {
931
+ [k]: newValue
932
+ };
933
+ }, {});
934
+ if (containsPromise(newProps)) {
935
+ return Promise.all(newProps).then(flatten);
936
+ }
937
+ return flatten(newProps);
938
+ };
939
+ function mapSlots(item, map, config, recurseSlots = false) {
940
+ var _a, _b, _c, _d;
941
+ const itemType = "type" in item ? item.type : "root";
942
+ const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
943
+ const newProps = walkObject({
944
+ value: (_b = item.props) != null ? _b : {},
945
+ fields: (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {},
946
+ map,
947
+ id: item.props ? (_d = item.props.id) != null ? _d : "root" : "root",
948
+ getPropPath: (k) => k,
949
+ config,
950
+ recurseSlots
951
+ });
952
+ if (isPromise(newProps)) {
953
+ return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
954
+ props: resolvedProps
955
+ }));
956
+ }
957
+ return __spreadProps(__spreadValues({}, item), {
958
+ props: newProps
959
+ });
960
+ }
961
+
962
+ // lib/data/flatten-node.ts
963
+ init_react_import();
964
+ var import_flat = require("flat");
965
+
871
966
  // lib/data/strip-slots.ts
872
967
  init_react_import();
873
- var stripSlots = (data) => {
874
- return __spreadProps(__spreadValues({}, data), {
875
- props: Object.entries(data.props).reduce(
876
- (acc, [propKey, propVal]) => {
877
- if (isSlot(propVal)) {
878
- return acc;
879
- }
880
- return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
881
- },
882
- { id: data.props.id }
883
- )
968
+ var stripSlots = (data, config) => {
969
+ return mapSlots(data, () => null, config);
970
+ };
971
+
972
+ // lib/data/flatten-node.ts
973
+ var flattenNode = (node, config) => {
974
+ return __spreadProps(__spreadValues({}, node), {
975
+ props: (0, import_flat.flatten)(stripSlots(node, config).props)
976
+ });
977
+ };
978
+ var expandNode = (node) => {
979
+ const props = (0, import_flat.unflatten)(node.props);
980
+ return __spreadProps(__spreadValues({}, node), {
981
+ props
884
982
  });
885
983
  };
886
984
 
@@ -926,10 +1024,9 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
926
1024
  const mappedItem = mapNodeOrSkip(item, path, index);
927
1025
  if (!mappedItem) return item;
928
1026
  const id = mappedItem.props.id;
929
- const newProps = __spreadValues({}, mappedItem.props);
930
- forEachSlot(
1027
+ const newProps = __spreadProps(__spreadValues({}, mapSlots(
931
1028
  mappedItem,
932
- (parentId2, slotId, content) => {
1029
+ (content, parentId2, slotId) => {
933
1030
  const zoneCompound = `${parentId2}:${slotId}`;
934
1031
  const [_2, newContent2] = processContent(
935
1032
  path,
@@ -938,18 +1035,19 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
938
1035
  "slot",
939
1036
  parentId2
940
1037
  );
941
- newProps[slotId] = newContent2;
1038
+ return newContent2;
942
1039
  },
943
- false,
944
- createIsSlotConfig(config)
945
- );
1040
+ config
1041
+ ).props), {
1042
+ id
1043
+ });
946
1044
  processRelatedZones(item, id, path);
947
1045
  const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
948
1046
  const thisZoneCompound = path[path.length - 1];
949
1047
  const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
950
1048
  newNodeIndex[id] = {
951
1049
  data: newItem,
952
- flatData: stripSlots(newItem),
1050
+ flatData: flattenNode(newItem, config),
953
1051
  path,
954
1052
  parentId,
955
1053
  zone
@@ -1047,15 +1145,74 @@ var getIdsForParent = (zoneCompound, state) => {
1047
1145
  return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
1048
1146
  };
1049
1147
 
1148
+ // lib/data/populate-ids.ts
1149
+ init_react_import();
1150
+
1151
+ // lib/data/walk-tree.ts
1152
+ init_react_import();
1153
+ function walkTree(data, config, callbackFn) {
1154
+ var _a, _b;
1155
+ const walkItem = (item) => {
1156
+ return mapSlots(
1157
+ item,
1158
+ (content, parentId, propName) => {
1159
+ var _a2;
1160
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
1161
+ },
1162
+ config,
1163
+ true
1164
+ );
1165
+ };
1166
+ if ("props" in data) {
1167
+ return walkItem(data);
1168
+ }
1169
+ const _data = data;
1170
+ const zones = (_a = _data.zones) != null ? _a : {};
1171
+ const mappedContent = _data.content.map(walkItem);
1172
+ return {
1173
+ root: walkItem(_data.root),
1174
+ content: (_b = callbackFn(mappedContent, {
1175
+ parentId: "root",
1176
+ propName: "default-zone"
1177
+ })) != null ? _b : mappedContent,
1178
+ zones: Object.keys(zones).reduce(
1179
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
1180
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
1181
+ }),
1182
+ {}
1183
+ )
1184
+ };
1185
+ }
1186
+
1187
+ // lib/data/populate-ids.ts
1188
+ var populateIds = (data, config, override = false) => {
1189
+ const id = generateId(data.type);
1190
+ return walkTree(
1191
+ __spreadProps(__spreadValues({}, data), {
1192
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
1193
+ }),
1194
+ config,
1195
+ (contents) => contents.map((item) => {
1196
+ const id2 = generateId(item.type);
1197
+ return __spreadProps(__spreadValues({}, item), {
1198
+ props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
1199
+ });
1200
+ })
1201
+ );
1202
+ };
1203
+
1050
1204
  // reducer/actions/insert.ts
1051
1205
  function insertAction(state, action, appStore) {
1052
1206
  const id = action.id || generateId(action.componentType);
1053
- const emptyComponentData = {
1054
- type: action.componentType,
1055
- props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
1056
- id
1057
- })
1058
- };
1207
+ const emptyComponentData = populateIds(
1208
+ {
1209
+ type: action.componentType,
1210
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
1211
+ id
1212
+ })
1213
+ },
1214
+ appStore.config
1215
+ );
1059
1216
  const [parentId] = action.destinationZone.split(":");
1060
1217
  const idsInPath = getIdsForParent(action.destinationZone, state);
1061
1218
  return walkAppState(
@@ -1096,25 +1253,26 @@ var replaceAction = (state, action, appStore) => {
1096
1253
  `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1097
1254
  );
1098
1255
  }
1256
+ const data = populateIds(action.data, appStore.config);
1099
1257
  return walkAppState(
1100
1258
  state,
1101
1259
  appStore.config,
1102
1260
  (content, zoneCompound) => {
1103
1261
  const newContent = [...content];
1104
1262
  if (zoneCompound === action.destinationZone) {
1105
- newContent[action.destinationIndex] = action.data;
1263
+ newContent[action.destinationIndex] = data;
1106
1264
  }
1107
1265
  return newContent;
1108
1266
  },
1109
1267
  (childItem, path) => {
1110
1268
  const pathIds = path.map((p) => p.split(":")[0]);
1111
- if (childItem.props.id === action.data.props.id) {
1112
- return action.data;
1269
+ if (childItem.props.id === data.props.id) {
1270
+ return data;
1113
1271
  } else if (childItem.props.id === parentId) {
1114
1272
  return childItem;
1115
1273
  } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1116
1274
  return childItem;
1117
- } else if (pathIds.indexOf(action.data.props.id) > -1) {
1275
+ } else if (pathIds.indexOf(data.props.id) > -1) {
1118
1276
  return childItem;
1119
1277
  }
1120
1278
  return null;
@@ -1733,7 +1891,11 @@ var createNodesSlice = (set, get) => ({
1733
1891
  const s = get().nodes;
1734
1892
  const emptyNode = {
1735
1893
  id,
1736
- methods: { sync: () => null },
1894
+ methods: {
1895
+ sync: () => null,
1896
+ hideOverlay: () => null,
1897
+ showOverlay: () => null
1898
+ },
1737
1899
  element: null
1738
1900
  };
1739
1901
  const existingNode = s.nodes[id];
@@ -1784,12 +1946,13 @@ var flattenData = (state, config) => {
1784
1946
 
1785
1947
  // lib/get-changed.ts
1786
1948
  init_react_import();
1949
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1787
1950
  var getChanged = (newItem, oldItem) => {
1788
1951
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1789
1952
  const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1790
1953
  const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1791
1954
  return __spreadProps(__spreadValues({}, acc), {
1792
- [item]: oldItemProps[item] !== newItemProps[item]
1955
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1793
1956
  });
1794
1957
  }, {}) : {};
1795
1958
  };
@@ -1935,7 +2098,8 @@ var createFieldsSlice = (_set, _get) => {
1935
2098
  return {
1936
2099
  fields: {},
1937
2100
  loading: false,
1938
- lastResolvedData: {}
2101
+ lastResolvedData: {},
2102
+ id: void 0
1939
2103
  };
1940
2104
  };
1941
2105
  var useRegisterFieldsSlice = (appStore, id) => {
@@ -1956,7 +2120,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
1956
2120
  let lastFields = fields;
1957
2121
  if (reset) {
1958
2122
  appStore.setState((s) => ({
1959
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2123
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1960
2124
  }));
1961
2125
  lastFields = defaultFields;
1962
2126
  }
@@ -1984,12 +2148,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
1984
2148
  fields: {
1985
2149
  fields: newFields,
1986
2150
  loading: false,
1987
- lastResolvedData: componentData
2151
+ lastResolvedData: componentData,
2152
+ id
1988
2153
  }
1989
2154
  });
1990
2155
  } else {
1991
2156
  appStore.setState((s) => ({
1992
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2157
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1993
2158
  }));
1994
2159
  }
1995
2160
  }),
@@ -2006,56 +2171,16 @@ var useRegisterFieldsSlice = (appStore, id) => {
2006
2171
 
2007
2172
  // lib/resolve-component-data.ts
2008
2173
  init_react_import();
2009
-
2010
- // lib/data/map-slots.ts
2011
- init_react_import();
2012
- function mapSlotsAsync(_0, _1) {
2013
- return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
2014
- const props = __spreadValues({}, item.props);
2015
- const propKeys = Object.keys(props);
2016
- for (let i = 0; i < propKeys.length; i++) {
2017
- const propKey = propKeys[i];
2018
- const itemType = "type" in item ? item.type : "root";
2019
- if (isSlot2(itemType, propKey, props[propKey])) {
2020
- const content = props[propKey];
2021
- const mappedContent = recursive ? yield Promise.all(
2022
- content.map((item2) => __async(this, null, function* () {
2023
- return yield mapSlotsAsync(item2, map, recursive, isSlot2);
2024
- }))
2025
- ) : content;
2026
- props[propKey] = yield map(mappedContent, propKey);
2027
- }
2028
- }
2029
- return __spreadProps(__spreadValues({}, item), { props });
2030
- });
2031
- }
2032
- function mapSlotsSync(item, map, isSlot2 = isSlot) {
2033
- var _a, _b;
2034
- const props = __spreadValues({}, item.props);
2035
- const propKeys = Object.keys(props);
2036
- for (let i = 0; i < propKeys.length; i++) {
2037
- const propKey = propKeys[i];
2038
- const itemType = "type" in item ? item.type : "root";
2039
- if (isSlot2(itemType, propKey, props[propKey])) {
2040
- const content = props[propKey];
2041
- const mappedContent = content.map((item2) => {
2042
- return mapSlotsSync(item2, map, isSlot2);
2043
- });
2044
- props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
2045
- }
2046
- }
2047
- return __spreadProps(__spreadValues({}, item), { props });
2048
- }
2049
-
2050
- // lib/resolve-component-data.ts
2051
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
2174
+ var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
2052
2175
  var cache = { lastChange: {} };
2053
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
2176
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2054
2177
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
2055
- if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
2056
- const id = "id" in item.props ? item.props.id : "root";
2178
+ const resolvedItem = __spreadValues({}, item);
2179
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
2180
+ const id = "id" in item.props ? item.props.id : "root";
2181
+ if (shouldRunResolver) {
2057
2182
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
2058
- if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
2183
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
2059
2184
  return { node: resolved, didChange: false };
2060
2185
  }
2061
2186
  const changed = getChanged(item, oldItem);
@@ -2068,46 +2193,42 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2068
2193
  metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
2069
2194
  trigger
2070
2195
  });
2071
- let resolvedItem = __spreadProps(__spreadValues({}, item), {
2072
- props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
2073
- });
2074
- if (recursive) {
2075
- resolvedItem = yield mapSlotsAsync(
2076
- resolvedItem,
2077
- (content) => __async(void 0, null, function* () {
2078
- return Promise.all(
2079
- content.map(
2080
- (childItem) => __async(void 0, null, function* () {
2081
- return (yield resolveComponentData(
2082
- childItem,
2083
- config,
2084
- metadata,
2085
- onResolveStart,
2086
- onResolveEnd,
2087
- trigger,
2088
- false
2089
- )).node;
2090
- })
2091
- )
2092
- );
2093
- }),
2094
- false,
2095
- createIsSlotConfig(config)
2096
- );
2097
- }
2196
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
2098
2197
  if (Object.keys(readOnly).length) {
2099
2198
  resolvedItem.readOnly = readOnly;
2100
2199
  }
2101
- cache.lastChange[id] = {
2102
- item,
2103
- resolved: resolvedItem
2104
- };
2105
- if (onResolveEnd) {
2106
- onResolveEnd(resolvedItem);
2107
- }
2108
- return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
2109
2200
  }
2110
- return { node: item, didChange: false };
2201
+ let itemWithResolvedChildren = yield mapSlots(
2202
+ resolvedItem,
2203
+ (content) => __async(void 0, null, function* () {
2204
+ return yield Promise.all(
2205
+ content.map(
2206
+ (childItem) => __async(void 0, null, function* () {
2207
+ return (yield resolveComponentData(
2208
+ childItem,
2209
+ config,
2210
+ metadata,
2211
+ onResolveStart,
2212
+ onResolveEnd,
2213
+ trigger
2214
+ )).node;
2215
+ })
2216
+ )
2217
+ );
2218
+ }),
2219
+ config
2220
+ );
2221
+ if (shouldRunResolver && onResolveEnd) {
2222
+ onResolveEnd(resolvedItem);
2223
+ }
2224
+ cache.lastChange[id] = {
2225
+ item,
2226
+ resolved: itemWithResolvedChildren
2227
+ };
2228
+ return {
2229
+ node: itemWithResolvedChildren,
2230
+ didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
2231
+ };
2111
2232
  });
2112
2233
 
2113
2234
  // lib/data/to-root.ts
@@ -2127,7 +2248,8 @@ var toRoot = (item) => {
2127
2248
  return { props: {}, readOnly };
2128
2249
  };
2129
2250
 
2130
- // store/index.ts
2251
+ // store/default-app-state.ts
2252
+ init_react_import();
2131
2253
  var defaultAppState = {
2132
2254
  data: { content: [], root: {}, zones: {} },
2133
2255
  ui: {
@@ -2153,6 +2275,8 @@ var defaultAppState = {
2153
2275
  zones: {}
2154
2276
  }
2155
2277
  };
2278
+
2279
+ // store/index.ts
2156
2280
  var defaultPageFields = {
2157
2281
  title: { type: "text" }
2158
2282
  };
@@ -2341,383 +2465,80 @@ function useAppStoreApi() {
2341
2465
  init_react_import();
2342
2466
  var import_react12 = require("@dnd-kit/react");
2343
2467
 
2344
- // lib/dnd/dnd-kit/safe.ts
2468
+ // lib/dnd/use-sensors.ts
2345
2469
  init_react_import();
2346
- var import_react10 = require("@dnd-kit/react");
2347
- var import_sortable = require("@dnd-kit/react/sortable");
2348
- function useDroppableSafe(input) {
2349
- if (typeof window === "undefined") {
2350
- return { ref: () => {
2351
- } };
2352
- }
2353
- return (0, import_react10.useDroppable)(input);
2354
- }
2355
- function useDraggableSafe(input) {
2356
- if (typeof window === "undefined") {
2357
- return { ref: () => {
2358
- } };
2359
- }
2360
- return (0, import_react10.useDraggable)(input);
2361
- }
2362
- function useSortableSafe(input) {
2363
- if (typeof window === "undefined") {
2364
- return { ref: () => {
2365
- }, status: "idle", handleRef: () => {
2366
- } };
2367
- }
2368
- return (0, import_sortable.useSortable)(input);
2369
- }
2470
+ var import_react10 = require("react");
2471
+ var import_react11 = require("@dnd-kit/react");
2472
+ var import_utilities = require("@dnd-kit/dom/utilities");
2473
+ var useSensors = ({
2474
+ other,
2475
+ mouse,
2476
+ touch
2477
+ } = {
2478
+ touch: { delay: { value: 200, tolerance: 10 } },
2479
+ other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
2480
+ }) => {
2481
+ const [sensors] = (0, import_react10.useState)(() => [
2482
+ import_react11.PointerSensor.configure({
2483
+ activationConstraints(event, source) {
2484
+ var _a;
2485
+ const { pointerType, target } = event;
2486
+ if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2487
+ return mouse;
2488
+ }
2489
+ if (pointerType === "touch") {
2490
+ return touch;
2491
+ }
2492
+ return other;
2493
+ }
2494
+ })
2495
+ ]);
2496
+ return sensors;
2497
+ };
2370
2498
 
2371
- // lib/dnd/use-sensors.ts
2499
+ // lib/dnd/collision/dynamic/index.ts
2372
2500
  init_react_import();
2373
- var import_react11 = require("react");
2501
+ var import_abstract8 = require("@dnd-kit/abstract");
2374
2502
 
2375
- // lib/dnd/PointerSensor.ts
2503
+ // lib/dnd/collision/directional/index.ts
2376
2504
  init_react_import();
2377
- var import_state = require("@dnd-kit/state");
2378
2505
  var import_abstract = require("@dnd-kit/abstract");
2379
- var import_geometry = require("@dnd-kit/geometry");
2380
- var import_utilities = require("@dnd-kit/dom/utilities");
2381
- var _clearTimeout;
2382
- var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
2383
- constructor(manager, options) {
2384
- super(manager);
2385
- this.manager = manager;
2386
- this.options = options;
2387
- this.listeners = new import_utilities.Listeners();
2388
- this.cleanup = /* @__PURE__ */ new Set();
2389
- this.source = void 0;
2390
- this.started = false;
2391
- __privateAdd(this, _clearTimeout);
2392
- this.handleCancel = this.handleCancel.bind(this);
2393
- this.handlePointerUp = this.handlePointerUp.bind(this);
2394
- this.handleKeyDown = this.handleKeyDown.bind(this);
2395
- (0, import_state.effect)(() => {
2396
- const unbindGlobal = this.bindGlobal(options != null ? options : {});
2397
- return () => {
2398
- unbindGlobal();
2399
- };
2400
- });
2401
- }
2402
- bind(source, options = this.options) {
2403
- const unbind = (0, import_state.effect)(() => {
2404
- var _a;
2405
- const target = (_a = source.handle) != null ? _a : source.element;
2406
- const listener = (event) => {
2407
- if ((0, import_utilities.isPointerEvent)(event)) {
2408
- this.handlePointerDown(event, source, options);
2409
- }
2410
- };
2411
- if (target) {
2412
- patchWindow(target.ownerDocument.defaultView);
2413
- target.addEventListener("pointerdown", listener);
2414
- return () => {
2415
- target.removeEventListener("pointerdown", listener);
2416
- };
2417
- }
2506
+
2507
+ // lib/dnd/collision/collision-debug.ts
2508
+ init_react_import();
2509
+ var DEBUG = false;
2510
+ var debugElements = {};
2511
+ var timeout;
2512
+ var collisionDebug = (a, b, id, color, label) => {
2513
+ if (!DEBUG) return;
2514
+ const debugId = `${id}-debug`;
2515
+ clearTimeout(timeout);
2516
+ timeout = setTimeout(() => {
2517
+ Object.entries(debugElements).forEach(([id2, { svg }]) => {
2518
+ svg.remove();
2519
+ delete debugElements[id2];
2418
2520
  });
2419
- return unbind;
2420
- }
2421
- bindGlobal(options) {
2422
- const documents = /* @__PURE__ */ new Set();
2423
- for (const draggable of this.manager.registry.draggables.value) {
2424
- if (draggable.element) {
2425
- documents.add((0, import_utilities.getDocument)(draggable.element));
2426
- }
2427
- }
2428
- for (const droppable of this.manager.registry.droppables.value) {
2429
- if (droppable.element) {
2430
- documents.add((0, import_utilities.getDocument)(droppable.element));
2431
- }
2432
- }
2433
- const unbindFns = Array.from(documents).map(
2434
- (doc) => this.listeners.bind(doc, [
2435
- {
2436
- type: "pointermove",
2437
- listener: (event) => this.handlePointerMove(event, doc, options)
2438
- },
2439
- {
2440
- type: "pointerup",
2441
- listener: this.handlePointerUp,
2442
- options: {
2443
- capture: true
2444
- }
2445
- },
2446
- {
2447
- // Cancel activation if there is a competing Drag and Drop interaction
2448
- type: "dragstart",
2449
- listener: this.handleDragStart
2450
- }
2451
- ])
2452
- );
2453
- return () => {
2454
- unbindFns.forEach((unbind) => unbind());
2455
- };
2456
- }
2457
- handlePointerDown(event, source, options = {}) {
2458
- if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
2459
- return;
2460
- }
2461
- const offset = (0, import_utilities.getFrameTransform)(source.element);
2462
- this.initialCoordinates = {
2463
- x: event.clientX * offset.scaleX + offset.x,
2464
- y: event.clientY * offset.scaleY + offset.y
2465
- };
2466
- this.source = source;
2467
- const { activationConstraints } = options;
2468
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
2469
- event.stopImmediatePropagation();
2470
- if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
2471
- this.handleStart(source, event);
2472
- } else {
2473
- const { delay } = constraints;
2474
- if (delay) {
2475
- const timeout3 = setTimeout(
2476
- () => this.handleStart(source, event),
2477
- delay.value
2478
- );
2479
- __privateSet(this, _clearTimeout, () => {
2480
- clearTimeout(timeout3);
2481
- __privateSet(this, _clearTimeout, void 0);
2482
- });
2483
- }
2484
- }
2485
- const cleanup = () => {
2486
- var _a;
2487
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2488
- this.initialCoordinates = void 0;
2489
- this.source = void 0;
2490
- };
2491
- this.cleanup.add(cleanup);
2492
- }
2493
- handlePointerMove(event, doc, options) {
2494
- if (!this.source) {
2495
- return;
2496
- }
2497
- const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
2498
- if (doc !== ownerDocument) {
2499
- return;
2500
- }
2501
- const coordinates = {
2502
- x: event.clientX,
2503
- y: event.clientY
2504
- };
2505
- const offset = (0, import_utilities.getFrameTransform)(this.source.element);
2506
- coordinates.x = coordinates.x * offset.scaleX + offset.x;
2507
- coordinates.y = coordinates.y * offset.scaleY + offset.y;
2508
- if (this.manager.dragOperation.status.dragging) {
2509
- event.preventDefault();
2510
- event.stopPropagation();
2511
- this.manager.actions.move({ to: coordinates });
2512
- return;
2513
- }
2514
- if (!this.initialCoordinates) {
2515
- return;
2516
- }
2517
- const delta = {
2518
- x: coordinates.x - this.initialCoordinates.x,
2519
- y: coordinates.y - this.initialCoordinates.y
2520
- };
2521
- const { activationConstraints } = options;
2522
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
2523
- const { distance, delay } = constraints != null ? constraints : {};
2524
- if (distance) {
2525
- if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
2526
- return this.handleCancel();
2527
- }
2528
- if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
2529
- return this.handleStart(this.source, event);
2530
- }
2531
- }
2532
- if (delay) {
2533
- if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
2534
- return this.handleCancel();
2535
- }
2536
- }
2537
- }
2538
- handlePointerUp(event) {
2539
- if (!this.source) {
2540
- return;
2541
- }
2542
- event.preventDefault();
2543
- event.stopPropagation();
2544
- const { status } = this.manager.dragOperation;
2545
- if (!status.idle) {
2546
- const canceled = !status.initialized;
2547
- this.manager.actions.stop({ canceled });
2548
- } else if (this.started) {
2549
- setTimeout(() => {
2550
- if (!this.manager.dragOperation.status.idle) {
2551
- this.manager.actions.stop({ canceled: false });
2552
- }
2553
- }, 10);
2554
- }
2555
- this.cleanup.forEach((cleanup) => cleanup());
2556
- this.cleanup.clear();
2557
- }
2558
- handleKeyDown(event) {
2559
- if (event.key === "Escape") {
2560
- event.preventDefault();
2561
- this.handleCancel();
2562
- }
2563
- }
2564
- handleStart(source, event) {
2565
- var _a;
2566
- const { manager, initialCoordinates } = this;
2567
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2568
- if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2569
- return;
2570
- }
2571
- if (event.defaultPrevented) {
2572
- return;
2573
- }
2574
- this.started = true;
2575
- event.preventDefault();
2576
- (0, import_state.batch)(() => {
2577
- manager.actions.setDragSource(source.id);
2578
- manager.actions.start({ coordinates: initialCoordinates, event });
2579
- });
2580
- const ownerDocument = (0, import_utilities.getDocument)(event.target);
2581
- const unbind = this.listeners.bind(ownerDocument, [
2582
- {
2583
- // Prevent scrolling on touch devices
2584
- type: "touchmove",
2585
- listener: preventDefault,
2586
- options: {
2587
- passive: false
2588
- }
2589
- },
2590
- {
2591
- // Prevent click events
2592
- type: "click",
2593
- listener: preventDefault
2594
- },
2595
- {
2596
- type: "keydown",
2597
- listener: this.handleKeyDown
2598
- }
2599
- ]);
2600
- ownerDocument.body.setPointerCapture(event.pointerId);
2601
- this.cleanup.add(unbind);
2602
- this.cleanup.add(() => {
2603
- this.started = false;
2604
- });
2605
- }
2606
- handleDragStart(event) {
2607
- const { target } = event;
2608
- if (!(0, import_utilities.isElement)(target)) {
2609
- return;
2610
- }
2611
- const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
2612
- if (isNativeDraggable) {
2613
- this.handleCancel();
2614
- } else {
2615
- preventDefault(event);
2616
- }
2617
- }
2618
- handleCancel() {
2619
- const { dragOperation } = this.manager;
2620
- if (dragOperation.status.initialized) {
2621
- this.manager.actions.stop({ canceled: true });
2622
- }
2623
- this.cleanup.forEach((cleanup) => cleanup());
2624
- this.cleanup.clear();
2625
- }
2626
- destroy() {
2627
- this.listeners.clear();
2628
- }
2629
- };
2630
- _clearTimeout = new WeakMap();
2631
- _PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
2632
- var PointerSensor = _PointerSensor;
2633
- function preventDefault(event) {
2634
- event.preventDefault();
2635
- }
2636
- function noop() {
2637
- }
2638
- var windows = /* @__PURE__ */ new WeakSet();
2639
- function patchWindow(window2) {
2640
- if (!window2 || windows.has(window2)) {
2641
- return;
2642
- }
2643
- window2.addEventListener("touchmove", noop, {
2644
- capture: false,
2645
- passive: false
2646
- });
2647
- windows.add(window2);
2648
- }
2649
-
2650
- // lib/dnd/use-sensors.ts
2651
- var import_utilities2 = require("@dnd-kit/dom/utilities");
2652
- var useSensors = ({
2653
- other,
2654
- mouse,
2655
- touch
2656
- } = {
2657
- touch: { delay: { value: 200, tolerance: 10 } },
2658
- other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
2659
- }) => {
2660
- const [sensors] = (0, import_react11.useState)(() => [
2661
- PointerSensor.configure({
2662
- activationConstraints(event, source) {
2663
- var _a;
2664
- const { pointerType, target } = event;
2665
- if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2666
- return mouse;
2667
- }
2668
- if (pointerType === "touch") {
2669
- return touch;
2670
- }
2671
- return other;
2672
- }
2673
- })
2674
- ]);
2675
- return sensors;
2676
- };
2677
-
2678
- // lib/dnd/collision/dynamic/index.ts
2679
- init_react_import();
2680
- var import_abstract9 = require("@dnd-kit/abstract");
2681
-
2682
- // lib/dnd/collision/directional/index.ts
2683
- init_react_import();
2684
- var import_abstract2 = require("@dnd-kit/abstract");
2685
-
2686
- // lib/dnd/collision/collision-debug.ts
2687
- init_react_import();
2688
- var DEBUG = false;
2689
- var debugElements = {};
2690
- var timeout;
2691
- var collisionDebug = (a, b, id, color, label) => {
2692
- if (!DEBUG) return;
2693
- const debugId = `${id}-debug`;
2694
- clearTimeout(timeout);
2695
- timeout = setTimeout(() => {
2696
- Object.entries(debugElements).forEach(([id2, { svg }]) => {
2697
- svg.remove();
2698
- delete debugElements[id2];
2699
- });
2700
- }, 1e3);
2701
- requestAnimationFrame(() => {
2702
- var _a, _b;
2703
- const existingEl = debugElements[debugId];
2704
- let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
2705
- let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
2706
- if (!existingEl) {
2707
- const svgNs = "http://www.w3.org/2000/svg";
2708
- const svg = document.createElementNS(svgNs, "svg");
2709
- line = document.createElementNS(svgNs, "line");
2710
- text = document.createElementNS(svgNs, "text");
2711
- svg.setAttribute("id", debugId);
2712
- svg.setAttribute(
2713
- "style",
2714
- "position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
2715
- );
2716
- svg.appendChild(line);
2717
- svg.appendChild(text);
2718
- text.setAttribute("fill", `black`);
2719
- document.body.appendChild(svg);
2720
- debugElements[debugId] = { svg, line, text };
2521
+ }, 1e3);
2522
+ requestAnimationFrame(() => {
2523
+ var _a, _b;
2524
+ const existingEl = debugElements[debugId];
2525
+ let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
2526
+ let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
2527
+ if (!existingEl) {
2528
+ const svgNs = "http://www.w3.org/2000/svg";
2529
+ const svg = document.createElementNS(svgNs, "svg");
2530
+ line = document.createElementNS(svgNs, "line");
2531
+ text = document.createElementNS(svgNs, "text");
2532
+ svg.setAttribute("id", debugId);
2533
+ svg.setAttribute(
2534
+ "style",
2535
+ "position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
2536
+ );
2537
+ svg.appendChild(line);
2538
+ svg.appendChild(text);
2539
+ text.setAttribute("fill", `black`);
2540
+ document.body.appendChild(svg);
2541
+ debugElements[debugId] = { svg, line, text };
2721
2542
  }
2722
2543
  line.setAttribute("x1", a.x.toString());
2723
2544
  line.setAttribute("x2", b.x.toString());
@@ -2759,7 +2580,7 @@ var directionalCollision = (input, previous) => {
2759
2580
  return {
2760
2581
  id: droppable.id,
2761
2582
  value: 1,
2762
- type: import_abstract2.CollisionType.Collision
2583
+ type: import_abstract.CollisionType.Collision
2763
2584
  };
2764
2585
  }
2765
2586
  return null;
@@ -2801,7 +2622,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2801
2622
 
2802
2623
  // lib/dnd/collision/dynamic/track-movement-interval.ts
2803
2624
  init_react_import();
2804
- var import_geometry2 = require("@dnd-kit/geometry");
2625
+ var import_geometry = require("@dnd-kit/geometry");
2805
2626
  var INTERVAL_SENSITIVITY = 10;
2806
2627
  var intervalCache = {
2807
2628
  current: { x: 0, y: 0 },
@@ -2817,13 +2638,15 @@ var trackMovementInterval = (point, dragAxis = "dynamic") => {
2817
2638
  };
2818
2639
  intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
2819
2640
  if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
2820
- intervalCache.previous = import_geometry2.Point.from(point);
2641
+ intervalCache.previous = import_geometry.Point.from(point);
2821
2642
  }
2822
2643
  return intervalCache;
2823
2644
  };
2824
2645
 
2825
2646
  // ../../node_modules/@dnd-kit/collision/dist/index.js
2826
2647
  init_react_import();
2648
+ var import_abstract2 = require("@dnd-kit/abstract");
2649
+ var import_geometry2 = require("@dnd-kit/geometry");
2827
2650
  var import_abstract3 = require("@dnd-kit/abstract");
2828
2651
  var import_geometry3 = require("@dnd-kit/geometry");
2829
2652
  var import_abstract4 = require("@dnd-kit/abstract");
@@ -2834,8 +2657,6 @@ var import_abstract6 = require("@dnd-kit/abstract");
2834
2657
  var import_geometry6 = require("@dnd-kit/geometry");
2835
2658
  var import_abstract7 = require("@dnd-kit/abstract");
2836
2659
  var import_geometry7 = require("@dnd-kit/geometry");
2837
- var import_abstract8 = require("@dnd-kit/abstract");
2838
- var import_geometry8 = require("@dnd-kit/geometry");
2839
2660
  var pointerIntersection = ({
2840
2661
  dragOperation,
2841
2662
  droppable
@@ -2849,12 +2670,12 @@ var pointerIntersection = ({
2849
2670
  return null;
2850
2671
  }
2851
2672
  if (droppable.shape.containsPoint(pointerCoordinates)) {
2852
- const distance = import_geometry3.Point.distance(droppable.shape.center, pointerCoordinates);
2673
+ const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
2853
2674
  return {
2854
2675
  id,
2855
2676
  value: 1 / distance,
2856
- type: import_abstract3.CollisionType.PointerIntersection,
2857
- priority: import_abstract3.CollisionPriority.High
2677
+ type: import_abstract2.CollisionType.PointerIntersection,
2678
+ priority: import_abstract2.CollisionPriority.High
2858
2679
  };
2859
2680
  }
2860
2681
  return null;
@@ -2865,31 +2686,15 @@ var closestCorners = (input) => {
2865
2686
  if (!droppable.shape) {
2866
2687
  return null;
2867
2688
  }
2868
- const { left, top, right, bottom } = droppable.shape.boundingRectangle;
2869
- const corners = [
2870
- {
2871
- x: left,
2872
- y: top
2873
- },
2874
- {
2875
- x: right,
2876
- y: top
2877
- },
2878
- {
2879
- x: left,
2880
- y: bottom
2881
- },
2882
- {
2883
- x: right,
2884
- y: bottom
2885
- }
2886
- ];
2887
- const distance = corners.reduce(
2888
- (acc, corner) => {
2689
+ const shapeCorners = shape ? import_geometry4.Rectangle.from(shape.current.boundingRectangle).corners : void 0;
2690
+ const distance = import_geometry4.Rectangle.from(
2691
+ droppable.shape.boundingRectangle
2692
+ ).corners.reduce(
2693
+ (acc, corner, index) => {
2889
2694
  var _a;
2890
- return acc + import_geometry5.Point.distance(
2891
- import_geometry5.Point.from(corner),
2892
- (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
2695
+ return acc + import_geometry4.Point.distance(
2696
+ import_geometry4.Point.from(corner),
2697
+ (_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
2893
2698
  );
2894
2699
  },
2895
2700
  0
@@ -2898,8 +2703,8 @@ var closestCorners = (input) => {
2898
2703
  return {
2899
2704
  id: droppable.id,
2900
2705
  value: 1 / value,
2901
- type: import_abstract5.CollisionType.Collision,
2902
- priority: import_abstract5.CollisionPriority.Normal
2706
+ type: import_abstract4.CollisionType.Collision,
2707
+ priority: import_abstract4.CollisionPriority.Normal
2903
2708
  };
2904
2709
  };
2905
2710
 
@@ -2924,12 +2729,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2924
2729
  const { center: dragCenter } = dragShape;
2925
2730
  const { fallbackEnabled } = collisionStore.getState();
2926
2731
  const interval = trackMovementInterval(position.current, dragAxis);
2927
- dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2928
- direction: interval.direction
2929
- });
2930
- const collisionMap = dragOperation.data.collisionMap || {};
2931
- dragOperation.data.collisionMap = collisionMap;
2932
- collisionMap[droppable.id] = {
2732
+ const data = {
2933
2733
  direction: interval.direction
2934
2734
  };
2935
2735
  const { center: dropCenter } = dropShape;
@@ -2944,7 +2744,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2944
2744
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
2945
2745
  if (collision) {
2946
2746
  return __spreadProps(__spreadValues({}, collision), {
2947
- priority: import_abstract9.CollisionPriority.Highest
2747
+ priority: import_abstract8.CollisionPriority.Highest,
2748
+ data
2948
2749
  });
2949
2750
  }
2950
2751
  }
@@ -2961,12 +2762,12 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2961
2762
  const collision = {
2962
2763
  id: droppable.id,
2963
2764
  value: intersectionRatio,
2964
- priority: import_abstract9.CollisionPriority.High,
2965
- type: import_abstract9.CollisionType.Collision
2765
+ priority: import_abstract8.CollisionPriority.High,
2766
+ type: import_abstract8.CollisionType.Collision
2966
2767
  };
2967
2768
  const shouldFlushId = flushNext === droppable.id;
2968
2769
  flushNext = "";
2969
- return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2770
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
2970
2771
  }
2971
2772
  if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2972
2773
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
@@ -2978,9 +2779,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2978
2779
  x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
2979
2780
  y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
2980
2781
  });
2981
- collisionMap[droppable.id] = {
2982
- direction
2983
- };
2782
+ data.direction = direction;
2984
2783
  if (intersectionArea) {
2985
2784
  collisionDebug(
2986
2785
  dragCenter,
@@ -2991,7 +2790,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2991
2790
  );
2992
2791
  flushNext = droppable.id;
2993
2792
  return __spreadProps(__spreadValues({}, fallbackCollision), {
2994
- priority: import_abstract9.CollisionPriority.Low
2793
+ priority: import_abstract8.CollisionPriority.Low,
2794
+ data
2995
2795
  });
2996
2796
  }
2997
2797
  collisionDebug(
@@ -3001,16 +2801,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3001
2801
  "orange",
3002
2802
  direction || ""
3003
2803
  );
3004
- return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract9.CollisionPriority.Lowest });
2804
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2805
+ priority: import_abstract8.CollisionPriority.Lowest,
2806
+ data
2807
+ });
3005
2808
  }
3006
2809
  }
3007
2810
  }
3008
2811
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
3009
- delete collisionMap[droppable.id];
3010
2812
  return null;
3011
2813
  };
3012
2814
 
3013
2815
  // components/Sortable/index.tsx
2816
+ var import_sortable = require("@dnd-kit/react/sortable");
3014
2817
  var import_jsx_runtime5 = require("react/jsx-runtime");
3015
2818
  var SortableProvider = ({
3016
2819
  children,
@@ -3030,16 +2833,16 @@ var SortableProvider = ({
3030
2833
  return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
3031
2834
  },
3032
2835
  onDragOver: (event, manager) => {
3033
- var _a, _b;
2836
+ var _a;
3034
2837
  event.preventDefault();
3035
2838
  const { operation } = event;
3036
2839
  const { source, target } = operation;
3037
2840
  if (!source || !target) return;
3038
2841
  let sourceIndex = source.data.index;
3039
2842
  let targetIndex = target.data.index;
3040
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2843
+ const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
3041
2844
  if (sourceIndex !== targetIndex && source.id !== target.id) {
3042
- const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2845
+ const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
3043
2846
  if (targetIndex >= sourceIndex) {
3044
2847
  targetIndex = targetIndex - 1;
3045
2848
  }
@@ -3070,9 +2873,10 @@ var Sortable = ({
3070
2873
  }) => {
3071
2874
  const {
3072
2875
  ref: sortableRef,
3073
- status,
2876
+ isDragging,
2877
+ isDropping,
3074
2878
  handleRef
3075
- } = useSortableSafe({
2879
+ } = (0, import_sortable.useSortable)({
3076
2880
  id,
3077
2881
  type,
3078
2882
  index,
@@ -3080,7 +2884,7 @@ var Sortable = ({
3080
2884
  data: { index },
3081
2885
  collisionDetector: createDynamicCollisionDetector("y")
3082
2886
  });
3083
- return children({ status, ref: sortableRef, handleRef });
2887
+ return children({ isDragging, isDropping, ref: sortableRef, handleRef });
3084
2888
  };
3085
2889
 
3086
2890
  // components/AutoField/context.tsx
@@ -3205,12 +3009,25 @@ var ArrayField = ({
3205
3009
  }
3206
3010
  }, []);
3207
3011
  const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
3208
- const isDragging = !!draggedItem;
3012
+ const isDraggingAny = !!draggedItem;
3209
3013
  const canEdit = useAppStore(
3210
3014
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
3211
3015
  );
3212
3016
  const forceReadOnly = !canEdit;
3213
3017
  const valueRef = (0, import_react14.useRef)(value);
3018
+ const uniqifyItem = (0, import_react14.useCallback)(
3019
+ (val) => {
3020
+ if (field.type !== "array" || !field.arrayFields) return;
3021
+ const config = appStore.getState().config;
3022
+ return walkField({
3023
+ value: val,
3024
+ fields: field.arrayFields,
3025
+ map: (content) => content.map((item) => populateIds(item, config, true)),
3026
+ config
3027
+ });
3028
+ },
3029
+ [appStore, field]
3030
+ );
3214
3031
  if (field.type !== "array" || !field.arrayFields) {
3215
3032
  return null;
3216
3033
  }
@@ -3270,13 +3087,13 @@ var ArrayField = ({
3270
3087
  id: _arrayId,
3271
3088
  index: i,
3272
3089
  disabled: readOnly,
3273
- children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3090
+ children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3274
3091
  "div",
3275
3092
  {
3276
3093
  ref,
3277
3094
  className: getClassNameItem({
3278
3095
  isExpanded: arrayState.openId === _arrayId,
3279
- isDragging: status === "dragging",
3096
+ isDragging,
3280
3097
  readOnly
3281
3098
  }),
3282
3099
  children: [
@@ -3315,11 +3132,10 @@ var ArrayField = ({
3315
3132
  onClick: (e) => {
3316
3133
  e.stopPropagation();
3317
3134
  const existingValue = [...value || []];
3318
- existingValue.splice(
3319
- i,
3320
- 0,
3135
+ const newItem = uniqifyItem(
3321
3136
  existingValue[i]
3322
3137
  );
3138
+ existingValue.splice(i, 0, newItem);
3323
3139
  const newUi = mapArrayStateToUi(
3324
3140
  regenerateArrayState(existingValue)
3325
3141
  );
@@ -3417,12 +3233,11 @@ var ArrayField = ({
3417
3233
  type: "button",
3418
3234
  className: getClassName5("addButton"),
3419
3235
  onClick: () => {
3420
- if (isDragging) return;
3236
+ var _a;
3237
+ if (isDraggingAny) return;
3421
3238
  const existingValue = value || [];
3422
- const newValue = [
3423
- ...existingValue,
3424
- field.defaultItemProps || {}
3425
- ];
3239
+ const newItem = uniqifyItem((_a = field.defaultItemProps) != null ? _a : {});
3240
+ const newValue = [...existingValue, newItem];
3426
3241
  const newArrayState = regenerateArrayState(newValue);
3427
3242
  setUi(mapArrayStateToUi(newArrayState), false);
3428
3243
  onChange(newValue);
@@ -4316,6 +4131,10 @@ function AutoFieldInternal(props) {
4316
4131
  });
4317
4132
  }
4318
4133
  }, []);
4134
+ const { visible = true } = props.field;
4135
+ if (!visible) {
4136
+ return null;
4137
+ }
4319
4138
  if (field.type === "slot") {
4320
4139
  return null;
4321
4140
  }
@@ -4400,24 +4219,24 @@ init_react_import();
4400
4219
 
4401
4220
  // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
4402
4221
  init_react_import();
4403
- 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" };
4222
+ 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" };
4404
4223
 
4405
4224
  // components/Drawer/index.tsx
4406
- var import_react37 = require("react");
4225
+ var import_react39 = require("react");
4407
4226
 
4408
4227
  // components/DragDropContext/index.tsx
4409
4228
  init_react_import();
4410
- var import_react35 = require("@dnd-kit/react");
4411
- var import_react36 = require("react");
4229
+ var import_react37 = require("@dnd-kit/react");
4230
+ var import_react38 = require("react");
4412
4231
  var import_dom = require("@dnd-kit/dom");
4413
4232
 
4414
4233
  // components/DropZone/index.tsx
4415
4234
  init_react_import();
4416
- var import_react34 = require("react");
4235
+ var import_react35 = require("react");
4417
4236
 
4418
4237
  // components/DraggableComponent/index.tsx
4419
4238
  init_react_import();
4420
- var import_react25 = require("react");
4239
+ var import_react26 = require("react");
4421
4240
 
4422
4241
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4423
4242
  init_react_import();
@@ -4458,7 +4277,9 @@ var ZoneStoreContext = (0, import_react23.createContext)(
4458
4277
  areaDepthIndex: {},
4459
4278
  nextAreaDepthIndex: {},
4460
4279
  draggedItem: null,
4461
- previewIndex: {}
4280
+ previewIndex: {},
4281
+ enabledIndex: {},
4282
+ hoveringComponent: null
4462
4283
  }))
4463
4284
  );
4464
4285
  var ZoneStoreProvider = ({
@@ -4471,7 +4292,6 @@ var DropZoneProvider = ({
4471
4292
  children,
4472
4293
  value
4473
4294
  }) => {
4474
- const [hoveringComponent, setHoveringComponent] = (0, import_react23.useState)();
4475
4295
  const dispatch = useAppStore((s) => s.dispatch);
4476
4296
  const registerZone = (0, import_react23.useCallback)(
4477
4297
  (zoneCompound) => {
@@ -4493,16 +4313,33 @@ var DropZoneProvider = ({
4493
4313
  );
4494
4314
  const memoValue = (0, import_react23.useMemo)(
4495
4315
  () => __spreadValues({
4496
- hoveringComponent,
4497
- setHoveringComponent,
4498
4316
  registerZone,
4499
4317
  unregisterZone
4500
4318
  }, value),
4501
- [value, hoveringComponent]
4319
+ [value]
4502
4320
  );
4503
4321
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4504
4322
  };
4505
4323
 
4324
+ // components/DraggableComponent/index.tsx
4325
+ var import_shallow2 = require("zustand/react/shallow");
4326
+ var import_sortable2 = require("@dnd-kit/react/sortable");
4327
+
4328
+ // lib/accumulate-transform.ts
4329
+ init_react_import();
4330
+ function accumulateTransform(el) {
4331
+ let matrix = new DOMMatrixReadOnly();
4332
+ let n = el.parentElement;
4333
+ while (n && n !== document.documentElement) {
4334
+ const t = getComputedStyle(n).transform;
4335
+ if (t && t !== "none") {
4336
+ matrix = new DOMMatrixReadOnly(t).multiply(matrix);
4337
+ }
4338
+ n = n.parentElement;
4339
+ }
4340
+ return { scaleX: matrix.a, scaleY: matrix.d };
4341
+ }
4342
+
4506
4343
  // lib/use-context-store.ts
4507
4344
  init_react_import();
4508
4345
  var import_react24 = require("react");
@@ -4516,8 +4353,39 @@ function useContextStore(context, selector) {
4516
4353
  return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
4517
4354
  }
4518
4355
 
4356
+ // lib/dnd/use-on-drag-finished.ts
4357
+ init_react_import();
4358
+ var import_react25 = require("react");
4359
+ var useOnDragFinished = (cb, deps = []) => {
4360
+ const appStore = useAppStoreApi();
4361
+ return (0, import_react25.useCallback)(() => {
4362
+ let dispose = () => {
4363
+ };
4364
+ const processDragging = (isDragging2) => {
4365
+ if (isDragging2) {
4366
+ cb(false);
4367
+ } else {
4368
+ setTimeout(() => {
4369
+ cb(true);
4370
+ }, 0);
4371
+ if (dispose) dispose();
4372
+ }
4373
+ };
4374
+ const isDragging = appStore.getState().state.ui.isDragging;
4375
+ processDragging(isDragging);
4376
+ if (isDragging) {
4377
+ dispose = appStore.subscribe(
4378
+ (s) => s.state.ui.isDragging,
4379
+ (isDragging2) => {
4380
+ processDragging(isDragging2);
4381
+ }
4382
+ );
4383
+ }
4384
+ return dispose;
4385
+ }, [appStore, ...deps]);
4386
+ };
4387
+
4519
4388
  // components/DraggableComponent/index.tsx
4520
- var import_shallow2 = require("zustand/react/shallow");
4521
4389
  var import_jsx_runtime20 = require("react/jsx-runtime");
4522
4390
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
4523
4391
  var DEBUG2 = false;
@@ -4547,7 +4415,6 @@ var DraggableComponent = ({
4547
4415
  isSelected = false,
4548
4416
  debug,
4549
4417
  label,
4550
- isEnabled,
4551
4418
  autoDragAxis,
4552
4419
  userDragAxis,
4553
4420
  inDroppableZone = true
@@ -4561,9 +4428,9 @@ var DraggableComponent = ({
4561
4428
  const overrides = useAppStore((s) => s.overrides);
4562
4429
  const dispatch = useAppStore((s) => s.dispatch);
4563
4430
  const iframe = useAppStore((s) => s.iframe);
4564
- const ctx = (0, import_react25.useContext)(dropZoneContext);
4565
- const [localZones, setLocalZones] = (0, import_react25.useState)({});
4566
- const registerLocalZone = (0, import_react25.useCallback)(
4431
+ const ctx = (0, import_react26.useContext)(dropZoneContext);
4432
+ const [localZones, setLocalZones] = (0, import_react26.useState)({});
4433
+ const registerLocalZone = (0, import_react26.useCallback)(
4567
4434
  (zoneCompound2, active) => {
4568
4435
  var _a;
4569
4436
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4573,7 +4440,7 @@ var DraggableComponent = ({
4573
4440
  },
4574
4441
  [setLocalZones]
4575
4442
  );
4576
- const unregisterLocalZone = (0, import_react25.useCallback)(
4443
+ const unregisterLocalZone = (0, import_react26.useCallback)(
4577
4444
  (zoneCompound2) => {
4578
4445
  var _a;
4579
4446
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4596,14 +4463,17 @@ var DraggableComponent = ({
4596
4463
  return s.permissions.getPermissions({ item });
4597
4464
  })
4598
4465
  );
4599
- const userIsDragging = useContextStore(
4600
- ZoneStoreContext,
4601
- (s) => !!s.draggedItem
4466
+ const zoneStore = (0, import_react26.useContext)(ZoneStoreContext);
4467
+ const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
4468
+ const dynamicCollisionDetector = (0, import_react26.useMemo)(
4469
+ () => createDynamicCollisionDetector(dragAxis),
4470
+ [dragAxis]
4602
4471
  );
4603
- const canCollide = permissions.drag || userIsDragging;
4604
- const disabled = !isEnabled || !canCollide;
4605
- const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
4606
- const { ref: sortableRef, status } = useSortableSafe({
4472
+ const {
4473
+ ref: sortableRef,
4474
+ isDragging: thisIsDragging,
4475
+ sortable
4476
+ } = (0, import_sortable2.useSortable)({
4607
4477
  id,
4608
4478
  index,
4609
4479
  group: zoneCompound,
@@ -4618,18 +4488,34 @@ var DraggableComponent = ({
4618
4488
  path: path || [],
4619
4489
  inDroppableZone
4620
4490
  },
4621
- collisionPriority: isEnabled ? depth : 0,
4622
- collisionDetector: createDynamicCollisionDetector(dragAxis),
4623
- disabled,
4491
+ collisionPriority: depth,
4492
+ collisionDetector: dynamicCollisionDetector,
4624
4493
  // "Out of the way" transition from react-beautiful-dnd
4625
4494
  transition: {
4626
4495
  duration: 200,
4627
4496
  easing: "cubic-bezier(0.2, 0, 0, 1)"
4628
- }
4497
+ },
4498
+ feedback: "clone"
4629
4499
  });
4630
- const thisIsDragging = status === "dragging";
4631
- const ref = (0, import_react25.useRef)(null);
4632
- const refSetter = (0, import_react25.useCallback)(
4500
+ (0, import_react26.useEffect)(() => {
4501
+ const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
4502
+ sortable.droppable.disabled = !isEnabled;
4503
+ sortable.draggable.disabled = !permissions.drag;
4504
+ const cleanup = zoneStore.subscribe((s) => {
4505
+ sortable.droppable.disabled = !s.enabledIndex[zoneCompound];
4506
+ });
4507
+ if (ref.current && !permissions.drag) {
4508
+ ref.current.setAttribute("data-puck-disabled", "");
4509
+ return () => {
4510
+ var _a;
4511
+ (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4512
+ cleanup();
4513
+ };
4514
+ }
4515
+ return cleanup;
4516
+ }, [permissions.drag, zoneCompound]);
4517
+ const ref = (0, import_react26.useRef)(null);
4518
+ const refSetter = (0, import_react26.useCallback)(
4633
4519
  (el) => {
4634
4520
  sortableRef(el);
4635
4521
  if (el) {
@@ -4638,14 +4524,14 @@ var DraggableComponent = ({
4638
4524
  },
4639
4525
  [sortableRef]
4640
4526
  );
4641
- const [portalEl, setPortalEl] = (0, import_react25.useState)();
4642
- (0, import_react25.useEffect)(() => {
4527
+ const [portalEl, setPortalEl] = (0, import_react26.useState)();
4528
+ (0, import_react26.useEffect)(() => {
4643
4529
  var _a, _b, _c;
4644
4530
  setPortalEl(
4645
4531
  iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
4646
4532
  );
4647
4533
  }, [iframe.enabled, ref.current]);
4648
- const getStyle = (0, import_react25.useCallback)(() => {
4534
+ const getStyle = (0, import_react26.useCallback)(() => {
4649
4535
  var _a, _b, _c;
4650
4536
  if (!ref.current) return;
4651
4537
  const rect = ref.current.getBoundingClientRect();
@@ -4657,40 +4543,61 @@ var DraggableComponent = ({
4657
4543
  x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
4658
4544
  y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
4659
4545
  };
4546
+ const untransformed = {
4547
+ height: ref.current.offsetHeight,
4548
+ width: ref.current.offsetWidth
4549
+ };
4550
+ const transform = accumulateTransform(ref.current);
4660
4551
  const style2 = {
4661
- left: `${rect.left + scroll.x}px`,
4662
- top: `${rect.top + scroll.y}px`,
4663
- height: `${rect.height}px`,
4664
- width: `${rect.width}px`
4552
+ left: `${(rect.left + scroll.x) / transform.scaleX}px`,
4553
+ top: `${(rect.top + scroll.y) / transform.scaleY}px`,
4554
+ height: `${untransformed.height}px`,
4555
+ width: `${untransformed.width}px`
4665
4556
  };
4666
4557
  return style2;
4667
4558
  }, [ref.current]);
4668
- const [style, setStyle] = (0, import_react25.useState)();
4669
- const sync = (0, import_react25.useCallback)(() => {
4559
+ const [style, setStyle] = (0, import_react26.useState)();
4560
+ const sync = (0, import_react26.useCallback)(() => {
4670
4561
  setStyle(getStyle());
4671
4562
  }, [ref.current, iframe]);
4672
- (0, import_react25.useEffect)(() => {
4673
- if (ref.current && !userIsDragging) {
4563
+ (0, import_react26.useEffect)(() => {
4564
+ if (ref.current) {
4674
4565
  const observer = new ResizeObserver(sync);
4675
4566
  observer.observe(ref.current);
4676
4567
  return () => {
4677
4568
  observer.disconnect();
4678
4569
  };
4679
4570
  }
4680
- }, [ref.current, userIsDragging]);
4571
+ }, [ref.current]);
4681
4572
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4682
- (0, import_react25.useEffect)(() => {
4573
+ const hideOverlay = (0, import_react26.useCallback)(() => {
4574
+ setIsVisible(false);
4575
+ }, []);
4576
+ const showOverlay = (0, import_react26.useCallback)(() => {
4577
+ setIsVisible(true);
4578
+ }, []);
4579
+ (0, import_react26.useEffect)(() => {
4683
4580
  var _a;
4684
- registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4581
+ registerNode(id, {
4582
+ methods: { sync, showOverlay, hideOverlay },
4583
+ element: (_a = ref.current) != null ? _a : null
4584
+ });
4685
4585
  return () => {
4686
- registerNode(id, { methods: { sync: () => null }, element: null });
4586
+ registerNode(id, {
4587
+ methods: {
4588
+ sync: () => null,
4589
+ hideOverlay: () => null,
4590
+ showOverlay: () => null
4591
+ },
4592
+ element: null
4593
+ });
4687
4594
  };
4688
4595
  }, [id, zoneCompound, index, componentType, sync]);
4689
- const CustomActionBar = (0, import_react25.useMemo)(
4596
+ const CustomActionBar = (0, import_react26.useMemo)(
4690
4597
  () => overrides.actionBar || DefaultActionBar,
4691
4598
  [overrides.actionBar]
4692
4599
  );
4693
- const onClick = (0, import_react25.useCallback)(
4600
+ const onClick = (0, import_react26.useCallback)(
4694
4601
  (e) => {
4695
4602
  e.stopPropagation();
4696
4603
  dispatch({
@@ -4703,7 +4610,7 @@ var DraggableComponent = ({
4703
4610
  [index, zoneCompound, id]
4704
4611
  );
4705
4612
  const appStore = useAppStoreApi();
4706
- const onSelectParent = (0, import_react25.useCallback)(() => {
4613
+ const onSelectParent = (0, import_react26.useCallback)(() => {
4707
4614
  const { nodes, zones } = appStore.getState().state.indexes;
4708
4615
  const node = nodes[id];
4709
4616
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4724,28 +4631,32 @@ var DraggableComponent = ({
4724
4631
  }
4725
4632
  });
4726
4633
  }, [ctx, path]);
4727
- const onDuplicate = (0, import_react25.useCallback)(() => {
4634
+ const onDuplicate = (0, import_react26.useCallback)(() => {
4728
4635
  dispatch({
4729
4636
  type: "duplicate",
4730
4637
  sourceIndex: index,
4731
4638
  sourceZone: zoneCompound
4732
4639
  });
4733
4640
  }, [index, zoneCompound]);
4734
- const onDelete = (0, import_react25.useCallback)(() => {
4641
+ const onDelete = (0, import_react26.useCallback)(() => {
4735
4642
  dispatch({
4736
4643
  type: "remove",
4737
4644
  index,
4738
4645
  zone: zoneCompound
4739
4646
  });
4740
4647
  }, [index, zoneCompound]);
4741
- const [hover, setHover] = (0, import_react25.useState)(false);
4742
- const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4743
- (0, import_react25.useEffect)(() => {
4648
+ const [hover, setHover] = (0, import_react26.useState)(false);
4649
+ const indicativeHover = useContextStore(
4650
+ ZoneStoreContext,
4651
+ (s) => s.hoveringComponent === id
4652
+ );
4653
+ (0, import_react26.useEffect)(() => {
4744
4654
  if (!ref.current) {
4745
4655
  return;
4746
4656
  }
4747
4657
  const el = ref.current;
4748
4658
  const _onMouseOver = (e) => {
4659
+ const userIsDragging = !!zoneStore.getState().draggedItem;
4749
4660
  if (userIsDragging) {
4750
4661
  if (thisIsDragging) {
4751
4662
  setHover(true);
@@ -4767,18 +4678,12 @@ var DraggableComponent = ({
4767
4678
  el.addEventListener("click", onClick);
4768
4679
  el.addEventListener("mouseover", _onMouseOver);
4769
4680
  el.addEventListener("mouseout", _onMouseOut);
4770
- if (thisIsDragging) {
4771
- el.setAttribute("data-puck-dragging", "");
4772
- } else {
4773
- el.removeAttribute("data-puck-dragging");
4774
- }
4775
4681
  return () => {
4776
4682
  el.removeAttribute("data-puck-component");
4777
4683
  el.removeAttribute("data-puck-dnd");
4778
4684
  el.removeEventListener("click", onClick);
4779
4685
  el.removeEventListener("mouseover", _onMouseOver);
4780
4686
  el.removeEventListener("mouseout", _onMouseOut);
4781
- el.removeAttribute("data-puck-dragging");
4782
4687
  };
4783
4688
  }, [
4784
4689
  ref,
@@ -4786,29 +4691,43 @@ var DraggableComponent = ({
4786
4691
  containsActiveZone,
4787
4692
  zoneCompound,
4788
4693
  id,
4789
- userIsDragging,
4790
4694
  thisIsDragging,
4791
4695
  inDroppableZone
4792
4696
  ]);
4793
- (0, import_react25.useEffect)(() => {
4794
- if (ref.current && disabled) {
4795
- ref.current.setAttribute("data-puck-disabled", "");
4796
- return () => {
4797
- var _a;
4798
- (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4799
- };
4800
- }
4801
- }, [disabled, ref]);
4802
- const [isVisible, setIsVisible] = (0, import_react25.useState)(false);
4803
- (0, import_react25.useEffect)(() => {
4804
- sync();
4805
- if ((isSelected || hover || indicativeHover) && !userIsDragging) {
4806
- setIsVisible(true);
4697
+ const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
4698
+ const [dragFinished, setDragFinished] = (0, import_react26.useState)(true);
4699
+ const [_, startTransition] = (0, import_react26.useTransition)();
4700
+ (0, import_react26.useEffect)(() => {
4701
+ startTransition(() => {
4702
+ if (hover || indicativeHover || isSelected) {
4703
+ sync();
4704
+ setIsVisible(true);
4705
+ setThisWasDragging(false);
4706
+ } else {
4707
+ setIsVisible(false);
4708
+ }
4709
+ });
4710
+ }, [hover, indicativeHover, isSelected, iframe]);
4711
+ const [thisWasDragging, setThisWasDragging] = (0, import_react26.useState)(false);
4712
+ const onDragFinished = useOnDragFinished((finished) => {
4713
+ if (finished) {
4714
+ startTransition(() => {
4715
+ sync();
4716
+ setDragFinished(true);
4717
+ });
4807
4718
  } else {
4808
- setIsVisible(false);
4719
+ setDragFinished(false);
4720
+ }
4721
+ });
4722
+ (0, import_react26.useEffect)(() => {
4723
+ if (thisIsDragging) {
4724
+ setThisWasDragging(true);
4809
4725
  }
4810
- }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
4811
- const syncActionsPosition = (0, import_react25.useCallback)(
4726
+ }, [thisIsDragging]);
4727
+ (0, import_react26.useEffect)(() => {
4728
+ if (thisWasDragging) return onDragFinished();
4729
+ }, [thisWasDragging, onDragFinished]);
4730
+ const syncActionsPosition = (0, import_react26.useCallback)(
4812
4731
  (el) => {
4813
4732
  if (el) {
4814
4733
  const view = el.ownerDocument.defaultView;
@@ -4833,7 +4752,7 @@ var DraggableComponent = ({
4833
4752
  },
4834
4753
  [zoom]
4835
4754
  );
4836
- (0, import_react25.useEffect)(() => {
4755
+ (0, import_react26.useEffect)(() => {
4837
4756
  if (userDragAxis) {
4838
4757
  setDragAxis(userDragAxis);
4839
4758
  return;
@@ -4847,8 +4766,11 @@ var DraggableComponent = ({
4847
4766
  }
4848
4767
  setDragAxis(autoDragAxis);
4849
4768
  }, [ref, userDragAxis, autoDragAxis]);
4850
- 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 }) });
4851
- const nextContextValue = (0, import_react25.useMemo)(
4769
+ const parentAction = (0, import_react26.useMemo)(
4770
+ () => (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 }) }),
4771
+ [ctx == null ? void 0 : ctx.areaId]
4772
+ );
4773
+ const nextContextValue = (0, import_react26.useMemo)(
4852
4774
  () => __spreadProps(__spreadValues({}, ctx), {
4853
4775
  areaId: id,
4854
4776
  zoneCompound,
@@ -4868,7 +4790,7 @@ var DraggableComponent = ({
4868
4790
  ]
4869
4791
  );
4870
4792
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
4871
- isVisible && (0, import_react_dom2.createPortal)(
4793
+ dragFinished && isVisible && (0, import_react_dom2.createPortal)(
4872
4794
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4873
4795
  "div",
4874
4796
  {
@@ -4928,19 +4850,23 @@ var DraggableComponent = ({
4928
4850
 
4929
4851
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
4930
4852
  init_react_import();
4931
- var styles_module_default12 = { "DropZone": "_DropZone_3dmev_1", "DropZone--hasChildren": "_DropZone--hasChildren_3dmev_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_3dmev_19", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_3dmev_23", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_3dmev_24", "DropZone--isRootZone": "_DropZone--isRootZone_3dmev_24", "DropZone--isDestination": "_DropZone--isDestination_3dmev_34", "DropZone-item": "_DropZone-item_3dmev_46", "DropZone-hitbox": "_DropZone-hitbox_3dmev_50", "DropZone--isEnabled": "_DropZone--isEnabled_3dmev_58", "DropZone--isAnimating": "_DropZone--isAnimating_3dmev_67" };
4853
+ var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
4854
+
4855
+ // components/DropZone/index.tsx
4856
+ var import_react36 = require("@dnd-kit/react");
4932
4857
 
4933
4858
  // components/DropZone/lib/use-min-empty-height.ts
4934
4859
  init_react_import();
4935
- var import_react26 = require("react");
4860
+ var import_react27 = require("react");
4861
+ var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
4936
4862
  var useMinEmptyHeight = ({
4937
4863
  zoneCompound,
4938
4864
  userMinEmptyHeight,
4939
4865
  ref
4940
4866
  }) => {
4941
4867
  const appStore = useAppStoreApi();
4942
- const [prevHeight, setPrevHeight] = (0, import_react26.useState)(0);
4943
- const [isAnimating, setIsAnimating] = (0, import_react26.useState)(false);
4868
+ const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
4869
+ const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
4944
4870
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
4945
4871
  var _a, _b;
4946
4872
  return {
@@ -4948,32 +4874,52 @@ var useMinEmptyHeight = ({
4948
4874
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4949
4875
  };
4950
4876
  });
4951
- (0, import_react26.useEffect)(() => {
4952
- if (draggedItem && ref.current) {
4953
- if (isZone) {
4954
- const rect = ref.current.getBoundingClientRect();
4955
- setPrevHeight(rect.height);
4956
- setIsAnimating(true);
4957
- return;
4958
- }
4959
- }
4960
- setPrevHeight(0);
4961
- setTimeout(() => {
4962
- var _a, _b;
4963
- const zones = appStore.getState().state.indexes.zones;
4964
- const nodes = appStore.getState().nodes;
4965
- const selectedItem = appStore.getState().selectedItem;
4966
- const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
4967
- contentIds.forEach((contentId) => {
4968
- const node = nodes.nodes[contentId];
4969
- node == null ? void 0 : node.methods.sync();
4970
- });
4971
- if (selectedItem) {
4972
- (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
4877
+ const numItems = (0, import_react27.useRef)(0);
4878
+ const onDragFinished = useOnDragFinished(
4879
+ (finished) => {
4880
+ var _a;
4881
+ if (finished) {
4882
+ const newNumItems = getNumItems(appStore, zoneCompound);
4883
+ setPrevHeight(0);
4884
+ if (newNumItems || numItems.current === 0) {
4885
+ setIsAnimating(false);
4886
+ return;
4887
+ }
4888
+ const selectedItem = appStore.getState().selectedItem;
4889
+ const zones = appStore.getState().state.indexes.zones;
4890
+ const nodes = appStore.getState().nodes;
4891
+ (_a = nodes.nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.methods.hideOverlay();
4892
+ setTimeout(() => {
4893
+ var _a2;
4894
+ const contentIds = ((_a2 = zones[zoneCompound]) == null ? void 0 : _a2.contentIds) || [];
4895
+ contentIds.forEach((contentId) => {
4896
+ const node = nodes.nodes[contentId];
4897
+ node == null ? void 0 : node.methods.sync();
4898
+ });
4899
+ if (selectedItem) {
4900
+ setTimeout(() => {
4901
+ var _a3, _b;
4902
+ (_a3 = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _a3.methods.sync();
4903
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.showOverlay();
4904
+ }, 200);
4905
+ }
4906
+ setIsAnimating(false);
4907
+ }, 100);
4908
+ }
4909
+ },
4910
+ [appStore, prevHeight, zoneCompound]
4911
+ );
4912
+ (0, import_react27.useEffect)(() => {
4913
+ if (draggedItem && ref.current) {
4914
+ if (isZone) {
4915
+ const rect = ref.current.getBoundingClientRect();
4916
+ numItems.current = getNumItems(appStore, zoneCompound);
4917
+ setPrevHeight(rect.height);
4918
+ setIsAnimating(true);
4919
+ return onDragFinished();
4973
4920
  }
4974
- setIsAnimating(false);
4975
- }, 400);
4976
- }, [ref.current, draggedItem, zoneCompound]);
4921
+ }
4922
+ }, [ref.current, draggedItem, onDragFinished]);
4977
4923
  return [prevHeight || userMinEmptyHeight, isAnimating];
4978
4924
  };
4979
4925
 
@@ -4994,15 +4940,15 @@ function assignRefs(refs, node) {
4994
4940
 
4995
4941
  // components/DropZone/lib/use-content-with-preview.ts
4996
4942
  init_react_import();
4997
- var import_react29 = require("react");
4943
+ var import_react30 = require("react");
4998
4944
 
4999
4945
  // lib/dnd/use-rendered-callback.ts
5000
4946
  init_react_import();
5001
- var import_react27 = require("@dnd-kit/react");
5002
- var import_react28 = require("react");
4947
+ var import_react28 = require("@dnd-kit/react");
4948
+ var import_react29 = require("react");
5003
4949
  function useRenderedCallback(callback, deps) {
5004
- const manager = (0, import_react27.useDragDropManager)();
5005
- return (0, import_react28.useCallback)(
4950
+ const manager = (0, import_react28.useDragDropManager)();
4951
+ return (0, import_react29.useCallback)(
5006
4952
  (...args) => __async(this, null, function* () {
5007
4953
  yield manager == null ? void 0 : manager.renderer.rendering;
5008
4954
  return callback(...args);
@@ -5013,27 +4959,21 @@ function useRenderedCallback(callback, deps) {
5013
4959
 
5014
4960
  // components/DropZone/lib/use-content-with-preview.ts
5015
4961
  var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5016
- const { draggedItemId, preview, previewExists } = useContextStore(
4962
+ const zoneStore = (0, import_react30.useContext)(ZoneStoreContext);
4963
+ const preview = useContextStore(
5017
4964
  ZoneStoreContext,
5018
- (s) => {
5019
- var _a;
5020
- return {
5021
- draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
5022
- preview: s.previewIndex[zoneCompound],
5023
- previewExists: Object.keys(s.previewIndex || {}).length > 0
5024
- };
5025
- }
4965
+ (s) => s.previewIndex[zoneCompound]
5026
4966
  );
5027
4967
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
5028
- const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react29.useState)(contentIds);
5029
- const [localPreview, setLocalPreview] = (0, import_react29.useState)(
4968
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
4969
+ const [localPreview, setLocalPreview] = (0, import_react30.useState)(
5030
4970
  preview
5031
4971
  );
5032
4972
  const updateContent = useRenderedCallback(
5033
- (contentIds2, preview2, isDragging2) => {
5034
- if (isDragging2 && !previewExists) {
5035
- return;
5036
- }
4973
+ (contentIds2, preview2) => {
4974
+ var _a;
4975
+ const s = zoneStore.getState();
4976
+ const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
5037
4977
  if (preview2) {
5038
4978
  if (preview2.type === "insert") {
5039
4979
  setContentIdsWithPreview(
@@ -5054,14 +4994,14 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5054
4994
  }
5055
4995
  } else {
5056
4996
  setContentIdsWithPreview(
5057
- previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
4997
+ contentIds2.filter((id) => id !== draggedItemId)
5058
4998
  );
5059
4999
  }
5060
5000
  setLocalPreview(preview2);
5061
5001
  },
5062
- [draggedItemId, previewExists]
5002
+ []
5063
5003
  );
5064
- (0, import_react29.useEffect)(() => {
5004
+ (0, import_react30.useEffect)(() => {
5065
5005
  updateContent(contentIds, preview, isDragging);
5066
5006
  }, [contentIds, preview, isDragging]);
5067
5007
  return [contentIdsWithPreview, localPreview];
@@ -5069,16 +5009,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5069
5009
 
5070
5010
  // components/DropZone/lib/use-drag-axis.ts
5071
5011
  init_react_import();
5072
- var import_react30 = require("react");
5012
+ var import_react31 = require("react");
5073
5013
  var GRID_DRAG_AXIS = "dynamic";
5074
5014
  var FLEX_ROW_DRAG_AXIS = "x";
5075
5015
  var DEFAULT_DRAG_AXIS = "y";
5076
5016
  var useDragAxis = (ref, collisionAxis) => {
5077
5017
  const status = useAppStore((s) => s.status);
5078
- const [dragAxis, setDragAxis] = (0, import_react30.useState)(
5018
+ const [dragAxis, setDragAxis] = (0, import_react31.useState)(
5079
5019
  collisionAxis || DEFAULT_DRAG_AXIS
5080
5020
  );
5081
- const calculateDragAxis = (0, import_react30.useCallback)(() => {
5021
+ const calculateDragAxis = (0, import_react31.useCallback)(() => {
5082
5022
  if (ref.current) {
5083
5023
  const computedStyle = window.getComputedStyle(ref.current);
5084
5024
  if (computedStyle.display === "grid") {
@@ -5090,7 +5030,7 @@ var useDragAxis = (ref, collisionAxis) => {
5090
5030
  }
5091
5031
  }
5092
5032
  }, [ref.current]);
5093
- (0, import_react30.useEffect)(() => {
5033
+ (0, import_react31.useEffect)(() => {
5094
5034
  const onViewportChange = () => {
5095
5035
  calculateDragAxis();
5096
5036
  };
@@ -5099,54 +5039,57 @@ var useDragAxis = (ref, collisionAxis) => {
5099
5039
  window.removeEventListener("viewportchange", onViewportChange);
5100
5040
  };
5101
5041
  }, []);
5102
- (0, import_react30.useEffect)(calculateDragAxis, [status, collisionAxis]);
5042
+ (0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
5103
5043
  return [dragAxis, calculateDragAxis];
5104
5044
  };
5105
5045
 
5106
5046
  // components/DropZone/index.tsx
5107
- var import_shallow3 = require("zustand/react/shallow");
5047
+ var import_shallow4 = require("zustand/react/shallow");
5108
5048
 
5109
5049
  // components/Render/index.tsx
5110
5050
  init_react_import();
5111
5051
 
5112
5052
  // lib/use-slots.tsx
5113
5053
  init_react_import();
5114
- var import_react31 = require("react");
5115
- function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5116
- const slotProps = (0, import_react31.useMemo)(() => {
5117
- if (!(config == null ? void 0 : config.fields)) return props;
5118
- const slotProps2 = {};
5119
- const fieldKeys = Object.keys(config.fields);
5120
- for (let i = 0; i < fieldKeys.length; i++) {
5121
- const fieldKey = fieldKeys[i];
5122
- const field = config.fields[fieldKey];
5123
- if ((field == null ? void 0 : field.type) === "slot") {
5124
- const content = props[fieldKey] || [];
5125
- const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
5054
+ var import_react32 = require("react");
5055
+ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5056
+ const slotProps = (0, import_react32.useMemo)(() => {
5057
+ const mapped = mapSlots(
5058
+ item,
5059
+ (content, _parentId, propName, field, propPath) => {
5060
+ const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
5061
+ const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
5062
+ const render = isReadOnly ? renderSlotRender : renderSlotEdit;
5126
5063
  const Slot = (dzProps) => render(__spreadProps(__spreadValues({
5127
- allow: field.allow,
5128
- disallow: field.disallow
5064
+ allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
5065
+ disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
5129
5066
  }, dzProps), {
5130
- zone: fieldKey,
5067
+ zone: propName,
5131
5068
  content
5132
5069
  }));
5133
- slotProps2[fieldKey] = Slot;
5134
- }
5135
- }
5136
- return slotProps2;
5137
- }, [config, readOnly, forceReadOnly]);
5138
- return __spreadValues(__spreadValues({}, props), slotProps);
5070
+ return Slot;
5071
+ },
5072
+ config
5073
+ ).props;
5074
+ return mapped;
5075
+ }, [config, item, readOnly, forceReadOnly]);
5076
+ const mergedProps = (0, import_react32.useMemo)(
5077
+ () => __spreadValues(__spreadValues({}, item.props), slotProps),
5078
+ [item.props, slotProps]
5079
+ );
5080
+ return mergedProps;
5139
5081
  }
5140
5082
 
5141
5083
  // components/Render/index.tsx
5142
- var import_react33 = __toESM(require("react"));
5084
+ var import_react34 = __toESM(require("react"));
5143
5085
 
5144
5086
  // components/SlotRender/index.tsx
5145
5087
  init_react_import();
5088
+ var import_shallow3 = require("zustand/react/shallow");
5146
5089
 
5147
5090
  // components/SlotRender/server.tsx
5148
5091
  init_react_import();
5149
- var import_react32 = require("react");
5092
+ var import_react33 = require("react");
5150
5093
 
5151
5094
  // components/ServerRender/index.tsx
5152
5095
  init_react_import();
@@ -5181,12 +5124,15 @@ function DropZoneRender({
5181
5124
  metadata
5182
5125
  }
5183
5126
  ),
5184
- metadata
5127
+ metadata,
5128
+ dragRef: null,
5129
+ isEditing: false
5185
5130
  }
5186
5131
  });
5187
- const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
5132
+ const renderItem = __spreadProps(__spreadValues({}, item), { props });
5133
+ const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
5188
5134
  if (Component) {
5189
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
5135
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
5190
5136
  }
5191
5137
  return null;
5192
5138
  }) });
@@ -5201,7 +5147,7 @@ var Item = ({
5201
5147
  metadata
5202
5148
  }) => {
5203
5149
  const Component = config.components[item.type];
5204
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5150
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5205
5151
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5206
5152
  Component.render,
5207
5153
  __spreadProps(__spreadValues({}, props), {
@@ -5212,7 +5158,7 @@ var Item = ({
5212
5158
  })
5213
5159
  );
5214
5160
  };
5215
- var SlotRender = (0, import_react32.forwardRef)(
5161
+ var SlotRender = (0, import_react33.forwardRef)(
5216
5162
  function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5217
5163
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
5218
5164
  if (!config.components[item.type]) {
@@ -5240,10 +5186,12 @@ var ContextSlotRender = ({
5240
5186
  const config = useAppStore((s) => s.config);
5241
5187
  const metadata = useAppStore((s) => s.metadata);
5242
5188
  const slotContent = useAppStore(
5243
- (s) => {
5189
+ (0, import_shallow3.useShallow)((s) => {
5244
5190
  var _a, _b;
5245
- return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
5246
- }
5191
+ const indexes = s.state.indexes;
5192
+ const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
5193
+ return contentIds.map((contentId) => indexes.nodes[contentId].flatData);
5194
+ })
5247
5195
  );
5248
5196
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5249
5197
  SlotRenderPure,
@@ -5258,7 +5206,7 @@ var ContextSlotRender = ({
5258
5206
 
5259
5207
  // components/Render/index.tsx
5260
5208
  var import_jsx_runtime24 = require("react/jsx-runtime");
5261
- var renderContext = import_react33.default.createContext({
5209
+ var renderContext = import_react34.default.createContext({
5262
5210
  config: { components: {} },
5263
5211
  data: { root: {}, content: [] },
5264
5212
  metadata: {}
@@ -5273,7 +5221,7 @@ function Render({
5273
5221
  root: data.root || {},
5274
5222
  content: data.content || []
5275
5223
  });
5276
- const rootProps = defaultedData.root.props || defaultedData.root;
5224
+ const rootProps = "props" in defaultedData.root ? defaultedData.root.props : defaultedData.root;
5277
5225
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
5278
5226
  const pageProps = __spreadProps(__spreadValues({}, rootProps), {
5279
5227
  puck: {
@@ -5286,8 +5234,12 @@ function Render({
5286
5234
  editMode: false,
5287
5235
  id: "puck-root"
5288
5236
  });
5289
- const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
5290
- const nextContextValue = (0, import_react33.useMemo)(
5237
+ const propsWithSlots = useSlots(
5238
+ config,
5239
+ { type: "root", props: pageProps },
5240
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
5241
+ );
5242
+ const nextContextValue = (0, import_react34.useMemo)(
5291
5243
  () => ({
5292
5244
  mode: "render",
5293
5245
  depth: 0
@@ -5309,19 +5261,18 @@ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5309
5261
  var DropZoneChild = ({
5310
5262
  zoneCompound,
5311
5263
  componentId,
5312
- preview,
5313
5264
  index,
5314
- isEnabled,
5315
5265
  dragAxis,
5316
5266
  collisionAxis,
5317
5267
  inDroppableZone
5318
5268
  }) => {
5319
5269
  var _a, _b;
5320
5270
  const metadata = useAppStore((s) => s.metadata);
5321
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5271
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5322
5272
  const { depth = 1 } = ctx != null ? ctx : {};
5273
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5323
5274
  const nodeProps = useAppStore(
5324
- (0, import_shallow3.useShallow)((s) => {
5275
+ (0, import_shallow4.useShallow)((s) => {
5325
5276
  var _a2;
5326
5277
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
5327
5278
  })
@@ -5333,22 +5284,42 @@ var DropZoneChild = ({
5333
5284
  }
5334
5285
  );
5335
5286
  const nodeReadOnly = useAppStore(
5336
- (0, import_shallow3.useShallow)((s) => {
5287
+ (0, import_shallow4.useShallow)((s) => {
5337
5288
  var _a2;
5338
5289
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
5339
5290
  })
5340
5291
  );
5341
- const node = { type: nodeType, props: nodeProps };
5342
- const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
5292
+ const appStore = useAppStoreApi();
5293
+ const item = (0, import_react35.useMemo)(() => {
5294
+ if (nodeProps) {
5295
+ const expanded = expandNode({
5296
+ type: nodeType,
5297
+ props: nodeProps
5298
+ });
5299
+ return expanded;
5300
+ }
5301
+ const preview = zoneStore.getState().previewIndex[zoneCompound];
5302
+ if (componentId === (preview == null ? void 0 : preview.props.id)) {
5303
+ return {
5304
+ type: preview.componentType,
5305
+ props: preview.props,
5306
+ previewType: preview.type
5307
+ };
5308
+ }
5309
+ return null;
5310
+ }, [appStore, componentId, zoneCompound, nodeType, nodeProps]);
5343
5311
  const componentConfig = useAppStore(
5344
5312
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5345
5313
  );
5346
- const puckProps = {
5347
- renderDropZone: DropZoneEditPure,
5348
- isEditing: true,
5349
- dragRef: null,
5350
- metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5351
- };
5314
+ const puckProps = (0, import_react35.useMemo)(
5315
+ () => ({
5316
+ renderDropZone: DropZoneEditPure,
5317
+ isEditing: true,
5318
+ dragRef: null,
5319
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5320
+ }),
5321
+ [metadata, componentConfig == null ? void 0 : componentConfig.metadata]
5322
+ );
5352
5323
  const overrides = useAppStore((s) => s.overrides);
5353
5324
  const isLoading = useAppStore(
5354
5325
  (s) => {
@@ -5363,13 +5334,13 @@ var DropZoneChild = ({
5363
5334
  }
5364
5335
  );
5365
5336
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5366
- const renderPreview = (0, import_react34.useMemo)(
5367
- () => function Preview4() {
5337
+ const renderPreview = (0, import_react35.useMemo)(
5338
+ () => function Preview3() {
5368
5339
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5369
5340
  },
5370
5341
  [componentId, label, overrides]
5371
5342
  );
5372
- const defaultsProps = (0, import_react34.useMemo)(
5343
+ const defaultsProps = (0, import_react35.useMemo)(
5373
5344
  () => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
5374
5345
  puck: puckProps,
5375
5346
  editMode: true
@@ -5377,9 +5348,17 @@ var DropZoneChild = ({
5377
5348
  }),
5378
5349
  [componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
5379
5350
  );
5351
+ const defaultedNode = (0, import_react35.useMemo)(
5352
+ () => {
5353
+ var _a2;
5354
+ return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
5355
+ },
5356
+ [item == null ? void 0 : item.type, nodeType, defaultsProps]
5357
+ );
5358
+ const config = useAppStore((s) => s.config);
5380
5359
  const defaultedPropsWithSlots = useSlots(
5381
- componentConfig,
5382
- defaultsProps,
5360
+ config,
5361
+ defaultedNode,
5383
5362
  DropZoneEditPure,
5384
5363
  (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
5385
5364
  nodeReadOnly,
@@ -5391,8 +5370,8 @@ var DropZoneChild = ({
5391
5370
  item.type
5392
5371
  ] });
5393
5372
  let componentType = item.type;
5394
- const isPreview = componentId === (preview == null ? void 0 : preview.props.id) && preview.type === "insert";
5395
- if (isPreview) {
5373
+ const isInserting = "previewType" in item ? item.previewType === "insert" : false;
5374
+ if (isInserting) {
5396
5375
  Render2 = renderPreview;
5397
5376
  }
5398
5377
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -5406,11 +5385,10 @@ var DropZoneChild = ({
5406
5385
  isLoading,
5407
5386
  isSelected,
5408
5387
  label,
5409
- isEnabled,
5410
5388
  autoDragAxis: dragAxis,
5411
5389
  userDragAxis: collisionAxis,
5412
5390
  inDroppableZone,
5413
- 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)(
5391
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5414
5392
  Render2,
5415
5393
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5416
5394
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
@@ -5421,8 +5399,8 @@ var DropZoneChild = ({
5421
5399
  }
5422
5400
  );
5423
5401
  };
5424
- var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
5425
- var DropZoneEdit = (0, import_react34.forwardRef)(
5402
+ var DropZoneChildMemo = (0, import_react35.memo)(DropZoneChild);
5403
+ var DropZoneEdit = (0, import_react35.forwardRef)(
5426
5404
  function DropZoneEditInternal({
5427
5405
  zone,
5428
5406
  allow,
@@ -5432,7 +5410,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5432
5410
  minEmptyHeight: userMinEmptyHeight = 128,
5433
5411
  collisionAxis
5434
5412
  }, userRef) {
5435
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5413
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5436
5414
  const {
5437
5415
  // These all need setting via context
5438
5416
  areaId,
@@ -5441,7 +5419,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5441
5419
  unregisterLocalZone
5442
5420
  } = ctx != null ? ctx : {};
5443
5421
  const path = useAppStore(
5444
- (0, import_shallow3.useShallow)((s) => {
5422
+ (0, import_shallow4.useShallow)((s) => {
5445
5423
  var _a;
5446
5424
  return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
5447
5425
  })
@@ -5453,39 +5431,24 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5453
5431
  }
5454
5432
  }
5455
5433
  const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
5456
- const {
5457
- isDeepestZone,
5458
- inNextDeepestArea,
5459
- draggedComponentType,
5460
- userIsDragging
5461
- } = useContextStore(ZoneStoreContext, (s) => {
5462
- var _a, _b;
5463
- return {
5464
- isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
5465
- inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
5466
- draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
5467
- userIsDragging: !!s.draggedItem
5468
- };
5469
- });
5434
+ const inNextDeepestArea = useContextStore(
5435
+ ZoneStoreContext,
5436
+ (s) => s.nextAreaDepthIndex[areaId || ""]
5437
+ );
5470
5438
  const zoneContentIds = useAppStore(
5471
- (0, import_shallow3.useShallow)((s) => {
5439
+ (0, import_shallow4.useShallow)((s) => {
5472
5440
  var _a;
5473
5441
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
5474
5442
  })
5475
5443
  );
5476
5444
  const zoneType = useAppStore(
5477
- (0, import_shallow3.useShallow)((s) => {
5445
+ (0, import_shallow4.useShallow)((s) => {
5478
5446
  var _a;
5479
5447
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
5480
5448
  })
5481
5449
  );
5482
- (0, import_react34.useEffect)(() => {
5450
+ (0, import_react35.useEffect)(() => {
5483
5451
  if (!zoneType || zoneType === "dropzone") {
5484
- if (zoneCompound !== rootDroppableId) {
5485
- console.warn(
5486
- "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"
5487
- );
5488
- }
5489
5452
  if (ctx == null ? void 0 : ctx.registerZone) {
5490
5453
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5491
5454
  }
@@ -5496,11 +5459,20 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5496
5459
  };
5497
5460
  }
5498
5461
  }, [zoneType]);
5499
- const contentIds = (0, import_react34.useMemo)(() => {
5462
+ (0, import_react35.useEffect)(() => {
5463
+ if (zoneType === "dropzone") {
5464
+ if (zoneCompound !== rootDroppableId) {
5465
+ console.warn(
5466
+ "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"
5467
+ );
5468
+ }
5469
+ }
5470
+ }, [zoneType]);
5471
+ const contentIds = (0, import_react35.useMemo)(() => {
5500
5472
  return zoneContentIds || [];
5501
5473
  }, [zoneContentIds]);
5502
- const ref = (0, import_react34.useRef)(null);
5503
- const acceptsTarget = (0, import_react34.useCallback)(
5474
+ const ref = (0, import_react35.useRef)(null);
5475
+ const acceptsTarget = (0, import_react35.useCallback)(
5504
5476
  (componentType) => {
5505
5477
  if (!componentType) {
5506
5478
  return true;
@@ -5522,29 +5494,44 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5522
5494
  },
5523
5495
  [allow, disallow]
5524
5496
  );
5525
- (0, import_react34.useEffect)(() => {
5497
+ const targetAccepted = useContextStore(ZoneStoreContext, (s) => {
5498
+ var _a;
5499
+ const draggedComponentType = (_a = s.draggedItem) == null ? void 0 : _a.data.componentType;
5500
+ return acceptsTarget(draggedComponentType);
5501
+ });
5502
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
5503
+ const isEnabled = useContextStore(ZoneStoreContext, (s) => {
5504
+ var _a;
5505
+ let _isEnabled = true;
5506
+ const isDeepestZone = (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false;
5507
+ _isEnabled = isDeepestZone;
5508
+ if (_isEnabled) {
5509
+ _isEnabled = targetAccepted;
5510
+ }
5511
+ return _isEnabled;
5512
+ });
5513
+ (0, import_react35.useEffect)(() => {
5526
5514
  if (registerLocalZone) {
5527
- registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
5515
+ registerLocalZone(zoneCompound, isEnabled);
5528
5516
  }
5529
5517
  return () => {
5530
5518
  if (unregisterLocalZone) {
5531
5519
  unregisterLocalZone(zoneCompound);
5532
5520
  }
5533
5521
  };
5534
- }, [draggedComponentType, zoneCompound]);
5535
- const hoveringOverArea = inNextDeepestArea || isRootZone;
5536
- let isEnabled = true;
5537
- if (userIsDragging) {
5538
- isEnabled = isDeepestZone;
5539
- }
5540
- if (isEnabled) {
5541
- isEnabled = acceptsTarget(draggedComponentType);
5542
- }
5522
+ }, [isEnabled, zoneCompound]);
5543
5523
  const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
5544
5524
  contentIds,
5545
5525
  zoneCompound
5546
5526
  );
5547
5527
  const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
5528
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5529
+ (0, import_react35.useEffect)(() => {
5530
+ const { enabledIndex } = zoneStore.getState();
5531
+ zoneStore.setState({
5532
+ enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
5533
+ });
5534
+ }, [isEnabled, zoneStore, zoneCompound]);
5548
5535
  const droppableConfig = {
5549
5536
  id: zoneCompound,
5550
5537
  collisionPriority: isEnabled ? depth : 0,
@@ -5554,11 +5541,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5554
5541
  data: {
5555
5542
  areaId,
5556
5543
  depth,
5557
- isDroppableTarget: acceptsTarget(draggedComponentType),
5544
+ isDroppableTarget: targetAccepted,
5558
5545
  path: path || []
5559
5546
  }
5560
5547
  };
5561
- const { ref: dropRef } = useDroppableSafe(droppableConfig);
5548
+ const { ref: dropRef } = (0, import_react36.useDroppable)(droppableConfig);
5562
5549
  const isAreaSelected = useAppStore(
5563
5550
  (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
5564
5551
  );
@@ -5573,7 +5560,6 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5573
5560
  {
5574
5561
  className: `${getClassName17({
5575
5562
  isRootZone,
5576
- userIsDragging,
5577
5563
  hoveringOverArea,
5578
5564
  isEnabled,
5579
5565
  isAreaSelected,
@@ -5595,12 +5581,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5595
5581
  {
5596
5582
  zoneCompound,
5597
5583
  componentId,
5598
- preview,
5599
5584
  dragAxis,
5600
- isEnabled,
5601
5585
  index: i,
5602
5586
  collisionAxis,
5603
- inDroppableZone: acceptsTarget(draggedComponentType)
5587
+ inDroppableZone: targetAccepted
5604
5588
  },
5605
5589
  componentId
5606
5590
  );
@@ -5615,8 +5599,8 @@ var DropZoneRenderItem = ({
5615
5599
  metadata
5616
5600
  }) => {
5617
5601
  const Component = config.components[item.type];
5618
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5619
- const nextContextValue = (0, import_react34.useMemo)(
5602
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5603
+ const nextContextValue = (0, import_react35.useMemo)(
5620
5604
  () => ({
5621
5605
  areaId: props.id,
5622
5606
  depth: 1
@@ -5634,14 +5618,14 @@ var DropZoneRenderItem = ({
5634
5618
  ) }, props.id);
5635
5619
  };
5636
5620
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
5637
- var DropZoneRender2 = (0, import_react34.forwardRef)(
5621
+ var DropZoneRender2 = (0, import_react35.forwardRef)(
5638
5622
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5639
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5623
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5640
5624
  const { areaId = "root" } = ctx || {};
5641
- const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
5625
+ const { config, data, metadata } = (0, import_react35.useContext)(renderContext);
5642
5626
  let zoneCompound = rootDroppableId;
5643
5627
  let content = (data == null ? void 0 : data.content) || [];
5644
- (0, import_react34.useEffect)(() => {
5628
+ (0, import_react35.useEffect)(() => {
5645
5629
  if (!content) {
5646
5630
  if (ctx == null ? void 0 : ctx.registerZone) {
5647
5631
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5678,9 +5662,9 @@ var DropZoneRender2 = (0, import_react34.forwardRef)(
5678
5662
  }
5679
5663
  );
5680
5664
  var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
5681
- var DropZone = (0, import_react34.forwardRef)(
5665
+ var DropZone = (0, import_react35.forwardRef)(
5682
5666
  function DropZone2(props, ref) {
5683
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5667
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5684
5668
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5685
5669
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5686
5670
  }
@@ -5690,8 +5674,7 @@ var DropZone = (0, import_react34.forwardRef)(
5690
5674
 
5691
5675
  // lib/dnd/NestedDroppablePlugin.ts
5692
5676
  init_react_import();
5693
- var import_abstract10 = require("@dnd-kit/abstract");
5694
- var import_state2 = require("@dnd-kit/state");
5677
+ var import_abstract9 = require("@dnd-kit/abstract");
5695
5678
 
5696
5679
  // lib/throttle.ts
5697
5680
  init_react_import();
@@ -5740,7 +5723,7 @@ var GlobalPosition = class {
5740
5723
  var _a;
5741
5724
  this.target = target;
5742
5725
  this.original = original;
5743
- this.frameEl = document.querySelector("#preview-frame");
5726
+ this.frameEl = document.querySelector("iframe#preview-frame");
5744
5727
  if (this.frameEl) {
5745
5728
  this.frameRect = this.frameEl.getBoundingClientRect();
5746
5729
  this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
@@ -5820,6 +5803,7 @@ var getZoneId2 = (candidate) => {
5820
5803
  }
5821
5804
  return id;
5822
5805
  };
5806
+ var BUFFER = 6;
5823
5807
  var getPointerCollisions = (position, manager) => {
5824
5808
  const candidates = [];
5825
5809
  let elements = position.target.ownerDocument.elementsFromPoint(
@@ -5843,13 +5827,26 @@ var getPointerCollisions = (position, manager) => {
5843
5827
  for (let i = 0; i < elements.length; i++) {
5844
5828
  const element = elements[i];
5845
5829
  const dropzoneId = element.getAttribute("data-puck-dropzone");
5830
+ const id = element.getAttribute("data-puck-dnd");
5831
+ const isVoid = element.hasAttribute("data-puck-dnd-void");
5832
+ if (BUFFER && (dropzoneId || id) && !isVoid) {
5833
+ const box = element.getBoundingClientRect();
5834
+ const contractedBox = {
5835
+ left: box.left + BUFFER,
5836
+ right: box.right - BUFFER,
5837
+ top: box.top + BUFFER,
5838
+ bottom: box.bottom - BUFFER
5839
+ };
5840
+ if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
5841
+ continue;
5842
+ }
5843
+ }
5846
5844
  if (dropzoneId) {
5847
5845
  const droppable = manager.registry.droppables.get(dropzoneId);
5848
5846
  if (droppable) {
5849
5847
  candidates.push(droppable);
5850
5848
  }
5851
5849
  }
5852
- const id = element.getAttribute("data-puck-dnd");
5853
5850
  if (id) {
5854
5851
  const droppable = manager.registry.droppables.get(id);
5855
5852
  if (droppable) {
@@ -5903,17 +5900,17 @@ var findDeepestCandidate = (position, manager) => {
5903
5900
  return { zone, area };
5904
5901
  }
5905
5902
  return {
5906
- zone: "default-zone",
5907
- area: null
5903
+ zone: rootDroppableId,
5904
+ area: rootAreaId
5908
5905
  };
5909
5906
  };
5910
- var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract10.Plugin {
5907
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
5911
5908
  constructor(manager, options) {
5912
5909
  super(manager);
5913
5910
  if (typeof window === "undefined") {
5914
5911
  return;
5915
5912
  }
5916
- const cleanupEffect = (0, import_state2.effects)(() => {
5913
+ this.registerEffect(() => {
5917
5914
  const handleMove = (event) => {
5918
5915
  const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
5919
5916
  const position = new GlobalPosition(target, {
@@ -5937,12 +5934,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
5937
5934
  capture: true
5938
5935
  // dndkit's PointerSensor prevents propagation during drag
5939
5936
  });
5940
- this.destroy = () => {
5937
+ const cleanup = () => {
5941
5938
  document.body.removeEventListener("pointermove", handlePointerMove, {
5942
5939
  capture: true
5943
5940
  });
5944
- cleanupEffect();
5945
5941
  };
5942
+ return cleanup;
5946
5943
  });
5947
5944
  }
5948
5945
  };
@@ -6002,14 +5999,15 @@ function getDeepDir(el) {
6002
5999
  }
6003
6000
 
6004
6001
  // components/DragDropContext/index.tsx
6002
+ var import_state = require("@dnd-kit/state");
6005
6003
  var import_jsx_runtime26 = require("react/jsx-runtime");
6006
6004
  var DEBUG3 = false;
6007
- var dragListenerContext = (0, import_react36.createContext)({
6005
+ var dragListenerContext = (0, import_react38.createContext)({
6008
6006
  dragListeners: {}
6009
6007
  });
6010
6008
  function useDragListener(type, fn, deps = []) {
6011
- const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
6012
- (0, import_react36.useEffect)(() => {
6009
+ const { setDragListeners } = (0, import_react38.useContext)(dragListenerContext);
6010
+ (0, import_react38.useEffect)(() => {
6013
6011
  if (setDragListeners) {
6014
6012
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
6015
6013
  [type]: [...old[type] || [], fn]
@@ -6019,8 +6017,8 @@ function useDragListener(type, fn, deps = []) {
6019
6017
  }
6020
6018
  var AREA_CHANGE_DEBOUNCE_MS = 100;
6021
6019
  var useTempDisableFallback = (timeout3) => {
6022
- const lastFallbackDisable = (0, import_react36.useRef)(null);
6023
- return (0, import_react36.useCallback)((manager) => {
6020
+ const lastFallbackDisable = (0, import_react38.useRef)(null);
6021
+ return (0, import_react38.useCallback)((manager) => {
6024
6022
  collisionStore.setState({ fallbackEnabled: false });
6025
6023
  const fallbackId = generateId();
6026
6024
  lastFallbackDisable.current = fallbackId;
@@ -6039,19 +6037,21 @@ var DragDropContextClient = ({
6039
6037
  const dispatch = useAppStore((s) => s.dispatch);
6040
6038
  const appStore = useAppStoreApi();
6041
6039
  const id = useSafeId();
6042
- const debouncedParamsRef = (0, import_react36.useRef)(null);
6040
+ const debouncedParamsRef = (0, import_react38.useRef)(null);
6043
6041
  const tempDisableFallback = useTempDisableFallback(100);
6044
- const [zoneStore] = (0, import_react36.useState)(
6042
+ const [zoneStore] = (0, import_react38.useState)(
6045
6043
  () => (0, import_zustand5.createStore)(() => ({
6046
6044
  zoneDepthIndex: {},
6047
6045
  nextZoneDepthIndex: {},
6048
6046
  areaDepthIndex: {},
6049
6047
  nextAreaDepthIndex: {},
6050
6048
  draggedItem: null,
6051
- previewIndex: {}
6049
+ previewIndex: {},
6050
+ enabledIndex: {},
6051
+ hoveringComponent: null
6052
6052
  }))
6053
6053
  );
6054
- const getChanged2 = (0, import_react36.useCallback)(
6054
+ const getChanged2 = (0, import_react38.useCallback)(
6055
6055
  (params, id2) => {
6056
6056
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
6057
6057
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -6072,7 +6072,7 @@ var DragDropContextClient = ({
6072
6072
  },
6073
6073
  [zoneStore]
6074
6074
  );
6075
- const setDeepestAndCollide = (0, import_react36.useCallback)(
6075
+ const setDeepestAndCollide = (0, import_react38.useCallback)(
6076
6076
  (params, manager) => {
6077
6077
  const { zoneChanged, areaChanged } = getChanged2(params, id);
6078
6078
  if (!zoneChanged && !areaChanged) return;
@@ -6096,7 +6096,7 @@ var DragDropContextClient = ({
6096
6096
  setDeepestDb.cancel();
6097
6097
  debouncedParamsRef.current = null;
6098
6098
  };
6099
- (0, import_react36.useEffect)(() => {
6099
+ (0, import_react38.useEffect)(() => {
6100
6100
  if (DEBUG3) {
6101
6101
  zoneStore.subscribe(
6102
6102
  (s) => {
@@ -6110,7 +6110,7 @@ var DragDropContextClient = ({
6110
6110
  );
6111
6111
  }
6112
6112
  }, []);
6113
- const [plugins] = (0, import_react36.useState)(() => [
6113
+ const [plugins] = (0, import_react38.useState)(() => [
6114
6114
  ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
6115
6115
  createNestedDroppablePlugin(
6116
6116
  {
@@ -6158,10 +6158,10 @@ var DragDropContextClient = ({
6158
6158
  )
6159
6159
  ]);
6160
6160
  const sensors = useSensors();
6161
- const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
6162
- const dragMode = (0, import_react36.useRef)(null);
6163
- const initialSelector = (0, import_react36.useRef)(void 0);
6164
- const nextContextValue = (0, import_react36.useMemo)(
6161
+ const [dragListeners, setDragListeners] = (0, import_react38.useState)({});
6162
+ const dragMode = (0, import_react38.useRef)(null);
6163
+ const initialSelector = (0, import_react38.useRef)(void 0);
6164
+ const nextContextValue = (0, import_react38.useMemo)(
6165
6165
  () => ({
6166
6166
  mode: "edit",
6167
6167
  areaId: "root",
@@ -6177,12 +6177,14 @@ var DragDropContextClient = ({
6177
6177
  setDragListeners
6178
6178
  },
6179
6179
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6180
- import_react35.DragDropProvider,
6180
+ import_react37.DragDropProvider,
6181
6181
  {
6182
6182
  plugins,
6183
6183
  sensors,
6184
6184
  onDragEnd: (event, manager) => {
6185
- var _a;
6185
+ var _a, _b;
6186
+ const entryEl = (_a = getFrame()) == null ? void 0 : _a.querySelector("[data-puck-entry]");
6187
+ entryEl == null ? void 0 : entryEl.removeAttribute("data-puck-dragging");
6186
6188
  const { source, target } = event.operation;
6187
6189
  if (!source) {
6188
6190
  zoneStore.setState({ draggedItem: null });
@@ -6190,9 +6192,9 @@ var DragDropContextClient = ({
6190
6192
  }
6191
6193
  const { zone, index } = source.data;
6192
6194
  const { previewIndex = {} } = zoneStore.getState() || {};
6193
- const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
6194
- setTimeout(() => {
6195
- var _a2, _b;
6195
+ const thisPreview = ((_b = previewIndex[zone]) == null ? void 0 : _b.props.id) === source.id ? previewIndex[zone] : null;
6196
+ const onAnimationEnd = () => {
6197
+ var _a2, _b2;
6196
6198
  zoneStore.setState({ draggedItem: null });
6197
6199
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
6198
6200
  zoneStore.setState({ previewIndex: {} });
@@ -6228,23 +6230,28 @@ var DragDropContextClient = ({
6228
6230
  });
6229
6231
  }
6230
6232
  }
6231
- setTimeout(() => {
6232
- dispatch({
6233
- type: "setUi",
6234
- ui: {
6235
- itemSelector: { index, zone },
6236
- isDragging: false
6237
- },
6238
- recordHistory: true
6239
- });
6240
- }, 50);
6241
- (_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
6233
+ dispatch({
6234
+ type: "setUi",
6235
+ ui: {
6236
+ itemSelector: { index, zone },
6237
+ isDragging: false
6238
+ },
6239
+ recordHistory: true
6240
+ });
6241
+ (_b2 = dragListeners.dragend) == null ? void 0 : _b2.forEach((fn) => {
6242
6242
  fn(event, manager);
6243
6243
  });
6244
- }, 250);
6244
+ };
6245
+ let dispose;
6246
+ dispose = (0, import_state.effect)(() => {
6247
+ if (source.status === "idle") {
6248
+ onAnimationEnd();
6249
+ dispose == null ? void 0 : dispose();
6250
+ }
6251
+ });
6245
6252
  },
6246
6253
  onDragOver: (event, manager) => {
6247
- var _a, _b, _c, _d, _e;
6254
+ var _a, _b, _c, _d;
6248
6255
  event.preventDefault();
6249
6256
  const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
6250
6257
  if (!draggedItem) return;
@@ -6262,7 +6269,7 @@ var DragDropContextClient = ({
6262
6269
  const targetData = target.data;
6263
6270
  targetZone = targetData.zone;
6264
6271
  targetIndex = targetData.index;
6265
- const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
6272
+ const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
6266
6273
  const dir = getDeepDir(target.element);
6267
6274
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
6268
6275
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
@@ -6275,7 +6282,7 @@ var DragDropContextClient = ({
6275
6282
  targetZone = target.id.toString();
6276
6283
  targetIndex = 0;
6277
6284
  }
6278
- const path = ((_d = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _d.path) || [];
6285
+ const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
6279
6286
  if (targetId === sourceId || path.find((path2) => {
6280
6287
  const [pathId] = path2.split(":");
6281
6288
  return pathId === sourceId;
@@ -6321,16 +6328,12 @@ var DragDropContextClient = ({
6321
6328
  });
6322
6329
  }
6323
6330
  }
6324
- (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
6331
+ (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
6325
6332
  fn(event, manager);
6326
6333
  });
6327
6334
  },
6328
6335
  onDragStart: (event, manager) => {
6329
6336
  var _a;
6330
- dispatch({
6331
- type: "setUi",
6332
- ui: { itemSelector: null, isDragging: true }
6333
- });
6334
6337
  const { source } = event.operation;
6335
6338
  if (source && source.type !== "void") {
6336
6339
  const sourceData = source.data;
@@ -6360,11 +6363,31 @@ var DragDropContextClient = ({
6360
6363
  });
6361
6364
  },
6362
6365
  onBeforeDragStart: (event) => {
6363
- var _a;
6364
- const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
6366
+ var _a, _b, _c, _d;
6367
+ const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
6365
6368
  dragMode.current = isNewComponent ? "new" : "existing";
6366
6369
  initialSelector.current = void 0;
6367
6370
  zoneStore.setState({ draggedItem: event.operation.source });
6371
+ if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== ((_c = event.operation.source) == null ? void 0 : _c.id)) {
6372
+ dispatch({
6373
+ type: "setUi",
6374
+ ui: {
6375
+ itemSelector: null,
6376
+ isDragging: true
6377
+ },
6378
+ recordHistory: false
6379
+ });
6380
+ } else {
6381
+ dispatch({
6382
+ type: "setUi",
6383
+ ui: {
6384
+ isDragging: true
6385
+ },
6386
+ recordHistory: false
6387
+ });
6388
+ }
6389
+ const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
6390
+ entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
6368
6391
  },
6369
6392
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
6370
6393
  }
@@ -6384,6 +6407,7 @@ var DragDropContext = ({
6384
6407
  };
6385
6408
 
6386
6409
  // components/Drawer/index.tsx
6410
+ var import_react40 = require("@dnd-kit/react");
6387
6411
  var import_jsx_runtime27 = require("react/jsx-runtime");
6388
6412
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
6389
6413
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
@@ -6394,7 +6418,7 @@ var DrawerItemInner = ({
6394
6418
  dragRef,
6395
6419
  isDragDisabled
6396
6420
  }) => {
6397
- const CustomInner = (0, import_react37.useMemo)(
6421
+ const CustomInner = (0, import_react39.useMemo)(
6398
6422
  () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
6399
6423
  [children]
6400
6424
  );
@@ -6420,10 +6444,11 @@ var DrawerItemDraggable = ({
6420
6444
  id,
6421
6445
  isDragDisabled
6422
6446
  }) => {
6423
- const { ref } = useDraggableSafe({
6447
+ const { ref } = (0, import_react40.useDraggable)({
6424
6448
  id,
6425
- data: { type: "drawer", componentType: name },
6426
- disabled: isDragDisabled
6449
+ data: { componentType: name },
6450
+ disabled: isDragDisabled,
6451
+ type: "drawer"
6427
6452
  });
6428
6453
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
6429
6454
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
@@ -6448,7 +6473,7 @@ var DrawerItem = ({
6448
6473
  isDragDisabled
6449
6474
  }) => {
6450
6475
  const resolvedId = id || name;
6451
- const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
6476
+ const [dynamicId, setDynamicId] = (0, import_react39.useState)(generateId(resolvedId));
6452
6477
  if (typeof index !== "undefined") {
6453
6478
  console.error(
6454
6479
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -6488,7 +6513,7 @@ var Drawer = ({
6488
6513
  );
6489
6514
  }
6490
6515
  const id = useSafeId();
6491
- const { ref } = useDroppableSafe({
6516
+ const { ref } = (0, import_react40.useDroppable)({
6492
6517
  id,
6493
6518
  type: "void",
6494
6519
  collisionPriority: 0
@@ -6501,6 +6526,7 @@ var Drawer = ({
6501
6526
  ref,
6502
6527
  "data-puck-dnd": id,
6503
6528
  "data-puck-drawer": true,
6529
+ "data-puck-dnd-void": true,
6504
6530
  children
6505
6531
  }
6506
6532
  );
@@ -6509,7 +6535,7 @@ Drawer.Item = DrawerItem;
6509
6535
 
6510
6536
  // components/Puck/index.tsx
6511
6537
  init_react_import();
6512
- var import_react52 = require("react");
6538
+ var import_react56 = require("react");
6513
6539
 
6514
6540
  // components/SidebarSection/index.tsx
6515
6541
  init_react_import();
@@ -6520,7 +6546,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
6520
6546
 
6521
6547
  // lib/use-breadcrumbs.ts
6522
6548
  init_react_import();
6523
- var import_react38 = require("react");
6549
+ var import_react41 = require("react");
6524
6550
  var useBreadcrumbs = (renderCount) => {
6525
6551
  const selectedId = useAppStore((s) => {
6526
6552
  var _a;
@@ -6532,7 +6558,7 @@ var useBreadcrumbs = (renderCount) => {
6532
6558
  return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
6533
6559
  });
6534
6560
  const appStore = useAppStoreApi();
6535
- return (0, import_react38.useMemo)(() => {
6561
+ return (0, import_react41.useMemo)(() => {
6536
6562
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6537
6563
  var _a, _b, _c;
6538
6564
  const [componentId] = zoneCompound.split(":");
@@ -6604,70 +6630,26 @@ var SidebarSection = ({
6604
6630
  );
6605
6631
  };
6606
6632
 
6607
- // components/MenuBar/index.tsx
6608
- init_react_import();
6609
-
6610
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
6611
- init_react_import();
6612
- 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" };
6613
-
6614
- // components/MenuBar/index.tsx
6615
- var import_jsx_runtime29 = require("react/jsx-runtime");
6616
- var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
6617
- function MenuBar({
6618
- menuOpen = false,
6619
- renderHeaderActions,
6620
- setMenuOpen
6621
- }) {
6622
- const back = useAppStore((s) => s.history.back);
6623
- const forward = useAppStore((s) => s.history.forward);
6624
- const hasFuture = useAppStore((s) => s.history.hasFuture());
6625
- const hasPast = useAppStore((s) => s.history.hasPast());
6626
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6627
- "div",
6628
- {
6629
- className: getClassName20({ menuOpen }),
6630
- onClick: (event) => {
6631
- var _a;
6632
- const element = event.target;
6633
- if (window.matchMedia("(min-width: 638px)").matches) {
6634
- return;
6635
- }
6636
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
6637
- setMenuOpen(false);
6638
- }
6639
- },
6640
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("inner"), children: [
6641
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("history"), children: [
6642
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Undo2, { size: 21 }) }),
6643
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Redo2, { size: 21 }) })
6644
- ] }),
6645
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: renderHeaderActions && renderHeaderActions() })
6646
- ] })
6647
- }
6648
- );
6649
- }
6650
-
6651
6633
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6652
6634
  init_react_import();
6653
- var styles_module_default15 = { "Puck": "_Puck_11o75_19", "Puck-portal": "_Puck-portal_11o75_24", "PuckLayout-inner": "_PuckLayout-inner_11o75_31", "PuckLayout--mounted": "_PuckLayout--mounted_11o75_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_11o75_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_11o75_53", "PuckLayout-mounted": "_PuckLayout-mounted_11o75_67", "PuckLayout": "_PuckLayout_11o75_31", "PuckLayout-header": "_PuckLayout-header_11o75_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_11o75_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_11o75_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_11o75_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_11o75_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_11o75_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_11o75_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_11o75_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_11o75_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_11o75_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_11o75_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_11o75_134" };
6635
+ var styles_module_default14 = { "Puck": "_Puck_mc1k2_19", "Puck-portal": "_Puck-portal_mc1k2_24", "PuckLayout-inner": "_PuckLayout-inner_mc1k2_31", "PuckLayout--mounted": "_PuckLayout--mounted_mc1k2_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_mc1k2_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_mc1k2_53", "PuckLayout-mounted": "_PuckLayout-mounted_mc1k2_67", "PuckLayout": "_PuckLayout_mc1k2_31", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_mc1k2_108", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_mc1k2_117" };
6654
6636
 
6655
6637
  // components/Puck/components/Fields/index.tsx
6656
6638
  init_react_import();
6657
6639
 
6658
6640
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
6659
6641
  init_react_import();
6660
- var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
6642
+ var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
6661
6643
 
6662
6644
  // components/Puck/components/Fields/index.tsx
6663
- var import_react39 = require("react");
6664
- var import_shallow4 = require("zustand/react/shallow");
6665
- var import_jsx_runtime30 = require("react/jsx-runtime");
6666
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
6645
+ var import_react42 = require("react");
6646
+ var import_shallow5 = require("zustand/react/shallow");
6647
+ var import_jsx_runtime29 = require("react/jsx-runtime");
6648
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
6667
6649
  var DefaultFields = ({
6668
6650
  children
6669
6651
  }) => {
6670
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
6652
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
6671
6653
  };
6672
6654
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6673
6655
  let currentProps;
@@ -6727,18 +6709,19 @@ var FieldsChild = ({ fieldName }) => {
6727
6709
  return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
6728
6710
  });
6729
6711
  const permissions = useAppStore(
6730
- (0, import_shallow4.useShallow)((s) => {
6712
+ (0, import_shallow5.useShallow)((s) => {
6731
6713
  const { selectedItem, permissions: permissions2 } = s;
6732
6714
  return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
6733
6715
  })
6734
6716
  );
6735
6717
  const appStore = useAppStoreApi();
6736
- const onChange = (0, import_react39.useCallback)(createOnChange(fieldName, appStore), [
6718
+ const onChange = (0, import_react42.useCallback)(createOnChange(fieldName, appStore), [
6737
6719
  fieldName
6738
6720
  ]);
6739
- if (!field || !id) return null;
6721
+ const { visible = true } = field != null ? field : {};
6722
+ if (!field || !id || !visible) return null;
6740
6723
  if (field.type === "slot") return null;
6741
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6724
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("field"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6742
6725
  AutoFieldPrivate,
6743
6726
  {
6744
6727
  field,
@@ -6750,14 +6733,15 @@ var FieldsChild = ({ fieldName }) => {
6750
6733
  }
6751
6734
  ) }, id);
6752
6735
  };
6753
- var Fields = ({ wrapFields = true }) => {
6736
+ var FieldsChildMemo = (0, import_react42.memo)(FieldsChild);
6737
+ var FieldsInternal = ({ wrapFields = true }) => {
6754
6738
  const overrides = useAppStore((s) => s.overrides);
6755
6739
  const componentResolving = useAppStore((s) => {
6756
6740
  var _a, _b;
6757
6741
  const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
6758
6742
  return (loadingCount != null ? loadingCount : 0) > 0;
6759
6743
  });
6760
- const itemSelector = useAppStore((0, import_shallow4.useShallow)((s) => s.state.ui.itemSelector));
6744
+ const itemSelector = useAppStore((0, import_shallow5.useShallow)((s) => s.state.ui.itemSelector));
6761
6745
  const id = useAppStore((s) => {
6762
6746
  var _a;
6763
6747
  return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
@@ -6766,42 +6750,48 @@ var Fields = ({ wrapFields = true }) => {
6766
6750
  useRegisterFieldsSlice(appStore, id);
6767
6751
  const fieldsLoading = useAppStore((s) => s.fields.loading);
6768
6752
  const fieldNames = useAppStore(
6769
- (0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
6753
+ (0, import_shallow5.useShallow)((s) => {
6754
+ if (s.fields.id === id) {
6755
+ return Object.keys(s.fields.fields);
6756
+ }
6757
+ return [];
6758
+ })
6770
6759
  );
6771
6760
  const isLoading = fieldsLoading || componentResolving;
6772
- const Wrapper = (0, import_react39.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6773
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6761
+ const Wrapper = (0, import_react42.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6762
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6774
6763
  "form",
6775
6764
  {
6776
- className: getClassName21({ wrapFields }),
6765
+ className: getClassName20({ wrapFields }),
6777
6766
  onSubmit: (e) => {
6778
6767
  e.preventDefault();
6779
6768
  },
6780
6769
  children: [
6781
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChild, { fieldName }, fieldName)) }),
6782
- 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 }) }) })
6770
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
6771
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) }) })
6783
6772
  ]
6784
6773
  }
6785
6774
  );
6786
6775
  };
6776
+ var Fields = (0, import_react42.memo)(FieldsInternal);
6787
6777
 
6788
6778
  // components/Puck/components/Components/index.tsx
6789
6779
  init_react_import();
6790
6780
 
6791
6781
  // lib/use-component-list.tsx
6792
6782
  init_react_import();
6793
- var import_react40 = require("react");
6783
+ var import_react43 = require("react");
6794
6784
 
6795
6785
  // components/ComponentList/index.tsx
6796
6786
  init_react_import();
6797
6787
 
6798
6788
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6799
6789
  init_react_import();
6800
- 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" };
6790
+ var styles_module_default16 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
6801
6791
 
6802
6792
  // components/ComponentList/index.tsx
6803
- var import_jsx_runtime31 = require("react/jsx-runtime");
6804
- var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
6793
+ var import_jsx_runtime30 = require("react/jsx-runtime");
6794
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6805
6795
  var ComponentListItem = ({
6806
6796
  name,
6807
6797
  label
@@ -6812,7 +6802,7 @@ var ComponentListItem = ({
6812
6802
  type: name
6813
6803
  }).insert
6814
6804
  );
6815
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6805
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6816
6806
  };
6817
6807
  var ComponentList = ({
6818
6808
  children,
@@ -6823,12 +6813,12 @@ var ComponentList = ({
6823
6813
  const setUi = useAppStore((s) => s.setUi);
6824
6814
  const componentList = useAppStore((s) => s.state.ui.componentList);
6825
6815
  const { expanded = true } = componentList[id] || {};
6826
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
6827
- title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
6816
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName21({ isExpanded: expanded }), children: [
6817
+ title && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6828
6818
  "button",
6829
6819
  {
6830
6820
  type: "button",
6831
- className: getClassName22("title"),
6821
+ className: getClassName21("title"),
6832
6822
  onClick: () => setUi({
6833
6823
  componentList: __spreadProps(__spreadValues({}, componentList), {
6834
6824
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6838,14 +6828,14 @@ var ComponentList = ({
6838
6828
  }),
6839
6829
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6840
6830
  children: [
6841
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
6842
- /* @__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 }) })
6831
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { children: title }),
6832
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronDown, { size: 12 }) })
6843
6833
  ]
6844
6834
  }
6845
6835
  ),
6846
- /* @__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) => {
6836
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("content"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6847
6837
  var _a;
6848
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6838
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6849
6839
  ComponentListItem,
6850
6840
  {
6851
6841
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6859,12 +6849,12 @@ var ComponentList = ({
6859
6849
  ComponentList.Item = ComponentListItem;
6860
6850
 
6861
6851
  // lib/use-component-list.tsx
6862
- var import_jsx_runtime32 = require("react/jsx-runtime");
6852
+ var import_jsx_runtime31 = require("react/jsx-runtime");
6863
6853
  var useComponentList = () => {
6864
- const [componentList, setComponentList] = (0, import_react40.useState)();
6854
+ const [componentList, setComponentList] = (0, import_react43.useState)();
6865
6855
  const config = useAppStore((s) => s.config);
6866
6856
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6867
- (0, import_react40.useEffect)(() => {
6857
+ (0, import_react43.useEffect)(() => {
6868
6858
  var _a, _b, _c;
6869
6859
  if (Object.keys(uiComponentList).length > 0) {
6870
6860
  const matchedComponents = [];
@@ -6874,7 +6864,7 @@ var useComponentList = () => {
6874
6864
  if (category.visible === false || !category.components) {
6875
6865
  return null;
6876
6866
  }
6877
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6867
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6878
6868
  ComponentList,
6879
6869
  {
6880
6870
  id: categoryKey,
@@ -6883,7 +6873,7 @@ var useComponentList = () => {
6883
6873
  var _a2;
6884
6874
  matchedComponents.push(componentName);
6885
6875
  const componentConf = config.components[componentName] || {};
6886
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6876
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6887
6877
  ComponentList.Item,
6888
6878
  {
6889
6879
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6903,7 +6893,7 @@ var useComponentList = () => {
6903
6893
  );
6904
6894
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6905
6895
  _componentList.push(
6906
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6896
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6907
6897
  ComponentList,
6908
6898
  {
6909
6899
  id: "other",
@@ -6911,7 +6901,7 @@ var useComponentList = () => {
6911
6901
  children: remainingComponents.map((componentName, i) => {
6912
6902
  var _a2;
6913
6903
  const componentConf = config.components[componentName] || {};
6914
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6904
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6915
6905
  ComponentList.Item,
6916
6906
  {
6917
6907
  name: componentName,
@@ -6933,25 +6923,25 @@ var useComponentList = () => {
6933
6923
  };
6934
6924
 
6935
6925
  // components/Puck/components/Components/index.tsx
6936
- var import_react41 = require("react");
6937
- var import_jsx_runtime33 = require("react/jsx-runtime");
6926
+ var import_react44 = require("react");
6927
+ var import_jsx_runtime32 = require("react/jsx-runtime");
6938
6928
  var Components = () => {
6939
6929
  const overrides = useAppStore((s) => s.overrides);
6940
6930
  const componentList = useComponentList();
6941
- const Wrapper = (0, import_react41.useMemo)(() => overrides.components || "div", [overrides]);
6942
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
6931
+ const Wrapper = (0, import_react44.useMemo)(() => overrides.components || "div", [overrides]);
6932
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
6943
6933
  };
6944
6934
 
6945
6935
  // components/Puck/components/Preview/index.tsx
6946
6936
  init_react_import();
6947
- var import_react43 = require("react");
6937
+ var import_react46 = require("react");
6948
6938
 
6949
6939
  // components/AutoFrame/index.tsx
6950
6940
  init_react_import();
6951
- var import_react42 = require("react");
6941
+ var import_react45 = require("react");
6952
6942
  var import_object_hash = __toESM(require("object-hash"));
6953
6943
  var import_react_dom3 = require("react-dom");
6954
- var import_jsx_runtime34 = require("react/jsx-runtime");
6944
+ var import_jsx_runtime33 = require("react/jsx-runtime");
6955
6945
  var styleSelector = 'style, link[rel="stylesheet"]';
6956
6946
  var collectStyles = (doc) => {
6957
6947
  const collected = [];
@@ -6994,7 +6984,7 @@ var CopyHostStyles = ({
6994
6984
  onStylesLoaded = () => null
6995
6985
  }) => {
6996
6986
  const { document: doc, window: win } = useFrame();
6997
- (0, import_react42.useEffect)(() => {
6987
+ (0, import_react45.useEffect)(() => {
6998
6988
  if (!win || !doc) {
6999
6989
  return () => {
7000
6990
  };
@@ -7151,10 +7141,10 @@ var CopyHostStyles = ({
7151
7141
  observer.disconnect();
7152
7142
  };
7153
7143
  }, []);
7154
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
7144
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
7155
7145
  };
7156
- var autoFrameContext = (0, import_react42.createContext)({});
7157
- var useFrame = () => (0, import_react42.useContext)(autoFrameContext);
7146
+ var autoFrameContext = (0, import_react45.createContext)({});
7147
+ var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
7158
7148
  function AutoFrame(_a) {
7159
7149
  var _b = _a, {
7160
7150
  children,
@@ -7175,11 +7165,11 @@ function AutoFrame(_a) {
7175
7165
  "onNotReady",
7176
7166
  "frameRef"
7177
7167
  ]);
7178
- const [loaded, setLoaded] = (0, import_react42.useState)(false);
7179
- const [ctx, setCtx] = (0, import_react42.useState)({});
7180
- const [mountTarget, setMountTarget] = (0, import_react42.useState)();
7181
- const [stylesLoaded, setStylesLoaded] = (0, import_react42.useState)(false);
7182
- (0, import_react42.useEffect)(() => {
7168
+ const [loaded, setLoaded] = (0, import_react45.useState)(false);
7169
+ const [ctx, setCtx] = (0, import_react45.useState)({});
7170
+ const [mountTarget, setMountTarget] = (0, import_react45.useState)();
7171
+ const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
7172
+ (0, import_react45.useEffect)(() => {
7183
7173
  var _a2;
7184
7174
  if (frameRef.current) {
7185
7175
  const doc = frameRef.current.contentDocument;
@@ -7198,7 +7188,7 @@ function AutoFrame(_a) {
7198
7188
  }
7199
7189
  }
7200
7190
  }, [frameRef, loaded, stylesLoaded]);
7201
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7191
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7202
7192
  "iframe",
7203
7193
  __spreadProps(__spreadValues({}, props), {
7204
7194
  className,
@@ -7208,7 +7198,7 @@ function AutoFrame(_a) {
7208
7198
  onLoad: () => {
7209
7199
  setLoaded(true);
7210
7200
  },
7211
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7201
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7212
7202
  CopyHostStyles,
7213
7203
  {
7214
7204
  debug,
@@ -7224,14 +7214,14 @@ var AutoFrame_default = AutoFrame;
7224
7214
 
7225
7215
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
7226
7216
  init_react_import();
7227
- var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7217
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7228
7218
 
7229
7219
  // components/Puck/components/Preview/index.tsx
7230
- var import_jsx_runtime35 = require("react/jsx-runtime");
7231
- var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
7220
+ var import_jsx_runtime34 = require("react/jsx-runtime");
7221
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
7232
7222
  var useBubbleIframeEvents = (ref) => {
7233
7223
  const status = useAppStore((s) => s.status);
7234
- (0, import_react43.useEffect)(() => {
7224
+ (0, import_react46.useEffect)(() => {
7235
7225
  if (ref.current && status === "READY") {
7236
7226
  const iframe = ref.current;
7237
7227
  const handlePointerMove = (event) => {
@@ -7269,7 +7259,7 @@ var useBubbleIframeEvents = (ref) => {
7269
7259
  }
7270
7260
  }, [status]);
7271
7261
  };
7272
- var Preview3 = ({ id = "puck-preview" }) => {
7262
+ var Preview2 = ({ id = "puck-preview" }) => {
7273
7263
  const dispatch = useAppStore((s) => s.dispatch);
7274
7264
  const root = useAppStore((s) => s.state.data.root);
7275
7265
  const config = useAppStore((s) => s.config);
@@ -7280,22 +7270,25 @@ var Preview3 = ({ id = "puck-preview" }) => {
7280
7270
  const renderData = useAppStore(
7281
7271
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7282
7272
  );
7283
- const Page = (0, import_react43.useCallback)(
7273
+ const Page = (0, import_react46.useCallback)(
7284
7274
  (pageProps) => {
7285
7275
  var _a, _b;
7286
- const rootConfig = config.root;
7287
- const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
7276
+ const propsWithSlots = useSlots(
7277
+ config,
7278
+ { type: "root", props: pageProps },
7279
+ DropZoneEditPure
7280
+ );
7288
7281
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7289
7282
  id: "puck-root"
7290
- }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
7283
+ }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: propsWithSlots.children });
7291
7284
  },
7292
- [config.root]
7285
+ [config]
7293
7286
  );
7294
- const Frame = (0, import_react43.useMemo)(() => overrides.iframe, [overrides]);
7287
+ const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
7295
7288
  const rootProps = root.props || root;
7296
- const ref = (0, import_react43.useRef)(null);
7289
+ const ref = (0, import_react46.useRef)(null);
7297
7290
  useBubbleIframeEvents(ref);
7298
- const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7291
+ const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7299
7292
  Page,
7300
7293
  __spreadProps(__spreadValues({}, rootProps), {
7301
7294
  puck: {
@@ -7305,28 +7298,28 @@ var Preview3 = ({ id = "puck-preview" }) => {
7305
7298
  metadata
7306
7299
  },
7307
7300
  editMode: true,
7308
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
7301
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7309
7302
  })
7310
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
7311
- (0, import_react43.useEffect)(() => {
7303
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config });
7304
+ (0, import_react46.useEffect)(() => {
7312
7305
  if (!iframe.enabled) {
7313
7306
  setStatus("READY");
7314
7307
  }
7315
7308
  }, [iframe.enabled]);
7316
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7309
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7317
7310
  "div",
7318
7311
  {
7319
- className: getClassName23(),
7312
+ className: getClassName22(),
7320
7313
  id,
7321
7314
  "data-puck-preview": true,
7322
7315
  onClick: () => {
7323
7316
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7324
7317
  },
7325
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7318
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7326
7319
  AutoFrame_default,
7327
7320
  {
7328
7321
  id: "preview-frame",
7329
- className: getClassName23("frame"),
7322
+ className: getClassName22("frame"),
7330
7323
  "data-rfd-iframe": true,
7331
7324
  onReady: () => {
7332
7325
  setStatus("READY");
@@ -7335,18 +7328,18 @@ var Preview3 = ({ id = "puck-preview" }) => {
7335
7328
  setStatus("MOUNTED");
7336
7329
  },
7337
7330
  frameRef: ref,
7338
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7331
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7339
7332
  if (Frame) {
7340
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
7333
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Frame, { document: document2, children: inner });
7341
7334
  }
7342
7335
  return inner;
7343
7336
  } })
7344
7337
  }
7345
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7338
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7346
7339
  "div",
7347
7340
  {
7348
7341
  id: "preview-frame",
7349
- className: getClassName23("frame"),
7342
+ className: getClassName22("frame"),
7350
7343
  ref,
7351
7344
  "data-puck-entry": true,
7352
7345
  children: inner
@@ -7364,7 +7357,7 @@ init_react_import();
7364
7357
 
7365
7358
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
7366
7359
  init_react_import();
7367
- var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7360
+ var styles_module_default18 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7368
7361
 
7369
7362
  // lib/scroll-into-view.ts
7370
7363
  init_react_import();
@@ -7378,7 +7371,7 @@ var scrollIntoView = (el) => {
7378
7371
  };
7379
7372
 
7380
7373
  // components/LayerTree/index.tsx
7381
- var import_react44 = require("react");
7374
+ var import_react47 = require("react");
7382
7375
 
7383
7376
  // lib/on-scroll-end.ts
7384
7377
  init_react_import();
@@ -7400,21 +7393,21 @@ var onScrollEnd = (frame, cb) => {
7400
7393
  };
7401
7394
 
7402
7395
  // components/LayerTree/index.tsx
7403
- var import_shallow5 = require("zustand/react/shallow");
7404
- var import_jsx_runtime36 = require("react/jsx-runtime");
7405
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7406
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
7396
+ var import_shallow6 = require("zustand/react/shallow");
7397
+ var import_jsx_runtime35 = require("react/jsx-runtime");
7398
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
7399
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
7407
7400
  var Layer = ({
7408
7401
  index,
7409
7402
  itemId,
7410
7403
  zoneCompound
7411
7404
  }) => {
7412
7405
  var _a;
7413
- const ctx = (0, import_react44.useContext)(dropZoneContext);
7406
+ const ctx = (0, import_react47.useContext)(dropZoneContext);
7414
7407
  const config = useAppStore((s) => s.config);
7415
7408
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7416
7409
  const dispatch = useAppStore((s) => s.dispatch);
7417
- const setItemSelector = (0, import_react44.useCallback)(
7410
+ const setItemSelector = (0, import_react47.useCallback)(
7418
7411
  (itemSelector2) => {
7419
7412
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
7420
7413
  },
@@ -7427,16 +7420,18 @@ var Layer = ({
7427
7420
  const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
7428
7421
  const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
7429
7422
  const zonesForItem = useAppStore(
7430
- (0, import_shallow5.useShallow)(
7423
+ (0, import_shallow6.useShallow)(
7431
7424
  (s) => Object.keys(s.state.indexes.zones).filter(
7432
7425
  (z) => z.split(":")[0] === itemId
7433
7426
  )
7434
7427
  )
7435
7428
  );
7436
7429
  const containsZone = zonesForItem.length > 0;
7437
- const { setHoveringComponent = () => {
7438
- }, hoveringComponent } = ctx || {};
7439
- const isHovering = hoveringComponent === itemId;
7430
+ const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
7431
+ const isHovering = useContextStore(
7432
+ ZoneStoreContext,
7433
+ (s) => s.hoveringComponent === itemId
7434
+ );
7440
7435
  const childIsSelected = useAppStore((s) => {
7441
7436
  var _a2, _b;
7442
7437
  const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
@@ -7447,7 +7442,7 @@ var Layer = ({
7447
7442
  });
7448
7443
  const componentConfig = config.components[nodeData.data.type];
7449
7444
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7450
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7445
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7451
7446
  "li",
7452
7447
  {
7453
7448
  className: getClassNameLayer({
@@ -7457,7 +7452,7 @@ var Layer = ({
7457
7452
  childIsSelected
7458
7453
  }),
7459
7454
  children: [
7460
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7455
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7461
7456
  "button",
7462
7457
  {
7463
7458
  type: "button",
@@ -7472,7 +7467,10 @@ var Layer = ({
7472
7467
  `[data-puck-component="${itemId}"]`
7473
7468
  );
7474
7469
  if (!el) {
7475
- console.error("Scroll failed. No element was found for", itemId);
7470
+ setItemSelector({
7471
+ index,
7472
+ zone: zoneCompound
7473
+ });
7476
7474
  return;
7477
7475
  }
7478
7476
  scrollIntoView(el);
@@ -7483,31 +7481,31 @@ var Layer = ({
7483
7481
  });
7484
7482
  });
7485
7483
  },
7486
- onMouseOver: (e) => {
7484
+ onMouseEnter: (e) => {
7487
7485
  e.stopPropagation();
7488
- setHoveringComponent(itemId);
7486
+ zoneStore.setState({ hoveringComponent: itemId });
7489
7487
  },
7490
- onMouseOut: (e) => {
7488
+ onMouseLeave: (e) => {
7491
7489
  e.stopPropagation();
7492
- setHoveringComponent(null);
7490
+ zoneStore.setState({ hoveringComponent: null });
7493
7491
  },
7494
7492
  children: [
7495
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7493
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7496
7494
  "div",
7497
7495
  {
7498
7496
  className: getClassNameLayer("chevron"),
7499
7497
  title: isSelected ? "Collapse" : "Expand",
7500
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
7498
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { size: "12" })
7501
7499
  }
7502
7500
  ),
7503
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
7504
- /* @__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" }) }),
7505
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
7501
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassNameLayer("title"), children: [
7502
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayoutGrid, { size: "16" }) }),
7503
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("name"), children: label })
7506
7504
  ] })
7507
7505
  ]
7508
7506
  }
7509
7507
  ) }),
7510
- 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))
7508
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7511
7509
  ]
7512
7510
  }
7513
7511
  );
@@ -7518,22 +7516,22 @@ var LayerTree = ({
7518
7516
  }) => {
7519
7517
  const label = _label != null ? _label : zoneCompound.split(":")[1];
7520
7518
  const contentIds = useAppStore(
7521
- (0, import_shallow5.useShallow)(
7519
+ (0, import_shallow6.useShallow)(
7522
7520
  (s) => {
7523
7521
  var _a, _b;
7524
7522
  return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
7525
7523
  }
7526
7524
  )
7527
7525
  );
7528
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
7529
- label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
7530
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
7526
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
7527
+ label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
7528
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
7531
7529
  label
7532
7530
  ] }),
7533
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
7534
- contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
7531
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
7532
+ contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
7535
7533
  contentIds.map((itemId, i) => {
7536
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7534
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7537
7535
  Layer,
7538
7536
  {
7539
7537
  index: i,
@@ -7548,7 +7546,7 @@ var LayerTree = ({
7548
7546
  };
7549
7547
 
7550
7548
  // components/Puck/components/Outline/index.tsx
7551
- var import_react45 = require("react");
7549
+ var import_react48 = require("react");
7552
7550
 
7553
7551
  // lib/data/find-zones-for-area.ts
7554
7552
  init_react_import();
@@ -7559,15 +7557,15 @@ var findZonesForArea = (state, area) => {
7559
7557
  };
7560
7558
 
7561
7559
  // components/Puck/components/Outline/index.tsx
7562
- var import_shallow6 = require("zustand/react/shallow");
7563
- var import_jsx_runtime37 = require("react/jsx-runtime");
7560
+ var import_shallow7 = require("zustand/react/shallow");
7561
+ var import_jsx_runtime36 = require("react/jsx-runtime");
7564
7562
  var Outline = () => {
7565
7563
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7566
7564
  const rootZones = useAppStore(
7567
- (0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
7565
+ (0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
7568
7566
  );
7569
- const Wrapper = (0, import_react45.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7570
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7567
+ const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7568
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7571
7569
  LayerTree,
7572
7570
  {
7573
7571
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -7700,25 +7698,25 @@ var getBox = function getBox2(el) {
7700
7698
  };
7701
7699
 
7702
7700
  // components/Puck/components/Canvas/index.tsx
7703
- var import_react47 = require("react");
7701
+ var import_react50 = require("react");
7704
7702
 
7705
7703
  // components/ViewportControls/index.tsx
7706
7704
  init_react_import();
7707
- var import_react46 = require("react");
7705
+ var import_react49 = require("react");
7708
7706
 
7709
7707
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7710
7708
  init_react_import();
7711
- 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" };
7709
+ var styles_module_default19 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
7712
7710
 
7713
7711
  // components/ViewportControls/index.tsx
7714
- var import_jsx_runtime38 = require("react/jsx-runtime");
7712
+ var import_jsx_runtime37 = require("react/jsx-runtime");
7715
7713
  var icons = {
7716
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
7717
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
7718
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
7714
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Smartphone, { size: 16 }),
7715
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Tablet, { size: 16 }),
7716
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Monitor, { size: 16 })
7719
7717
  };
7720
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7721
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
7718
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7719
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7722
7720
  var ViewportButton = ({
7723
7721
  children,
7724
7722
  height = "auto",
@@ -7727,11 +7725,11 @@ var ViewportButton = ({
7727
7725
  onClick
7728
7726
  }) => {
7729
7727
  const viewports = useAppStore((s) => s.state.ui.viewports);
7730
- const [isActive, setIsActive] = (0, import_react46.useState)(false);
7731
- (0, import_react46.useEffect)(() => {
7728
+ const [isActive, setIsActive] = (0, import_react49.useState)(false);
7729
+ (0, import_react49.useEffect)(() => {
7732
7730
  setIsActive(width === viewports.current.width);
7733
7731
  }, [width, viewports.current.width]);
7734
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7732
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7735
7733
  IconButton,
7736
7734
  {
7737
7735
  title,
@@ -7740,7 +7738,7 @@ var ViewportButton = ({
7740
7738
  e.stopPropagation();
7741
7739
  onClick({ width, height });
7742
7740
  },
7743
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
7741
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton("inner"), children })
7744
7742
  }
7745
7743
  ) });
7746
7744
  };
@@ -7764,7 +7762,7 @@ var ViewportControls = ({
7764
7762
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7765
7763
  (option) => option.value === autoZoom
7766
7764
  );
7767
- const zoomOptions = (0, import_react46.useMemo)(
7765
+ const zoomOptions = (0, import_react49.useMemo)(
7768
7766
  () => [
7769
7767
  ...defaultZoomOptions,
7770
7768
  ...defaultsContainAutoZoom ? [] : [
@@ -7776,8 +7774,8 @@ var ViewportControls = ({
7776
7774
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7777
7775
  [autoZoom]
7778
7776
  );
7779
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
7780
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7777
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName24(), children: [
7778
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7781
7779
  ViewportButton,
7782
7780
  {
7783
7781
  height: viewport.height,
@@ -7788,8 +7786,8 @@ var ViewportControls = ({
7788
7786
  },
7789
7787
  i
7790
7788
  )),
7791
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7792
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7789
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7790
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7793
7791
  IconButton,
7794
7792
  {
7795
7793
  title: "Zoom viewport out",
@@ -7803,10 +7801,10 @@ var ViewportControls = ({
7803
7801
  )].value
7804
7802
  );
7805
7803
  },
7806
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
7804
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomOut, { size: 16 })
7807
7805
  }
7808
7806
  ),
7809
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7807
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7810
7808
  IconButton,
7811
7809
  {
7812
7810
  title: "Zoom viewport in",
@@ -7820,19 +7818,19 @@ var ViewportControls = ({
7820
7818
  )].value
7821
7819
  );
7822
7820
  },
7823
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
7821
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomIn, { size: 16 })
7824
7822
  }
7825
7823
  ),
7826
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7827
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7824
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7825
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7828
7826
  "select",
7829
7827
  {
7830
- className: getClassName25("zoomSelect"),
7828
+ className: getClassName24("zoomSelect"),
7831
7829
  value: zoom.toString(),
7832
7830
  onChange: (e) => {
7833
7831
  onZoom(parseFloat(e.currentTarget.value));
7834
7832
  },
7835
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7833
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7836
7834
  "option",
7837
7835
  {
7838
7836
  value: option.value,
@@ -7847,7 +7845,7 @@ var ViewportControls = ({
7847
7845
 
7848
7846
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7849
7847
  init_react_import();
7850
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7848
+ var styles_module_default20 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7851
7849
 
7852
7850
  // lib/get-zoom-config.ts
7853
7851
  init_react_import();
@@ -7880,9 +7878,9 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7880
7878
  };
7881
7879
 
7882
7880
  // components/Puck/components/Canvas/index.tsx
7883
- var import_shallow7 = require("zustand/react/shallow");
7884
- var import_jsx_runtime39 = require("react/jsx-runtime");
7885
- var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
7881
+ var import_shallow8 = require("zustand/react/shallow");
7882
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7883
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7886
7884
  var ZOOM_ON_CHANGE = true;
7887
7885
  var Canvas = () => {
7888
7886
  const {
@@ -7894,7 +7892,7 @@ var Canvas = () => {
7894
7892
  status,
7895
7893
  iframe
7896
7894
  } = useAppStore(
7897
- (0, import_shallow7.useShallow)((s) => ({
7895
+ (0, import_shallow8.useShallow)((s) => ({
7898
7896
  dispatch: s.dispatch,
7899
7897
  overrides: s.overrides,
7900
7898
  setUi: s.setUi,
@@ -7905,23 +7903,23 @@ var Canvas = () => {
7905
7903
  }))
7906
7904
  );
7907
7905
  const { leftSideBarVisible, rightSideBarVisible, viewports } = useAppStore(
7908
- (0, import_shallow7.useShallow)((s) => ({
7906
+ (0, import_shallow8.useShallow)((s) => ({
7909
7907
  leftSideBarVisible: s.state.ui.leftSideBarVisible,
7910
7908
  rightSideBarVisible: s.state.ui.rightSideBarVisible,
7911
7909
  viewports: s.state.ui.viewports
7912
7910
  }))
7913
7911
  );
7914
- const frameRef = (0, import_react47.useRef)(null);
7915
- const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
7916
- const defaultRender = (0, import_react47.useMemo)(() => {
7917
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
7912
+ const frameRef = (0, import_react50.useRef)(null);
7913
+ const [showTransition, setShowTransition] = (0, import_react50.useState)(false);
7914
+ const defaultRender = (0, import_react50.useMemo)(() => {
7915
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
7918
7916
  return PuckDefault;
7919
7917
  }, []);
7920
- const CustomPreview = (0, import_react47.useMemo)(
7918
+ const CustomPreview = (0, import_react50.useMemo)(
7921
7919
  () => overrides.preview || defaultRender,
7922
7920
  [overrides]
7923
7921
  );
7924
- const getFrameDimensions = (0, import_react47.useCallback)(() => {
7922
+ const getFrameDimensions = (0, import_react50.useCallback)(() => {
7925
7923
  if (frameRef.current) {
7926
7924
  const frame = frameRef.current;
7927
7925
  const box = getBox(frame);
@@ -7929,7 +7927,7 @@ var Canvas = () => {
7929
7927
  }
7930
7928
  return { width: 0, height: 0 };
7931
7929
  }, [frameRef]);
7932
- const resetAutoZoom = (0, import_react47.useCallback)(
7930
+ const resetAutoZoom = (0, import_react50.useCallback)(
7933
7931
  (newViewports = viewports) => {
7934
7932
  if (frameRef.current) {
7935
7933
  setZoomConfig(
@@ -7943,11 +7941,11 @@ var Canvas = () => {
7943
7941
  },
7944
7942
  [frameRef, zoomConfig, viewports]
7945
7943
  );
7946
- (0, import_react47.useEffect)(() => {
7944
+ (0, import_react50.useEffect)(() => {
7947
7945
  setShowTransition(false);
7948
7946
  resetAutoZoom(viewports);
7949
7947
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7950
- (0, import_react47.useEffect)(() => {
7948
+ (0, import_react50.useEffect)(() => {
7951
7949
  const { height: frameHeight } = getFrameDimensions();
7952
7950
  if (viewports.current.height === "auto") {
7953
7951
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7955,13 +7953,13 @@ var Canvas = () => {
7955
7953
  }));
7956
7954
  }
7957
7955
  }, [zoomConfig.zoom]);
7958
- (0, import_react47.useEffect)(() => {
7956
+ (0, import_react50.useEffect)(() => {
7959
7957
  if (ZOOM_ON_CHANGE) {
7960
7958
  setShowTransition(true);
7961
7959
  resetAutoZoom(viewports);
7962
7960
  }
7963
7961
  }, [viewports.current.width]);
7964
- (0, import_react47.useEffect)(() => {
7962
+ (0, import_react50.useEffect)(() => {
7965
7963
  const cb = () => {
7966
7964
  setShowTransition(false);
7967
7965
  resetAutoZoom();
@@ -7971,16 +7969,16 @@ var Canvas = () => {
7971
7969
  window.removeEventListener("resize", cb);
7972
7970
  };
7973
7971
  }, []);
7974
- const [showLoader, setShowLoader] = (0, import_react47.useState)(false);
7975
- (0, import_react47.useEffect)(() => {
7972
+ const [showLoader, setShowLoader] = (0, import_react50.useState)(false);
7973
+ (0, import_react50.useEffect)(() => {
7976
7974
  setTimeout(() => {
7977
7975
  setShowLoader(true);
7978
7976
  }, 500);
7979
7977
  }, []);
7980
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
7978
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
7981
7979
  "div",
7982
7980
  {
7983
- className: getClassName26({
7981
+ className: getClassName25({
7984
7982
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7985
7983
  showLoader
7986
7984
  }),
@@ -7990,7 +7988,7 @@ var Canvas = () => {
7990
7988
  recordHistory: true
7991
7989
  }),
7992
7990
  children: [
7993
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7991
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7994
7992
  ViewportControls,
7995
7993
  {
7996
7994
  autoZoom: zoomConfig.autoZoom,
@@ -8016,11 +8014,11 @@ var Canvas = () => {
8016
8014
  }
8017
8015
  }
8018
8016
  ) }),
8019
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
8020
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8017
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
8018
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8021
8019
  "div",
8022
8020
  {
8023
- className: getClassName26("root"),
8021
+ className: getClassName25("root"),
8024
8022
  style: {
8025
8023
  width: iframe.enabled ? viewports.current.width : "100%",
8026
8024
  height: zoomConfig.rootHeight,
@@ -8038,10 +8036,10 @@ var Canvas = () => {
8038
8036
  })
8039
8037
  );
8040
8038
  },
8041
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview3, {}) })
8039
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Preview2, {}) })
8042
8040
  }
8043
8041
  ),
8044
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
8042
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { size: 24 }) })
8045
8043
  ] })
8046
8044
  ]
8047
8045
  }
@@ -8050,7 +8048,7 @@ var Canvas = () => {
8050
8048
 
8051
8049
  // lib/use-loaded-overrides.ts
8052
8050
  init_react_import();
8053
- var import_react48 = require("react");
8051
+ var import_react51 = require("react");
8054
8052
 
8055
8053
  // lib/load-overrides.ts
8056
8054
  init_react_import();
@@ -8089,26 +8087,26 @@ var useLoadedOverrides = ({
8089
8087
  overrides,
8090
8088
  plugins
8091
8089
  }) => {
8092
- return (0, import_react48.useMemo)(() => {
8090
+ return (0, import_react51.useMemo)(() => {
8093
8091
  return loadOverrides({ overrides, plugins });
8094
8092
  }, [plugins, overrides]);
8095
8093
  };
8096
8094
 
8097
8095
  // components/DefaultOverride/index.tsx
8098
8096
  init_react_import();
8099
- var import_jsx_runtime40 = require("react/jsx-runtime");
8100
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
8097
+ var import_jsx_runtime39 = require("react/jsx-runtime");
8098
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
8101
8099
 
8102
8100
  // lib/use-inject-css.ts
8103
8101
  init_react_import();
8104
- var import_react49 = require("react");
8102
+ var import_react52 = require("react");
8105
8103
  var styles = ``;
8106
8104
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
8107
- const [el, setEl] = (0, import_react49.useState)();
8108
- (0, import_react49.useEffect)(() => {
8105
+ const [el, setEl] = (0, import_react52.useState)();
8106
+ (0, import_react52.useEffect)(() => {
8109
8107
  setEl(document.createElement("style"));
8110
8108
  }, []);
8111
- (0, import_react49.useEffect)(() => {
8109
+ (0, import_react52.useEffect)(() => {
8112
8110
  var _a;
8113
8111
  if (!el || typeof window === "undefined") {
8114
8112
  return;
@@ -8128,10 +8126,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
8128
8126
 
8129
8127
  // lib/use-preview-mode-hotkeys.ts
8130
8128
  init_react_import();
8131
- var import_react50 = require("react");
8129
+ var import_react53 = require("react");
8132
8130
  var usePreviewModeHotkeys = () => {
8133
8131
  const appStore = useAppStoreApi();
8134
- const toggleInteractive = (0, import_react50.useCallback)(() => {
8132
+ const toggleInteractive = (0, import_react53.useCallback)(() => {
8135
8133
  const dispatch = appStore.getState().dispatch;
8136
8134
  dispatch({
8137
8135
  type: "setUi",
@@ -8146,7 +8144,7 @@ var usePreviewModeHotkeys = () => {
8146
8144
 
8147
8145
  // lib/use-puck.ts
8148
8146
  init_react_import();
8149
- var import_react51 = require("react");
8147
+ var import_react54 = require("react");
8150
8148
  var import_zustand6 = require("zustand");
8151
8149
  var generateUsePuck = (store) => {
8152
8150
  const history = {
@@ -8180,7 +8178,7 @@ var generateUsePuck = (store) => {
8180
8178
  const get = () => storeData;
8181
8179
  return __spreadProps(__spreadValues({}, storeData), { get });
8182
8180
  };
8183
- var UsePuckStoreContext = (0, import_react51.createContext)(
8181
+ var UsePuckStoreContext = (0, import_react54.createContext)(
8184
8182
  null
8185
8183
  );
8186
8184
  var convertToPickedStore = (store) => {
@@ -8194,12 +8192,12 @@ var convertToPickedStore = (store) => {
8194
8192
  };
8195
8193
  };
8196
8194
  var useRegisterUsePuckStore = (appStore) => {
8197
- const [usePuckStore] = (0, import_react51.useState)(
8195
+ const [usePuckStore] = (0, import_react54.useState)(
8198
8196
  () => (0, import_zustand6.createStore)(
8199
8197
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
8200
8198
  )
8201
8199
  );
8202
- (0, import_react51.useEffect)(() => {
8200
+ (0, import_react54.useEffect)(() => {
8203
8201
  return appStore.subscribe(
8204
8202
  (store) => convertToPickedStore(store),
8205
8203
  (pickedStore) => {
@@ -8211,7 +8209,7 @@ var useRegisterUsePuckStore = (appStore) => {
8211
8209
  };
8212
8210
  function createUsePuck() {
8213
8211
  return function usePuck2(selector) {
8214
- const usePuckApi = (0, import_react51.useContext)(UsePuckStoreContext);
8212
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8215
8213
  if (!usePuckApi) {
8216
8214
  throw new Error("usePuck must be used inside <Puck>.");
8217
8215
  }
@@ -8223,32 +8221,255 @@ function createUsePuck() {
8223
8221
  };
8224
8222
  }
8225
8223
  function usePuck() {
8226
- (0, import_react51.useEffect)(() => {
8224
+ (0, import_react54.useEffect)(() => {
8227
8225
  console.warn(
8228
8226
  "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
8229
8227
  );
8230
8228
  }, []);
8231
8229
  return createUsePuck()((s) => s);
8232
8230
  }
8231
+ function useGetPuck() {
8232
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8233
+ if (!usePuckApi) {
8234
+ throw new Error("usePuckGet must be used inside <Puck>.");
8235
+ }
8236
+ return usePuckApi.getState;
8237
+ }
8233
8238
 
8234
8239
  // components/Puck/index.tsx
8235
- var import_jsx_runtime41 = require("react/jsx-runtime");
8236
- var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
8237
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
8238
- var FieldSideBar = () => {
8239
- const title = useAppStore(
8240
- (s) => {
8240
+ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
8241
+
8242
+ // components/Puck/components/Header/index.tsx
8243
+ init_react_import();
8244
+ var import_react55 = require("react");
8245
+
8246
+ // components/MenuBar/index.tsx
8247
+ init_react_import();
8248
+
8249
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
8250
+ init_react_import();
8251
+ var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
8252
+
8253
+ // components/MenuBar/index.tsx
8254
+ var import_jsx_runtime40 = require("react/jsx-runtime");
8255
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
8256
+ function MenuBar({
8257
+ menuOpen = false,
8258
+ renderHeaderActions,
8259
+ setMenuOpen
8260
+ }) {
8261
+ const back = useAppStore((s) => s.history.back);
8262
+ const forward = useAppStore((s) => s.history.forward);
8263
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
8264
+ const hasPast = useAppStore((s) => s.history.hasPast());
8265
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8266
+ "div",
8267
+ {
8268
+ className: getClassName26({ menuOpen }),
8269
+ onClick: (event) => {
8270
+ var _a;
8271
+ const element = event.target;
8272
+ if (window.matchMedia("(min-width: 638px)").matches) {
8273
+ return;
8274
+ }
8275
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
8276
+ setMenuOpen(false);
8277
+ }
8278
+ },
8279
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("inner"), children: [
8280
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("history"), children: [
8281
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Undo2, { size: 21 }) }),
8282
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Redo2, { size: 21 }) })
8283
+ ] }),
8284
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: renderHeaderActions && renderHeaderActions() })
8285
+ ] })
8286
+ }
8287
+ );
8288
+ }
8289
+
8290
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
8291
+ init_react_import();
8292
+ var styles_module_default22 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
8293
+
8294
+ // components/Puck/components/Header/index.tsx
8295
+ var import_jsx_runtime41 = require("react/jsx-runtime");
8296
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
8297
+ var HeaderInner = () => {
8298
+ const {
8299
+ onPublish,
8300
+ renderHeader,
8301
+ renderHeaderActions,
8302
+ headerTitle,
8303
+ headerPath,
8304
+ iframe: _iframe
8305
+ } = usePropsContext();
8306
+ const dispatch = useAppStore((s) => s.dispatch);
8307
+ const appStore = useAppStoreApi();
8308
+ const defaultHeaderRender = (0, import_react55.useMemo)(() => {
8309
+ if (renderHeader) {
8310
+ console.warn(
8311
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8312
+ );
8313
+ const RenderHeader = (_a) => {
8314
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8315
+ const Comp = renderHeader;
8316
+ const appState = useAppStore((s) => s.state);
8317
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8318
+ };
8319
+ return RenderHeader;
8320
+ }
8321
+ return DefaultOverride;
8322
+ }, [renderHeader]);
8323
+ const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
8324
+ if (renderHeaderActions) {
8325
+ console.warn(
8326
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8327
+ );
8328
+ const RenderHeader = (props) => {
8329
+ const Comp = renderHeaderActions;
8330
+ const appState = useAppStore((s) => s.state);
8331
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8332
+ };
8333
+ return RenderHeader;
8334
+ }
8335
+ return DefaultOverride;
8336
+ }, [renderHeader]);
8337
+ const CustomHeader = useAppStore(
8338
+ (s) => s.overrides.header || defaultHeaderRender
8339
+ );
8340
+ const CustomHeaderActions = useAppStore(
8341
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
8342
+ );
8343
+ const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
8344
+ const rootTitle = useAppStore((s) => {
8345
+ var _a, _b;
8346
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
8347
+ return (_b = rootData.props.title) != null ? _b : "";
8348
+ });
8349
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8350
+ const rightSideBarVisible = useAppStore(
8351
+ (s) => s.state.ui.rightSideBarVisible
8352
+ );
8353
+ const toggleSidebars = (0, import_react55.useCallback)(
8354
+ (sidebar) => {
8355
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8356
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8357
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8358
+ dispatch({
8359
+ type: "setUi",
8360
+ ui: __spreadValues({
8361
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
8362
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
8363
+ });
8364
+ },
8365
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
8366
+ );
8367
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8368
+ CustomHeader,
8369
+ {
8370
+ 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)(
8371
+ Button,
8372
+ {
8373
+ onClick: () => {
8374
+ const data = appStore.getState().state.data;
8375
+ onPublish && onPublish(data);
8376
+ },
8377
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8378
+ children: "Publish"
8379
+ }
8380
+ ) }) }),
8381
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8382
+ "header",
8383
+ {
8384
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
8385
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("inner"), children: [
8386
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("toggle"), children: [
8387
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8388
+ IconButton,
8389
+ {
8390
+ onClick: () => {
8391
+ toggleSidebars("left");
8392
+ },
8393
+ title: "Toggle left sidebar",
8394
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8395
+ }
8396
+ ) }),
8397
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8398
+ IconButton,
8399
+ {
8400
+ onClick: () => {
8401
+ toggleSidebars("right");
8402
+ },
8403
+ title: "Toggle right sidebar",
8404
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8405
+ }
8406
+ ) })
8407
+ ] }),
8408
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8409
+ headerTitle || rootTitle || "Page",
8410
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8411
+ " ",
8412
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("code", { className: getClassName27("path"), children: headerPath })
8413
+ ] })
8414
+ ] }) }),
8415
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("tools"), children: [
8416
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8417
+ IconButton,
8418
+ {
8419
+ onClick: () => {
8420
+ return setMenuOpen(!menuOpen);
8421
+ },
8422
+ title: "Toggle menu bar",
8423
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8424
+ }
8425
+ ) }),
8426
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8427
+ MenuBar,
8428
+ {
8429
+ dispatch,
8430
+ onPublish,
8431
+ menuOpen,
8432
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8433
+ Button,
8434
+ {
8435
+ onClick: () => {
8436
+ const data = appStore.getState().state.data;
8437
+ onPublish && onPublish(data);
8438
+ },
8439
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8440
+ children: "Publish"
8441
+ }
8442
+ ) }),
8443
+ setMenuOpen
8444
+ }
8445
+ )
8446
+ ] })
8447
+ ] })
8448
+ }
8449
+ )
8450
+ }
8451
+ );
8452
+ };
8453
+ var Header = (0, import_react55.memo)(HeaderInner);
8454
+
8455
+ // components/Puck/index.tsx
8456
+ var import_jsx_runtime42 = require("react/jsx-runtime");
8457
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
8458
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
8459
+ var FieldSideBar = () => {
8460
+ const title = useAppStore(
8461
+ (s) => {
8241
8462
  var _a, _b;
8242
8463
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
8243
8464
  }
8244
8465
  );
8245
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
8466
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
8246
8467
  };
8247
- var propsContext = (0, import_react52.createContext)({});
8468
+ var propsContext = (0, import_react56.createContext)({});
8248
8469
  function PropsProvider(props) {
8249
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
8470
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
8250
8471
  }
8251
- var usePropsContext = () => (0, import_react52.useContext)(propsContext);
8472
+ var usePropsContext = () => (0, import_react56.useContext)(propsContext);
8252
8473
  function PuckProvider({ children }) {
8253
8474
  const {
8254
8475
  config,
@@ -8264,11 +8485,14 @@ function PuckProvider({ children }) {
8264
8485
  metadata,
8265
8486
  onAction
8266
8487
  } = usePropsContext();
8267
- const iframe = __spreadValues({
8268
- enabled: true,
8269
- waitForStyles: true
8270
- }, _iframe);
8271
- const [generatedAppState] = (0, import_react52.useState)(() => {
8488
+ const iframe = (0, import_react56.useMemo)(
8489
+ () => __spreadValues({
8490
+ enabled: true,
8491
+ waitForStyles: true
8492
+ }, _iframe),
8493
+ [_iframe]
8494
+ );
8495
+ const [generatedAppState] = (0, import_react56.useState)(() => {
8272
8496
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8273
8497
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8274
8498
  let clientUiState = {};
@@ -8328,7 +8552,7 @@ function PuckProvider({ children }) {
8328
8552
  return walkAppState(newAppState, config);
8329
8553
  });
8330
8554
  const { appendData = true } = _initialHistory || {};
8331
- const [blendedHistories] = (0, import_react52.useState)(
8555
+ const [blendedHistories] = (0, import_react56.useState)(
8332
8556
  [
8333
8557
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8334
8558
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8348,7 +8572,7 @@ function PuckProvider({ children }) {
8348
8572
  overrides,
8349
8573
  plugins
8350
8574
  });
8351
- const generateAppStore = (0, import_react52.useCallback)(
8575
+ const generateAppStore = (0, import_react56.useCallback)(
8352
8576
  (state) => {
8353
8577
  return {
8354
8578
  state,
@@ -8372,10 +8596,10 @@ function PuckProvider({ children }) {
8372
8596
  metadata
8373
8597
  ]
8374
8598
  );
8375
- const [appStore] = (0, import_react52.useState)(
8599
+ const [appStore] = (0, import_react56.useState)(
8376
8600
  () => createAppStore(generateAppStore(initialAppState))
8377
8601
  );
8378
- (0, import_react52.useEffect)(() => {
8602
+ (0, import_react56.useEffect)(() => {
8379
8603
  const state = appStore.getState().state;
8380
8604
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8381
8605
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8384,66 +8608,47 @@ function PuckProvider({ children }) {
8384
8608
  index: initialHistoryIndex,
8385
8609
  initialAppState
8386
8610
  });
8387
- (0, import_react52.useEffect)(() => {
8388
- appStore.subscribe((s) => {
8389
- if (onChange) onChange(s.state.data);
8390
- });
8611
+ const previousData = (0, import_react56.useRef)(null);
8612
+ (0, import_react56.useEffect)(() => {
8613
+ appStore.subscribe(
8614
+ (s) => s.state.data,
8615
+ (data) => {
8616
+ if (onChange) {
8617
+ if ((0, import_fast_deep_equal3.default)(data, previousData.current)) return;
8618
+ onChange(data);
8619
+ previousData.current = data;
8620
+ }
8621
+ }
8622
+ );
8391
8623
  }, []);
8392
8624
  useRegisterPermissionsSlice(appStore, permissions);
8393
8625
  const uPuckStore = useRegisterUsePuckStore(appStore);
8394
- (0, import_react52.useEffect)(() => {
8626
+ (0, import_react56.useEffect)(() => {
8395
8627
  const { resolveAndCommitData } = appStore.getState();
8396
8628
  resolveAndCommitData();
8397
8629
  }, []);
8398
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8630
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8399
8631
  }
8400
8632
  function PuckLayout({ children }) {
8401
8633
  const {
8402
- onChange,
8403
- onPublish,
8404
- renderHeader,
8405
- renderHeaderActions,
8406
- headerTitle,
8407
- headerPath,
8408
8634
  iframe: _iframe,
8409
8635
  dnd,
8410
8636
  initialHistory: _initialHistory
8411
8637
  } = usePropsContext();
8412
- const iframe = __spreadValues({
8413
- enabled: true,
8414
- waitForStyles: true
8415
- }, _iframe);
8638
+ const iframe = (0, import_react56.useMemo)(
8639
+ () => __spreadValues({
8640
+ enabled: true,
8641
+ waitForStyles: true
8642
+ }, _iframe),
8643
+ [_iframe]
8644
+ );
8416
8645
  useInjectGlobalCss(iframe.enabled);
8417
8646
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8418
8647
  const rightSideBarVisible = useAppStore(
8419
8648
  (s) => s.state.ui.rightSideBarVisible
8420
8649
  );
8421
- const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
8422
- const appStore = useAppStoreApi();
8423
- (0, import_react52.useEffect)(() => {
8424
- return appStore.subscribe((s) => {
8425
- if (onChange) onChange(s.state.data);
8426
- });
8427
- }, [appStore]);
8428
- const rootProps = useAppStore(
8429
- (s) => s.state.data.root.props || s.state.data.root.props
8430
- );
8431
8650
  const dispatch = useAppStore((s) => s.dispatch);
8432
- const toggleSidebars = (0, import_react52.useCallback)(
8433
- (sidebar) => {
8434
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8435
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8436
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8437
- dispatch({
8438
- type: "setUi",
8439
- ui: __spreadValues({
8440
- [`${sidebar}SideBarVisible`]: !sideBarVisible
8441
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
8442
- });
8443
- },
8444
- [dispatch, leftSideBarVisible, rightSideBarVisible]
8445
- );
8446
- (0, import_react52.useEffect)(() => {
8651
+ (0, import_react56.useEffect)(() => {
8447
8652
  if (!window.matchMedia("(min-width: 638px)").matches) {
8448
8653
  dispatch({
8449
8654
  type: "setUi",
@@ -8466,55 +8671,18 @@ function PuckLayout({ children }) {
8466
8671
  window.removeEventListener("resize", handleResize);
8467
8672
  };
8468
8673
  }, []);
8469
- const defaultHeaderRender = (0, import_react52.useMemo)(() => {
8470
- if (renderHeader) {
8471
- console.warn(
8472
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8473
- );
8474
- const RenderHeader = (_a) => {
8475
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8476
- const Comp = renderHeader;
8477
- const appState = useAppStore((s) => s.state);
8478
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8479
- };
8480
- return RenderHeader;
8481
- }
8482
- return DefaultOverride;
8483
- }, [renderHeader]);
8484
- const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
8485
- if (renderHeaderActions) {
8486
- console.warn(
8487
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8488
- );
8489
- const RenderHeader = (props) => {
8490
- const Comp = renderHeaderActions;
8491
- const appState = useAppStore((s) => s.state);
8492
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8493
- };
8494
- return RenderHeader;
8495
- }
8496
- return DefaultOverride;
8497
- }, [renderHeader]);
8498
8674
  const overrides = useAppStore((s) => s.overrides);
8499
- const CustomPuck = (0, import_react52.useMemo)(
8675
+ const CustomPuck = (0, import_react56.useMemo)(
8500
8676
  () => overrides.puck || DefaultOverride,
8501
8677
  [overrides]
8502
8678
  );
8503
- const CustomHeader = (0, import_react52.useMemo)(
8504
- () => overrides.header || defaultHeaderRender,
8505
- [overrides]
8506
- );
8507
- const CustomHeaderActions = (0, import_react52.useMemo)(
8508
- () => overrides.headerActions || defaultHeaderActionsRender,
8509
- [overrides]
8510
- );
8511
- const [mounted, setMounted] = (0, import_react52.useState)(false);
8512
- (0, import_react52.useEffect)(() => {
8679
+ const [mounted, setMounted] = (0, import_react56.useState)(false);
8680
+ (0, import_react56.useEffect)(() => {
8513
8681
  setMounted(true);
8514
8682
  }, []);
8515
8683
  const ready = useAppStore((s) => s.status === "READY");
8516
8684
  useMonitorHotkeys();
8517
- (0, import_react52.useEffect)(() => {
8685
+ (0, import_react56.useEffect)(() => {
8518
8686
  if (ready && iframe.enabled) {
8519
8687
  const frameDoc = getFrame();
8520
8688
  if (frameDoc) {
@@ -8523,133 +8691,36 @@ function PuckLayout({ children }) {
8523
8691
  }
8524
8692
  }, [ready, iframe.enabled]);
8525
8693
  usePreviewModeHotkeys();
8526
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
8527
- /* @__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)(
8694
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `Puck ${getClassName28()}`, children: [
8695
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8528
8696
  "div",
8529
8697
  {
8530
8698
  className: getLayoutClassName({
8531
8699
  leftSideBarVisible,
8532
- menuOpen,
8533
8700
  mounted,
8534
8701
  rightSideBarVisible
8535
8702
  }),
8536
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8537
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8538
- CustomHeader,
8539
- {
8540
- 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)(
8541
- Button,
8542
- {
8543
- onClick: () => {
8544
- const data = appStore.getState().state.data;
8545
- onPublish && onPublish(data);
8546
- },
8547
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8548
- children: "Publish"
8549
- }
8550
- ) }) }),
8551
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
8552
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
8553
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8554
- "div",
8555
- {
8556
- className: getLayoutClassName("leftSideBarToggle"),
8557
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8558
- IconButton,
8559
- {
8560
- onClick: () => {
8561
- toggleSidebars("left");
8562
- },
8563
- title: "Toggle left sidebar",
8564
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8565
- }
8566
- )
8567
- }
8568
- ),
8569
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8570
- "div",
8571
- {
8572
- className: getLayoutClassName("rightSideBarToggle"),
8573
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8574
- IconButton,
8575
- {
8576
- onClick: () => {
8577
- toggleSidebars("right");
8578
- },
8579
- title: "Toggle right sidebar",
8580
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8581
- }
8582
- )
8583
- }
8584
- )
8585
- ] }),
8586
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8587
- headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
8588
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8589
- " ",
8590
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8591
- "code",
8592
- {
8593
- className: getLayoutClassName("headerPath"),
8594
- children: headerPath
8595
- }
8596
- )
8597
- ] })
8598
- ] }) }),
8599
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
8600
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8601
- IconButton,
8602
- {
8603
- onClick: () => {
8604
- return setMenuOpen(!menuOpen);
8605
- },
8606
- title: "Toggle menu bar",
8607
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8608
- }
8609
- ) }),
8610
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8611
- MenuBar,
8612
- {
8613
- dispatch,
8614
- onPublish,
8615
- menuOpen,
8616
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8617
- Button,
8618
- {
8619
- onClick: () => {
8620
- const data = appStore.getState().state.data;
8621
- onPublish && onPublish(data);
8622
- },
8623
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8624
- children: "Publish"
8625
- }
8626
- ) }),
8627
- setMenuOpen
8628
- }
8629
- )
8630
- ] })
8631
- ] }) })
8632
- }
8633
- ),
8634
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8635
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Components, {}) }),
8636
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Outline, {}) })
8703
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8704
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Header, {}),
8705
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8706
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Components, {}) }),
8707
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Outline, {}) })
8637
8708
  ] }),
8638
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Canvas, {}),
8639
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FieldSideBar, {}) })
8709
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Canvas, {}),
8710
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FieldSideBar, {}) })
8640
8711
  ] })
8641
8712
  }
8642
8713
  ) }) }),
8643
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
8714
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { id: "puck-portal-root", className: getClassName28("portal") })
8644
8715
  ] });
8645
8716
  }
8646
8717
  function Puck(props) {
8647
- 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)) })) }));
8718
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
8648
8719
  }
8649
8720
  Puck.Components = Components;
8650
8721
  Puck.Fields = Fields;
8651
8722
  Puck.Outline = Outline;
8652
- Puck.Preview = Preview3;
8723
+ Puck.Preview = Preview2;
8653
8724
 
8654
8725
  // lib/migrate.ts
8655
8726
  init_react_import();
@@ -8684,7 +8755,7 @@ var migrations = [
8684
8755
  const [id, slotName] = zoneCompound.split(":");
8685
8756
  const nodeData = indexes.nodes[id].data;
8686
8757
  const componentType = nodeData.type;
8687
- const configForComponent = config.components[componentType];
8758
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
8688
8759
  if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
8689
8760
  updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8690
8761
  props: __spreadProps(__spreadValues({}, nodeData.props), {
@@ -8742,11 +8813,13 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
8742
8813
  });
8743
8814
 
8744
8815
  // lib/transform-props.ts
8745
- function transformProps(data, propTransforms) {
8816
+ function transformProps(data, propTransforms, config = { components: {} }) {
8746
8817
  const mapItem = (item) => {
8747
8818
  if (propTransforms[item.type]) {
8748
8819
  return __spreadProps(__spreadValues({}, item), {
8749
- props: propTransforms[item.type](item.props)
8820
+ props: __spreadValues({
8821
+ id: item.props.id
8822
+ }, propTransforms[item.type](item.props))
8750
8823
  });
8751
8824
  }
8752
8825
  return item;
@@ -8755,23 +8828,18 @@ function transformProps(data, propTransforms) {
8755
8828
  const rootProps = defaultedData.root.props || defaultedData.root;
8756
8829
  let newRoot = __spreadValues({}, defaultedData.root);
8757
8830
  if (propTransforms["root"]) {
8758
- if (defaultedData.root.props) {
8759
- newRoot.props = propTransforms["root"](rootProps);
8760
- } else {
8761
- newRoot = propTransforms["root"](rootProps);
8762
- }
8831
+ newRoot.props = propTransforms["root"](rootProps);
8763
8832
  }
8764
- const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
8765
- root: newRoot,
8766
- content: defaultedData.content.map(mapItem),
8767
- zones: Object.keys(data.zones || {}).reduce(
8768
- (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
8769
- [zoneKey]: data.zones[zoneKey].map(mapItem)
8770
- }),
8771
- {}
8772
- )
8773
- });
8774
- return afterPropTransforms;
8833
+ const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
8834
+ const updatedData = walkTree(
8835
+ dataWithUpdatedRoot,
8836
+ config,
8837
+ (content) => content.map(mapItem)
8838
+ );
8839
+ if (!defaultedData.root.props) {
8840
+ updatedData.root = updatedData.root.props;
8841
+ }
8842
+ return updatedData;
8775
8843
  }
8776
8844
 
8777
8845
  // lib/resolve-all-data.ts
@@ -8802,13 +8870,12 @@ function resolveAllData(_0, _1) {
8802
8870
  },
8803
8871
  () => {
8804
8872
  },
8805
- "force",
8806
- false
8873
+ "force"
8807
8874
  )).node;
8808
- const resolvedDeep = yield mapSlotsAsync(
8875
+ const resolvedDeep = yield mapSlots(
8809
8876
  resolved,
8810
8877
  processContent,
8811
- false
8878
+ config
8812
8879
  );
8813
8880
  onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
8814
8881
  return resolvedDeep;
@@ -8836,39 +8903,6 @@ function resolveAllData(_0, _1) {
8836
8903
  return dynamic;
8837
8904
  });
8838
8905
  }
8839
-
8840
- // lib/data/walk-tree.ts
8841
- init_react_import();
8842
- function walkTree(data, config, callbackFn) {
8843
- var _a, _b;
8844
- const isSlot2 = createIsSlotConfig(config);
8845
- const walkItem = (item) => {
8846
- return mapSlotsSync(
8847
- item,
8848
- (content, parentId, propName) => callbackFn(content, { parentId, propName }),
8849
- isSlot2
8850
- );
8851
- };
8852
- if ("props" in data) {
8853
- return walkItem(data);
8854
- }
8855
- const _data = data;
8856
- const zones = (_a = _data.zones) != null ? _a : {};
8857
- const mappedContent = _data.content.map(walkItem);
8858
- return {
8859
- root: walkItem(_data.root),
8860
- content: (_b = callbackFn(mappedContent, {
8861
- parentId: "root",
8862
- propName: "default-zone"
8863
- })) != null ? _b : mappedContent,
8864
- zones: Object.keys(zones).reduce(
8865
- (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
8866
- [zoneCompound]: zones[zoneCompound].map(walkItem)
8867
- }),
8868
- {}
8869
- )
8870
- };
8871
- }
8872
8906
  // Annotate the CommonJS export names for ESM import in node:
8873
8907
  0 && (module.exports = {
8874
8908
  Action,
@@ -8889,6 +8923,7 @@ function walkTree(data, config, callbackFn) {
8889
8923
  renderContext,
8890
8924
  resolveAllData,
8891
8925
  transformProps,
8926
+ useGetPuck,
8892
8927
  usePuck,
8893
8928
  walkTree
8894
8929
  });