@measured/puck 0.19.0-canary.fb0e8e24 → 0.19.1-canary.00fbbb8a

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
  });
@@ -309,7 +303,7 @@ init_react_import();
309
303
 
310
304
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
311
305
  init_react_import();
312
- var styles_module_default2 = { "InputWrapper": "_InputWrapper_4xor1_1", "Input-label": "_Input-label_4xor1_5", "Input-labelIcon": "_Input-labelIcon_4xor1_14", "Input-disabledIcon": "_Input-disabledIcon_4xor1_21", "Input-input": "_Input-input_4xor1_26", "Input": "_Input_4xor1_1", "Input--readOnly": "_Input--readOnly_4xor1_75", "Input-radioGroupItems": "_Input-radioGroupItems_4xor1_86", "Input-radio": "_Input-radio_4xor1_86", "Input-radioInner": "_Input-radioInner_4xor1_103", "Input-radioInput": "_Input-radioInput_4xor1_148" };
306
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_py9hf_1", "Input-label": "_Input-label_py9hf_5", "Input-labelIcon": "_Input-labelIcon_py9hf_14", "Input-disabledIcon": "_Input-disabledIcon_py9hf_21", "Input-input": "_Input-input_py9hf_26", "Input": "_Input_py9hf_1", "Input--readOnly": "_Input--readOnly_py9hf_76", "Input-radioGroupItems": "_Input-radioGroupItems_py9hf_87", "Input-radio": "_Input-radio_py9hf_87", "Input-radioInner": "_Input-radioInner_py9hf_104", "Input-radioInput": "_Input-radioInput_py9hf_149" };
313
307
 
314
308
  // components/AutoField/index.tsx
315
309
  var import_react22 = require("react");
@@ -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,170 @@ function forRelatedZones(item, data, cb, path = []) {
868
825
  });
869
826
  }
870
827
 
828
+ // lib/data/map-slots.ts
829
+ init_react_import();
830
+
831
+ // lib/data/default-slots.ts
832
+ init_react_import();
833
+ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
834
+ (acc, fieldName) => fields[fieldName].type === "slot" ? __spreadValues({ [fieldName]: [] }, acc) : acc,
835
+ value
836
+ );
837
+
838
+ // lib/data/map-slots.ts
839
+ var isPromise = (v) => !!v && typeof v.then === "function";
840
+ var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
841
+ var containsPromise = (arr) => arr.some(isPromise);
842
+ var walkField = ({
843
+ value,
844
+ fields,
845
+ map,
846
+ propKey = "",
847
+ propPath = "",
848
+ id = "",
849
+ config,
850
+ recurseSlots = false
851
+ }) => {
852
+ var _a, _b, _c;
853
+ if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
854
+ const content = value || [];
855
+ const mappedContent = recurseSlots ? content.map((el) => {
856
+ var _a2;
857
+ const componentConfig = config.components[el.type];
858
+ if (!componentConfig) {
859
+ throw new Error(`Could not find component config for ${el.type}`);
860
+ }
861
+ const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
862
+ return walkField({
863
+ value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
864
+ fields: fields2,
865
+ map,
866
+ id: el.props.id,
867
+ config,
868
+ recurseSlots
869
+ });
870
+ }) : content;
871
+ if (containsPromise(mappedContent)) {
872
+ return Promise.all(mappedContent);
873
+ }
874
+ return map(mappedContent, id, propPath, fields[propKey], propPath);
875
+ }
876
+ if (value && typeof value === "object") {
877
+ if (Array.isArray(value)) {
878
+ const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
879
+ if (!arrayFields) return value;
880
+ const newValue = value.map(
881
+ (el, idx) => walkField({
882
+ value: el,
883
+ fields: arrayFields,
884
+ map,
885
+ propKey,
886
+ propPath: `${propPath}[${idx}]`,
887
+ id,
888
+ config,
889
+ recurseSlots
890
+ })
891
+ );
892
+ if (containsPromise(newValue)) {
893
+ return Promise.all(newValue);
894
+ }
895
+ return newValue;
896
+ } else if ("$$typeof" in value) {
897
+ return value;
898
+ } else {
899
+ const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
900
+ return walkObject({
901
+ value,
902
+ fields: objectFields,
903
+ map,
904
+ id,
905
+ getPropPath: (k) => `${propPath}.${k}`,
906
+ config,
907
+ recurseSlots
908
+ });
909
+ }
910
+ }
911
+ return value;
912
+ };
913
+ var walkObject = ({
914
+ value,
915
+ fields,
916
+ map,
917
+ id,
918
+ getPropPath,
919
+ config,
920
+ recurseSlots
921
+ }) => {
922
+ const newProps = Object.entries(value).map(([k, v]) => {
923
+ const opts = {
924
+ value: v,
925
+ fields,
926
+ map,
927
+ propKey: k,
928
+ propPath: getPropPath(k),
929
+ id,
930
+ config,
931
+ recurseSlots
932
+ };
933
+ const newValue = walkField(opts);
934
+ if (isPromise(newValue)) {
935
+ return newValue.then((resolvedValue) => ({
936
+ [k]: resolvedValue
937
+ }));
938
+ }
939
+ return {
940
+ [k]: newValue
941
+ };
942
+ }, {});
943
+ if (containsPromise(newProps)) {
944
+ return Promise.all(newProps).then(flatten);
945
+ }
946
+ return flatten(newProps);
947
+ };
948
+ function mapSlots(item, map, config, recurseSlots = false) {
949
+ var _a, _b, _c, _d, _e;
950
+ const itemType = "type" in item ? item.type : "root";
951
+ const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
952
+ const newProps = walkObject({
953
+ value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
954
+ fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
955
+ map,
956
+ id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
957
+ getPropPath: (k) => k,
958
+ config,
959
+ recurseSlots
960
+ });
961
+ if (isPromise(newProps)) {
962
+ return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
963
+ props: resolvedProps
964
+ }));
965
+ }
966
+ return __spreadProps(__spreadValues({}, item), {
967
+ props: newProps
968
+ });
969
+ }
970
+
971
+ // lib/data/flatten-node.ts
972
+ init_react_import();
973
+ var import_flat = __toESM(require("flat"));
974
+
871
975
  // lib/data/strip-slots.ts
872
976
  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
- )
977
+ var stripSlots = (data, config) => {
978
+ return mapSlots(data, () => null, config);
979
+ };
980
+
981
+ // lib/data/flatten-node.ts
982
+ var { flatten: flatten2, unflatten } = import_flat.default;
983
+ var flattenNode = (node, config) => {
984
+ return __spreadProps(__spreadValues({}, node), {
985
+ props: flatten2(stripSlots(node, config).props)
986
+ });
987
+ };
988
+ var expandNode = (node) => {
989
+ const props = unflatten(node.props);
990
+ return __spreadProps(__spreadValues({}, node), {
991
+ props
884
992
  });
885
993
  };
886
994
 
@@ -926,10 +1034,9 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
926
1034
  const mappedItem = mapNodeOrSkip(item, path, index);
927
1035
  if (!mappedItem) return item;
928
1036
  const id = mappedItem.props.id;
929
- const newProps = __spreadValues({}, mappedItem.props);
930
- forEachSlot(
1037
+ const newProps = __spreadProps(__spreadValues({}, mapSlots(
931
1038
  mappedItem,
932
- (parentId2, slotId, content) => {
1039
+ (content, parentId2, slotId) => {
933
1040
  const zoneCompound = `${parentId2}:${slotId}`;
934
1041
  const [_2, newContent2] = processContent(
935
1042
  path,
@@ -938,18 +1045,19 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
938
1045
  "slot",
939
1046
  parentId2
940
1047
  );
941
- newProps[slotId] = newContent2;
1048
+ return newContent2;
942
1049
  },
943
- false,
944
- createIsSlotConfig(config)
945
- );
1050
+ config
1051
+ ).props), {
1052
+ id
1053
+ });
946
1054
  processRelatedZones(item, id, path);
947
1055
  const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
948
1056
  const thisZoneCompound = path[path.length - 1];
949
1057
  const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
950
1058
  newNodeIndex[id] = {
951
1059
  data: newItem,
952
- flatData: stripSlots(newItem),
1060
+ flatData: flattenNode(newItem, config),
953
1061
  path,
954
1062
  parentId,
955
1063
  zone
@@ -1052,56 +1160,17 @@ init_react_import();
1052
1160
 
1053
1161
  // lib/data/walk-tree.ts
1054
1162
  init_react_import();
1055
-
1056
- // lib/data/map-slots.ts
1057
- init_react_import();
1058
- function mapSlotsAsync(_0, _1) {
1059
- return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
1060
- const props = __spreadValues({}, item.props);
1061
- const propKeys = Object.keys(props);
1062
- for (let i = 0; i < propKeys.length; i++) {
1063
- const propKey = propKeys[i];
1064
- const itemType = "type" in item ? item.type : "root";
1065
- if (isSlot2(itemType, propKey, props[propKey])) {
1066
- const content = props[propKey];
1067
- const mappedContent = recursive ? yield Promise.all(
1068
- content.map((item2) => __async(this, null, function* () {
1069
- return yield mapSlotsAsync(item2, map, recursive, isSlot2);
1070
- }))
1071
- ) : content;
1072
- props[propKey] = yield map(mappedContent, propKey);
1073
- }
1074
- }
1075
- return __spreadProps(__spreadValues({}, item), { props });
1076
- });
1077
- }
1078
- function mapSlotsSync(item, map, isSlot2 = isSlot) {
1079
- var _a, _b;
1080
- const props = __spreadValues({}, item.props);
1081
- const propKeys = Object.keys(props);
1082
- for (let i = 0; i < propKeys.length; i++) {
1083
- const propKey = propKeys[i];
1084
- const itemType = "type" in item ? item.type : "root";
1085
- if (isSlot2(itemType, propKey, props[propKey])) {
1086
- const content = props[propKey];
1087
- const mappedContent = content.map((item2) => {
1088
- return mapSlotsSync(item2, map, isSlot2);
1089
- });
1090
- props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
1091
- }
1092
- }
1093
- return __spreadProps(__spreadValues({}, item), { props });
1094
- }
1095
-
1096
- // lib/data/walk-tree.ts
1097
1163
  function walkTree(data, config, callbackFn) {
1098
1164
  var _a, _b;
1099
- const isSlot2 = createIsSlotConfig(config);
1100
1165
  const walkItem = (item) => {
1101
- return mapSlotsSync(
1166
+ return mapSlots(
1102
1167
  item,
1103
- (content, parentId, propName) => callbackFn(content, { parentId, propName }),
1104
- isSlot2
1168
+ (content, parentId, propName) => {
1169
+ var _a2;
1170
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
1171
+ },
1172
+ config,
1173
+ true
1105
1174
  );
1106
1175
  };
1107
1176
  if ("props" in data) {
@@ -1130,7 +1199,7 @@ var populateIds = (data, config, override = false) => {
1130
1199
  const id = generateId(data.type);
1131
1200
  return walkTree(
1132
1201
  __spreadProps(__spreadValues({}, data), {
1133
- props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
1202
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
1134
1203
  }),
1135
1204
  config,
1136
1205
  (contents) => contents.map((item) => {
@@ -1832,7 +1901,11 @@ var createNodesSlice = (set, get) => ({
1832
1901
  const s = get().nodes;
1833
1902
  const emptyNode = {
1834
1903
  id,
1835
- methods: { sync: () => null },
1904
+ methods: {
1905
+ sync: () => null,
1906
+ hideOverlay: () => null,
1907
+ showOverlay: () => null
1908
+ },
1836
1909
  element: null
1837
1910
  };
1838
1911
  const existingNode = s.nodes[id];
@@ -1883,12 +1956,13 @@ var flattenData = (state, config) => {
1883
1956
 
1884
1957
  // lib/get-changed.ts
1885
1958
  init_react_import();
1959
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1886
1960
  var getChanged = (newItem, oldItem) => {
1887
1961
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1888
1962
  const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1889
1963
  const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1890
1964
  return __spreadProps(__spreadValues({}, acc), {
1891
- [item]: oldItemProps[item] !== newItemProps[item]
1965
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1892
1966
  });
1893
1967
  }, {}) : {};
1894
1968
  };
@@ -2034,7 +2108,8 @@ var createFieldsSlice = (_set, _get) => {
2034
2108
  return {
2035
2109
  fields: {},
2036
2110
  loading: false,
2037
- lastResolvedData: {}
2111
+ lastResolvedData: {},
2112
+ id: void 0
2038
2113
  };
2039
2114
  };
2040
2115
  var useRegisterFieldsSlice = (appStore, id) => {
@@ -2055,7 +2130,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
2055
2130
  let lastFields = fields;
2056
2131
  if (reset) {
2057
2132
  appStore.setState((s) => ({
2058
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2133
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
2059
2134
  }));
2060
2135
  lastFields = defaultFields;
2061
2136
  }
@@ -2083,12 +2158,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
2083
2158
  fields: {
2084
2159
  fields: newFields,
2085
2160
  loading: false,
2086
- lastResolvedData: componentData
2161
+ lastResolvedData: componentData,
2162
+ id
2087
2163
  }
2088
2164
  });
2089
2165
  } else {
2090
2166
  appStore.setState((s) => ({
2091
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2167
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
2092
2168
  }));
2093
2169
  }
2094
2170
  }),
@@ -2105,14 +2181,16 @@ var useRegisterFieldsSlice = (appStore, id) => {
2105
2181
 
2106
2182
  // lib/resolve-component-data.ts
2107
2183
  init_react_import();
2108
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
2184
+ var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
2109
2185
  var cache = { lastChange: {} };
2110
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
2186
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2111
2187
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
2112
- if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
2113
- const id = "id" in item.props ? item.props.id : "root";
2188
+ const resolvedItem = __spreadValues({}, item);
2189
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
2190
+ const id = "id" in item.props ? item.props.id : "root";
2191
+ if (shouldRunResolver) {
2114
2192
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
2115
- if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
2193
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
2116
2194
  return { node: resolved, didChange: false };
2117
2195
  }
2118
2196
  const changed = getChanged(item, oldItem);
@@ -2125,46 +2203,42 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2125
2203
  metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
2126
2204
  trigger
2127
2205
  });
2128
- let resolvedItem = __spreadProps(__spreadValues({}, item), {
2129
- props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
2130
- });
2131
- if (recursive) {
2132
- resolvedItem = yield mapSlotsAsync(
2133
- resolvedItem,
2134
- (content) => __async(void 0, null, function* () {
2135
- return Promise.all(
2136
- content.map(
2137
- (childItem) => __async(void 0, null, function* () {
2138
- return (yield resolveComponentData(
2139
- childItem,
2140
- config,
2141
- metadata,
2142
- onResolveStart,
2143
- onResolveEnd,
2144
- trigger,
2145
- false
2146
- )).node;
2147
- })
2148
- )
2149
- );
2150
- }),
2151
- false,
2152
- createIsSlotConfig(config)
2153
- );
2154
- }
2206
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
2155
2207
  if (Object.keys(readOnly).length) {
2156
2208
  resolvedItem.readOnly = readOnly;
2157
2209
  }
2158
- cache.lastChange[id] = {
2159
- item,
2160
- resolved: resolvedItem
2161
- };
2162
- if (onResolveEnd) {
2163
- onResolveEnd(resolvedItem);
2164
- }
2165
- return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
2166
2210
  }
2167
- return { node: item, didChange: false };
2211
+ let itemWithResolvedChildren = yield mapSlots(
2212
+ resolvedItem,
2213
+ (content) => __async(void 0, null, function* () {
2214
+ return yield Promise.all(
2215
+ content.map(
2216
+ (childItem) => __async(void 0, null, function* () {
2217
+ return (yield resolveComponentData(
2218
+ childItem,
2219
+ config,
2220
+ metadata,
2221
+ onResolveStart,
2222
+ onResolveEnd,
2223
+ trigger
2224
+ )).node;
2225
+ })
2226
+ )
2227
+ );
2228
+ }),
2229
+ config
2230
+ );
2231
+ if (shouldRunResolver && onResolveEnd) {
2232
+ onResolveEnd(resolvedItem);
2233
+ }
2234
+ cache.lastChange[id] = {
2235
+ item,
2236
+ resolved: itemWithResolvedChildren
2237
+ };
2238
+ return {
2239
+ node: itemWithResolvedChildren,
2240
+ didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
2241
+ };
2168
2242
  });
2169
2243
 
2170
2244
  // lib/data/to-root.ts
@@ -2184,7 +2258,8 @@ var toRoot = (item) => {
2184
2258
  return { props: {}, readOnly };
2185
2259
  };
2186
2260
 
2187
- // store/index.ts
2261
+ // store/default-app-state.ts
2262
+ init_react_import();
2188
2263
  var defaultAppState = {
2189
2264
  data: { content: [], root: {}, zones: {} },
2190
2265
  ui: {
@@ -2210,6 +2285,8 @@ var defaultAppState = {
2210
2285
  zones: {}
2211
2286
  }
2212
2287
  };
2288
+
2289
+ // store/index.ts
2213
2290
  var defaultPageFields = {
2214
2291
  title: { type: "text" }
2215
2292
  };
@@ -2398,328 +2475,30 @@ function useAppStoreApi() {
2398
2475
  init_react_import();
2399
2476
  var import_react12 = require("@dnd-kit/react");
2400
2477
 
2401
- // lib/dnd/dnd-kit/safe.ts
2402
- init_react_import();
2403
- var import_react10 = require("@dnd-kit/react");
2404
- var import_sortable = require("@dnd-kit/react/sortable");
2405
- function useDroppableSafe(input) {
2406
- if (typeof window === "undefined") {
2407
- return { ref: () => {
2408
- } };
2409
- }
2410
- return (0, import_react10.useDroppable)(input);
2411
- }
2412
- function useDraggableSafe(input) {
2413
- if (typeof window === "undefined") {
2414
- return { ref: () => {
2415
- } };
2416
- }
2417
- return (0, import_react10.useDraggable)(input);
2418
- }
2419
- function useSortableSafe(input) {
2420
- if (typeof window === "undefined") {
2421
- return { ref: () => {
2422
- }, status: "idle", handleRef: () => {
2423
- } };
2424
- }
2425
- return (0, import_sortable.useSortable)(input);
2426
- }
2427
-
2428
2478
  // lib/dnd/use-sensors.ts
2429
2479
  init_react_import();
2430
- var import_react11 = require("react");
2431
-
2432
- // lib/dnd/PointerSensor.ts
2433
- init_react_import();
2434
- var import_state = require("@dnd-kit/state");
2435
- var import_abstract = require("@dnd-kit/abstract");
2436
- var import_geometry = require("@dnd-kit/geometry");
2480
+ var import_react10 = require("react");
2481
+ var import_react11 = require("@dnd-kit/react");
2437
2482
  var import_utilities = require("@dnd-kit/dom/utilities");
2438
- var _clearTimeout;
2439
- var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
2440
- constructor(manager, options) {
2441
- super(manager);
2442
- this.manager = manager;
2443
- this.options = options;
2444
- this.listeners = new import_utilities.Listeners();
2445
- this.cleanup = /* @__PURE__ */ new Set();
2446
- this.source = void 0;
2447
- this.started = false;
2448
- __privateAdd(this, _clearTimeout);
2449
- this.handleCancel = this.handleCancel.bind(this);
2450
- this.handlePointerUp = this.handlePointerUp.bind(this);
2451
- this.handleKeyDown = this.handleKeyDown.bind(this);
2452
- (0, import_state.effect)(() => {
2453
- const unbindGlobal = this.bindGlobal(options != null ? options : {});
2454
- return () => {
2455
- unbindGlobal();
2456
- };
2457
- });
2458
- }
2459
- bind(source, options = this.options) {
2460
- const unbind = (0, import_state.effect)(() => {
2461
- var _a;
2462
- const target = (_a = source.handle) != null ? _a : source.element;
2463
- const listener = (event) => {
2464
- if ((0, import_utilities.isPointerEvent)(event)) {
2465
- this.handlePointerDown(event, source, options);
2466
- }
2467
- };
2468
- if (target) {
2469
- patchWindow(target.ownerDocument.defaultView);
2470
- target.addEventListener("pointerdown", listener);
2471
- return () => {
2472
- target.removeEventListener("pointerdown", listener);
2473
- };
2474
- }
2475
- });
2476
- return unbind;
2477
- }
2478
- bindGlobal(options) {
2479
- const documents = /* @__PURE__ */ new Set();
2480
- for (const draggable of this.manager.registry.draggables.value) {
2481
- if (draggable.element) {
2482
- documents.add((0, import_utilities.getDocument)(draggable.element));
2483
- }
2484
- }
2485
- for (const droppable of this.manager.registry.droppables.value) {
2486
- if (droppable.element) {
2487
- documents.add((0, import_utilities.getDocument)(droppable.element));
2488
- }
2489
- }
2490
- const unbindFns = Array.from(documents).map(
2491
- (doc) => this.listeners.bind(doc, [
2492
- {
2493
- type: "pointermove",
2494
- listener: (event) => this.handlePointerMove(event, doc, options)
2495
- },
2496
- {
2497
- type: "pointerup",
2498
- listener: this.handlePointerUp,
2499
- options: {
2500
- capture: true
2501
- }
2502
- },
2503
- {
2504
- // Cancel activation if there is a competing Drag and Drop interaction
2505
- type: "dragstart",
2506
- listener: this.handleDragStart
2507
- }
2508
- ])
2509
- );
2510
- return () => {
2511
- unbindFns.forEach((unbind) => unbind());
2512
- };
2513
- }
2514
- handlePointerDown(event, source, options = {}) {
2515
- if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
2516
- return;
2517
- }
2518
- const offset = (0, import_utilities.getFrameTransform)(source.element);
2519
- this.initialCoordinates = {
2520
- x: event.clientX * offset.scaleX + offset.x,
2521
- y: event.clientY * offset.scaleY + offset.y
2522
- };
2523
- this.source = source;
2524
- const { activationConstraints } = options;
2525
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
2526
- event.stopImmediatePropagation();
2527
- if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
2528
- this.handleStart(source, event);
2529
- } else {
2530
- const { delay } = constraints;
2531
- if (delay) {
2532
- const timeout3 = setTimeout(
2533
- () => this.handleStart(source, event),
2534
- delay.value
2535
- );
2536
- __privateSet(this, _clearTimeout, () => {
2537
- clearTimeout(timeout3);
2538
- __privateSet(this, _clearTimeout, void 0);
2539
- });
2540
- }
2541
- }
2542
- const cleanup = () => {
2543
- var _a;
2544
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2545
- this.initialCoordinates = void 0;
2546
- this.source = void 0;
2547
- };
2548
- this.cleanup.add(cleanup);
2549
- }
2550
- handlePointerMove(event, doc, options) {
2551
- if (!this.source) {
2552
- return;
2553
- }
2554
- const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
2555
- if (doc !== ownerDocument) {
2556
- return;
2557
- }
2558
- const coordinates = {
2559
- x: event.clientX,
2560
- y: event.clientY
2561
- };
2562
- const offset = (0, import_utilities.getFrameTransform)(this.source.element);
2563
- coordinates.x = coordinates.x * offset.scaleX + offset.x;
2564
- coordinates.y = coordinates.y * offset.scaleY + offset.y;
2565
- if (this.manager.dragOperation.status.dragging) {
2566
- event.preventDefault();
2567
- event.stopPropagation();
2568
- this.manager.actions.move({ to: coordinates });
2569
- return;
2570
- }
2571
- if (!this.initialCoordinates) {
2572
- return;
2573
- }
2574
- const delta = {
2575
- x: coordinates.x - this.initialCoordinates.x,
2576
- y: coordinates.y - this.initialCoordinates.y
2577
- };
2578
- const { activationConstraints } = options;
2579
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
2580
- const { distance, delay } = constraints != null ? constraints : {};
2581
- if (distance) {
2582
- if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
2583
- return this.handleCancel();
2584
- }
2585
- if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
2586
- return this.handleStart(this.source, event);
2587
- }
2588
- }
2589
- if (delay) {
2590
- if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
2591
- return this.handleCancel();
2592
- }
2593
- }
2594
- }
2595
- handlePointerUp(event) {
2596
- if (!this.source) {
2597
- return;
2598
- }
2599
- event.preventDefault();
2600
- event.stopPropagation();
2601
- const { status } = this.manager.dragOperation;
2602
- if (!status.idle) {
2603
- const canceled = !status.initialized;
2604
- this.manager.actions.stop({ canceled });
2605
- } else if (this.started) {
2606
- setTimeout(() => {
2607
- if (!this.manager.dragOperation.status.idle) {
2608
- this.manager.actions.stop({ canceled: false });
2609
- }
2610
- }, 10);
2611
- }
2612
- this.cleanup.forEach((cleanup) => cleanup());
2613
- this.cleanup.clear();
2614
- }
2615
- handleKeyDown(event) {
2616
- if (event.key === "Escape") {
2617
- event.preventDefault();
2618
- this.handleCancel();
2619
- }
2620
- }
2621
- handleStart(source, event) {
2622
- var _a;
2623
- const { manager, initialCoordinates } = this;
2624
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2625
- if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2626
- return;
2627
- }
2628
- if (event.defaultPrevented) {
2629
- return;
2630
- }
2631
- this.started = true;
2632
- event.preventDefault();
2633
- (0, import_state.batch)(() => {
2634
- manager.actions.setDragSource(source.id);
2635
- manager.actions.start({ coordinates: initialCoordinates, event });
2636
- });
2637
- const ownerDocument = (0, import_utilities.getDocument)(event.target);
2638
- const unbind = this.listeners.bind(ownerDocument, [
2639
- {
2640
- // Prevent scrolling on touch devices
2641
- type: "touchmove",
2642
- listener: preventDefault,
2643
- options: {
2644
- passive: false
2645
- }
2646
- },
2647
- {
2648
- // Prevent click events
2649
- type: "click",
2650
- listener: preventDefault
2651
- },
2652
- {
2653
- type: "keydown",
2654
- listener: this.handleKeyDown
2655
- }
2656
- ]);
2657
- ownerDocument.body.setPointerCapture(event.pointerId);
2658
- this.cleanup.add(unbind);
2659
- this.cleanup.add(() => {
2660
- this.started = false;
2661
- });
2662
- }
2663
- handleDragStart(event) {
2664
- const { target } = event;
2665
- if (!(0, import_utilities.isElement)(target)) {
2666
- return;
2667
- }
2668
- const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
2669
- if (isNativeDraggable) {
2670
- this.handleCancel();
2671
- } else {
2672
- preventDefault(event);
2673
- }
2674
- }
2675
- handleCancel() {
2676
- const { dragOperation } = this.manager;
2677
- if (dragOperation.status.initialized) {
2678
- this.manager.actions.stop({ canceled: true });
2679
- }
2680
- this.cleanup.forEach((cleanup) => cleanup());
2681
- this.cleanup.clear();
2682
- }
2683
- destroy() {
2684
- this.listeners.clear();
2685
- }
2483
+ var touchDefault = { delay: { value: 200, tolerance: 10 } };
2484
+ var otherDefault = {
2485
+ delay: { value: 200, tolerance: 10 },
2486
+ distance: { value: 5 }
2686
2487
  };
2687
- _clearTimeout = new WeakMap();
2688
- _PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
2689
- var PointerSensor = _PointerSensor;
2690
- function preventDefault(event) {
2691
- event.preventDefault();
2692
- }
2693
- function noop() {
2694
- }
2695
- var windows = /* @__PURE__ */ new WeakSet();
2696
- function patchWindow(window2) {
2697
- if (!window2 || windows.has(window2)) {
2698
- return;
2699
- }
2700
- window2.addEventListener("touchmove", noop, {
2701
- capture: false,
2702
- passive: false
2703
- });
2704
- windows.add(window2);
2705
- }
2706
-
2707
- // lib/dnd/use-sensors.ts
2708
- var import_utilities2 = require("@dnd-kit/dom/utilities");
2709
2488
  var useSensors = ({
2710
- other,
2489
+ other = otherDefault,
2711
2490
  mouse,
2712
- touch
2491
+ touch = touchDefault
2713
2492
  } = {
2714
- touch: { delay: { value: 200, tolerance: 10 } },
2715
- other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
2493
+ touch: touchDefault,
2494
+ other: otherDefault
2716
2495
  }) => {
2717
- const [sensors] = (0, import_react11.useState)(() => [
2718
- PointerSensor.configure({
2496
+ const [sensors] = (0, import_react10.useState)(() => [
2497
+ import_react11.PointerSensor.configure({
2719
2498
  activationConstraints(event, source) {
2720
2499
  var _a;
2721
2500
  const { pointerType, target } = event;
2722
- if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2501
+ if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2723
2502
  return mouse;
2724
2503
  }
2725
2504
  if (pointerType === "touch") {
@@ -2734,11 +2513,11 @@ var useSensors = ({
2734
2513
 
2735
2514
  // lib/dnd/collision/dynamic/index.ts
2736
2515
  init_react_import();
2737
- var import_abstract9 = require("@dnd-kit/abstract");
2516
+ var import_abstract8 = require("@dnd-kit/abstract");
2738
2517
 
2739
2518
  // lib/dnd/collision/directional/index.ts
2740
2519
  init_react_import();
2741
- var import_abstract2 = require("@dnd-kit/abstract");
2520
+ var import_abstract = require("@dnd-kit/abstract");
2742
2521
 
2743
2522
  // lib/dnd/collision/collision-debug.ts
2744
2523
  init_react_import();
@@ -2816,7 +2595,7 @@ var directionalCollision = (input, previous) => {
2816
2595
  return {
2817
2596
  id: droppable.id,
2818
2597
  value: 1,
2819
- type: import_abstract2.CollisionType.Collision
2598
+ type: import_abstract.CollisionType.Collision
2820
2599
  };
2821
2600
  }
2822
2601
  return null;
@@ -2858,7 +2637,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2858
2637
 
2859
2638
  // lib/dnd/collision/dynamic/track-movement-interval.ts
2860
2639
  init_react_import();
2861
- var import_geometry2 = require("@dnd-kit/geometry");
2640
+ var import_geometry = require("@dnd-kit/geometry");
2862
2641
  var INTERVAL_SENSITIVITY = 10;
2863
2642
  var intervalCache = {
2864
2643
  current: { x: 0, y: 0 },
@@ -2874,13 +2653,15 @@ var trackMovementInterval = (point, dragAxis = "dynamic") => {
2874
2653
  };
2875
2654
  intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
2876
2655
  if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
2877
- intervalCache.previous = import_geometry2.Point.from(point);
2656
+ intervalCache.previous = import_geometry.Point.from(point);
2878
2657
  }
2879
2658
  return intervalCache;
2880
2659
  };
2881
2660
 
2882
2661
  // ../../node_modules/@dnd-kit/collision/dist/index.js
2883
2662
  init_react_import();
2663
+ var import_abstract2 = require("@dnd-kit/abstract");
2664
+ var import_geometry2 = require("@dnd-kit/geometry");
2884
2665
  var import_abstract3 = require("@dnd-kit/abstract");
2885
2666
  var import_geometry3 = require("@dnd-kit/geometry");
2886
2667
  var import_abstract4 = require("@dnd-kit/abstract");
@@ -2891,8 +2672,6 @@ var import_abstract6 = require("@dnd-kit/abstract");
2891
2672
  var import_geometry6 = require("@dnd-kit/geometry");
2892
2673
  var import_abstract7 = require("@dnd-kit/abstract");
2893
2674
  var import_geometry7 = require("@dnd-kit/geometry");
2894
- var import_abstract8 = require("@dnd-kit/abstract");
2895
- var import_geometry8 = require("@dnd-kit/geometry");
2896
2675
  var pointerIntersection = ({
2897
2676
  dragOperation,
2898
2677
  droppable
@@ -2906,12 +2685,12 @@ var pointerIntersection = ({
2906
2685
  return null;
2907
2686
  }
2908
2687
  if (droppable.shape.containsPoint(pointerCoordinates)) {
2909
- const distance = import_geometry3.Point.distance(droppable.shape.center, pointerCoordinates);
2688
+ const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
2910
2689
  return {
2911
2690
  id,
2912
2691
  value: 1 / distance,
2913
- type: import_abstract3.CollisionType.PointerIntersection,
2914
- priority: import_abstract3.CollisionPriority.High
2692
+ type: import_abstract2.CollisionType.PointerIntersection,
2693
+ priority: import_abstract2.CollisionPriority.High
2915
2694
  };
2916
2695
  }
2917
2696
  return null;
@@ -2922,31 +2701,15 @@ var closestCorners = (input) => {
2922
2701
  if (!droppable.shape) {
2923
2702
  return null;
2924
2703
  }
2925
- const { left, top, right, bottom } = droppable.shape.boundingRectangle;
2926
- const corners = [
2927
- {
2928
- x: left,
2929
- y: top
2930
- },
2931
- {
2932
- x: right,
2933
- y: top
2934
- },
2935
- {
2936
- x: left,
2937
- y: bottom
2938
- },
2939
- {
2940
- x: right,
2941
- y: bottom
2942
- }
2943
- ];
2944
- const distance = corners.reduce(
2945
- (acc, corner) => {
2704
+ const shapeCorners = shape ? import_geometry4.Rectangle.from(shape.current.boundingRectangle).corners : void 0;
2705
+ const distance = import_geometry4.Rectangle.from(
2706
+ droppable.shape.boundingRectangle
2707
+ ).corners.reduce(
2708
+ (acc, corner, index) => {
2946
2709
  var _a;
2947
- return acc + import_geometry5.Point.distance(
2948
- import_geometry5.Point.from(corner),
2949
- (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
2710
+ return acc + import_geometry4.Point.distance(
2711
+ import_geometry4.Point.from(corner),
2712
+ (_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
2950
2713
  );
2951
2714
  },
2952
2715
  0
@@ -2955,8 +2718,8 @@ var closestCorners = (input) => {
2955
2718
  return {
2956
2719
  id: droppable.id,
2957
2720
  value: 1 / value,
2958
- type: import_abstract5.CollisionType.Collision,
2959
- priority: import_abstract5.CollisionPriority.Normal
2721
+ type: import_abstract4.CollisionType.Collision,
2722
+ priority: import_abstract4.CollisionPriority.Normal
2960
2723
  };
2961
2724
  };
2962
2725
 
@@ -2981,12 +2744,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2981
2744
  const { center: dragCenter } = dragShape;
2982
2745
  const { fallbackEnabled } = collisionStore.getState();
2983
2746
  const interval = trackMovementInterval(position.current, dragAxis);
2984
- dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2985
- direction: interval.direction
2986
- });
2987
- const collisionMap = dragOperation.data.collisionMap || {};
2988
- dragOperation.data.collisionMap = collisionMap;
2989
- collisionMap[droppable.id] = {
2747
+ const data = {
2990
2748
  direction: interval.direction
2991
2749
  };
2992
2750
  const { center: dropCenter } = dropShape;
@@ -3001,7 +2759,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3001
2759
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
3002
2760
  if (collision) {
3003
2761
  return __spreadProps(__spreadValues({}, collision), {
3004
- priority: import_abstract9.CollisionPriority.Highest
2762
+ priority: import_abstract8.CollisionPriority.Highest,
2763
+ data
3005
2764
  });
3006
2765
  }
3007
2766
  }
@@ -3018,12 +2777,12 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3018
2777
  const collision = {
3019
2778
  id: droppable.id,
3020
2779
  value: intersectionRatio,
3021
- priority: import_abstract9.CollisionPriority.High,
3022
- type: import_abstract9.CollisionType.Collision
2780
+ priority: import_abstract8.CollisionPriority.High,
2781
+ type: import_abstract8.CollisionType.Collision
3023
2782
  };
3024
2783
  const shouldFlushId = flushNext === droppable.id;
3025
2784
  flushNext = "";
3026
- return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2785
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
3027
2786
  }
3028
2787
  if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
3029
2788
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
@@ -3035,9 +2794,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3035
2794
  x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
3036
2795
  y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
3037
2796
  });
3038
- collisionMap[droppable.id] = {
3039
- direction
3040
- };
2797
+ data.direction = direction;
3041
2798
  if (intersectionArea) {
3042
2799
  collisionDebug(
3043
2800
  dragCenter,
@@ -3048,7 +2805,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3048
2805
  );
3049
2806
  flushNext = droppable.id;
3050
2807
  return __spreadProps(__spreadValues({}, fallbackCollision), {
3051
- priority: import_abstract9.CollisionPriority.Low
2808
+ priority: import_abstract8.CollisionPriority.Low,
2809
+ data
3052
2810
  });
3053
2811
  }
3054
2812
  collisionDebug(
@@ -3058,16 +2816,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3058
2816
  "orange",
3059
2817
  direction || ""
3060
2818
  );
3061
- return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract9.CollisionPriority.Lowest });
2819
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2820
+ priority: import_abstract8.CollisionPriority.Lowest,
2821
+ data
2822
+ });
3062
2823
  }
3063
2824
  }
3064
2825
  }
3065
2826
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
3066
- delete collisionMap[droppable.id];
3067
2827
  return null;
3068
2828
  };
3069
2829
 
3070
2830
  // components/Sortable/index.tsx
2831
+ var import_sortable = require("@dnd-kit/react/sortable");
3071
2832
  var import_jsx_runtime5 = require("react/jsx-runtime");
3072
2833
  var SortableProvider = ({
3073
2834
  children,
@@ -3087,16 +2848,16 @@ var SortableProvider = ({
3087
2848
  return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
3088
2849
  },
3089
2850
  onDragOver: (event, manager) => {
3090
- var _a, _b;
2851
+ var _a;
3091
2852
  event.preventDefault();
3092
2853
  const { operation } = event;
3093
2854
  const { source, target } = operation;
3094
2855
  if (!source || !target) return;
3095
2856
  let sourceIndex = source.data.index;
3096
2857
  let targetIndex = target.data.index;
3097
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2858
+ const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
3098
2859
  if (sourceIndex !== targetIndex && source.id !== target.id) {
3099
- const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2860
+ const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
3100
2861
  if (targetIndex >= sourceIndex) {
3101
2862
  targetIndex = targetIndex - 1;
3102
2863
  }
@@ -3127,9 +2888,10 @@ var Sortable = ({
3127
2888
  }) => {
3128
2889
  const {
3129
2890
  ref: sortableRef,
3130
- status,
2891
+ isDragging,
2892
+ isDropping,
3131
2893
  handleRef
3132
- } = useSortableSafe({
2894
+ } = (0, import_sortable.useSortable)({
3133
2895
  id,
3134
2896
  type,
3135
2897
  index,
@@ -3137,7 +2899,7 @@ var Sortable = ({
3137
2899
  data: { index },
3138
2900
  collisionDetector: createDynamicCollisionDetector("y")
3139
2901
  });
3140
- return children({ status, ref: sortableRef, handleRef });
2902
+ return children({ isDragging, isDropping, ref: sortableRef, handleRef });
3141
2903
  };
3142
2904
 
3143
2905
  // components/AutoField/context.tsx
@@ -3262,12 +3024,25 @@ var ArrayField = ({
3262
3024
  }
3263
3025
  }, []);
3264
3026
  const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
3265
- const isDragging = !!draggedItem;
3027
+ const isDraggingAny = !!draggedItem;
3266
3028
  const canEdit = useAppStore(
3267
3029
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
3268
3030
  );
3269
3031
  const forceReadOnly = !canEdit;
3270
3032
  const valueRef = (0, import_react14.useRef)(value);
3033
+ const uniqifyItem = (0, import_react14.useCallback)(
3034
+ (val) => {
3035
+ if (field.type !== "array" || !field.arrayFields) return;
3036
+ const config = appStore.getState().config;
3037
+ return walkField({
3038
+ value: val,
3039
+ fields: field.arrayFields,
3040
+ map: (content) => content.map((item) => populateIds(item, config, true)),
3041
+ config
3042
+ });
3043
+ },
3044
+ [appStore, field]
3045
+ );
3271
3046
  if (field.type !== "array" || !field.arrayFields) {
3272
3047
  return null;
3273
3048
  }
@@ -3327,13 +3102,13 @@ var ArrayField = ({
3327
3102
  id: _arrayId,
3328
3103
  index: i,
3329
3104
  disabled: readOnly,
3330
- children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3105
+ children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3331
3106
  "div",
3332
3107
  {
3333
3108
  ref,
3334
3109
  className: getClassNameItem({
3335
3110
  isExpanded: arrayState.openId === _arrayId,
3336
- isDragging: status === "dragging",
3111
+ isDragging,
3337
3112
  readOnly
3338
3113
  }),
3339
3114
  children: [
@@ -3372,11 +3147,10 @@ var ArrayField = ({
3372
3147
  onClick: (e) => {
3373
3148
  e.stopPropagation();
3374
3149
  const existingValue = [...value || []];
3375
- existingValue.splice(
3376
- i,
3377
- 0,
3150
+ const newItem = uniqifyItem(
3378
3151
  existingValue[i]
3379
3152
  );
3153
+ existingValue.splice(i, 0, newItem);
3380
3154
  const newUi = mapArrayStateToUi(
3381
3155
  regenerateArrayState(existingValue)
3382
3156
  );
@@ -3474,12 +3248,14 @@ var ArrayField = ({
3474
3248
  type: "button",
3475
3249
  className: getClassName5("addButton"),
3476
3250
  onClick: () => {
3477
- if (isDragging) return;
3251
+ var _a;
3252
+ if (isDraggingAny) return;
3478
3253
  const existingValue = value || [];
3479
- const newValue = [
3480
- ...existingValue,
3481
- field.defaultItemProps || {}
3482
- ];
3254
+ const newItem = defaultSlots(
3255
+ uniqifyItem((_a = field.defaultItemProps) != null ? _a : {}),
3256
+ field.arrayFields
3257
+ );
3258
+ const newValue = [...existingValue, newItem];
3483
3259
  const newArrayState = regenerateArrayState(newValue);
3484
3260
  setUi(mapArrayStateToUi(newArrayState), false);
3485
3261
  onChange(newValue);
@@ -4373,6 +4149,10 @@ function AutoFieldInternal(props) {
4373
4149
  });
4374
4150
  }
4375
4151
  }, []);
4152
+ const { visible = true } = props.field;
4153
+ if (!visible) {
4154
+ return null;
4155
+ }
4376
4156
  if (field.type === "slot") {
4377
4157
  return null;
4378
4158
  }
@@ -4457,24 +4237,24 @@ init_react_import();
4457
4237
 
4458
4238
  // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
4459
4239
  init_react_import();
4460
- 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" };
4240
+ 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" };
4461
4241
 
4462
4242
  // components/Drawer/index.tsx
4463
- var import_react37 = require("react");
4243
+ var import_react39 = require("react");
4464
4244
 
4465
4245
  // components/DragDropContext/index.tsx
4466
4246
  init_react_import();
4467
- var import_react35 = require("@dnd-kit/react");
4468
- var import_react36 = require("react");
4247
+ var import_react37 = require("@dnd-kit/react");
4248
+ var import_react38 = require("react");
4469
4249
  var import_dom = require("@dnd-kit/dom");
4470
4250
 
4471
4251
  // components/DropZone/index.tsx
4472
4252
  init_react_import();
4473
- var import_react34 = require("react");
4253
+ var import_react35 = require("react");
4474
4254
 
4475
4255
  // components/DraggableComponent/index.tsx
4476
4256
  init_react_import();
4477
- var import_react25 = require("react");
4257
+ var import_react26 = require("react");
4478
4258
 
4479
4259
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4480
4260
  init_react_import();
@@ -4515,7 +4295,9 @@ var ZoneStoreContext = (0, import_react23.createContext)(
4515
4295
  areaDepthIndex: {},
4516
4296
  nextAreaDepthIndex: {},
4517
4297
  draggedItem: null,
4518
- previewIndex: {}
4298
+ previewIndex: {},
4299
+ enabledIndex: {},
4300
+ hoveringComponent: null
4519
4301
  }))
4520
4302
  );
4521
4303
  var ZoneStoreProvider = ({
@@ -4528,7 +4310,6 @@ var DropZoneProvider = ({
4528
4310
  children,
4529
4311
  value
4530
4312
  }) => {
4531
- const [hoveringComponent, setHoveringComponent] = (0, import_react23.useState)();
4532
4313
  const dispatch = useAppStore((s) => s.dispatch);
4533
4314
  const registerZone = (0, import_react23.useCallback)(
4534
4315
  (zoneCompound) => {
@@ -4550,16 +4331,33 @@ var DropZoneProvider = ({
4550
4331
  );
4551
4332
  const memoValue = (0, import_react23.useMemo)(
4552
4333
  () => __spreadValues({
4553
- hoveringComponent,
4554
- setHoveringComponent,
4555
4334
  registerZone,
4556
4335
  unregisterZone
4557
4336
  }, value),
4558
- [value, hoveringComponent]
4337
+ [value]
4559
4338
  );
4560
4339
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4561
4340
  };
4562
4341
 
4342
+ // components/DraggableComponent/index.tsx
4343
+ var import_shallow2 = require("zustand/react/shallow");
4344
+ var import_sortable2 = require("@dnd-kit/react/sortable");
4345
+
4346
+ // lib/accumulate-transform.ts
4347
+ init_react_import();
4348
+ function accumulateTransform(el) {
4349
+ let matrix = new DOMMatrixReadOnly();
4350
+ let n = el.parentElement;
4351
+ while (n && n !== document.documentElement) {
4352
+ const t = getComputedStyle(n).transform;
4353
+ if (t && t !== "none") {
4354
+ matrix = new DOMMatrixReadOnly(t).multiply(matrix);
4355
+ }
4356
+ n = n.parentElement;
4357
+ }
4358
+ return { scaleX: matrix.a, scaleY: matrix.d };
4359
+ }
4360
+
4563
4361
  // lib/use-context-store.ts
4564
4362
  init_react_import();
4565
4363
  var import_react24 = require("react");
@@ -4573,8 +4371,39 @@ function useContextStore(context, selector) {
4573
4371
  return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
4574
4372
  }
4575
4373
 
4374
+ // lib/dnd/use-on-drag-finished.ts
4375
+ init_react_import();
4376
+ var import_react25 = require("react");
4377
+ var useOnDragFinished = (cb, deps = []) => {
4378
+ const appStore = useAppStoreApi();
4379
+ return (0, import_react25.useCallback)(() => {
4380
+ let dispose = () => {
4381
+ };
4382
+ const processDragging = (isDragging2) => {
4383
+ if (isDragging2) {
4384
+ cb(false);
4385
+ } else {
4386
+ setTimeout(() => {
4387
+ cb(true);
4388
+ }, 0);
4389
+ if (dispose) dispose();
4390
+ }
4391
+ };
4392
+ const isDragging = appStore.getState().state.ui.isDragging;
4393
+ processDragging(isDragging);
4394
+ if (isDragging) {
4395
+ dispose = appStore.subscribe(
4396
+ (s) => s.state.ui.isDragging,
4397
+ (isDragging2) => {
4398
+ processDragging(isDragging2);
4399
+ }
4400
+ );
4401
+ }
4402
+ return dispose;
4403
+ }, [appStore, ...deps]);
4404
+ };
4405
+
4576
4406
  // components/DraggableComponent/index.tsx
4577
- var import_shallow2 = require("zustand/react/shallow");
4578
4407
  var import_jsx_runtime20 = require("react/jsx-runtime");
4579
4408
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
4580
4409
  var DEBUG2 = false;
@@ -4604,7 +4433,6 @@ var DraggableComponent = ({
4604
4433
  isSelected = false,
4605
4434
  debug,
4606
4435
  label,
4607
- isEnabled,
4608
4436
  autoDragAxis,
4609
4437
  userDragAxis,
4610
4438
  inDroppableZone = true
@@ -4618,9 +4446,9 @@ var DraggableComponent = ({
4618
4446
  const overrides = useAppStore((s) => s.overrides);
4619
4447
  const dispatch = useAppStore((s) => s.dispatch);
4620
4448
  const iframe = useAppStore((s) => s.iframe);
4621
- const ctx = (0, import_react25.useContext)(dropZoneContext);
4622
- const [localZones, setLocalZones] = (0, import_react25.useState)({});
4623
- const registerLocalZone = (0, import_react25.useCallback)(
4449
+ const ctx = (0, import_react26.useContext)(dropZoneContext);
4450
+ const [localZones, setLocalZones] = (0, import_react26.useState)({});
4451
+ const registerLocalZone = (0, import_react26.useCallback)(
4624
4452
  (zoneCompound2, active) => {
4625
4453
  var _a;
4626
4454
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4630,7 +4458,7 @@ var DraggableComponent = ({
4630
4458
  },
4631
4459
  [setLocalZones]
4632
4460
  );
4633
- const unregisterLocalZone = (0, import_react25.useCallback)(
4461
+ const unregisterLocalZone = (0, import_react26.useCallback)(
4634
4462
  (zoneCompound2) => {
4635
4463
  var _a;
4636
4464
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4653,14 +4481,17 @@ var DraggableComponent = ({
4653
4481
  return s.permissions.getPermissions({ item });
4654
4482
  })
4655
4483
  );
4656
- const userIsDragging = useContextStore(
4657
- ZoneStoreContext,
4658
- (s) => !!s.draggedItem
4484
+ const zoneStore = (0, import_react26.useContext)(ZoneStoreContext);
4485
+ const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
4486
+ const dynamicCollisionDetector = (0, import_react26.useMemo)(
4487
+ () => createDynamicCollisionDetector(dragAxis),
4488
+ [dragAxis]
4659
4489
  );
4660
- const canCollide = permissions.drag || userIsDragging;
4661
- const disabled = !isEnabled || !canCollide;
4662
- const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
4663
- const { ref: sortableRef, status } = useSortableSafe({
4490
+ const {
4491
+ ref: sortableRef,
4492
+ isDragging: thisIsDragging,
4493
+ sortable
4494
+ } = (0, import_sortable2.useSortable)({
4664
4495
  id,
4665
4496
  index,
4666
4497
  group: zoneCompound,
@@ -4675,18 +4506,34 @@ var DraggableComponent = ({
4675
4506
  path: path || [],
4676
4507
  inDroppableZone
4677
4508
  },
4678
- collisionPriority: isEnabled ? depth : 0,
4679
- collisionDetector: createDynamicCollisionDetector(dragAxis),
4680
- disabled,
4509
+ collisionPriority: depth,
4510
+ collisionDetector: dynamicCollisionDetector,
4681
4511
  // "Out of the way" transition from react-beautiful-dnd
4682
4512
  transition: {
4683
4513
  duration: 200,
4684
4514
  easing: "cubic-bezier(0.2, 0, 0, 1)"
4685
- }
4515
+ },
4516
+ feedback: "clone"
4686
4517
  });
4687
- const thisIsDragging = status === "dragging";
4688
- const ref = (0, import_react25.useRef)(null);
4689
- const refSetter = (0, import_react25.useCallback)(
4518
+ (0, import_react26.useEffect)(() => {
4519
+ const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
4520
+ sortable.droppable.disabled = !isEnabled;
4521
+ sortable.draggable.disabled = !permissions.drag;
4522
+ const cleanup = zoneStore.subscribe((s) => {
4523
+ sortable.droppable.disabled = !s.enabledIndex[zoneCompound];
4524
+ });
4525
+ if (ref.current && !permissions.drag) {
4526
+ ref.current.setAttribute("data-puck-disabled", "");
4527
+ return () => {
4528
+ var _a;
4529
+ (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4530
+ cleanup();
4531
+ };
4532
+ }
4533
+ return cleanup;
4534
+ }, [permissions.drag, zoneCompound]);
4535
+ const ref = (0, import_react26.useRef)(null);
4536
+ const refSetter = (0, import_react26.useCallback)(
4690
4537
  (el) => {
4691
4538
  sortableRef(el);
4692
4539
  if (el) {
@@ -4695,14 +4542,14 @@ var DraggableComponent = ({
4695
4542
  },
4696
4543
  [sortableRef]
4697
4544
  );
4698
- const [portalEl, setPortalEl] = (0, import_react25.useState)();
4699
- (0, import_react25.useEffect)(() => {
4545
+ const [portalEl, setPortalEl] = (0, import_react26.useState)();
4546
+ (0, import_react26.useEffect)(() => {
4700
4547
  var _a, _b, _c;
4701
4548
  setPortalEl(
4702
4549
  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
4703
4550
  );
4704
4551
  }, [iframe.enabled, ref.current]);
4705
- const getStyle = (0, import_react25.useCallback)(() => {
4552
+ const getStyle = (0, import_react26.useCallback)(() => {
4706
4553
  var _a, _b, _c;
4707
4554
  if (!ref.current) return;
4708
4555
  const rect = ref.current.getBoundingClientRect();
@@ -4714,40 +4561,61 @@ var DraggableComponent = ({
4714
4561
  x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
4715
4562
  y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
4716
4563
  };
4564
+ const untransformed = {
4565
+ height: ref.current.offsetHeight,
4566
+ width: ref.current.offsetWidth
4567
+ };
4568
+ const transform = accumulateTransform(ref.current);
4717
4569
  const style2 = {
4718
- left: `${rect.left + scroll.x}px`,
4719
- top: `${rect.top + scroll.y}px`,
4720
- height: `${rect.height}px`,
4721
- width: `${rect.width}px`
4570
+ left: `${(rect.left + scroll.x) / transform.scaleX}px`,
4571
+ top: `${(rect.top + scroll.y) / transform.scaleY}px`,
4572
+ height: `${untransformed.height}px`,
4573
+ width: `${untransformed.width}px`
4722
4574
  };
4723
4575
  return style2;
4724
4576
  }, [ref.current]);
4725
- const [style, setStyle] = (0, import_react25.useState)();
4726
- const sync = (0, import_react25.useCallback)(() => {
4577
+ const [style, setStyle] = (0, import_react26.useState)();
4578
+ const sync = (0, import_react26.useCallback)(() => {
4727
4579
  setStyle(getStyle());
4728
4580
  }, [ref.current, iframe]);
4729
- (0, import_react25.useEffect)(() => {
4730
- if (ref.current && !userIsDragging) {
4581
+ (0, import_react26.useEffect)(() => {
4582
+ if (ref.current) {
4731
4583
  const observer = new ResizeObserver(sync);
4732
4584
  observer.observe(ref.current);
4733
4585
  return () => {
4734
4586
  observer.disconnect();
4735
4587
  };
4736
4588
  }
4737
- }, [ref.current, userIsDragging]);
4589
+ }, [ref.current]);
4738
4590
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4739
- (0, import_react25.useEffect)(() => {
4591
+ const hideOverlay = (0, import_react26.useCallback)(() => {
4592
+ setIsVisible(false);
4593
+ }, []);
4594
+ const showOverlay = (0, import_react26.useCallback)(() => {
4595
+ setIsVisible(true);
4596
+ }, []);
4597
+ (0, import_react26.useEffect)(() => {
4740
4598
  var _a;
4741
- registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4599
+ registerNode(id, {
4600
+ methods: { sync, showOverlay, hideOverlay },
4601
+ element: (_a = ref.current) != null ? _a : null
4602
+ });
4742
4603
  return () => {
4743
- registerNode(id, { methods: { sync: () => null }, element: null });
4604
+ registerNode(id, {
4605
+ methods: {
4606
+ sync: () => null,
4607
+ hideOverlay: () => null,
4608
+ showOverlay: () => null
4609
+ },
4610
+ element: null
4611
+ });
4744
4612
  };
4745
4613
  }, [id, zoneCompound, index, componentType, sync]);
4746
- const CustomActionBar = (0, import_react25.useMemo)(
4614
+ const CustomActionBar = (0, import_react26.useMemo)(
4747
4615
  () => overrides.actionBar || DefaultActionBar,
4748
4616
  [overrides.actionBar]
4749
4617
  );
4750
- const onClick = (0, import_react25.useCallback)(
4618
+ const onClick = (0, import_react26.useCallback)(
4751
4619
  (e) => {
4752
4620
  e.stopPropagation();
4753
4621
  dispatch({
@@ -4760,7 +4628,7 @@ var DraggableComponent = ({
4760
4628
  [index, zoneCompound, id]
4761
4629
  );
4762
4630
  const appStore = useAppStoreApi();
4763
- const onSelectParent = (0, import_react25.useCallback)(() => {
4631
+ const onSelectParent = (0, import_react26.useCallback)(() => {
4764
4632
  const { nodes, zones } = appStore.getState().state.indexes;
4765
4633
  const node = nodes[id];
4766
4634
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4781,28 +4649,32 @@ var DraggableComponent = ({
4781
4649
  }
4782
4650
  });
4783
4651
  }, [ctx, path]);
4784
- const onDuplicate = (0, import_react25.useCallback)(() => {
4652
+ const onDuplicate = (0, import_react26.useCallback)(() => {
4785
4653
  dispatch({
4786
4654
  type: "duplicate",
4787
4655
  sourceIndex: index,
4788
4656
  sourceZone: zoneCompound
4789
4657
  });
4790
4658
  }, [index, zoneCompound]);
4791
- const onDelete = (0, import_react25.useCallback)(() => {
4659
+ const onDelete = (0, import_react26.useCallback)(() => {
4792
4660
  dispatch({
4793
4661
  type: "remove",
4794
4662
  index,
4795
4663
  zone: zoneCompound
4796
4664
  });
4797
4665
  }, [index, zoneCompound]);
4798
- const [hover, setHover] = (0, import_react25.useState)(false);
4799
- const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4800
- (0, import_react25.useEffect)(() => {
4666
+ const [hover, setHover] = (0, import_react26.useState)(false);
4667
+ const indicativeHover = useContextStore(
4668
+ ZoneStoreContext,
4669
+ (s) => s.hoveringComponent === id
4670
+ );
4671
+ (0, import_react26.useEffect)(() => {
4801
4672
  if (!ref.current) {
4802
4673
  return;
4803
4674
  }
4804
4675
  const el = ref.current;
4805
4676
  const _onMouseOver = (e) => {
4677
+ const userIsDragging = !!zoneStore.getState().draggedItem;
4806
4678
  if (userIsDragging) {
4807
4679
  if (thisIsDragging) {
4808
4680
  setHover(true);
@@ -4824,18 +4696,12 @@ var DraggableComponent = ({
4824
4696
  el.addEventListener("click", onClick);
4825
4697
  el.addEventListener("mouseover", _onMouseOver);
4826
4698
  el.addEventListener("mouseout", _onMouseOut);
4827
- if (thisIsDragging) {
4828
- el.setAttribute("data-puck-dragging", "");
4829
- } else {
4830
- el.removeAttribute("data-puck-dragging");
4831
- }
4832
4699
  return () => {
4833
4700
  el.removeAttribute("data-puck-component");
4834
4701
  el.removeAttribute("data-puck-dnd");
4835
4702
  el.removeEventListener("click", onClick);
4836
4703
  el.removeEventListener("mouseover", _onMouseOver);
4837
4704
  el.removeEventListener("mouseout", _onMouseOut);
4838
- el.removeAttribute("data-puck-dragging");
4839
4705
  };
4840
4706
  }, [
4841
4707
  ref,
@@ -4843,29 +4709,43 @@ var DraggableComponent = ({
4843
4709
  containsActiveZone,
4844
4710
  zoneCompound,
4845
4711
  id,
4846
- userIsDragging,
4847
4712
  thisIsDragging,
4848
4713
  inDroppableZone
4849
4714
  ]);
4850
- (0, import_react25.useEffect)(() => {
4851
- if (ref.current && disabled) {
4852
- ref.current.setAttribute("data-puck-disabled", "");
4853
- return () => {
4854
- var _a;
4855
- (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4856
- };
4857
- }
4858
- }, [disabled, ref]);
4859
- const [isVisible, setIsVisible] = (0, import_react25.useState)(false);
4860
- (0, import_react25.useEffect)(() => {
4861
- sync();
4862
- if ((isSelected || hover || indicativeHover) && !userIsDragging) {
4863
- setIsVisible(true);
4715
+ const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
4716
+ const [dragFinished, setDragFinished] = (0, import_react26.useState)(true);
4717
+ const [_, startTransition] = (0, import_react26.useTransition)();
4718
+ (0, import_react26.useEffect)(() => {
4719
+ startTransition(() => {
4720
+ if (hover || indicativeHover || isSelected) {
4721
+ sync();
4722
+ setIsVisible(true);
4723
+ setThisWasDragging(false);
4724
+ } else {
4725
+ setIsVisible(false);
4726
+ }
4727
+ });
4728
+ }, [hover, indicativeHover, isSelected, iframe]);
4729
+ const [thisWasDragging, setThisWasDragging] = (0, import_react26.useState)(false);
4730
+ const onDragFinished = useOnDragFinished((finished) => {
4731
+ if (finished) {
4732
+ startTransition(() => {
4733
+ sync();
4734
+ setDragFinished(true);
4735
+ });
4864
4736
  } else {
4865
- setIsVisible(false);
4737
+ setDragFinished(false);
4738
+ }
4739
+ });
4740
+ (0, import_react26.useEffect)(() => {
4741
+ if (thisIsDragging) {
4742
+ setThisWasDragging(true);
4866
4743
  }
4867
- }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
4868
- const syncActionsPosition = (0, import_react25.useCallback)(
4744
+ }, [thisIsDragging]);
4745
+ (0, import_react26.useEffect)(() => {
4746
+ if (thisWasDragging) return onDragFinished();
4747
+ }, [thisWasDragging, onDragFinished]);
4748
+ const syncActionsPosition = (0, import_react26.useCallback)(
4869
4749
  (el) => {
4870
4750
  if (el) {
4871
4751
  const view = el.ownerDocument.defaultView;
@@ -4890,7 +4770,7 @@ var DraggableComponent = ({
4890
4770
  },
4891
4771
  [zoom]
4892
4772
  );
4893
- (0, import_react25.useEffect)(() => {
4773
+ (0, import_react26.useEffect)(() => {
4894
4774
  if (userDragAxis) {
4895
4775
  setDragAxis(userDragAxis);
4896
4776
  return;
@@ -4904,8 +4784,11 @@ var DraggableComponent = ({
4904
4784
  }
4905
4785
  setDragAxis(autoDragAxis);
4906
4786
  }, [ref, userDragAxis, autoDragAxis]);
4907
- 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 }) });
4908
- const nextContextValue = (0, import_react25.useMemo)(
4787
+ const parentAction = (0, import_react26.useMemo)(
4788
+ () => (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 }) }),
4789
+ [ctx == null ? void 0 : ctx.areaId]
4790
+ );
4791
+ const nextContextValue = (0, import_react26.useMemo)(
4909
4792
  () => __spreadProps(__spreadValues({}, ctx), {
4910
4793
  areaId: id,
4911
4794
  zoneCompound,
@@ -4925,7 +4808,7 @@ var DraggableComponent = ({
4925
4808
  ]
4926
4809
  );
4927
4810
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
4928
- isVisible && (0, import_react_dom2.createPortal)(
4811
+ dragFinished && isVisible && (0, import_react_dom2.createPortal)(
4929
4812
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4930
4813
  "div",
4931
4814
  {
@@ -4985,19 +4868,23 @@ var DraggableComponent = ({
4985
4868
 
4986
4869
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
4987
4870
  init_react_import();
4988
- 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" };
4871
+ 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" };
4872
+
4873
+ // components/DropZone/index.tsx
4874
+ var import_react36 = require("@dnd-kit/react");
4989
4875
 
4990
4876
  // components/DropZone/lib/use-min-empty-height.ts
4991
4877
  init_react_import();
4992
- var import_react26 = require("react");
4878
+ var import_react27 = require("react");
4879
+ var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
4993
4880
  var useMinEmptyHeight = ({
4994
4881
  zoneCompound,
4995
4882
  userMinEmptyHeight,
4996
4883
  ref
4997
4884
  }) => {
4998
4885
  const appStore = useAppStoreApi();
4999
- const [prevHeight, setPrevHeight] = (0, import_react26.useState)(0);
5000
- const [isAnimating, setIsAnimating] = (0, import_react26.useState)(false);
4886
+ const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
4887
+ const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
5001
4888
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
5002
4889
  var _a, _b;
5003
4890
  return {
@@ -5005,32 +4892,52 @@ var useMinEmptyHeight = ({
5005
4892
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
5006
4893
  };
5007
4894
  });
5008
- (0, import_react26.useEffect)(() => {
4895
+ const numItems = (0, import_react27.useRef)(0);
4896
+ const onDragFinished = useOnDragFinished(
4897
+ (finished) => {
4898
+ var _a;
4899
+ if (finished) {
4900
+ const newNumItems = getNumItems(appStore, zoneCompound);
4901
+ setPrevHeight(0);
4902
+ if (newNumItems || numItems.current === 0) {
4903
+ setIsAnimating(false);
4904
+ return;
4905
+ }
4906
+ const selectedItem = appStore.getState().selectedItem;
4907
+ const zones = appStore.getState().state.indexes.zones;
4908
+ const nodes = appStore.getState().nodes;
4909
+ (_a = nodes.nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.methods.hideOverlay();
4910
+ setTimeout(() => {
4911
+ var _a2;
4912
+ const contentIds = ((_a2 = zones[zoneCompound]) == null ? void 0 : _a2.contentIds) || [];
4913
+ contentIds.forEach((contentId) => {
4914
+ const node = nodes.nodes[contentId];
4915
+ node == null ? void 0 : node.methods.sync();
4916
+ });
4917
+ if (selectedItem) {
4918
+ setTimeout(() => {
4919
+ var _a3, _b;
4920
+ (_a3 = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _a3.methods.sync();
4921
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.showOverlay();
4922
+ }, 200);
4923
+ }
4924
+ setIsAnimating(false);
4925
+ }, 100);
4926
+ }
4927
+ },
4928
+ [appStore, prevHeight, zoneCompound]
4929
+ );
4930
+ (0, import_react27.useEffect)(() => {
5009
4931
  if (draggedItem && ref.current) {
5010
4932
  if (isZone) {
5011
4933
  const rect = ref.current.getBoundingClientRect();
4934
+ numItems.current = getNumItems(appStore, zoneCompound);
5012
4935
  setPrevHeight(rect.height);
5013
4936
  setIsAnimating(true);
5014
- return;
4937
+ return onDragFinished();
5015
4938
  }
5016
4939
  }
5017
- setPrevHeight(0);
5018
- setTimeout(() => {
5019
- var _a, _b;
5020
- const zones = appStore.getState().state.indexes.zones;
5021
- const nodes = appStore.getState().nodes;
5022
- const selectedItem = appStore.getState().selectedItem;
5023
- const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
5024
- contentIds.forEach((contentId) => {
5025
- const node = nodes.nodes[contentId];
5026
- node == null ? void 0 : node.methods.sync();
5027
- });
5028
- if (selectedItem) {
5029
- (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
5030
- }
5031
- setIsAnimating(false);
5032
- }, 400);
5033
- }, [ref.current, draggedItem, zoneCompound]);
4940
+ }, [ref.current, draggedItem, onDragFinished]);
5034
4941
  return [prevHeight || userMinEmptyHeight, isAnimating];
5035
4942
  };
5036
4943
 
@@ -5051,15 +4958,15 @@ function assignRefs(refs, node) {
5051
4958
 
5052
4959
  // components/DropZone/lib/use-content-with-preview.ts
5053
4960
  init_react_import();
5054
- var import_react29 = require("react");
4961
+ var import_react30 = require("react");
5055
4962
 
5056
4963
  // lib/dnd/use-rendered-callback.ts
5057
4964
  init_react_import();
5058
- var import_react27 = require("@dnd-kit/react");
5059
- var import_react28 = require("react");
4965
+ var import_react28 = require("@dnd-kit/react");
4966
+ var import_react29 = require("react");
5060
4967
  function useRenderedCallback(callback, deps) {
5061
- const manager = (0, import_react27.useDragDropManager)();
5062
- return (0, import_react28.useCallback)(
4968
+ const manager = (0, import_react28.useDragDropManager)();
4969
+ return (0, import_react29.useCallback)(
5063
4970
  (...args) => __async(this, null, function* () {
5064
4971
  yield manager == null ? void 0 : manager.renderer.rendering;
5065
4972
  return callback(...args);
@@ -5070,24 +4977,18 @@ function useRenderedCallback(callback, deps) {
5070
4977
 
5071
4978
  // components/DropZone/lib/use-content-with-preview.ts
5072
4979
  var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5073
- const { draggedItemId, preview, previewExists } = useContextStore(
4980
+ const zoneStore = (0, import_react30.useContext)(ZoneStoreContext);
4981
+ const preview = useContextStore(
5074
4982
  ZoneStoreContext,
5075
- (s) => {
5076
- var _a;
5077
- return {
5078
- draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
5079
- preview: s.previewIndex[zoneCompound],
5080
- previewExists: Object.keys(s.previewIndex || {}).length > 0
5081
- };
5082
- }
4983
+ (s) => s.previewIndex[zoneCompound]
5083
4984
  );
5084
4985
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
5085
- const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react29.useState)(contentIds);
5086
- const [localPreview, setLocalPreview] = (0, import_react29.useState)(
4986
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
4987
+ const [localPreview, setLocalPreview] = (0, import_react30.useState)(
5087
4988
  preview
5088
4989
  );
5089
4990
  const updateContent = useRenderedCallback(
5090
- (contentIds2, preview2, isDragging2) => {
4991
+ (contentIds2, preview2, isDragging2, draggedItemId, previewExists) => {
5091
4992
  if (isDragging2 && !previewExists) {
5092
4993
  return;
5093
4994
  }
@@ -5116,26 +5017,36 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5116
5017
  }
5117
5018
  setLocalPreview(preview2);
5118
5019
  },
5119
- [draggedItemId, previewExists]
5020
+ []
5120
5021
  );
5121
- (0, import_react29.useEffect)(() => {
5122
- updateContent(contentIds, preview, isDragging);
5022
+ (0, import_react30.useEffect)(() => {
5023
+ var _a;
5024
+ const s = zoneStore.getState();
5025
+ const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
5026
+ const previewExists = Object.keys(s.previewIndex || {}).length > 0;
5027
+ updateContent(
5028
+ contentIds,
5029
+ preview,
5030
+ isDragging,
5031
+ draggedItemId,
5032
+ previewExists
5033
+ );
5123
5034
  }, [contentIds, preview, isDragging]);
5124
5035
  return [contentIdsWithPreview, localPreview];
5125
5036
  };
5126
5037
 
5127
5038
  // components/DropZone/lib/use-drag-axis.ts
5128
5039
  init_react_import();
5129
- var import_react30 = require("react");
5040
+ var import_react31 = require("react");
5130
5041
  var GRID_DRAG_AXIS = "dynamic";
5131
5042
  var FLEX_ROW_DRAG_AXIS = "x";
5132
5043
  var DEFAULT_DRAG_AXIS = "y";
5133
5044
  var useDragAxis = (ref, collisionAxis) => {
5134
5045
  const status = useAppStore((s) => s.status);
5135
- const [dragAxis, setDragAxis] = (0, import_react30.useState)(
5046
+ const [dragAxis, setDragAxis] = (0, import_react31.useState)(
5136
5047
  collisionAxis || DEFAULT_DRAG_AXIS
5137
5048
  );
5138
- const calculateDragAxis = (0, import_react30.useCallback)(() => {
5049
+ const calculateDragAxis = (0, import_react31.useCallback)(() => {
5139
5050
  if (ref.current) {
5140
5051
  const computedStyle = window.getComputedStyle(ref.current);
5141
5052
  if (computedStyle.display === "grid") {
@@ -5147,7 +5058,7 @@ var useDragAxis = (ref, collisionAxis) => {
5147
5058
  }
5148
5059
  }
5149
5060
  }, [ref.current]);
5150
- (0, import_react30.useEffect)(() => {
5061
+ (0, import_react31.useEffect)(() => {
5151
5062
  const onViewportChange = () => {
5152
5063
  calculateDragAxis();
5153
5064
  };
@@ -5156,54 +5067,57 @@ var useDragAxis = (ref, collisionAxis) => {
5156
5067
  window.removeEventListener("viewportchange", onViewportChange);
5157
5068
  };
5158
5069
  }, []);
5159
- (0, import_react30.useEffect)(calculateDragAxis, [status, collisionAxis]);
5070
+ (0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
5160
5071
  return [dragAxis, calculateDragAxis];
5161
5072
  };
5162
5073
 
5163
5074
  // components/DropZone/index.tsx
5164
- var import_shallow3 = require("zustand/react/shallow");
5075
+ var import_shallow4 = require("zustand/react/shallow");
5165
5076
 
5166
5077
  // components/Render/index.tsx
5167
5078
  init_react_import();
5168
5079
 
5169
5080
  // lib/use-slots.tsx
5170
5081
  init_react_import();
5171
- var import_react31 = require("react");
5172
- function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5173
- const slotProps = (0, import_react31.useMemo)(() => {
5174
- if (!(config == null ? void 0 : config.fields)) return props;
5175
- const slotProps2 = {};
5176
- const fieldKeys = Object.keys(config.fields);
5177
- for (let i = 0; i < fieldKeys.length; i++) {
5178
- const fieldKey = fieldKeys[i];
5179
- const field = config.fields[fieldKey];
5180
- if ((field == null ? void 0 : field.type) === "slot") {
5181
- const content = props[fieldKey] || [];
5182
- const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
5082
+ var import_react32 = require("react");
5083
+ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5084
+ const slotProps = (0, import_react32.useMemo)(() => {
5085
+ const mapped = mapSlots(
5086
+ item,
5087
+ (content, _parentId, propName, field, propPath) => {
5088
+ const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
5089
+ const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
5090
+ const render = isReadOnly ? renderSlotRender : renderSlotEdit;
5183
5091
  const Slot = (dzProps) => render(__spreadProps(__spreadValues({
5184
- allow: field.allow,
5185
- disallow: field.disallow
5092
+ allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
5093
+ disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
5186
5094
  }, dzProps), {
5187
- zone: fieldKey,
5095
+ zone: propName,
5188
5096
  content
5189
5097
  }));
5190
- slotProps2[fieldKey] = Slot;
5191
- }
5192
- }
5193
- return slotProps2;
5194
- }, [config, readOnly, forceReadOnly]);
5195
- return __spreadValues(__spreadValues({}, props), slotProps);
5098
+ return Slot;
5099
+ },
5100
+ config
5101
+ ).props;
5102
+ return mapped;
5103
+ }, [config, item, readOnly, forceReadOnly]);
5104
+ const mergedProps = (0, import_react32.useMemo)(
5105
+ () => __spreadValues(__spreadValues({}, item.props), slotProps),
5106
+ [item.props, slotProps]
5107
+ );
5108
+ return mergedProps;
5196
5109
  }
5197
5110
 
5198
5111
  // components/Render/index.tsx
5199
- var import_react33 = __toESM(require("react"));
5112
+ var import_react34 = __toESM(require("react"));
5200
5113
 
5201
5114
  // components/SlotRender/index.tsx
5202
5115
  init_react_import();
5116
+ var import_shallow3 = require("zustand/react/shallow");
5203
5117
 
5204
5118
  // components/SlotRender/server.tsx
5205
5119
  init_react_import();
5206
- var import_react32 = require("react");
5120
+ var import_react33 = require("react");
5207
5121
 
5208
5122
  // components/ServerRender/index.tsx
5209
5123
  init_react_import();
@@ -5238,12 +5152,15 @@ function DropZoneRender({
5238
5152
  metadata
5239
5153
  }
5240
5154
  ),
5241
- metadata
5155
+ metadata,
5156
+ dragRef: null,
5157
+ isEditing: false
5242
5158
  }
5243
5159
  });
5244
- const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
5160
+ const renderItem = __spreadProps(__spreadValues({}, item), { props });
5161
+ const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
5245
5162
  if (Component) {
5246
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
5163
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
5247
5164
  }
5248
5165
  return null;
5249
5166
  }) });
@@ -5258,7 +5175,7 @@ var Item = ({
5258
5175
  metadata
5259
5176
  }) => {
5260
5177
  const Component = config.components[item.type];
5261
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5178
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5262
5179
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5263
5180
  Component.render,
5264
5181
  __spreadProps(__spreadValues({}, props), {
@@ -5269,7 +5186,7 @@ var Item = ({
5269
5186
  })
5270
5187
  );
5271
5188
  };
5272
- var SlotRender = (0, import_react32.forwardRef)(
5189
+ var SlotRender = (0, import_react33.forwardRef)(
5273
5190
  function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5274
5191
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
5275
5192
  if (!config.components[item.type]) {
@@ -5297,10 +5214,12 @@ var ContextSlotRender = ({
5297
5214
  const config = useAppStore((s) => s.config);
5298
5215
  const metadata = useAppStore((s) => s.metadata);
5299
5216
  const slotContent = useAppStore(
5300
- (s) => {
5217
+ (0, import_shallow3.useShallow)((s) => {
5301
5218
  var _a, _b;
5302
- return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
5303
- }
5219
+ const indexes = s.state.indexes;
5220
+ const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
5221
+ return contentIds.map((contentId) => indexes.nodes[contentId].flatData);
5222
+ })
5304
5223
  );
5305
5224
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5306
5225
  SlotRenderPure,
@@ -5315,7 +5234,7 @@ var ContextSlotRender = ({
5315
5234
 
5316
5235
  // components/Render/index.tsx
5317
5236
  var import_jsx_runtime24 = require("react/jsx-runtime");
5318
- var renderContext = import_react33.default.createContext({
5237
+ var renderContext = import_react34.default.createContext({
5319
5238
  config: { components: {} },
5320
5239
  data: { root: {}, content: [] },
5321
5240
  metadata: {}
@@ -5330,7 +5249,7 @@ function Render({
5330
5249
  root: data.root || {},
5331
5250
  content: data.content || []
5332
5251
  });
5333
- const rootProps = defaultedData.root.props || defaultedData.root;
5252
+ const rootProps = "props" in defaultedData.root ? defaultedData.root.props : defaultedData.root;
5334
5253
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
5335
5254
  const pageProps = __spreadProps(__spreadValues({}, rootProps), {
5336
5255
  puck: {
@@ -5343,8 +5262,12 @@ function Render({
5343
5262
  editMode: false,
5344
5263
  id: "puck-root"
5345
5264
  });
5346
- const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
5347
- const nextContextValue = (0, import_react33.useMemo)(
5265
+ const propsWithSlots = useSlots(
5266
+ config,
5267
+ { type: "root", props: pageProps },
5268
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
5269
+ );
5270
+ const nextContextValue = (0, import_react34.useMemo)(
5348
5271
  () => ({
5349
5272
  mode: "render",
5350
5273
  depth: 0
@@ -5366,19 +5289,18 @@ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5366
5289
  var DropZoneChild = ({
5367
5290
  zoneCompound,
5368
5291
  componentId,
5369
- preview,
5370
5292
  index,
5371
- isEnabled,
5372
5293
  dragAxis,
5373
5294
  collisionAxis,
5374
5295
  inDroppableZone
5375
5296
  }) => {
5376
5297
  var _a, _b;
5377
5298
  const metadata = useAppStore((s) => s.metadata);
5378
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5299
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5379
5300
  const { depth = 1 } = ctx != null ? ctx : {};
5301
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5380
5302
  const nodeProps = useAppStore(
5381
- (0, import_shallow3.useShallow)((s) => {
5303
+ (0, import_shallow4.useShallow)((s) => {
5382
5304
  var _a2;
5383
5305
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
5384
5306
  })
@@ -5390,22 +5312,42 @@ var DropZoneChild = ({
5390
5312
  }
5391
5313
  );
5392
5314
  const nodeReadOnly = useAppStore(
5393
- (0, import_shallow3.useShallow)((s) => {
5315
+ (0, import_shallow4.useShallow)((s) => {
5394
5316
  var _a2;
5395
5317
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
5396
5318
  })
5397
5319
  );
5398
- const node = { type: nodeType, props: nodeProps };
5399
- const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
5320
+ const appStore = useAppStoreApi();
5321
+ const item = (0, import_react35.useMemo)(() => {
5322
+ if (nodeProps) {
5323
+ const expanded = expandNode({
5324
+ type: nodeType,
5325
+ props: nodeProps
5326
+ });
5327
+ return expanded;
5328
+ }
5329
+ const preview = zoneStore.getState().previewIndex[zoneCompound];
5330
+ if (componentId === (preview == null ? void 0 : preview.props.id)) {
5331
+ return {
5332
+ type: preview.componentType,
5333
+ props: preview.props,
5334
+ previewType: preview.type
5335
+ };
5336
+ }
5337
+ return null;
5338
+ }, [appStore, componentId, zoneCompound, nodeType, nodeProps]);
5400
5339
  const componentConfig = useAppStore(
5401
5340
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5402
5341
  );
5403
- const puckProps = {
5404
- renderDropZone: DropZoneEditPure,
5405
- isEditing: true,
5406
- dragRef: null,
5407
- metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5408
- };
5342
+ const puckProps = (0, import_react35.useMemo)(
5343
+ () => ({
5344
+ renderDropZone: DropZoneEditPure,
5345
+ isEditing: true,
5346
+ dragRef: null,
5347
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5348
+ }),
5349
+ [metadata, componentConfig == null ? void 0 : componentConfig.metadata]
5350
+ );
5409
5351
  const overrides = useAppStore((s) => s.overrides);
5410
5352
  const isLoading = useAppStore(
5411
5353
  (s) => {
@@ -5420,13 +5362,13 @@ var DropZoneChild = ({
5420
5362
  }
5421
5363
  );
5422
5364
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5423
- const renderPreview = (0, import_react34.useMemo)(
5424
- () => function Preview4() {
5365
+ const renderPreview = (0, import_react35.useMemo)(
5366
+ () => function Preview3() {
5425
5367
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5426
5368
  },
5427
5369
  [componentId, label, overrides]
5428
5370
  );
5429
- const defaultsProps = (0, import_react34.useMemo)(
5371
+ const defaultsProps = (0, import_react35.useMemo)(
5430
5372
  () => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
5431
5373
  puck: puckProps,
5432
5374
  editMode: true
@@ -5434,9 +5376,17 @@ var DropZoneChild = ({
5434
5376
  }),
5435
5377
  [componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
5436
5378
  );
5379
+ const defaultedNode = (0, import_react35.useMemo)(
5380
+ () => {
5381
+ var _a2;
5382
+ return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
5383
+ },
5384
+ [item == null ? void 0 : item.type, nodeType, defaultsProps]
5385
+ );
5386
+ const config = useAppStore((s) => s.config);
5437
5387
  const defaultedPropsWithSlots = useSlots(
5438
- componentConfig,
5439
- defaultsProps,
5388
+ config,
5389
+ defaultedNode,
5440
5390
  DropZoneEditPure,
5441
5391
  (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
5442
5392
  nodeReadOnly,
@@ -5448,8 +5398,8 @@ var DropZoneChild = ({
5448
5398
  item.type
5449
5399
  ] });
5450
5400
  let componentType = item.type;
5451
- const isPreview = componentId === (preview == null ? void 0 : preview.props.id) && preview.type === "insert";
5452
- if (isPreview) {
5401
+ const isInserting = "previewType" in item ? item.previewType === "insert" : false;
5402
+ if (isInserting) {
5453
5403
  Render2 = renderPreview;
5454
5404
  }
5455
5405
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -5463,11 +5413,10 @@ var DropZoneChild = ({
5463
5413
  isLoading,
5464
5414
  isSelected,
5465
5415
  label,
5466
- isEnabled,
5467
5416
  autoDragAxis: dragAxis,
5468
5417
  userDragAxis: collisionAxis,
5469
5418
  inDroppableZone,
5470
- 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)(
5419
+ 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)(
5471
5420
  Render2,
5472
5421
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5473
5422
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
@@ -5478,8 +5427,8 @@ var DropZoneChild = ({
5478
5427
  }
5479
5428
  );
5480
5429
  };
5481
- var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
5482
- var DropZoneEdit = (0, import_react34.forwardRef)(
5430
+ var DropZoneChildMemo = (0, import_react35.memo)(DropZoneChild);
5431
+ var DropZoneEdit = (0, import_react35.forwardRef)(
5483
5432
  function DropZoneEditInternal({
5484
5433
  zone,
5485
5434
  allow,
@@ -5489,7 +5438,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5489
5438
  minEmptyHeight: userMinEmptyHeight = 128,
5490
5439
  collisionAxis
5491
5440
  }, userRef) {
5492
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5441
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5493
5442
  const {
5494
5443
  // These all need setting via context
5495
5444
  areaId,
@@ -5498,7 +5447,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5498
5447
  unregisterLocalZone
5499
5448
  } = ctx != null ? ctx : {};
5500
5449
  const path = useAppStore(
5501
- (0, import_shallow3.useShallow)((s) => {
5450
+ (0, import_shallow4.useShallow)((s) => {
5502
5451
  var _a;
5503
5452
  return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
5504
5453
  })
@@ -5510,39 +5459,24 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5510
5459
  }
5511
5460
  }
5512
5461
  const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
5513
- const {
5514
- isDeepestZone,
5515
- inNextDeepestArea,
5516
- draggedComponentType,
5517
- userIsDragging
5518
- } = useContextStore(ZoneStoreContext, (s) => {
5519
- var _a, _b;
5520
- return {
5521
- isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
5522
- inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
5523
- draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
5524
- userIsDragging: !!s.draggedItem
5525
- };
5526
- });
5462
+ const inNextDeepestArea = useContextStore(
5463
+ ZoneStoreContext,
5464
+ (s) => s.nextAreaDepthIndex[areaId || ""]
5465
+ );
5527
5466
  const zoneContentIds = useAppStore(
5528
- (0, import_shallow3.useShallow)((s) => {
5467
+ (0, import_shallow4.useShallow)((s) => {
5529
5468
  var _a;
5530
5469
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
5531
5470
  })
5532
5471
  );
5533
5472
  const zoneType = useAppStore(
5534
- (0, import_shallow3.useShallow)((s) => {
5473
+ (0, import_shallow4.useShallow)((s) => {
5535
5474
  var _a;
5536
5475
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
5537
5476
  })
5538
5477
  );
5539
- (0, import_react34.useEffect)(() => {
5478
+ (0, import_react35.useEffect)(() => {
5540
5479
  if (!zoneType || zoneType === "dropzone") {
5541
- if (zoneCompound !== rootDroppableId) {
5542
- console.warn(
5543
- "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"
5544
- );
5545
- }
5546
5480
  if (ctx == null ? void 0 : ctx.registerZone) {
5547
5481
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5548
5482
  }
@@ -5553,11 +5487,20 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5553
5487
  };
5554
5488
  }
5555
5489
  }, [zoneType]);
5556
- const contentIds = (0, import_react34.useMemo)(() => {
5490
+ (0, import_react35.useEffect)(() => {
5491
+ if (zoneType === "dropzone") {
5492
+ if (zoneCompound !== rootDroppableId) {
5493
+ console.warn(
5494
+ "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"
5495
+ );
5496
+ }
5497
+ }
5498
+ }, [zoneType]);
5499
+ const contentIds = (0, import_react35.useMemo)(() => {
5557
5500
  return zoneContentIds || [];
5558
5501
  }, [zoneContentIds]);
5559
- const ref = (0, import_react34.useRef)(null);
5560
- const acceptsTarget = (0, import_react34.useCallback)(
5502
+ const ref = (0, import_react35.useRef)(null);
5503
+ const acceptsTarget = (0, import_react35.useCallback)(
5561
5504
  (componentType) => {
5562
5505
  if (!componentType) {
5563
5506
  return true;
@@ -5579,29 +5522,44 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5579
5522
  },
5580
5523
  [allow, disallow]
5581
5524
  );
5582
- (0, import_react34.useEffect)(() => {
5525
+ const targetAccepted = useContextStore(ZoneStoreContext, (s) => {
5526
+ var _a;
5527
+ const draggedComponentType = (_a = s.draggedItem) == null ? void 0 : _a.data.componentType;
5528
+ return acceptsTarget(draggedComponentType);
5529
+ });
5530
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
5531
+ const isEnabled = useContextStore(ZoneStoreContext, (s) => {
5532
+ var _a;
5533
+ let _isEnabled = true;
5534
+ const isDeepestZone = (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false;
5535
+ _isEnabled = isDeepestZone;
5536
+ if (_isEnabled) {
5537
+ _isEnabled = targetAccepted;
5538
+ }
5539
+ return _isEnabled;
5540
+ });
5541
+ (0, import_react35.useEffect)(() => {
5583
5542
  if (registerLocalZone) {
5584
- registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
5543
+ registerLocalZone(zoneCompound, targetAccepted || isEnabled);
5585
5544
  }
5586
5545
  return () => {
5587
5546
  if (unregisterLocalZone) {
5588
5547
  unregisterLocalZone(zoneCompound);
5589
5548
  }
5590
5549
  };
5591
- }, [draggedComponentType, zoneCompound]);
5592
- const hoveringOverArea = inNextDeepestArea || isRootZone;
5593
- let isEnabled = true;
5594
- if (userIsDragging) {
5595
- isEnabled = isDeepestZone;
5596
- }
5597
- if (isEnabled) {
5598
- isEnabled = acceptsTarget(draggedComponentType);
5599
- }
5550
+ }, [targetAccepted, isEnabled, zoneCompound]);
5600
5551
  const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
5601
5552
  contentIds,
5602
5553
  zoneCompound
5603
5554
  );
5604
5555
  const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
5556
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5557
+ (0, import_react35.useEffect)(() => {
5558
+ const { enabledIndex } = zoneStore.getState();
5559
+ zoneStore.setState({
5560
+ enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
5561
+ });
5562
+ }, [isEnabled, zoneStore, zoneCompound]);
5605
5563
  const droppableConfig = {
5606
5564
  id: zoneCompound,
5607
5565
  collisionPriority: isEnabled ? depth : 0,
@@ -5611,11 +5569,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5611
5569
  data: {
5612
5570
  areaId,
5613
5571
  depth,
5614
- isDroppableTarget: acceptsTarget(draggedComponentType),
5572
+ isDroppableTarget: targetAccepted,
5615
5573
  path: path || []
5616
5574
  }
5617
5575
  };
5618
- const { ref: dropRef } = useDroppableSafe(droppableConfig);
5576
+ const { ref: dropRef } = (0, import_react36.useDroppable)(droppableConfig);
5619
5577
  const isAreaSelected = useAppStore(
5620
5578
  (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
5621
5579
  );
@@ -5630,7 +5588,6 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5630
5588
  {
5631
5589
  className: `${getClassName17({
5632
5590
  isRootZone,
5633
- userIsDragging,
5634
5591
  hoveringOverArea,
5635
5592
  isEnabled,
5636
5593
  isAreaSelected,
@@ -5652,12 +5609,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5652
5609
  {
5653
5610
  zoneCompound,
5654
5611
  componentId,
5655
- preview,
5656
5612
  dragAxis,
5657
- isEnabled,
5658
5613
  index: i,
5659
5614
  collisionAxis,
5660
- inDroppableZone: acceptsTarget(draggedComponentType)
5615
+ inDroppableZone: targetAccepted
5661
5616
  },
5662
5617
  componentId
5663
5618
  );
@@ -5672,8 +5627,8 @@ var DropZoneRenderItem = ({
5672
5627
  metadata
5673
5628
  }) => {
5674
5629
  const Component = config.components[item.type];
5675
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5676
- const nextContextValue = (0, import_react34.useMemo)(
5630
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5631
+ const nextContextValue = (0, import_react35.useMemo)(
5677
5632
  () => ({
5678
5633
  areaId: props.id,
5679
5634
  depth: 1
@@ -5691,14 +5646,14 @@ var DropZoneRenderItem = ({
5691
5646
  ) }, props.id);
5692
5647
  };
5693
5648
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
5694
- var DropZoneRender2 = (0, import_react34.forwardRef)(
5649
+ var DropZoneRender2 = (0, import_react35.forwardRef)(
5695
5650
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5696
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5651
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5697
5652
  const { areaId = "root" } = ctx || {};
5698
- const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
5653
+ const { config, data, metadata } = (0, import_react35.useContext)(renderContext);
5699
5654
  let zoneCompound = rootDroppableId;
5700
5655
  let content = (data == null ? void 0 : data.content) || [];
5701
- (0, import_react34.useEffect)(() => {
5656
+ (0, import_react35.useEffect)(() => {
5702
5657
  if (!content) {
5703
5658
  if (ctx == null ? void 0 : ctx.registerZone) {
5704
5659
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5735,9 +5690,9 @@ var DropZoneRender2 = (0, import_react34.forwardRef)(
5735
5690
  }
5736
5691
  );
5737
5692
  var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
5738
- var DropZone = (0, import_react34.forwardRef)(
5693
+ var DropZone = (0, import_react35.forwardRef)(
5739
5694
  function DropZone2(props, ref) {
5740
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5695
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5741
5696
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5742
5697
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5743
5698
  }
@@ -5747,8 +5702,7 @@ var DropZone = (0, import_react34.forwardRef)(
5747
5702
 
5748
5703
  // lib/dnd/NestedDroppablePlugin.ts
5749
5704
  init_react_import();
5750
- var import_abstract10 = require("@dnd-kit/abstract");
5751
- var import_state2 = require("@dnd-kit/state");
5705
+ var import_abstract9 = require("@dnd-kit/abstract");
5752
5706
 
5753
5707
  // lib/throttle.ts
5754
5708
  init_react_import();
@@ -5797,7 +5751,7 @@ var GlobalPosition = class {
5797
5751
  var _a;
5798
5752
  this.target = target;
5799
5753
  this.original = original;
5800
- this.frameEl = document.querySelector("#preview-frame");
5754
+ this.frameEl = document.querySelector("iframe#preview-frame");
5801
5755
  if (this.frameEl) {
5802
5756
  this.frameRect = this.frameEl.getBoundingClientRect();
5803
5757
  this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
@@ -5877,6 +5831,7 @@ var getZoneId2 = (candidate) => {
5877
5831
  }
5878
5832
  return id;
5879
5833
  };
5834
+ var BUFFER = 6;
5880
5835
  var getPointerCollisions = (position, manager) => {
5881
5836
  const candidates = [];
5882
5837
  let elements = position.target.ownerDocument.elementsFromPoint(
@@ -5900,13 +5855,26 @@ var getPointerCollisions = (position, manager) => {
5900
5855
  for (let i = 0; i < elements.length; i++) {
5901
5856
  const element = elements[i];
5902
5857
  const dropzoneId = element.getAttribute("data-puck-dropzone");
5858
+ const id = element.getAttribute("data-puck-dnd");
5859
+ const isVoid = element.hasAttribute("data-puck-dnd-void");
5860
+ if (BUFFER && (dropzoneId || id) && !isVoid) {
5861
+ const box = element.getBoundingClientRect();
5862
+ const contractedBox = {
5863
+ left: box.left + BUFFER,
5864
+ right: box.right - BUFFER,
5865
+ top: box.top + BUFFER,
5866
+ bottom: box.bottom - BUFFER
5867
+ };
5868
+ if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
5869
+ continue;
5870
+ }
5871
+ }
5903
5872
  if (dropzoneId) {
5904
5873
  const droppable = manager.registry.droppables.get(dropzoneId);
5905
5874
  if (droppable) {
5906
5875
  candidates.push(droppable);
5907
5876
  }
5908
5877
  }
5909
- const id = element.getAttribute("data-puck-dnd");
5910
5878
  if (id) {
5911
5879
  const droppable = manager.registry.droppables.get(id);
5912
5880
  if (droppable) {
@@ -5955,22 +5923,25 @@ var findDeepestCandidate = (position, manager) => {
5955
5923
  return true;
5956
5924
  });
5957
5925
  filteredCandidates.reverse();
5958
- const zone = getZoneId2(filteredCandidates[0]);
5959
- const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
5926
+ const primaryCandidate = filteredCandidates[0];
5927
+ const primaryCandidateData = primaryCandidate.data;
5928
+ const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
5929
+ const zone = getZoneId2(primaryCandidate);
5930
+ const area = primaryCandidateIsComponent && primaryCandidateData.containsActiveZone ? filteredCandidates[0].id : (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
5960
5931
  return { zone, area };
5961
5932
  }
5962
5933
  return {
5963
- zone: "default-zone",
5964
- area: null
5934
+ zone: rootDroppableId,
5935
+ area: rootAreaId
5965
5936
  };
5966
5937
  };
5967
- var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract10.Plugin {
5938
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
5968
5939
  constructor(manager, options) {
5969
5940
  super(manager);
5970
5941
  if (typeof window === "undefined") {
5971
5942
  return;
5972
5943
  }
5973
- const cleanupEffect = (0, import_state2.effects)(() => {
5944
+ this.registerEffect(() => {
5974
5945
  const handleMove = (event) => {
5975
5946
  const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
5976
5947
  const position = new GlobalPosition(target, {
@@ -5994,12 +5965,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
5994
5965
  capture: true
5995
5966
  // dndkit's PointerSensor prevents propagation during drag
5996
5967
  });
5997
- this.destroy = () => {
5968
+ const cleanup = () => {
5998
5969
  document.body.removeEventListener("pointermove", handlePointerMove, {
5999
5970
  capture: true
6000
5971
  });
6001
- cleanupEffect();
6002
5972
  };
5973
+ return cleanup;
6003
5974
  });
6004
5975
  }
6005
5976
  };
@@ -6059,14 +6030,15 @@ function getDeepDir(el) {
6059
6030
  }
6060
6031
 
6061
6032
  // components/DragDropContext/index.tsx
6033
+ var import_state = require("@dnd-kit/state");
6062
6034
  var import_jsx_runtime26 = require("react/jsx-runtime");
6063
6035
  var DEBUG3 = false;
6064
- var dragListenerContext = (0, import_react36.createContext)({
6036
+ var dragListenerContext = (0, import_react38.createContext)({
6065
6037
  dragListeners: {}
6066
6038
  });
6067
6039
  function useDragListener(type, fn, deps = []) {
6068
- const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
6069
- (0, import_react36.useEffect)(() => {
6040
+ const { setDragListeners } = (0, import_react38.useContext)(dragListenerContext);
6041
+ (0, import_react38.useEffect)(() => {
6070
6042
  if (setDragListeners) {
6071
6043
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
6072
6044
  [type]: [...old[type] || [], fn]
@@ -6076,8 +6048,8 @@ function useDragListener(type, fn, deps = []) {
6076
6048
  }
6077
6049
  var AREA_CHANGE_DEBOUNCE_MS = 100;
6078
6050
  var useTempDisableFallback = (timeout3) => {
6079
- const lastFallbackDisable = (0, import_react36.useRef)(null);
6080
- return (0, import_react36.useCallback)((manager) => {
6051
+ const lastFallbackDisable = (0, import_react38.useRef)(null);
6052
+ return (0, import_react38.useCallback)((manager) => {
6081
6053
  collisionStore.setState({ fallbackEnabled: false });
6082
6054
  const fallbackId = generateId();
6083
6055
  lastFallbackDisable.current = fallbackId;
@@ -6096,19 +6068,21 @@ var DragDropContextClient = ({
6096
6068
  const dispatch = useAppStore((s) => s.dispatch);
6097
6069
  const appStore = useAppStoreApi();
6098
6070
  const id = useSafeId();
6099
- const debouncedParamsRef = (0, import_react36.useRef)(null);
6071
+ const debouncedParamsRef = (0, import_react38.useRef)(null);
6100
6072
  const tempDisableFallback = useTempDisableFallback(100);
6101
- const [zoneStore] = (0, import_react36.useState)(
6073
+ const [zoneStore] = (0, import_react38.useState)(
6102
6074
  () => (0, import_zustand5.createStore)(() => ({
6103
6075
  zoneDepthIndex: {},
6104
6076
  nextZoneDepthIndex: {},
6105
6077
  areaDepthIndex: {},
6106
6078
  nextAreaDepthIndex: {},
6107
6079
  draggedItem: null,
6108
- previewIndex: {}
6080
+ previewIndex: {},
6081
+ enabledIndex: {},
6082
+ hoveringComponent: null
6109
6083
  }))
6110
6084
  );
6111
- const getChanged2 = (0, import_react36.useCallback)(
6085
+ const getChanged2 = (0, import_react38.useCallback)(
6112
6086
  (params, id2) => {
6113
6087
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
6114
6088
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -6129,7 +6103,7 @@ var DragDropContextClient = ({
6129
6103
  },
6130
6104
  [zoneStore]
6131
6105
  );
6132
- const setDeepestAndCollide = (0, import_react36.useCallback)(
6106
+ const setDeepestAndCollide = (0, import_react38.useCallback)(
6133
6107
  (params, manager) => {
6134
6108
  const { zoneChanged, areaChanged } = getChanged2(params, id);
6135
6109
  if (!zoneChanged && !areaChanged) return;
@@ -6153,7 +6127,7 @@ var DragDropContextClient = ({
6153
6127
  setDeepestDb.cancel();
6154
6128
  debouncedParamsRef.current = null;
6155
6129
  };
6156
- (0, import_react36.useEffect)(() => {
6130
+ (0, import_react38.useEffect)(() => {
6157
6131
  if (DEBUG3) {
6158
6132
  zoneStore.subscribe(
6159
6133
  (s) => {
@@ -6167,7 +6141,7 @@ var DragDropContextClient = ({
6167
6141
  );
6168
6142
  }
6169
6143
  }, []);
6170
- const [plugins] = (0, import_react36.useState)(() => [
6144
+ const [plugins] = (0, import_react38.useState)(() => [
6171
6145
  ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
6172
6146
  createNestedDroppablePlugin(
6173
6147
  {
@@ -6215,10 +6189,10 @@ var DragDropContextClient = ({
6215
6189
  )
6216
6190
  ]);
6217
6191
  const sensors = useSensors();
6218
- const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
6219
- const dragMode = (0, import_react36.useRef)(null);
6220
- const initialSelector = (0, import_react36.useRef)(void 0);
6221
- const nextContextValue = (0, import_react36.useMemo)(
6192
+ const [dragListeners, setDragListeners] = (0, import_react38.useState)({});
6193
+ const dragMode = (0, import_react38.useRef)(null);
6194
+ const initialSelector = (0, import_react38.useRef)(void 0);
6195
+ const nextContextValue = (0, import_react38.useMemo)(
6222
6196
  () => ({
6223
6197
  mode: "edit",
6224
6198
  areaId: "root",
@@ -6234,12 +6208,14 @@ var DragDropContextClient = ({
6234
6208
  setDragListeners
6235
6209
  },
6236
6210
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6237
- import_react35.DragDropProvider,
6211
+ import_react37.DragDropProvider,
6238
6212
  {
6239
6213
  plugins,
6240
6214
  sensors,
6241
6215
  onDragEnd: (event, manager) => {
6242
- var _a;
6216
+ var _a, _b;
6217
+ const entryEl = (_a = getFrame()) == null ? void 0 : _a.querySelector("[data-puck-entry]");
6218
+ entryEl == null ? void 0 : entryEl.removeAttribute("data-puck-dragging");
6243
6219
  const { source, target } = event.operation;
6244
6220
  if (!source) {
6245
6221
  zoneStore.setState({ draggedItem: null });
@@ -6247,9 +6223,9 @@ var DragDropContextClient = ({
6247
6223
  }
6248
6224
  const { zone, index } = source.data;
6249
6225
  const { previewIndex = {} } = zoneStore.getState() || {};
6250
- const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
6251
- setTimeout(() => {
6252
- var _a2, _b;
6226
+ const thisPreview = ((_b = previewIndex[zone]) == null ? void 0 : _b.props.id) === source.id ? previewIndex[zone] : null;
6227
+ const onAnimationEnd = () => {
6228
+ var _a2, _b2;
6253
6229
  zoneStore.setState({ draggedItem: null });
6254
6230
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
6255
6231
  zoneStore.setState({ previewIndex: {} });
@@ -6285,23 +6261,28 @@ var DragDropContextClient = ({
6285
6261
  });
6286
6262
  }
6287
6263
  }
6288
- setTimeout(() => {
6289
- dispatch({
6290
- type: "setUi",
6291
- ui: {
6292
- itemSelector: { index, zone },
6293
- isDragging: false
6294
- },
6295
- recordHistory: true
6296
- });
6297
- }, 50);
6298
- (_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
6264
+ dispatch({
6265
+ type: "setUi",
6266
+ ui: {
6267
+ itemSelector: { index, zone },
6268
+ isDragging: false
6269
+ },
6270
+ recordHistory: true
6271
+ });
6272
+ (_b2 = dragListeners.dragend) == null ? void 0 : _b2.forEach((fn) => {
6299
6273
  fn(event, manager);
6300
6274
  });
6301
- }, 250);
6275
+ };
6276
+ let dispose;
6277
+ dispose = (0, import_state.effect)(() => {
6278
+ if (source.status === "idle") {
6279
+ onAnimationEnd();
6280
+ dispose == null ? void 0 : dispose();
6281
+ }
6282
+ });
6302
6283
  },
6303
6284
  onDragOver: (event, manager) => {
6304
- var _a, _b, _c, _d, _e;
6285
+ var _a, _b, _c, _d;
6305
6286
  event.preventDefault();
6306
6287
  const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
6307
6288
  if (!draggedItem) return;
@@ -6319,7 +6300,7 @@ var DragDropContextClient = ({
6319
6300
  const targetData = target.data;
6320
6301
  targetZone = targetData.zone;
6321
6302
  targetIndex = targetData.index;
6322
- const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
6303
+ const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
6323
6304
  const dir = getDeepDir(target.element);
6324
6305
  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";
6325
6306
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
@@ -6332,7 +6313,7 @@ var DragDropContextClient = ({
6332
6313
  targetZone = target.id.toString();
6333
6314
  targetIndex = 0;
6334
6315
  }
6335
- const path = ((_d = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _d.path) || [];
6316
+ const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
6336
6317
  if (targetId === sourceId || path.find((path2) => {
6337
6318
  const [pathId] = path2.split(":");
6338
6319
  return pathId === sourceId;
@@ -6378,16 +6359,12 @@ var DragDropContextClient = ({
6378
6359
  });
6379
6360
  }
6380
6361
  }
6381
- (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
6362
+ (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
6382
6363
  fn(event, manager);
6383
6364
  });
6384
6365
  },
6385
6366
  onDragStart: (event, manager) => {
6386
6367
  var _a;
6387
- dispatch({
6388
- type: "setUi",
6389
- ui: { itemSelector: null, isDragging: true }
6390
- });
6391
6368
  const { source } = event.operation;
6392
6369
  if (source && source.type !== "void") {
6393
6370
  const sourceData = source.data;
@@ -6417,11 +6394,31 @@ var DragDropContextClient = ({
6417
6394
  });
6418
6395
  },
6419
6396
  onBeforeDragStart: (event) => {
6420
- var _a;
6421
- const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
6397
+ var _a, _b, _c, _d;
6398
+ const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
6422
6399
  dragMode.current = isNewComponent ? "new" : "existing";
6423
6400
  initialSelector.current = void 0;
6424
6401
  zoneStore.setState({ draggedItem: event.operation.source });
6402
+ if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== ((_c = event.operation.source) == null ? void 0 : _c.id)) {
6403
+ dispatch({
6404
+ type: "setUi",
6405
+ ui: {
6406
+ itemSelector: null,
6407
+ isDragging: true
6408
+ },
6409
+ recordHistory: false
6410
+ });
6411
+ } else {
6412
+ dispatch({
6413
+ type: "setUi",
6414
+ ui: {
6415
+ isDragging: true
6416
+ },
6417
+ recordHistory: false
6418
+ });
6419
+ }
6420
+ const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
6421
+ entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
6425
6422
  },
6426
6423
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
6427
6424
  }
@@ -6441,6 +6438,7 @@ var DragDropContext = ({
6441
6438
  };
6442
6439
 
6443
6440
  // components/Drawer/index.tsx
6441
+ var import_react40 = require("@dnd-kit/react");
6444
6442
  var import_jsx_runtime27 = require("react/jsx-runtime");
6445
6443
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
6446
6444
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
@@ -6451,7 +6449,7 @@ var DrawerItemInner = ({
6451
6449
  dragRef,
6452
6450
  isDragDisabled
6453
6451
  }) => {
6454
- const CustomInner = (0, import_react37.useMemo)(
6452
+ const CustomInner = (0, import_react39.useMemo)(
6455
6453
  () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
6456
6454
  [children]
6457
6455
  );
@@ -6477,10 +6475,11 @@ var DrawerItemDraggable = ({
6477
6475
  id,
6478
6476
  isDragDisabled
6479
6477
  }) => {
6480
- const { ref } = useDraggableSafe({
6478
+ const { ref } = (0, import_react40.useDraggable)({
6481
6479
  id,
6482
- data: { type: "drawer", componentType: name },
6483
- disabled: isDragDisabled
6480
+ data: { componentType: name },
6481
+ disabled: isDragDisabled,
6482
+ type: "drawer"
6484
6483
  });
6485
6484
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
6486
6485
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
@@ -6505,7 +6504,7 @@ var DrawerItem = ({
6505
6504
  isDragDisabled
6506
6505
  }) => {
6507
6506
  const resolvedId = id || name;
6508
- const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
6507
+ const [dynamicId, setDynamicId] = (0, import_react39.useState)(generateId(resolvedId));
6509
6508
  if (typeof index !== "undefined") {
6510
6509
  console.error(
6511
6510
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -6545,7 +6544,7 @@ var Drawer = ({
6545
6544
  );
6546
6545
  }
6547
6546
  const id = useSafeId();
6548
- const { ref } = useDroppableSafe({
6547
+ const { ref } = (0, import_react40.useDroppable)({
6549
6548
  id,
6550
6549
  type: "void",
6551
6550
  collisionPriority: 0
@@ -6558,6 +6557,7 @@ var Drawer = ({
6558
6557
  ref,
6559
6558
  "data-puck-dnd": id,
6560
6559
  "data-puck-drawer": true,
6560
+ "data-puck-dnd-void": true,
6561
6561
  children
6562
6562
  }
6563
6563
  );
@@ -6566,7 +6566,7 @@ Drawer.Item = DrawerItem;
6566
6566
 
6567
6567
  // components/Puck/index.tsx
6568
6568
  init_react_import();
6569
- var import_react52 = require("react");
6569
+ var import_react56 = require("react");
6570
6570
 
6571
6571
  // components/SidebarSection/index.tsx
6572
6572
  init_react_import();
@@ -6577,7 +6577,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
6577
6577
 
6578
6578
  // lib/use-breadcrumbs.ts
6579
6579
  init_react_import();
6580
- var import_react38 = require("react");
6580
+ var import_react41 = require("react");
6581
6581
  var useBreadcrumbs = (renderCount) => {
6582
6582
  const selectedId = useAppStore((s) => {
6583
6583
  var _a;
@@ -6589,7 +6589,7 @@ var useBreadcrumbs = (renderCount) => {
6589
6589
  return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
6590
6590
  });
6591
6591
  const appStore = useAppStoreApi();
6592
- return (0, import_react38.useMemo)(() => {
6592
+ return (0, import_react41.useMemo)(() => {
6593
6593
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6594
6594
  var _a, _b, _c;
6595
6595
  const [componentId] = zoneCompound.split(":");
@@ -6661,70 +6661,26 @@ var SidebarSection = ({
6661
6661
  );
6662
6662
  };
6663
6663
 
6664
- // components/MenuBar/index.tsx
6664
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6665
6665
  init_react_import();
6666
+ var styles_module_default14 = { "Puck": "_Puck_dnlfp_19", "Puck-portal": "_Puck-portal_dnlfp_31", "PuckLayout-inner": "_PuckLayout-inner_dnlfp_38", "PuckLayout--mounted": "_PuckLayout--mounted_dnlfp_50", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_dnlfp_54", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_dnlfp_60", "PuckLayout-mounted": "_PuckLayout-mounted_dnlfp_74", "PuckLayout": "_PuckLayout_dnlfp_38", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_dnlfp_115", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_dnlfp_124" };
6666
6667
 
6667
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
6668
+ // components/Puck/components/Fields/index.tsx
6668
6669
  init_react_import();
6669
- 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" };
6670
6670
 
6671
- // components/MenuBar/index.tsx
6671
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
6672
+ init_react_import();
6673
+ 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" };
6674
+
6675
+ // components/Puck/components/Fields/index.tsx
6676
+ var import_react42 = require("react");
6677
+ var import_shallow5 = require("zustand/react/shallow");
6672
6678
  var import_jsx_runtime29 = require("react/jsx-runtime");
6673
- var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
6674
- function MenuBar({
6675
- menuOpen = false,
6676
- renderHeaderActions,
6677
- setMenuOpen
6678
- }) {
6679
- const back = useAppStore((s) => s.history.back);
6680
- const forward = useAppStore((s) => s.history.forward);
6681
- const hasFuture = useAppStore((s) => s.history.hasFuture());
6682
- const hasPast = useAppStore((s) => s.history.hasPast());
6683
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6684
- "div",
6685
- {
6686
- className: getClassName20({ menuOpen }),
6687
- onClick: (event) => {
6688
- var _a;
6689
- const element = event.target;
6690
- if (window.matchMedia("(min-width: 638px)").matches) {
6691
- return;
6692
- }
6693
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
6694
- setMenuOpen(false);
6695
- }
6696
- },
6697
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("inner"), children: [
6698
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("history"), children: [
6699
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Undo2, { size: 21 }) }),
6700
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Redo2, { size: 21 }) })
6701
- ] }),
6702
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: renderHeaderActions && renderHeaderActions() })
6703
- ] })
6704
- }
6705
- );
6706
- }
6707
-
6708
- // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6709
- init_react_import();
6710
- 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" };
6711
-
6712
- // components/Puck/components/Fields/index.tsx
6713
- init_react_import();
6714
-
6715
- // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
6716
- init_react_import();
6717
- 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" };
6718
-
6719
- // components/Puck/components/Fields/index.tsx
6720
- var import_react39 = require("react");
6721
- var import_shallow4 = require("zustand/react/shallow");
6722
- var import_jsx_runtime30 = require("react/jsx-runtime");
6723
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
6679
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
6724
6680
  var DefaultFields = ({
6725
6681
  children
6726
6682
  }) => {
6727
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
6683
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
6728
6684
  };
6729
6685
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6730
6686
  let currentProps;
@@ -6784,18 +6740,19 @@ var FieldsChild = ({ fieldName }) => {
6784
6740
  return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
6785
6741
  });
6786
6742
  const permissions = useAppStore(
6787
- (0, import_shallow4.useShallow)((s) => {
6743
+ (0, import_shallow5.useShallow)((s) => {
6788
6744
  const { selectedItem, permissions: permissions2 } = s;
6789
6745
  return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
6790
6746
  })
6791
6747
  );
6792
6748
  const appStore = useAppStoreApi();
6793
- const onChange = (0, import_react39.useCallback)(createOnChange(fieldName, appStore), [
6749
+ const onChange = (0, import_react42.useCallback)(createOnChange(fieldName, appStore), [
6794
6750
  fieldName
6795
6751
  ]);
6796
- if (!field || !id) return null;
6752
+ const { visible = true } = field != null ? field : {};
6753
+ if (!field || !id || !visible) return null;
6797
6754
  if (field.type === "slot") return null;
6798
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6755
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("field"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6799
6756
  AutoFieldPrivate,
6800
6757
  {
6801
6758
  field,
@@ -6807,14 +6764,15 @@ var FieldsChild = ({ fieldName }) => {
6807
6764
  }
6808
6765
  ) }, id);
6809
6766
  };
6810
- var Fields = ({ wrapFields = true }) => {
6767
+ var FieldsChildMemo = (0, import_react42.memo)(FieldsChild);
6768
+ var FieldsInternal = ({ wrapFields = true }) => {
6811
6769
  const overrides = useAppStore((s) => s.overrides);
6812
6770
  const componentResolving = useAppStore((s) => {
6813
6771
  var _a, _b;
6814
6772
  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;
6815
6773
  return (loadingCount != null ? loadingCount : 0) > 0;
6816
6774
  });
6817
- const itemSelector = useAppStore((0, import_shallow4.useShallow)((s) => s.state.ui.itemSelector));
6775
+ const itemSelector = useAppStore((0, import_shallow5.useShallow)((s) => s.state.ui.itemSelector));
6818
6776
  const id = useAppStore((s) => {
6819
6777
  var _a;
6820
6778
  return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
@@ -6823,42 +6781,48 @@ var Fields = ({ wrapFields = true }) => {
6823
6781
  useRegisterFieldsSlice(appStore, id);
6824
6782
  const fieldsLoading = useAppStore((s) => s.fields.loading);
6825
6783
  const fieldNames = useAppStore(
6826
- (0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
6784
+ (0, import_shallow5.useShallow)((s) => {
6785
+ if (s.fields.id === id) {
6786
+ return Object.keys(s.fields.fields);
6787
+ }
6788
+ return [];
6789
+ })
6827
6790
  );
6828
6791
  const isLoading = fieldsLoading || componentResolving;
6829
- const Wrapper = (0, import_react39.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6830
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6792
+ const Wrapper = (0, import_react42.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6793
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6831
6794
  "form",
6832
6795
  {
6833
- className: getClassName21({ wrapFields }),
6796
+ className: getClassName20({ wrapFields }),
6834
6797
  onSubmit: (e) => {
6835
6798
  e.preventDefault();
6836
6799
  },
6837
6800
  children: [
6838
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChild, { fieldName }, fieldName)) }),
6839
- 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 }) }) })
6801
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
6802
+ 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 }) }) })
6840
6803
  ]
6841
6804
  }
6842
6805
  );
6843
6806
  };
6807
+ var Fields = (0, import_react42.memo)(FieldsInternal);
6844
6808
 
6845
6809
  // components/Puck/components/Components/index.tsx
6846
6810
  init_react_import();
6847
6811
 
6848
6812
  // lib/use-component-list.tsx
6849
6813
  init_react_import();
6850
- var import_react40 = require("react");
6814
+ var import_react43 = require("react");
6851
6815
 
6852
6816
  // components/ComponentList/index.tsx
6853
6817
  init_react_import();
6854
6818
 
6855
6819
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6856
6820
  init_react_import();
6857
- 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" };
6821
+ 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" };
6858
6822
 
6859
6823
  // components/ComponentList/index.tsx
6860
- var import_jsx_runtime31 = require("react/jsx-runtime");
6861
- var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
6824
+ var import_jsx_runtime30 = require("react/jsx-runtime");
6825
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6862
6826
  var ComponentListItem = ({
6863
6827
  name,
6864
6828
  label
@@ -6869,7 +6833,7 @@ var ComponentListItem = ({
6869
6833
  type: name
6870
6834
  }).insert
6871
6835
  );
6872
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6836
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6873
6837
  };
6874
6838
  var ComponentList = ({
6875
6839
  children,
@@ -6880,12 +6844,12 @@ var ComponentList = ({
6880
6844
  const setUi = useAppStore((s) => s.setUi);
6881
6845
  const componentList = useAppStore((s) => s.state.ui.componentList);
6882
6846
  const { expanded = true } = componentList[id] || {};
6883
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
6884
- title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
6847
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName21({ isExpanded: expanded }), children: [
6848
+ title && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6885
6849
  "button",
6886
6850
  {
6887
6851
  type: "button",
6888
- className: getClassName22("title"),
6852
+ className: getClassName21("title"),
6889
6853
  onClick: () => setUi({
6890
6854
  componentList: __spreadProps(__spreadValues({}, componentList), {
6891
6855
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6895,14 +6859,14 @@ var ComponentList = ({
6895
6859
  }),
6896
6860
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6897
6861
  children: [
6898
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
6899
- /* @__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 }) })
6862
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { children: title }),
6863
+ /* @__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 }) })
6900
6864
  ]
6901
6865
  }
6902
6866
  ),
6903
- /* @__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) => {
6867
+ /* @__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) => {
6904
6868
  var _a;
6905
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6869
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6906
6870
  ComponentListItem,
6907
6871
  {
6908
6872
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6916,12 +6880,12 @@ var ComponentList = ({
6916
6880
  ComponentList.Item = ComponentListItem;
6917
6881
 
6918
6882
  // lib/use-component-list.tsx
6919
- var import_jsx_runtime32 = require("react/jsx-runtime");
6883
+ var import_jsx_runtime31 = require("react/jsx-runtime");
6920
6884
  var useComponentList = () => {
6921
- const [componentList, setComponentList] = (0, import_react40.useState)();
6885
+ const [componentList, setComponentList] = (0, import_react43.useState)();
6922
6886
  const config = useAppStore((s) => s.config);
6923
6887
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6924
- (0, import_react40.useEffect)(() => {
6888
+ (0, import_react43.useEffect)(() => {
6925
6889
  var _a, _b, _c;
6926
6890
  if (Object.keys(uiComponentList).length > 0) {
6927
6891
  const matchedComponents = [];
@@ -6931,7 +6895,7 @@ var useComponentList = () => {
6931
6895
  if (category.visible === false || !category.components) {
6932
6896
  return null;
6933
6897
  }
6934
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6898
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6935
6899
  ComponentList,
6936
6900
  {
6937
6901
  id: categoryKey,
@@ -6940,7 +6904,7 @@ var useComponentList = () => {
6940
6904
  var _a2;
6941
6905
  matchedComponents.push(componentName);
6942
6906
  const componentConf = config.components[componentName] || {};
6943
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6907
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6944
6908
  ComponentList.Item,
6945
6909
  {
6946
6910
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6960,7 +6924,7 @@ var useComponentList = () => {
6960
6924
  );
6961
6925
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6962
6926
  _componentList.push(
6963
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6927
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6964
6928
  ComponentList,
6965
6929
  {
6966
6930
  id: "other",
@@ -6968,7 +6932,7 @@ var useComponentList = () => {
6968
6932
  children: remainingComponents.map((componentName, i) => {
6969
6933
  var _a2;
6970
6934
  const componentConf = config.components[componentName] || {};
6971
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6935
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6972
6936
  ComponentList.Item,
6973
6937
  {
6974
6938
  name: componentName,
@@ -6990,25 +6954,25 @@ var useComponentList = () => {
6990
6954
  };
6991
6955
 
6992
6956
  // components/Puck/components/Components/index.tsx
6993
- var import_react41 = require("react");
6994
- var import_jsx_runtime33 = require("react/jsx-runtime");
6957
+ var import_react44 = require("react");
6958
+ var import_jsx_runtime32 = require("react/jsx-runtime");
6995
6959
  var Components = () => {
6996
6960
  const overrides = useAppStore((s) => s.overrides);
6997
6961
  const componentList = useComponentList();
6998
- const Wrapper = (0, import_react41.useMemo)(() => overrides.components || "div", [overrides]);
6999
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
6962
+ const Wrapper = (0, import_react44.useMemo)(() => overrides.components || "div", [overrides]);
6963
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
7000
6964
  };
7001
6965
 
7002
6966
  // components/Puck/components/Preview/index.tsx
7003
6967
  init_react_import();
7004
- var import_react43 = require("react");
6968
+ var import_react46 = require("react");
7005
6969
 
7006
6970
  // components/AutoFrame/index.tsx
7007
6971
  init_react_import();
7008
- var import_react42 = require("react");
6972
+ var import_react45 = require("react");
7009
6973
  var import_object_hash = __toESM(require("object-hash"));
7010
6974
  var import_react_dom3 = require("react-dom");
7011
- var import_jsx_runtime34 = require("react/jsx-runtime");
6975
+ var import_jsx_runtime33 = require("react/jsx-runtime");
7012
6976
  var styleSelector = 'style, link[rel="stylesheet"]';
7013
6977
  var collectStyles = (doc) => {
7014
6978
  const collected = [];
@@ -7051,7 +7015,7 @@ var CopyHostStyles = ({
7051
7015
  onStylesLoaded = () => null
7052
7016
  }) => {
7053
7017
  const { document: doc, window: win } = useFrame();
7054
- (0, import_react42.useEffect)(() => {
7018
+ (0, import_react45.useEffect)(() => {
7055
7019
  if (!win || !doc) {
7056
7020
  return () => {
7057
7021
  };
@@ -7208,10 +7172,10 @@ var CopyHostStyles = ({
7208
7172
  observer.disconnect();
7209
7173
  };
7210
7174
  }, []);
7211
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
7175
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
7212
7176
  };
7213
- var autoFrameContext = (0, import_react42.createContext)({});
7214
- var useFrame = () => (0, import_react42.useContext)(autoFrameContext);
7177
+ var autoFrameContext = (0, import_react45.createContext)({});
7178
+ var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
7215
7179
  function AutoFrame(_a) {
7216
7180
  var _b = _a, {
7217
7181
  children,
@@ -7232,11 +7196,11 @@ function AutoFrame(_a) {
7232
7196
  "onNotReady",
7233
7197
  "frameRef"
7234
7198
  ]);
7235
- const [loaded, setLoaded] = (0, import_react42.useState)(false);
7236
- const [ctx, setCtx] = (0, import_react42.useState)({});
7237
- const [mountTarget, setMountTarget] = (0, import_react42.useState)();
7238
- const [stylesLoaded, setStylesLoaded] = (0, import_react42.useState)(false);
7239
- (0, import_react42.useEffect)(() => {
7199
+ const [loaded, setLoaded] = (0, import_react45.useState)(false);
7200
+ const [ctx, setCtx] = (0, import_react45.useState)({});
7201
+ const [mountTarget, setMountTarget] = (0, import_react45.useState)();
7202
+ const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
7203
+ (0, import_react45.useEffect)(() => {
7240
7204
  var _a2;
7241
7205
  if (frameRef.current) {
7242
7206
  const doc = frameRef.current.contentDocument;
@@ -7255,7 +7219,7 @@ function AutoFrame(_a) {
7255
7219
  }
7256
7220
  }
7257
7221
  }, [frameRef, loaded, stylesLoaded]);
7258
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7222
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7259
7223
  "iframe",
7260
7224
  __spreadProps(__spreadValues({}, props), {
7261
7225
  className,
@@ -7265,7 +7229,7 @@ function AutoFrame(_a) {
7265
7229
  onLoad: () => {
7266
7230
  setLoaded(true);
7267
7231
  },
7268
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7232
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7269
7233
  CopyHostStyles,
7270
7234
  {
7271
7235
  debug,
@@ -7281,14 +7245,14 @@ var AutoFrame_default = AutoFrame;
7281
7245
 
7282
7246
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
7283
7247
  init_react_import();
7284
- var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7248
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7285
7249
 
7286
7250
  // components/Puck/components/Preview/index.tsx
7287
- var import_jsx_runtime35 = require("react/jsx-runtime");
7288
- var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
7251
+ var import_jsx_runtime34 = require("react/jsx-runtime");
7252
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
7289
7253
  var useBubbleIframeEvents = (ref) => {
7290
7254
  const status = useAppStore((s) => s.status);
7291
- (0, import_react43.useEffect)(() => {
7255
+ (0, import_react46.useEffect)(() => {
7292
7256
  if (ref.current && status === "READY") {
7293
7257
  const iframe = ref.current;
7294
7258
  const handlePointerMove = (event) => {
@@ -7326,7 +7290,7 @@ var useBubbleIframeEvents = (ref) => {
7326
7290
  }
7327
7291
  }, [status]);
7328
7292
  };
7329
- var Preview3 = ({ id = "puck-preview" }) => {
7293
+ var Preview2 = ({ id = "puck-preview" }) => {
7330
7294
  const dispatch = useAppStore((s) => s.dispatch);
7331
7295
  const root = useAppStore((s) => s.state.data.root);
7332
7296
  const config = useAppStore((s) => s.config);
@@ -7337,22 +7301,25 @@ var Preview3 = ({ id = "puck-preview" }) => {
7337
7301
  const renderData = useAppStore(
7338
7302
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7339
7303
  );
7340
- const Page = (0, import_react43.useCallback)(
7304
+ const Page = (0, import_react46.useCallback)(
7341
7305
  (pageProps) => {
7342
7306
  var _a, _b;
7343
- const rootConfig = config.root;
7344
- const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
7307
+ const propsWithSlots = useSlots(
7308
+ config,
7309
+ { type: "root", props: pageProps },
7310
+ DropZoneEditPure
7311
+ );
7345
7312
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7346
7313
  id: "puck-root"
7347
- }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
7314
+ }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: propsWithSlots.children });
7348
7315
  },
7349
- [config.root]
7316
+ [config]
7350
7317
  );
7351
- const Frame = (0, import_react43.useMemo)(() => overrides.iframe, [overrides]);
7318
+ const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
7352
7319
  const rootProps = root.props || root;
7353
- const ref = (0, import_react43.useRef)(null);
7320
+ const ref = (0, import_react46.useRef)(null);
7354
7321
  useBubbleIframeEvents(ref);
7355
- const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7322
+ const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7356
7323
  Page,
7357
7324
  __spreadProps(__spreadValues({}, rootProps), {
7358
7325
  puck: {
@@ -7362,28 +7329,28 @@ var Preview3 = ({ id = "puck-preview" }) => {
7362
7329
  metadata
7363
7330
  },
7364
7331
  editMode: true,
7365
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
7332
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7366
7333
  })
7367
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
7368
- (0, import_react43.useEffect)(() => {
7334
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config });
7335
+ (0, import_react46.useEffect)(() => {
7369
7336
  if (!iframe.enabled) {
7370
7337
  setStatus("READY");
7371
7338
  }
7372
7339
  }, [iframe.enabled]);
7373
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7340
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7374
7341
  "div",
7375
7342
  {
7376
- className: getClassName23(),
7343
+ className: getClassName22(),
7377
7344
  id,
7378
7345
  "data-puck-preview": true,
7379
7346
  onClick: () => {
7380
7347
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7381
7348
  },
7382
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7349
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7383
7350
  AutoFrame_default,
7384
7351
  {
7385
7352
  id: "preview-frame",
7386
- className: getClassName23("frame"),
7353
+ className: getClassName22("frame"),
7387
7354
  "data-rfd-iframe": true,
7388
7355
  onReady: () => {
7389
7356
  setStatus("READY");
@@ -7392,18 +7359,18 @@ var Preview3 = ({ id = "puck-preview" }) => {
7392
7359
  setStatus("MOUNTED");
7393
7360
  },
7394
7361
  frameRef: ref,
7395
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7362
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7396
7363
  if (Frame) {
7397
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
7364
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Frame, { document: document2, children: inner });
7398
7365
  }
7399
7366
  return inner;
7400
7367
  } })
7401
7368
  }
7402
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7369
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7403
7370
  "div",
7404
7371
  {
7405
7372
  id: "preview-frame",
7406
- className: getClassName23("frame"),
7373
+ className: getClassName22("frame"),
7407
7374
  ref,
7408
7375
  "data-puck-entry": true,
7409
7376
  children: inner
@@ -7421,7 +7388,7 @@ init_react_import();
7421
7388
 
7422
7389
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
7423
7390
  init_react_import();
7424
- 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" };
7391
+ 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" };
7425
7392
 
7426
7393
  // lib/scroll-into-view.ts
7427
7394
  init_react_import();
@@ -7435,7 +7402,7 @@ var scrollIntoView = (el) => {
7435
7402
  };
7436
7403
 
7437
7404
  // components/LayerTree/index.tsx
7438
- var import_react44 = require("react");
7405
+ var import_react47 = require("react");
7439
7406
 
7440
7407
  // lib/on-scroll-end.ts
7441
7408
  init_react_import();
@@ -7457,21 +7424,21 @@ var onScrollEnd = (frame, cb) => {
7457
7424
  };
7458
7425
 
7459
7426
  // components/LayerTree/index.tsx
7460
- var import_shallow5 = require("zustand/react/shallow");
7461
- var import_jsx_runtime36 = require("react/jsx-runtime");
7462
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7463
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
7427
+ var import_shallow6 = require("zustand/react/shallow");
7428
+ var import_jsx_runtime35 = require("react/jsx-runtime");
7429
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
7430
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
7464
7431
  var Layer = ({
7465
7432
  index,
7466
7433
  itemId,
7467
7434
  zoneCompound
7468
7435
  }) => {
7469
7436
  var _a;
7470
- const ctx = (0, import_react44.useContext)(dropZoneContext);
7437
+ const ctx = (0, import_react47.useContext)(dropZoneContext);
7471
7438
  const config = useAppStore((s) => s.config);
7472
7439
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7473
7440
  const dispatch = useAppStore((s) => s.dispatch);
7474
- const setItemSelector = (0, import_react44.useCallback)(
7441
+ const setItemSelector = (0, import_react47.useCallback)(
7475
7442
  (itemSelector2) => {
7476
7443
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
7477
7444
  },
@@ -7484,16 +7451,18 @@ var Layer = ({
7484
7451
  const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
7485
7452
  const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
7486
7453
  const zonesForItem = useAppStore(
7487
- (0, import_shallow5.useShallow)(
7454
+ (0, import_shallow6.useShallow)(
7488
7455
  (s) => Object.keys(s.state.indexes.zones).filter(
7489
7456
  (z) => z.split(":")[0] === itemId
7490
7457
  )
7491
7458
  )
7492
7459
  );
7493
7460
  const containsZone = zonesForItem.length > 0;
7494
- const { setHoveringComponent = () => {
7495
- }, hoveringComponent } = ctx || {};
7496
- const isHovering = hoveringComponent === itemId;
7461
+ const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
7462
+ const isHovering = useContextStore(
7463
+ ZoneStoreContext,
7464
+ (s) => s.hoveringComponent === itemId
7465
+ );
7497
7466
  const childIsSelected = useAppStore((s) => {
7498
7467
  var _a2, _b;
7499
7468
  const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
@@ -7504,7 +7473,7 @@ var Layer = ({
7504
7473
  });
7505
7474
  const componentConfig = config.components[nodeData.data.type];
7506
7475
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7507
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7476
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7508
7477
  "li",
7509
7478
  {
7510
7479
  className: getClassNameLayer({
@@ -7514,7 +7483,7 @@ var Layer = ({
7514
7483
  childIsSelected
7515
7484
  }),
7516
7485
  children: [
7517
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7486
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7518
7487
  "button",
7519
7488
  {
7520
7489
  type: "button",
@@ -7529,7 +7498,10 @@ var Layer = ({
7529
7498
  `[data-puck-component="${itemId}"]`
7530
7499
  );
7531
7500
  if (!el) {
7532
- console.error("Scroll failed. No element was found for", itemId);
7501
+ setItemSelector({
7502
+ index,
7503
+ zone: zoneCompound
7504
+ });
7533
7505
  return;
7534
7506
  }
7535
7507
  scrollIntoView(el);
@@ -7540,31 +7512,31 @@ var Layer = ({
7540
7512
  });
7541
7513
  });
7542
7514
  },
7543
- onMouseOver: (e) => {
7515
+ onMouseEnter: (e) => {
7544
7516
  e.stopPropagation();
7545
- setHoveringComponent(itemId);
7517
+ zoneStore.setState({ hoveringComponent: itemId });
7546
7518
  },
7547
- onMouseOut: (e) => {
7519
+ onMouseLeave: (e) => {
7548
7520
  e.stopPropagation();
7549
- setHoveringComponent(null);
7521
+ zoneStore.setState({ hoveringComponent: null });
7550
7522
  },
7551
7523
  children: [
7552
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7524
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7553
7525
  "div",
7554
7526
  {
7555
7527
  className: getClassNameLayer("chevron"),
7556
7528
  title: isSelected ? "Collapse" : "Expand",
7557
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
7529
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { size: "12" })
7558
7530
  }
7559
7531
  ),
7560
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
7561
- /* @__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" }) }),
7562
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
7532
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassNameLayer("title"), children: [
7533
+ /* @__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" }) }),
7534
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("name"), children: label })
7563
7535
  ] })
7564
7536
  ]
7565
7537
  }
7566
7538
  ) }),
7567
- 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))
7539
+ 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))
7568
7540
  ]
7569
7541
  }
7570
7542
  );
@@ -7575,22 +7547,22 @@ var LayerTree = ({
7575
7547
  }) => {
7576
7548
  const label = _label != null ? _label : zoneCompound.split(":")[1];
7577
7549
  const contentIds = useAppStore(
7578
- (0, import_shallow5.useShallow)(
7550
+ (0, import_shallow6.useShallow)(
7579
7551
  (s) => {
7580
7552
  var _a, _b;
7581
7553
  return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
7582
7554
  }
7583
7555
  )
7584
7556
  );
7585
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
7586
- label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
7587
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
7557
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
7558
+ label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
7559
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
7588
7560
  label
7589
7561
  ] }),
7590
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
7591
- contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
7562
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
7563
+ contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
7592
7564
  contentIds.map((itemId, i) => {
7593
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7565
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7594
7566
  Layer,
7595
7567
  {
7596
7568
  index: i,
@@ -7605,7 +7577,7 @@ var LayerTree = ({
7605
7577
  };
7606
7578
 
7607
7579
  // components/Puck/components/Outline/index.tsx
7608
- var import_react45 = require("react");
7580
+ var import_react48 = require("react");
7609
7581
 
7610
7582
  // lib/data/find-zones-for-area.ts
7611
7583
  init_react_import();
@@ -7616,15 +7588,15 @@ var findZonesForArea = (state, area) => {
7616
7588
  };
7617
7589
 
7618
7590
  // components/Puck/components/Outline/index.tsx
7619
- var import_shallow6 = require("zustand/react/shallow");
7620
- var import_jsx_runtime37 = require("react/jsx-runtime");
7591
+ var import_shallow7 = require("zustand/react/shallow");
7592
+ var import_jsx_runtime36 = require("react/jsx-runtime");
7621
7593
  var Outline = () => {
7622
7594
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7623
7595
  const rootZones = useAppStore(
7624
- (0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
7596
+ (0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
7625
7597
  );
7626
- const Wrapper = (0, import_react45.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7627
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7598
+ const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7599
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7628
7600
  LayerTree,
7629
7601
  {
7630
7602
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -7757,25 +7729,25 @@ var getBox = function getBox2(el) {
7757
7729
  };
7758
7730
 
7759
7731
  // components/Puck/components/Canvas/index.tsx
7760
- var import_react47 = require("react");
7732
+ var import_react50 = require("react");
7761
7733
 
7762
7734
  // components/ViewportControls/index.tsx
7763
7735
  init_react_import();
7764
- var import_react46 = require("react");
7736
+ var import_react49 = require("react");
7765
7737
 
7766
7738
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7767
7739
  init_react_import();
7768
- 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" };
7740
+ 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" };
7769
7741
 
7770
7742
  // components/ViewportControls/index.tsx
7771
- var import_jsx_runtime38 = require("react/jsx-runtime");
7743
+ var import_jsx_runtime37 = require("react/jsx-runtime");
7772
7744
  var icons = {
7773
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
7774
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
7775
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
7745
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Smartphone, { size: 16 }),
7746
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Tablet, { size: 16 }),
7747
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Monitor, { size: 16 })
7776
7748
  };
7777
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7778
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
7749
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7750
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7779
7751
  var ViewportButton = ({
7780
7752
  children,
7781
7753
  height = "auto",
@@ -7784,11 +7756,11 @@ var ViewportButton = ({
7784
7756
  onClick
7785
7757
  }) => {
7786
7758
  const viewports = useAppStore((s) => s.state.ui.viewports);
7787
- const [isActive, setIsActive] = (0, import_react46.useState)(false);
7788
- (0, import_react46.useEffect)(() => {
7759
+ const [isActive, setIsActive] = (0, import_react49.useState)(false);
7760
+ (0, import_react49.useEffect)(() => {
7789
7761
  setIsActive(width === viewports.current.width);
7790
7762
  }, [width, viewports.current.width]);
7791
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7763
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7792
7764
  IconButton,
7793
7765
  {
7794
7766
  title,
@@ -7797,7 +7769,7 @@ var ViewportButton = ({
7797
7769
  e.stopPropagation();
7798
7770
  onClick({ width, height });
7799
7771
  },
7800
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
7772
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton("inner"), children })
7801
7773
  }
7802
7774
  ) });
7803
7775
  };
@@ -7821,7 +7793,7 @@ var ViewportControls = ({
7821
7793
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7822
7794
  (option) => option.value === autoZoom
7823
7795
  );
7824
- const zoomOptions = (0, import_react46.useMemo)(
7796
+ const zoomOptions = (0, import_react49.useMemo)(
7825
7797
  () => [
7826
7798
  ...defaultZoomOptions,
7827
7799
  ...defaultsContainAutoZoom ? [] : [
@@ -7833,8 +7805,8 @@ var ViewportControls = ({
7833
7805
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7834
7806
  [autoZoom]
7835
7807
  );
7836
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
7837
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7808
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName24(), children: [
7809
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7838
7810
  ViewportButton,
7839
7811
  {
7840
7812
  height: viewport.height,
@@ -7845,8 +7817,8 @@ var ViewportControls = ({
7845
7817
  },
7846
7818
  i
7847
7819
  )),
7848
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7849
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7820
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7821
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7850
7822
  IconButton,
7851
7823
  {
7852
7824
  title: "Zoom viewport out",
@@ -7860,10 +7832,10 @@ var ViewportControls = ({
7860
7832
  )].value
7861
7833
  );
7862
7834
  },
7863
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
7835
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomOut, { size: 16 })
7864
7836
  }
7865
7837
  ),
7866
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7838
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7867
7839
  IconButton,
7868
7840
  {
7869
7841
  title: "Zoom viewport in",
@@ -7877,19 +7849,19 @@ var ViewportControls = ({
7877
7849
  )].value
7878
7850
  );
7879
7851
  },
7880
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
7852
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomIn, { size: 16 })
7881
7853
  }
7882
7854
  ),
7883
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7884
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7855
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7856
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7885
7857
  "select",
7886
7858
  {
7887
- className: getClassName25("zoomSelect"),
7859
+ className: getClassName24("zoomSelect"),
7888
7860
  value: zoom.toString(),
7889
7861
  onChange: (e) => {
7890
7862
  onZoom(parseFloat(e.currentTarget.value));
7891
7863
  },
7892
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7864
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7893
7865
  "option",
7894
7866
  {
7895
7867
  value: option.value,
@@ -7904,7 +7876,7 @@ var ViewportControls = ({
7904
7876
 
7905
7877
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7906
7878
  init_react_import();
7907
- 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" };
7879
+ 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" };
7908
7880
 
7909
7881
  // lib/get-zoom-config.ts
7910
7882
  init_react_import();
@@ -7937,9 +7909,9 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7937
7909
  };
7938
7910
 
7939
7911
  // components/Puck/components/Canvas/index.tsx
7940
- var import_shallow7 = require("zustand/react/shallow");
7941
- var import_jsx_runtime39 = require("react/jsx-runtime");
7942
- var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
7912
+ var import_shallow8 = require("zustand/react/shallow");
7913
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7914
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7943
7915
  var ZOOM_ON_CHANGE = true;
7944
7916
  var Canvas = () => {
7945
7917
  const {
@@ -7951,7 +7923,7 @@ var Canvas = () => {
7951
7923
  status,
7952
7924
  iframe
7953
7925
  } = useAppStore(
7954
- (0, import_shallow7.useShallow)((s) => ({
7926
+ (0, import_shallow8.useShallow)((s) => ({
7955
7927
  dispatch: s.dispatch,
7956
7928
  overrides: s.overrides,
7957
7929
  setUi: s.setUi,
@@ -7962,23 +7934,23 @@ var Canvas = () => {
7962
7934
  }))
7963
7935
  );
7964
7936
  const { leftSideBarVisible, rightSideBarVisible, viewports } = useAppStore(
7965
- (0, import_shallow7.useShallow)((s) => ({
7937
+ (0, import_shallow8.useShallow)((s) => ({
7966
7938
  leftSideBarVisible: s.state.ui.leftSideBarVisible,
7967
7939
  rightSideBarVisible: s.state.ui.rightSideBarVisible,
7968
7940
  viewports: s.state.ui.viewports
7969
7941
  }))
7970
7942
  );
7971
- const frameRef = (0, import_react47.useRef)(null);
7972
- const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
7973
- const defaultRender = (0, import_react47.useMemo)(() => {
7974
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
7943
+ const frameRef = (0, import_react50.useRef)(null);
7944
+ const [showTransition, setShowTransition] = (0, import_react50.useState)(false);
7945
+ const defaultRender = (0, import_react50.useMemo)(() => {
7946
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
7975
7947
  return PuckDefault;
7976
7948
  }, []);
7977
- const CustomPreview = (0, import_react47.useMemo)(
7949
+ const CustomPreview = (0, import_react50.useMemo)(
7978
7950
  () => overrides.preview || defaultRender,
7979
7951
  [overrides]
7980
7952
  );
7981
- const getFrameDimensions = (0, import_react47.useCallback)(() => {
7953
+ const getFrameDimensions = (0, import_react50.useCallback)(() => {
7982
7954
  if (frameRef.current) {
7983
7955
  const frame = frameRef.current;
7984
7956
  const box = getBox(frame);
@@ -7986,7 +7958,7 @@ var Canvas = () => {
7986
7958
  }
7987
7959
  return { width: 0, height: 0 };
7988
7960
  }, [frameRef]);
7989
- const resetAutoZoom = (0, import_react47.useCallback)(
7961
+ const resetAutoZoom = (0, import_react50.useCallback)(
7990
7962
  (newViewports = viewports) => {
7991
7963
  if (frameRef.current) {
7992
7964
  setZoomConfig(
@@ -8000,11 +7972,11 @@ var Canvas = () => {
8000
7972
  },
8001
7973
  [frameRef, zoomConfig, viewports]
8002
7974
  );
8003
- (0, import_react47.useEffect)(() => {
7975
+ (0, import_react50.useEffect)(() => {
8004
7976
  setShowTransition(false);
8005
7977
  resetAutoZoom(viewports);
8006
7978
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
8007
- (0, import_react47.useEffect)(() => {
7979
+ (0, import_react50.useEffect)(() => {
8008
7980
  const { height: frameHeight } = getFrameDimensions();
8009
7981
  if (viewports.current.height === "auto") {
8010
7982
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -8012,13 +7984,13 @@ var Canvas = () => {
8012
7984
  }));
8013
7985
  }
8014
7986
  }, [zoomConfig.zoom]);
8015
- (0, import_react47.useEffect)(() => {
7987
+ (0, import_react50.useEffect)(() => {
8016
7988
  if (ZOOM_ON_CHANGE) {
8017
7989
  setShowTransition(true);
8018
7990
  resetAutoZoom(viewports);
8019
7991
  }
8020
7992
  }, [viewports.current.width]);
8021
- (0, import_react47.useEffect)(() => {
7993
+ (0, import_react50.useEffect)(() => {
8022
7994
  const cb = () => {
8023
7995
  setShowTransition(false);
8024
7996
  resetAutoZoom();
@@ -8028,16 +8000,16 @@ var Canvas = () => {
8028
8000
  window.removeEventListener("resize", cb);
8029
8001
  };
8030
8002
  }, []);
8031
- const [showLoader, setShowLoader] = (0, import_react47.useState)(false);
8032
- (0, import_react47.useEffect)(() => {
8003
+ const [showLoader, setShowLoader] = (0, import_react50.useState)(false);
8004
+ (0, import_react50.useEffect)(() => {
8033
8005
  setTimeout(() => {
8034
8006
  setShowLoader(true);
8035
8007
  }, 500);
8036
8008
  }, []);
8037
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
8009
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
8038
8010
  "div",
8039
8011
  {
8040
- className: getClassName26({
8012
+ className: getClassName25({
8041
8013
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
8042
8014
  showLoader
8043
8015
  }),
@@ -8047,7 +8019,7 @@ var Canvas = () => {
8047
8019
  recordHistory: true
8048
8020
  }),
8049
8021
  children: [
8050
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8022
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8051
8023
  ViewportControls,
8052
8024
  {
8053
8025
  autoZoom: zoomConfig.autoZoom,
@@ -8073,11 +8045,11 @@ var Canvas = () => {
8073
8045
  }
8074
8046
  }
8075
8047
  ) }),
8076
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
8077
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8048
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
8049
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8078
8050
  "div",
8079
8051
  {
8080
- className: getClassName26("root"),
8052
+ className: getClassName25("root"),
8081
8053
  style: {
8082
8054
  width: iframe.enabled ? viewports.current.width : "100%",
8083
8055
  height: zoomConfig.rootHeight,
@@ -8095,10 +8067,10 @@ var Canvas = () => {
8095
8067
  })
8096
8068
  );
8097
8069
  },
8098
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview3, {}) })
8070
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Preview2, {}) })
8099
8071
  }
8100
8072
  ),
8101
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
8073
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { size: 24 }) })
8102
8074
  ] })
8103
8075
  ]
8104
8076
  }
@@ -8107,7 +8079,7 @@ var Canvas = () => {
8107
8079
 
8108
8080
  // lib/use-loaded-overrides.ts
8109
8081
  init_react_import();
8110
- var import_react48 = require("react");
8082
+ var import_react51 = require("react");
8111
8083
 
8112
8084
  // lib/load-overrides.ts
8113
8085
  init_react_import();
@@ -8146,26 +8118,26 @@ var useLoadedOverrides = ({
8146
8118
  overrides,
8147
8119
  plugins
8148
8120
  }) => {
8149
- return (0, import_react48.useMemo)(() => {
8121
+ return (0, import_react51.useMemo)(() => {
8150
8122
  return loadOverrides({ overrides, plugins });
8151
8123
  }, [plugins, overrides]);
8152
8124
  };
8153
8125
 
8154
8126
  // components/DefaultOverride/index.tsx
8155
8127
  init_react_import();
8156
- var import_jsx_runtime40 = require("react/jsx-runtime");
8157
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
8128
+ var import_jsx_runtime39 = require("react/jsx-runtime");
8129
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
8158
8130
 
8159
8131
  // lib/use-inject-css.ts
8160
8132
  init_react_import();
8161
- var import_react49 = require("react");
8133
+ var import_react52 = require("react");
8162
8134
  var styles = ``;
8163
8135
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
8164
- const [el, setEl] = (0, import_react49.useState)();
8165
- (0, import_react49.useEffect)(() => {
8136
+ const [el, setEl] = (0, import_react52.useState)();
8137
+ (0, import_react52.useEffect)(() => {
8166
8138
  setEl(document.createElement("style"));
8167
8139
  }, []);
8168
- (0, import_react49.useEffect)(() => {
8140
+ (0, import_react52.useEffect)(() => {
8169
8141
  var _a;
8170
8142
  if (!el || typeof window === "undefined") {
8171
8143
  return;
@@ -8185,10 +8157,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
8185
8157
 
8186
8158
  // lib/use-preview-mode-hotkeys.ts
8187
8159
  init_react_import();
8188
- var import_react50 = require("react");
8160
+ var import_react53 = require("react");
8189
8161
  var usePreviewModeHotkeys = () => {
8190
8162
  const appStore = useAppStoreApi();
8191
- const toggleInteractive = (0, import_react50.useCallback)(() => {
8163
+ const toggleInteractive = (0, import_react53.useCallback)(() => {
8192
8164
  const dispatch = appStore.getState().dispatch;
8193
8165
  dispatch({
8194
8166
  type: "setUi",
@@ -8203,7 +8175,7 @@ var usePreviewModeHotkeys = () => {
8203
8175
 
8204
8176
  // lib/use-puck.ts
8205
8177
  init_react_import();
8206
- var import_react51 = require("react");
8178
+ var import_react54 = require("react");
8207
8179
  var import_zustand6 = require("zustand");
8208
8180
  var generateUsePuck = (store) => {
8209
8181
  const history = {
@@ -8237,7 +8209,7 @@ var generateUsePuck = (store) => {
8237
8209
  const get = () => storeData;
8238
8210
  return __spreadProps(__spreadValues({}, storeData), { get });
8239
8211
  };
8240
- var UsePuckStoreContext = (0, import_react51.createContext)(
8212
+ var UsePuckStoreContext = (0, import_react54.createContext)(
8241
8213
  null
8242
8214
  );
8243
8215
  var convertToPickedStore = (store) => {
@@ -8251,12 +8223,12 @@ var convertToPickedStore = (store) => {
8251
8223
  };
8252
8224
  };
8253
8225
  var useRegisterUsePuckStore = (appStore) => {
8254
- const [usePuckStore] = (0, import_react51.useState)(
8226
+ const [usePuckStore] = (0, import_react54.useState)(
8255
8227
  () => (0, import_zustand6.createStore)(
8256
8228
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
8257
8229
  )
8258
8230
  );
8259
- (0, import_react51.useEffect)(() => {
8231
+ (0, import_react54.useEffect)(() => {
8260
8232
  return appStore.subscribe(
8261
8233
  (store) => convertToPickedStore(store),
8262
8234
  (pickedStore) => {
@@ -8268,7 +8240,7 @@ var useRegisterUsePuckStore = (appStore) => {
8268
8240
  };
8269
8241
  function createUsePuck() {
8270
8242
  return function usePuck2(selector) {
8271
- const usePuckApi = (0, import_react51.useContext)(UsePuckStoreContext);
8243
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8272
8244
  if (!usePuckApi) {
8273
8245
  throw new Error("usePuck must be used inside <Puck>.");
8274
8246
  }
@@ -8280,18 +8252,241 @@ function createUsePuck() {
8280
8252
  };
8281
8253
  }
8282
8254
  function usePuck() {
8283
- (0, import_react51.useEffect)(() => {
8255
+ (0, import_react54.useEffect)(() => {
8284
8256
  console.warn(
8285
8257
  "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."
8286
8258
  );
8287
8259
  }, []);
8288
8260
  return createUsePuck()((s) => s);
8289
8261
  }
8262
+ function useGetPuck() {
8263
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8264
+ if (!usePuckApi) {
8265
+ throw new Error("usePuckGet must be used inside <Puck>.");
8266
+ }
8267
+ return usePuckApi.getState;
8268
+ }
8290
8269
 
8291
8270
  // components/Puck/index.tsx
8271
+ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
8272
+
8273
+ // components/Puck/components/Header/index.tsx
8274
+ init_react_import();
8275
+ var import_react55 = require("react");
8276
+
8277
+ // components/MenuBar/index.tsx
8278
+ init_react_import();
8279
+
8280
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
8281
+ init_react_import();
8282
+ 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" };
8283
+
8284
+ // components/MenuBar/index.tsx
8285
+ var import_jsx_runtime40 = require("react/jsx-runtime");
8286
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
8287
+ function MenuBar({
8288
+ menuOpen = false,
8289
+ renderHeaderActions,
8290
+ setMenuOpen
8291
+ }) {
8292
+ const back = useAppStore((s) => s.history.back);
8293
+ const forward = useAppStore((s) => s.history.forward);
8294
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
8295
+ const hasPast = useAppStore((s) => s.history.hasPast());
8296
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8297
+ "div",
8298
+ {
8299
+ className: getClassName26({ menuOpen }),
8300
+ onClick: (event) => {
8301
+ var _a;
8302
+ const element = event.target;
8303
+ if (window.matchMedia("(min-width: 638px)").matches) {
8304
+ return;
8305
+ }
8306
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
8307
+ setMenuOpen(false);
8308
+ }
8309
+ },
8310
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("inner"), children: [
8311
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("history"), children: [
8312
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Undo2, { size: 21 }) }),
8313
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Redo2, { size: 21 }) })
8314
+ ] }),
8315
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: renderHeaderActions && renderHeaderActions() })
8316
+ ] })
8317
+ }
8318
+ );
8319
+ }
8320
+
8321
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
8322
+ init_react_import();
8323
+ 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" };
8324
+
8325
+ // components/Puck/components/Header/index.tsx
8292
8326
  var import_jsx_runtime41 = require("react/jsx-runtime");
8293
- var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
8294
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
8327
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
8328
+ var HeaderInner = () => {
8329
+ const {
8330
+ onPublish,
8331
+ renderHeader,
8332
+ renderHeaderActions,
8333
+ headerTitle,
8334
+ headerPath,
8335
+ iframe: _iframe
8336
+ } = usePropsContext();
8337
+ const dispatch = useAppStore((s) => s.dispatch);
8338
+ const appStore = useAppStoreApi();
8339
+ const defaultHeaderRender = (0, import_react55.useMemo)(() => {
8340
+ if (renderHeader) {
8341
+ console.warn(
8342
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8343
+ );
8344
+ const RenderHeader = (_a) => {
8345
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8346
+ const Comp = renderHeader;
8347
+ const appState = useAppStore((s) => s.state);
8348
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8349
+ };
8350
+ return RenderHeader;
8351
+ }
8352
+ return DefaultOverride;
8353
+ }, [renderHeader]);
8354
+ const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
8355
+ if (renderHeaderActions) {
8356
+ console.warn(
8357
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8358
+ );
8359
+ const RenderHeader = (props) => {
8360
+ const Comp = renderHeaderActions;
8361
+ const appState = useAppStore((s) => s.state);
8362
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8363
+ };
8364
+ return RenderHeader;
8365
+ }
8366
+ return DefaultOverride;
8367
+ }, [renderHeader]);
8368
+ const CustomHeader = useAppStore(
8369
+ (s) => s.overrides.header || defaultHeaderRender
8370
+ );
8371
+ const CustomHeaderActions = useAppStore(
8372
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
8373
+ );
8374
+ const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
8375
+ const rootTitle = useAppStore((s) => {
8376
+ var _a, _b;
8377
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
8378
+ return (_b = rootData.props.title) != null ? _b : "";
8379
+ });
8380
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8381
+ const rightSideBarVisible = useAppStore(
8382
+ (s) => s.state.ui.rightSideBarVisible
8383
+ );
8384
+ const toggleSidebars = (0, import_react55.useCallback)(
8385
+ (sidebar) => {
8386
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8387
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8388
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8389
+ dispatch({
8390
+ type: "setUi",
8391
+ ui: __spreadValues({
8392
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
8393
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
8394
+ });
8395
+ },
8396
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
8397
+ );
8398
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8399
+ CustomHeader,
8400
+ {
8401
+ 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)(
8402
+ Button,
8403
+ {
8404
+ onClick: () => {
8405
+ const data = appStore.getState().state.data;
8406
+ onPublish && onPublish(data);
8407
+ },
8408
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8409
+ children: "Publish"
8410
+ }
8411
+ ) }) }),
8412
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8413
+ "header",
8414
+ {
8415
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
8416
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("inner"), children: [
8417
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("toggle"), children: [
8418
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8419
+ IconButton,
8420
+ {
8421
+ onClick: () => {
8422
+ toggleSidebars("left");
8423
+ },
8424
+ title: "Toggle left sidebar",
8425
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8426
+ }
8427
+ ) }),
8428
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8429
+ IconButton,
8430
+ {
8431
+ onClick: () => {
8432
+ toggleSidebars("right");
8433
+ },
8434
+ title: "Toggle right sidebar",
8435
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8436
+ }
8437
+ ) })
8438
+ ] }),
8439
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8440
+ headerTitle || rootTitle || "Page",
8441
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8442
+ " ",
8443
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("code", { className: getClassName27("path"), children: headerPath })
8444
+ ] })
8445
+ ] }) }),
8446
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("tools"), children: [
8447
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8448
+ IconButton,
8449
+ {
8450
+ onClick: () => {
8451
+ return setMenuOpen(!menuOpen);
8452
+ },
8453
+ title: "Toggle menu bar",
8454
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8455
+ }
8456
+ ) }),
8457
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8458
+ MenuBar,
8459
+ {
8460
+ dispatch,
8461
+ onPublish,
8462
+ menuOpen,
8463
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8464
+ Button,
8465
+ {
8466
+ onClick: () => {
8467
+ const data = appStore.getState().state.data;
8468
+ onPublish && onPublish(data);
8469
+ },
8470
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8471
+ children: "Publish"
8472
+ }
8473
+ ) }),
8474
+ setMenuOpen
8475
+ }
8476
+ )
8477
+ ] })
8478
+ ] })
8479
+ }
8480
+ )
8481
+ }
8482
+ );
8483
+ };
8484
+ var Header = (0, import_react55.memo)(HeaderInner);
8485
+
8486
+ // components/Puck/index.tsx
8487
+ var import_jsx_runtime42 = require("react/jsx-runtime");
8488
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
8489
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
8295
8490
  var FieldSideBar = () => {
8296
8491
  const title = useAppStore(
8297
8492
  (s) => {
@@ -8299,13 +8494,13 @@ var FieldSideBar = () => {
8299
8494
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
8300
8495
  }
8301
8496
  );
8302
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
8497
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
8303
8498
  };
8304
- var propsContext = (0, import_react52.createContext)({});
8499
+ var propsContext = (0, import_react56.createContext)({});
8305
8500
  function PropsProvider(props) {
8306
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
8501
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
8307
8502
  }
8308
- var usePropsContext = () => (0, import_react52.useContext)(propsContext);
8503
+ var usePropsContext = () => (0, import_react56.useContext)(propsContext);
8309
8504
  function PuckProvider({ children }) {
8310
8505
  const {
8311
8506
  config,
@@ -8321,11 +8516,14 @@ function PuckProvider({ children }) {
8321
8516
  metadata,
8322
8517
  onAction
8323
8518
  } = usePropsContext();
8324
- const iframe = __spreadValues({
8325
- enabled: true,
8326
- waitForStyles: true
8327
- }, _iframe);
8328
- const [generatedAppState] = (0, import_react52.useState)(() => {
8519
+ const iframe = (0, import_react56.useMemo)(
8520
+ () => __spreadValues({
8521
+ enabled: true,
8522
+ waitForStyles: true
8523
+ }, _iframe),
8524
+ [_iframe]
8525
+ );
8526
+ const [generatedAppState] = (0, import_react56.useState)(() => {
8329
8527
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8330
8528
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8331
8529
  let clientUiState = {};
@@ -8385,7 +8583,7 @@ function PuckProvider({ children }) {
8385
8583
  return walkAppState(newAppState, config);
8386
8584
  });
8387
8585
  const { appendData = true } = _initialHistory || {};
8388
- const [blendedHistories] = (0, import_react52.useState)(
8586
+ const [blendedHistories] = (0, import_react56.useState)(
8389
8587
  [
8390
8588
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8391
8589
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8405,7 +8603,7 @@ function PuckProvider({ children }) {
8405
8603
  overrides,
8406
8604
  plugins
8407
8605
  });
8408
- const generateAppStore = (0, import_react52.useCallback)(
8606
+ const generateAppStore = (0, import_react56.useCallback)(
8409
8607
  (state) => {
8410
8608
  return {
8411
8609
  state,
@@ -8429,10 +8627,15 @@ function PuckProvider({ children }) {
8429
8627
  metadata
8430
8628
  ]
8431
8629
  );
8432
- const [appStore] = (0, import_react52.useState)(
8630
+ const [appStore] = (0, import_react56.useState)(
8433
8631
  () => createAppStore(generateAppStore(initialAppState))
8434
8632
  );
8435
- (0, import_react52.useEffect)(() => {
8633
+ (0, import_react56.useEffect)(() => {
8634
+ if (process.env.NODE_ENV !== "production") {
8635
+ window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
8636
+ }
8637
+ }, [appStore]);
8638
+ (0, import_react56.useEffect)(() => {
8436
8639
  const state = appStore.getState().state;
8437
8640
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8438
8641
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8441,66 +8644,47 @@ function PuckProvider({ children }) {
8441
8644
  index: initialHistoryIndex,
8442
8645
  initialAppState
8443
8646
  });
8444
- (0, import_react52.useEffect)(() => {
8445
- appStore.subscribe((s) => {
8446
- if (onChange) onChange(s.state.data);
8447
- });
8647
+ const previousData = (0, import_react56.useRef)(null);
8648
+ (0, import_react56.useEffect)(() => {
8649
+ appStore.subscribe(
8650
+ (s) => s.state.data,
8651
+ (data) => {
8652
+ if (onChange) {
8653
+ if ((0, import_fast_deep_equal3.default)(data, previousData.current)) return;
8654
+ onChange(data);
8655
+ previousData.current = data;
8656
+ }
8657
+ }
8658
+ );
8448
8659
  }, []);
8449
8660
  useRegisterPermissionsSlice(appStore, permissions);
8450
8661
  const uPuckStore = useRegisterUsePuckStore(appStore);
8451
- (0, import_react52.useEffect)(() => {
8662
+ (0, import_react56.useEffect)(() => {
8452
8663
  const { resolveAndCommitData } = appStore.getState();
8453
8664
  resolveAndCommitData();
8454
8665
  }, []);
8455
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8666
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8456
8667
  }
8457
8668
  function PuckLayout({ children }) {
8458
8669
  const {
8459
- onChange,
8460
- onPublish,
8461
- renderHeader,
8462
- renderHeaderActions,
8463
- headerTitle,
8464
- headerPath,
8465
8670
  iframe: _iframe,
8466
8671
  dnd,
8467
8672
  initialHistory: _initialHistory
8468
8673
  } = usePropsContext();
8469
- const iframe = __spreadValues({
8470
- enabled: true,
8471
- waitForStyles: true
8472
- }, _iframe);
8674
+ const iframe = (0, import_react56.useMemo)(
8675
+ () => __spreadValues({
8676
+ enabled: true,
8677
+ waitForStyles: true
8678
+ }, _iframe),
8679
+ [_iframe]
8680
+ );
8473
8681
  useInjectGlobalCss(iframe.enabled);
8474
8682
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8475
8683
  const rightSideBarVisible = useAppStore(
8476
8684
  (s) => s.state.ui.rightSideBarVisible
8477
8685
  );
8478
- const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
8479
- const appStore = useAppStoreApi();
8480
- (0, import_react52.useEffect)(() => {
8481
- return appStore.subscribe((s) => {
8482
- if (onChange) onChange(s.state.data);
8483
- });
8484
- }, [appStore]);
8485
- const rootProps = useAppStore(
8486
- (s) => s.state.data.root.props || s.state.data.root.props
8487
- );
8488
8686
  const dispatch = useAppStore((s) => s.dispatch);
8489
- const toggleSidebars = (0, import_react52.useCallback)(
8490
- (sidebar) => {
8491
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8492
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8493
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8494
- dispatch({
8495
- type: "setUi",
8496
- ui: __spreadValues({
8497
- [`${sidebar}SideBarVisible`]: !sideBarVisible
8498
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
8499
- });
8500
- },
8501
- [dispatch, leftSideBarVisible, rightSideBarVisible]
8502
- );
8503
- (0, import_react52.useEffect)(() => {
8687
+ (0, import_react56.useEffect)(() => {
8504
8688
  if (!window.matchMedia("(min-width: 638px)").matches) {
8505
8689
  dispatch({
8506
8690
  type: "setUi",
@@ -8523,55 +8707,18 @@ function PuckLayout({ children }) {
8523
8707
  window.removeEventListener("resize", handleResize);
8524
8708
  };
8525
8709
  }, []);
8526
- const defaultHeaderRender = (0, import_react52.useMemo)(() => {
8527
- if (renderHeader) {
8528
- console.warn(
8529
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8530
- );
8531
- const RenderHeader = (_a) => {
8532
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8533
- const Comp = renderHeader;
8534
- const appState = useAppStore((s) => s.state);
8535
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8536
- };
8537
- return RenderHeader;
8538
- }
8539
- return DefaultOverride;
8540
- }, [renderHeader]);
8541
- const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
8542
- if (renderHeaderActions) {
8543
- console.warn(
8544
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8545
- );
8546
- const RenderHeader = (props) => {
8547
- const Comp = renderHeaderActions;
8548
- const appState = useAppStore((s) => s.state);
8549
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8550
- };
8551
- return RenderHeader;
8552
- }
8553
- return DefaultOverride;
8554
- }, [renderHeader]);
8555
8710
  const overrides = useAppStore((s) => s.overrides);
8556
- const CustomPuck = (0, import_react52.useMemo)(
8711
+ const CustomPuck = (0, import_react56.useMemo)(
8557
8712
  () => overrides.puck || DefaultOverride,
8558
8713
  [overrides]
8559
8714
  );
8560
- const CustomHeader = (0, import_react52.useMemo)(
8561
- () => overrides.header || defaultHeaderRender,
8562
- [overrides]
8563
- );
8564
- const CustomHeaderActions = (0, import_react52.useMemo)(
8565
- () => overrides.headerActions || defaultHeaderActionsRender,
8566
- [overrides]
8567
- );
8568
- const [mounted, setMounted] = (0, import_react52.useState)(false);
8569
- (0, import_react52.useEffect)(() => {
8715
+ const [mounted, setMounted] = (0, import_react56.useState)(false);
8716
+ (0, import_react56.useEffect)(() => {
8570
8717
  setMounted(true);
8571
8718
  }, []);
8572
8719
  const ready = useAppStore((s) => s.status === "READY");
8573
8720
  useMonitorHotkeys();
8574
- (0, import_react52.useEffect)(() => {
8721
+ (0, import_react56.useEffect)(() => {
8575
8722
  if (ready && iframe.enabled) {
8576
8723
  const frameDoc = getFrame();
8577
8724
  if (frameDoc) {
@@ -8580,133 +8727,36 @@ function PuckLayout({ children }) {
8580
8727
  }
8581
8728
  }, [ready, iframe.enabled]);
8582
8729
  usePreviewModeHotkeys();
8583
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
8584
- /* @__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)(
8730
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `Puck ${getClassName28()}`, children: [
8731
+ /* @__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)(
8585
8732
  "div",
8586
8733
  {
8587
8734
  className: getLayoutClassName({
8588
8735
  leftSideBarVisible,
8589
- menuOpen,
8590
8736
  mounted,
8591
8737
  rightSideBarVisible
8592
8738
  }),
8593
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8594
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8595
- CustomHeader,
8596
- {
8597
- 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)(
8598
- Button,
8599
- {
8600
- onClick: () => {
8601
- const data = appStore.getState().state.data;
8602
- onPublish && onPublish(data);
8603
- },
8604
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8605
- children: "Publish"
8606
- }
8607
- ) }) }),
8608
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
8609
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
8610
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8611
- "div",
8612
- {
8613
- className: getLayoutClassName("leftSideBarToggle"),
8614
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8615
- IconButton,
8616
- {
8617
- onClick: () => {
8618
- toggleSidebars("left");
8619
- },
8620
- title: "Toggle left sidebar",
8621
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8622
- }
8623
- )
8624
- }
8625
- ),
8626
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8627
- "div",
8628
- {
8629
- className: getLayoutClassName("rightSideBarToggle"),
8630
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8631
- IconButton,
8632
- {
8633
- onClick: () => {
8634
- toggleSidebars("right");
8635
- },
8636
- title: "Toggle right sidebar",
8637
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8638
- }
8639
- )
8640
- }
8641
- )
8642
- ] }),
8643
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8644
- headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
8645
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8646
- " ",
8647
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8648
- "code",
8649
- {
8650
- className: getLayoutClassName("headerPath"),
8651
- children: headerPath
8652
- }
8653
- )
8654
- ] })
8655
- ] }) }),
8656
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
8657
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8658
- IconButton,
8659
- {
8660
- onClick: () => {
8661
- return setMenuOpen(!menuOpen);
8662
- },
8663
- title: "Toggle menu bar",
8664
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8665
- }
8666
- ) }),
8667
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8668
- MenuBar,
8669
- {
8670
- dispatch,
8671
- onPublish,
8672
- menuOpen,
8673
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8674
- Button,
8675
- {
8676
- onClick: () => {
8677
- const data = appStore.getState().state.data;
8678
- onPublish && onPublish(data);
8679
- },
8680
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8681
- children: "Publish"
8682
- }
8683
- ) }),
8684
- setMenuOpen
8685
- }
8686
- )
8687
- ] })
8688
- ] }) })
8689
- }
8690
- ),
8691
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8692
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Components, {}) }),
8693
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Outline, {}) })
8739
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8740
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Header, {}),
8741
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8742
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Components, {}) }),
8743
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Outline, {}) })
8694
8744
  ] }),
8695
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Canvas, {}),
8696
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FieldSideBar, {}) })
8745
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Canvas, {}),
8746
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FieldSideBar, {}) })
8697
8747
  ] })
8698
8748
  }
8699
8749
  ) }) }),
8700
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
8750
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { id: "puck-portal-root", className: getClassName28("portal") })
8701
8751
  ] });
8702
8752
  }
8703
8753
  function Puck(props) {
8704
- 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)) })) }));
8754
+ 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)) })) }));
8705
8755
  }
8706
8756
  Puck.Components = Components;
8707
8757
  Puck.Fields = Fields;
8708
8758
  Puck.Outline = Outline;
8709
- Puck.Preview = Preview3;
8759
+ Puck.Preview = Preview2;
8710
8760
 
8711
8761
  // lib/migrate.ts
8712
8762
  init_react_import();
@@ -8736,15 +8786,15 @@ var migrations = [
8736
8786
  const { indexes } = walkAppState(appState, config);
8737
8787
  const deletedCompounds = [];
8738
8788
  walkAppState(appState, config, (content, zoneCompound, zoneType) => {
8739
- var _a2, _b;
8789
+ var _a2, _b, _c;
8740
8790
  if (zoneType === "dropzone") {
8741
8791
  const [id, slotName] = zoneCompound.split(":");
8742
8792
  const nodeData = indexes.nodes[id].data;
8743
8793
  const componentType = nodeData.type;
8744
- const configForComponent = config.components[componentType];
8794
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
8745
8795
  if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
8746
8796
  updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8747
- props: __spreadProps(__spreadValues({}, nodeData.props), {
8797
+ props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
8748
8798
  [slotName]: content
8749
8799
  })
8750
8800
  });
@@ -8799,11 +8849,13 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
8799
8849
  });
8800
8850
 
8801
8851
  // lib/transform-props.ts
8802
- function transformProps(data, propTransforms) {
8852
+ function transformProps(data, propTransforms, config = { components: {} }) {
8803
8853
  const mapItem = (item) => {
8804
8854
  if (propTransforms[item.type]) {
8805
8855
  return __spreadProps(__spreadValues({}, item), {
8806
- props: propTransforms[item.type](item.props)
8856
+ props: __spreadValues({
8857
+ id: item.props.id
8858
+ }, propTransforms[item.type](item.props))
8807
8859
  });
8808
8860
  }
8809
8861
  return item;
@@ -8812,23 +8864,18 @@ function transformProps(data, propTransforms) {
8812
8864
  const rootProps = defaultedData.root.props || defaultedData.root;
8813
8865
  let newRoot = __spreadValues({}, defaultedData.root);
8814
8866
  if (propTransforms["root"]) {
8815
- if (defaultedData.root.props) {
8816
- newRoot.props = propTransforms["root"](rootProps);
8817
- } else {
8818
- newRoot = propTransforms["root"](rootProps);
8819
- }
8867
+ newRoot.props = propTransforms["root"](rootProps);
8820
8868
  }
8821
- const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
8822
- root: newRoot,
8823
- content: defaultedData.content.map(mapItem),
8824
- zones: Object.keys(data.zones || {}).reduce(
8825
- (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
8826
- [zoneKey]: data.zones[zoneKey].map(mapItem)
8827
- }),
8828
- {}
8829
- )
8830
- });
8831
- return afterPropTransforms;
8869
+ const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
8870
+ const updatedData = walkTree(
8871
+ dataWithUpdatedRoot,
8872
+ config,
8873
+ (content) => content.map(mapItem)
8874
+ );
8875
+ if (!defaultedData.root.props) {
8876
+ updatedData.root = updatedData.root.props;
8877
+ }
8878
+ return updatedData;
8832
8879
  }
8833
8880
 
8834
8881
  // lib/resolve-all-data.ts
@@ -8859,13 +8906,12 @@ function resolveAllData(_0, _1) {
8859
8906
  },
8860
8907
  () => {
8861
8908
  },
8862
- "force",
8863
- false
8909
+ "force"
8864
8910
  )).node;
8865
- const resolvedDeep = yield mapSlotsAsync(
8911
+ const resolvedDeep = yield mapSlots(
8866
8912
  resolved,
8867
8913
  processContent,
8868
- false
8914
+ config
8869
8915
  );
8870
8916
  onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
8871
8917
  return resolvedDeep;
@@ -8913,6 +8959,7 @@ function resolveAllData(_0, _1) {
8913
8959
  renderContext,
8914
8960
  resolveAllData,
8915
8961
  transformProps,
8962
+ useGetPuck,
8916
8963
  usePuck,
8917
8964
  walkTree
8918
8965
  });