@measured/puck 0.19.0-canary.a967ca42 → 0.19.0-canary.af1dc891

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
@@ -792,43 +792,6 @@ init_react_import();
792
792
  // lib/data/walk-app-state.ts
793
793
  init_react_import();
794
794
 
795
- // lib/data/for-each-slot.ts
796
- init_react_import();
797
-
798
- // lib/data/is-slot.ts
799
- init_react_import();
800
- var isSlot = (prop) => {
801
- var _a, _b;
802
- return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
803
- };
804
- var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
805
- var _a, _b;
806
- const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
807
- if (!configForComponent) return isSlot(propValue);
808
- return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
809
- };
810
-
811
- // lib/data/for-each-slot.ts
812
- var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
813
- const props = item.props || {};
814
- const propKeys = Object.keys(props);
815
- for (let i = 0; i < propKeys.length; i++) {
816
- const propKey = propKeys[i];
817
- const itemType = "type" in item ? item.type : "root";
818
- if (isSlot2(itemType, propKey, props[propKey])) {
819
- const content = props[propKey];
820
- cb(props.id, propKey, content);
821
- if (recursive) {
822
- content.forEach(
823
- (childItem) => __async(void 0, null, function* () {
824
- return forEachSlot(childItem, cb, true, isSlot2);
825
- })
826
- );
827
- }
828
- }
829
- }
830
- };
831
-
832
795
  // lib/data/for-related-zones.ts
833
796
  init_react_import();
834
797
 
@@ -862,19 +825,160 @@ function forRelatedZones(item, data, cb, path = []) {
862
825
  });
863
826
  }
864
827
 
828
+ // lib/data/map-slots.ts
829
+ init_react_import();
830
+ var isPromise = (v) => !!v && typeof v.then === "function";
831
+ var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
832
+ var containsPromise = (arr) => arr.some(isPromise);
833
+ var walkField = ({
834
+ value,
835
+ fields,
836
+ map,
837
+ propKey = "",
838
+ propPath = "",
839
+ id = "",
840
+ config,
841
+ recurseSlots = false
842
+ }) => {
843
+ var _a, _b, _c;
844
+ if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
845
+ const content = value || [];
846
+ const mappedContent = recurseSlots ? content.map((el) => {
847
+ var _a2;
848
+ const componentConfig = config.components[el.type];
849
+ if (!componentConfig) {
850
+ throw new Error(`Could not find component config for ${el.type}`);
851
+ }
852
+ const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
853
+ return walkField({
854
+ value: el,
855
+ fields: fields2,
856
+ map,
857
+ id: el.props.id,
858
+ config,
859
+ recurseSlots
860
+ });
861
+ }) : content;
862
+ if (containsPromise(mappedContent)) {
863
+ return Promise.all(mappedContent);
864
+ }
865
+ return map(mappedContent, id, propPath, fields[propKey], propPath);
866
+ }
867
+ if (value && typeof value === "object") {
868
+ if (Array.isArray(value)) {
869
+ const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
870
+ if (!arrayFields) return value;
871
+ const newValue = value.map(
872
+ (el, idx) => walkField({
873
+ value: el,
874
+ fields: arrayFields,
875
+ map,
876
+ propKey,
877
+ propPath: `${propPath}[${idx}]`,
878
+ id,
879
+ config,
880
+ recurseSlots
881
+ })
882
+ );
883
+ if (containsPromise(newValue)) {
884
+ return Promise.all(newValue);
885
+ }
886
+ return newValue;
887
+ } else if ("$$typeof" in value) {
888
+ return value;
889
+ } else {
890
+ const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
891
+ return walkObject({
892
+ value,
893
+ fields: objectFields,
894
+ map,
895
+ id,
896
+ getPropPath: (k) => `${propPath}.${k}`,
897
+ config,
898
+ recurseSlots
899
+ });
900
+ }
901
+ }
902
+ return value;
903
+ };
904
+ var walkObject = ({
905
+ value,
906
+ fields,
907
+ map,
908
+ id,
909
+ getPropPath,
910
+ config,
911
+ recurseSlots
912
+ }) => {
913
+ const newProps = Object.entries(value).map(([k, v]) => {
914
+ const opts = {
915
+ value: v,
916
+ fields,
917
+ map,
918
+ propKey: k,
919
+ propPath: getPropPath(k),
920
+ id,
921
+ config,
922
+ recurseSlots
923
+ };
924
+ const newValue = walkField(opts);
925
+ if (isPromise(newValue)) {
926
+ return newValue.then((resolvedValue) => ({
927
+ [k]: resolvedValue
928
+ }));
929
+ }
930
+ return {
931
+ [k]: newValue
932
+ };
933
+ }, {});
934
+ if (containsPromise(newProps)) {
935
+ return Promise.all(newProps).then(flatten);
936
+ }
937
+ return flatten(newProps);
938
+ };
939
+ function mapSlots(item, map, config, recurseSlots = false) {
940
+ var _a, _b, _c, _d;
941
+ const itemType = "type" in item ? item.type : "root";
942
+ const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
943
+ const newProps = walkObject({
944
+ value: (_b = item.props) != null ? _b : {},
945
+ fields: (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {},
946
+ map,
947
+ id: item.props ? (_d = item.props.id) != null ? _d : "root" : "root",
948
+ getPropPath: (k) => k,
949
+ config,
950
+ recurseSlots
951
+ });
952
+ if (isPromise(newProps)) {
953
+ return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
954
+ props: resolvedProps
955
+ }));
956
+ }
957
+ return __spreadProps(__spreadValues({}, item), {
958
+ props: newProps
959
+ });
960
+ }
961
+
962
+ // lib/data/flatten-node.ts
963
+ init_react_import();
964
+ var import_flat = require("flat");
965
+
865
966
  // lib/data/strip-slots.ts
866
967
  init_react_import();
867
- var stripSlots = (data) => {
868
- return __spreadProps(__spreadValues({}, data), {
869
- props: Object.entries(data.props).reduce(
870
- (acc, [propKey, propVal]) => {
871
- if (isSlot(propVal)) {
872
- return acc;
873
- }
874
- return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
875
- },
876
- { id: data.props.id }
877
- )
968
+ var stripSlots = (data, config) => {
969
+ return mapSlots(data, () => null, config);
970
+ };
971
+
972
+ // lib/data/flatten-node.ts
973
+ var flattenNode = (node, config) => {
974
+ return __spreadProps(__spreadValues({}, node), {
975
+ props: (0, import_flat.flatten)(stripSlots(node, config).props)
976
+ });
977
+ };
978
+ var expandNode = (node) => {
979
+ const props = (0, import_flat.unflatten)(node.props);
980
+ return __spreadProps(__spreadValues({}, node), {
981
+ props
878
982
  });
879
983
  };
880
984
 
@@ -920,10 +1024,9 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
920
1024
  const mappedItem = mapNodeOrSkip(item, path, index);
921
1025
  if (!mappedItem) return item;
922
1026
  const id = mappedItem.props.id;
923
- const newProps = __spreadValues({}, mappedItem.props);
924
- forEachSlot(
1027
+ const newProps = __spreadProps(__spreadValues({}, mapSlots(
925
1028
  mappedItem,
926
- (parentId2, slotId, content) => {
1029
+ (content, parentId2, slotId) => {
927
1030
  const zoneCompound = `${parentId2}:${slotId}`;
928
1031
  const [_2, newContent2] = processContent(
929
1032
  path,
@@ -932,18 +1035,19 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
932
1035
  "slot",
933
1036
  parentId2
934
1037
  );
935
- newProps[slotId] = newContent2;
1038
+ return newContent2;
936
1039
  },
937
- false,
938
- createIsSlotConfig(config)
939
- );
1040
+ config
1041
+ ).props), {
1042
+ id
1043
+ });
940
1044
  processRelatedZones(item, id, path);
941
1045
  const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
942
1046
  const thisZoneCompound = path[path.length - 1];
943
1047
  const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
944
1048
  newNodeIndex[id] = {
945
1049
  data: newItem,
946
- flatData: stripSlots(newItem),
1050
+ flatData: flattenNode(newItem, config),
947
1051
  path,
948
1052
  parentId,
949
1053
  zone
@@ -1046,56 +1150,17 @@ init_react_import();
1046
1150
 
1047
1151
  // lib/data/walk-tree.ts
1048
1152
  init_react_import();
1049
-
1050
- // lib/data/map-slots.ts
1051
- init_react_import();
1052
- function mapSlotsAsync(_0, _1) {
1053
- return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
1054
- const props = __spreadValues({}, item.props);
1055
- const propKeys = Object.keys(props);
1056
- for (let i = 0; i < propKeys.length; i++) {
1057
- const propKey = propKeys[i];
1058
- const itemType = "type" in item ? item.type : "root";
1059
- if (isSlot2(itemType, propKey, props[propKey])) {
1060
- const content = props[propKey];
1061
- const mappedContent = recursive ? yield Promise.all(
1062
- content.map((item2) => __async(this, null, function* () {
1063
- return yield mapSlotsAsync(item2, map, recursive, isSlot2);
1064
- }))
1065
- ) : content;
1066
- props[propKey] = yield map(mappedContent, propKey);
1067
- }
1068
- }
1069
- return __spreadProps(__spreadValues({}, item), { props });
1070
- });
1071
- }
1072
- function mapSlotsSync(item, map, isSlot2 = isSlot) {
1073
- var _a, _b;
1074
- const props = __spreadValues({}, item.props);
1075
- const propKeys = Object.keys(props);
1076
- for (let i = 0; i < propKeys.length; i++) {
1077
- const propKey = propKeys[i];
1078
- const itemType = "type" in item ? item.type : "root";
1079
- if (isSlot2(itemType, propKey, props[propKey])) {
1080
- const content = props[propKey];
1081
- const mappedContent = content.map((item2) => {
1082
- return mapSlotsSync(item2, map, isSlot2);
1083
- });
1084
- props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
1085
- }
1086
- }
1087
- return __spreadProps(__spreadValues({}, item), { props });
1088
- }
1089
-
1090
- // lib/data/walk-tree.ts
1091
1153
  function walkTree(data, config, callbackFn) {
1092
1154
  var _a, _b;
1093
- const isSlot2 = createIsSlotConfig(config);
1094
1155
  const walkItem = (item) => {
1095
- return mapSlotsSync(
1156
+ return mapSlots(
1096
1157
  item,
1097
- (content, parentId, propName) => callbackFn(content, { parentId, propName }),
1098
- isSlot2
1158
+ (content, parentId, propName) => {
1159
+ var _a2;
1160
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
1161
+ },
1162
+ config,
1163
+ true
1099
1164
  );
1100
1165
  };
1101
1166
  if ("props" in data) {
@@ -1124,7 +1189,7 @@ var populateIds = (data, config, override = false) => {
1124
1189
  const id = generateId(data.type);
1125
1190
  return walkTree(
1126
1191
  __spreadProps(__spreadValues({}, data), {
1127
- props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
1192
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
1128
1193
  }),
1129
1194
  config,
1130
1195
  (contents) => contents.map((item) => {
@@ -1826,7 +1891,11 @@ var createNodesSlice = (set, get) => ({
1826
1891
  const s = get().nodes;
1827
1892
  const emptyNode = {
1828
1893
  id,
1829
- methods: { sync: () => null },
1894
+ methods: {
1895
+ sync: () => null,
1896
+ hideOverlay: () => null,
1897
+ showOverlay: () => null
1898
+ },
1830
1899
  element: null
1831
1900
  };
1832
1901
  const existingNode = s.nodes[id];
@@ -1877,12 +1946,13 @@ var flattenData = (state, config) => {
1877
1946
 
1878
1947
  // lib/get-changed.ts
1879
1948
  init_react_import();
1949
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1880
1950
  var getChanged = (newItem, oldItem) => {
1881
1951
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1882
1952
  const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1883
1953
  const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1884
1954
  return __spreadProps(__spreadValues({}, acc), {
1885
- [item]: oldItemProps[item] !== newItemProps[item]
1955
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1886
1956
  });
1887
1957
  }, {}) : {};
1888
1958
  };
@@ -2101,14 +2171,16 @@ var useRegisterFieldsSlice = (appStore, id) => {
2101
2171
 
2102
2172
  // lib/resolve-component-data.ts
2103
2173
  init_react_import();
2104
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
2174
+ var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
2105
2175
  var cache = { lastChange: {} };
2106
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
2176
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2107
2177
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
2108
- if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
2109
- const id = "id" in item.props ? item.props.id : "root";
2178
+ const resolvedItem = __spreadValues({}, item);
2179
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
2180
+ const id = "id" in item.props ? item.props.id : "root";
2181
+ if (shouldRunResolver) {
2110
2182
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
2111
- if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
2183
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
2112
2184
  return { node: resolved, didChange: false };
2113
2185
  }
2114
2186
  const changed = getChanged(item, oldItem);
@@ -2121,46 +2193,42 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2121
2193
  metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
2122
2194
  trigger
2123
2195
  });
2124
- let resolvedItem = __spreadProps(__spreadValues({}, item), {
2125
- props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
2126
- });
2127
- if (recursive) {
2128
- resolvedItem = yield mapSlotsAsync(
2129
- resolvedItem,
2130
- (content) => __async(void 0, null, function* () {
2131
- return Promise.all(
2132
- content.map(
2133
- (childItem) => __async(void 0, null, function* () {
2134
- return (yield resolveComponentData(
2135
- childItem,
2136
- config,
2137
- metadata,
2138
- onResolveStart,
2139
- onResolveEnd,
2140
- trigger,
2141
- false
2142
- )).node;
2143
- })
2144
- )
2145
- );
2146
- }),
2147
- false,
2148
- createIsSlotConfig(config)
2149
- );
2150
- }
2196
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
2151
2197
  if (Object.keys(readOnly).length) {
2152
2198
  resolvedItem.readOnly = readOnly;
2153
2199
  }
2154
- cache.lastChange[id] = {
2155
- item,
2156
- resolved: resolvedItem
2157
- };
2158
- if (onResolveEnd) {
2159
- onResolveEnd(resolvedItem);
2160
- }
2161
- return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
2162
2200
  }
2163
- return { node: item, didChange: false };
2201
+ let itemWithResolvedChildren = yield mapSlots(
2202
+ resolvedItem,
2203
+ (content) => __async(void 0, null, function* () {
2204
+ return yield Promise.all(
2205
+ content.map(
2206
+ (childItem) => __async(void 0, null, function* () {
2207
+ return (yield resolveComponentData(
2208
+ childItem,
2209
+ config,
2210
+ metadata,
2211
+ onResolveStart,
2212
+ onResolveEnd,
2213
+ trigger
2214
+ )).node;
2215
+ })
2216
+ )
2217
+ );
2218
+ }),
2219
+ config
2220
+ );
2221
+ if (shouldRunResolver && onResolveEnd) {
2222
+ onResolveEnd(resolvedItem);
2223
+ }
2224
+ cache.lastChange[id] = {
2225
+ item,
2226
+ resolved: itemWithResolvedChildren
2227
+ };
2228
+ return {
2229
+ node: itemWithResolvedChildren,
2230
+ didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
2231
+ };
2164
2232
  });
2165
2233
 
2166
2234
  // lib/data/to-root.ts
@@ -2947,6 +3015,19 @@ var ArrayField = ({
2947
3015
  );
2948
3016
  const forceReadOnly = !canEdit;
2949
3017
  const valueRef = (0, import_react14.useRef)(value);
3018
+ const uniqifyItem = (0, import_react14.useCallback)(
3019
+ (val) => {
3020
+ if (field.type !== "array" || !field.arrayFields) return;
3021
+ const config = appStore.getState().config;
3022
+ return walkField({
3023
+ value: val,
3024
+ fields: field.arrayFields,
3025
+ map: (content) => content.map((item) => populateIds(item, config, true)),
3026
+ config
3027
+ });
3028
+ },
3029
+ [appStore, field]
3030
+ );
2950
3031
  if (field.type !== "array" || !field.arrayFields) {
2951
3032
  return null;
2952
3033
  }
@@ -3051,11 +3132,10 @@ var ArrayField = ({
3051
3132
  onClick: (e) => {
3052
3133
  e.stopPropagation();
3053
3134
  const existingValue = [...value || []];
3054
- existingValue.splice(
3055
- i,
3056
- 0,
3135
+ const newItem = uniqifyItem(
3057
3136
  existingValue[i]
3058
3137
  );
3138
+ existingValue.splice(i, 0, newItem);
3059
3139
  const newUi = mapArrayStateToUi(
3060
3140
  regenerateArrayState(existingValue)
3061
3141
  );
@@ -3153,12 +3233,11 @@ var ArrayField = ({
3153
3233
  type: "button",
3154
3234
  className: getClassName5("addButton"),
3155
3235
  onClick: () => {
3236
+ var _a;
3156
3237
  if (isDraggingAny) return;
3157
3238
  const existingValue = value || [];
3158
- const newValue = [
3159
- ...existingValue,
3160
- field.defaultItemProps || {}
3161
- ];
3239
+ const newItem = uniqifyItem((_a = field.defaultItemProps) != null ? _a : {});
3240
+ const newValue = [...existingValue, newItem];
3162
3241
  const newArrayState = regenerateArrayState(newValue);
3163
3242
  setUi(mapArrayStateToUi(newArrayState), false);
3164
3243
  onChange(newValue);
@@ -4052,6 +4131,10 @@ function AutoFieldInternal(props) {
4052
4131
  });
4053
4132
  }
4054
4133
  }, []);
4134
+ const { visible = true } = props.field;
4135
+ if (!visible) {
4136
+ return null;
4137
+ }
4055
4138
  if (field.type === "slot") {
4056
4139
  return null;
4057
4140
  }
@@ -4242,6 +4325,21 @@ var DropZoneProvider = ({
4242
4325
  var import_shallow2 = require("zustand/react/shallow");
4243
4326
  var import_sortable2 = require("@dnd-kit/react/sortable");
4244
4327
 
4328
+ // lib/accumulate-transform.ts
4329
+ init_react_import();
4330
+ function accumulateTransform(el) {
4331
+ let matrix = new DOMMatrixReadOnly();
4332
+ let n = el.parentElement;
4333
+ while (n && n !== document.documentElement) {
4334
+ const t = getComputedStyle(n).transform;
4335
+ if (t && t !== "none") {
4336
+ matrix = new DOMMatrixReadOnly(t).multiply(matrix);
4337
+ }
4338
+ n = n.parentElement;
4339
+ }
4340
+ return { scaleX: matrix.a, scaleY: matrix.d };
4341
+ }
4342
+
4245
4343
  // lib/use-context-store.ts
4246
4344
  init_react_import();
4247
4345
  var import_react24 = require("react");
@@ -4267,7 +4365,9 @@ var useOnDragFinished = (cb, deps = []) => {
4267
4365
  if (isDragging2) {
4268
4366
  cb(false);
4269
4367
  } else {
4270
- cb(true);
4368
+ setTimeout(() => {
4369
+ cb(true);
4370
+ }, 0);
4271
4371
  if (dispose) dispose();
4272
4372
  }
4273
4373
  };
@@ -4443,11 +4543,16 @@ var DraggableComponent = ({
4443
4543
  x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
4444
4544
  y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
4445
4545
  };
4546
+ const untransformed = {
4547
+ height: ref.current.offsetHeight,
4548
+ width: ref.current.offsetWidth
4549
+ };
4550
+ const transform = accumulateTransform(ref.current);
4446
4551
  const style2 = {
4447
- left: `${rect.left + scroll.x}px`,
4448
- top: `${rect.top + scroll.y}px`,
4449
- height: `${rect.height}px`,
4450
- width: `${rect.width}px`
4552
+ left: `${(rect.left + scroll.x) / transform.scaleX}px`,
4553
+ top: `${(rect.top + scroll.y) / transform.scaleY}px`,
4554
+ height: `${untransformed.height}px`,
4555
+ width: `${untransformed.width}px`
4451
4556
  };
4452
4557
  return style2;
4453
4558
  }, [ref.current]);
@@ -4456,8 +4561,7 @@ var DraggableComponent = ({
4456
4561
  setStyle(getStyle());
4457
4562
  }, [ref.current, iframe]);
4458
4563
  (0, import_react26.useEffect)(() => {
4459
- const userIsDragging = !!zoneStore.getState().draggedItem;
4460
- if (ref.current && !userIsDragging) {
4564
+ if (ref.current) {
4461
4565
  const observer = new ResizeObserver(sync);
4462
4566
  observer.observe(ref.current);
4463
4567
  return () => {
@@ -4466,11 +4570,27 @@ var DraggableComponent = ({
4466
4570
  }
4467
4571
  }, [ref.current]);
4468
4572
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4573
+ const hideOverlay = (0, import_react26.useCallback)(() => {
4574
+ setIsVisible(false);
4575
+ }, []);
4576
+ const showOverlay = (0, import_react26.useCallback)(() => {
4577
+ setIsVisible(true);
4578
+ }, []);
4469
4579
  (0, import_react26.useEffect)(() => {
4470
4580
  var _a;
4471
- registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4581
+ registerNode(id, {
4582
+ methods: { sync, showOverlay, hideOverlay },
4583
+ element: (_a = ref.current) != null ? _a : null
4584
+ });
4472
4585
  return () => {
4473
- registerNode(id, { methods: { sync: () => null }, element: null });
4586
+ registerNode(id, {
4587
+ methods: {
4588
+ sync: () => null,
4589
+ hideOverlay: () => null,
4590
+ showOverlay: () => null
4591
+ },
4592
+ element: null
4593
+ });
4474
4594
  };
4475
4595
  }, [id, zoneCompound, index, componentType, sync]);
4476
4596
  const CustomActionBar = (0, import_react26.useMemo)(
@@ -4738,6 +4858,7 @@ var import_react36 = require("@dnd-kit/react");
4738
4858
  // components/DropZone/lib/use-min-empty-height.ts
4739
4859
  init_react_import();
4740
4860
  var import_react27 = require("react");
4861
+ var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
4741
4862
  var useMinEmptyHeight = ({
4742
4863
  zoneCompound,
4743
4864
  userMinEmptyHeight,
@@ -4753,35 +4874,52 @@ var useMinEmptyHeight = ({
4753
4874
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4754
4875
  };
4755
4876
  });
4877
+ const numItems = (0, import_react27.useRef)(0);
4878
+ const onDragFinished = useOnDragFinished(
4879
+ (finished) => {
4880
+ var _a;
4881
+ if (finished) {
4882
+ const newNumItems = getNumItems(appStore, zoneCompound);
4883
+ setPrevHeight(0);
4884
+ if (newNumItems || numItems.current === 0) {
4885
+ setIsAnimating(false);
4886
+ return;
4887
+ }
4888
+ const selectedItem = appStore.getState().selectedItem;
4889
+ const zones = appStore.getState().state.indexes.zones;
4890
+ const nodes = appStore.getState().nodes;
4891
+ (_a = nodes.nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.methods.hideOverlay();
4892
+ setTimeout(() => {
4893
+ var _a2;
4894
+ const contentIds = ((_a2 = zones[zoneCompound]) == null ? void 0 : _a2.contentIds) || [];
4895
+ contentIds.forEach((contentId) => {
4896
+ const node = nodes.nodes[contentId];
4897
+ node == null ? void 0 : node.methods.sync();
4898
+ });
4899
+ if (selectedItem) {
4900
+ setTimeout(() => {
4901
+ var _a3, _b;
4902
+ (_a3 = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _a3.methods.sync();
4903
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.showOverlay();
4904
+ }, 200);
4905
+ }
4906
+ setIsAnimating(false);
4907
+ }, 100);
4908
+ }
4909
+ },
4910
+ [appStore, prevHeight, zoneCompound]
4911
+ );
4756
4912
  (0, import_react27.useEffect)(() => {
4757
4913
  if (draggedItem && ref.current) {
4758
4914
  if (isZone) {
4759
4915
  const rect = ref.current.getBoundingClientRect();
4916
+ numItems.current = getNumItems(appStore, zoneCompound);
4760
4917
  setPrevHeight(rect.height);
4761
4918
  setIsAnimating(true);
4762
- return;
4919
+ return onDragFinished();
4763
4920
  }
4764
4921
  }
4765
- const _prevHeight = prevHeight;
4766
- setPrevHeight(0);
4767
- setTimeout(() => {
4768
- var _a, _b, _c;
4769
- const newHeight = (_a = ref.current) == null ? void 0 : _a.getBoundingClientRect().height;
4770
- if (newHeight === _prevHeight) return;
4771
- const zones = appStore.getState().state.indexes.zones;
4772
- const nodes = appStore.getState().nodes;
4773
- const selectedItem = appStore.getState().selectedItem;
4774
- const contentIds = ((_b = zones[zoneCompound]) == null ? void 0 : _b.contentIds) || [];
4775
- contentIds.forEach((contentId) => {
4776
- const node = nodes.nodes[contentId];
4777
- node == null ? void 0 : node.methods.sync();
4778
- });
4779
- if (selectedItem) {
4780
- (_c = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _c.methods.sync();
4781
- }
4782
- setIsAnimating(false);
4783
- }, 400);
4784
- }, [ref.current, draggedItem, zoneCompound]);
4922
+ }, [ref.current, draggedItem, onDragFinished]);
4785
4923
  return [prevHeight || userMinEmptyHeight, isAnimating];
4786
4924
  };
4787
4925
 
@@ -4906,7 +5044,7 @@ var useDragAxis = (ref, collisionAxis) => {
4906
5044
  };
4907
5045
 
4908
5046
  // components/DropZone/index.tsx
4909
- var import_shallow3 = require("zustand/react/shallow");
5047
+ var import_shallow4 = require("zustand/react/shallow");
4910
5048
 
4911
5049
  // components/Render/index.tsx
4912
5050
  init_react_import();
@@ -4914,32 +5052,30 @@ init_react_import();
4914
5052
  // lib/use-slots.tsx
4915
5053
  init_react_import();
4916
5054
  var import_react32 = require("react");
4917
- function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5055
+ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
4918
5056
  const slotProps = (0, import_react32.useMemo)(() => {
4919
- if (!(config == null ? void 0 : config.fields)) return props;
4920
- const slotProps2 = {};
4921
- const fieldKeys = Object.keys(config.fields);
4922
- for (let i = 0; i < fieldKeys.length; i++) {
4923
- const fieldKey = fieldKeys[i];
4924
- const field = config.fields[fieldKey];
4925
- if ((field == null ? void 0 : field.type) === "slot") {
4926
- const content = props[fieldKey] || [];
4927
- const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
5057
+ const mapped = mapSlots(
5058
+ item,
5059
+ (content, _parentId, propName, field, propPath) => {
5060
+ const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
5061
+ const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
5062
+ const render = isReadOnly ? renderSlotRender : renderSlotEdit;
4928
5063
  const Slot = (dzProps) => render(__spreadProps(__spreadValues({
4929
- allow: field.allow,
4930
- disallow: field.disallow
5064
+ allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
5065
+ disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
4931
5066
  }, dzProps), {
4932
- zone: fieldKey,
5067
+ zone: propName,
4933
5068
  content
4934
5069
  }));
4935
- slotProps2[fieldKey] = Slot;
4936
- }
4937
- }
4938
- return slotProps2;
4939
- }, [config, readOnly, forceReadOnly]);
5070
+ return Slot;
5071
+ },
5072
+ config
5073
+ ).props;
5074
+ return mapped;
5075
+ }, [config, item, readOnly, forceReadOnly]);
4940
5076
  const mergedProps = (0, import_react32.useMemo)(
4941
- () => __spreadValues(__spreadValues({}, props), slotProps),
4942
- [props, slotProps]
5077
+ () => __spreadValues(__spreadValues({}, item.props), slotProps),
5078
+ [item.props, slotProps]
4943
5079
  );
4944
5080
  return mergedProps;
4945
5081
  }
@@ -4949,6 +5085,7 @@ var import_react34 = __toESM(require("react"));
4949
5085
 
4950
5086
  // components/SlotRender/index.tsx
4951
5087
  init_react_import();
5088
+ var import_shallow3 = require("zustand/react/shallow");
4952
5089
 
4953
5090
  // components/SlotRender/server.tsx
4954
5091
  init_react_import();
@@ -4987,12 +5124,15 @@ function DropZoneRender({
4987
5124
  metadata
4988
5125
  }
4989
5126
  ),
4990
- metadata
5127
+ metadata,
5128
+ dragRef: null,
5129
+ isEditing: false
4991
5130
  }
4992
5131
  });
4993
- const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
5132
+ const renderItem = __spreadProps(__spreadValues({}, item), { props });
5133
+ const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
4994
5134
  if (Component) {
4995
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
5135
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
4996
5136
  }
4997
5137
  return null;
4998
5138
  }) });
@@ -5007,7 +5147,7 @@ var Item = ({
5007
5147
  metadata
5008
5148
  }) => {
5009
5149
  const Component = config.components[item.type];
5010
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5150
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5011
5151
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5012
5152
  Component.render,
5013
5153
  __spreadProps(__spreadValues({}, props), {
@@ -5046,10 +5186,12 @@ var ContextSlotRender = ({
5046
5186
  const config = useAppStore((s) => s.config);
5047
5187
  const metadata = useAppStore((s) => s.metadata);
5048
5188
  const slotContent = useAppStore(
5049
- (s) => {
5189
+ (0, import_shallow3.useShallow)((s) => {
5050
5190
  var _a, _b;
5051
- return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
5052
- }
5191
+ const indexes = s.state.indexes;
5192
+ const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
5193
+ return contentIds.map((contentId) => indexes.nodes[contentId].flatData);
5194
+ })
5053
5195
  );
5054
5196
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5055
5197
  SlotRenderPure,
@@ -5079,7 +5221,7 @@ function Render({
5079
5221
  root: data.root || {},
5080
5222
  content: data.content || []
5081
5223
  });
5082
- const rootProps = defaultedData.root.props || defaultedData.root;
5224
+ const rootProps = "props" in defaultedData.root ? defaultedData.root.props : defaultedData.root;
5083
5225
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
5084
5226
  const pageProps = __spreadProps(__spreadValues({}, rootProps), {
5085
5227
  puck: {
@@ -5092,7 +5234,11 @@ function Render({
5092
5234
  editMode: false,
5093
5235
  id: "puck-root"
5094
5236
  });
5095
- const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
5237
+ const propsWithSlots = useSlots(
5238
+ config,
5239
+ { type: "root", props: pageProps },
5240
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
5241
+ );
5096
5242
  const nextContextValue = (0, import_react34.useMemo)(
5097
5243
  () => ({
5098
5244
  mode: "render",
@@ -5126,7 +5272,7 @@ var DropZoneChild = ({
5126
5272
  const { depth = 1 } = ctx != null ? ctx : {};
5127
5273
  const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5128
5274
  const nodeProps = useAppStore(
5129
- (0, import_shallow3.useShallow)((s) => {
5275
+ (0, import_shallow4.useShallow)((s) => {
5130
5276
  var _a2;
5131
5277
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
5132
5278
  })
@@ -5138,14 +5284,19 @@ var DropZoneChild = ({
5138
5284
  }
5139
5285
  );
5140
5286
  const nodeReadOnly = useAppStore(
5141
- (0, import_shallow3.useShallow)((s) => {
5287
+ (0, import_shallow4.useShallow)((s) => {
5142
5288
  var _a2;
5143
5289
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
5144
5290
  })
5145
5291
  );
5292
+ const appStore = useAppStoreApi();
5146
5293
  const item = (0, import_react35.useMemo)(() => {
5147
5294
  if (nodeProps) {
5148
- return { type: nodeType, props: nodeProps };
5295
+ const expanded = expandNode({
5296
+ type: nodeType,
5297
+ props: nodeProps
5298
+ });
5299
+ return expanded;
5149
5300
  }
5150
5301
  const preview = zoneStore.getState().previewIndex[zoneCompound];
5151
5302
  if (componentId === (preview == null ? void 0 : preview.props.id)) {
@@ -5156,7 +5307,7 @@ var DropZoneChild = ({
5156
5307
  };
5157
5308
  }
5158
5309
  return null;
5159
- }, [componentId, zoneCompound, nodeType, nodeProps]);
5310
+ }, [appStore, componentId, zoneCompound, nodeType, nodeProps]);
5160
5311
  const componentConfig = useAppStore(
5161
5312
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5162
5313
  );
@@ -5197,9 +5348,17 @@ var DropZoneChild = ({
5197
5348
  }),
5198
5349
  [componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
5199
5350
  );
5351
+ const defaultedNode = (0, import_react35.useMemo)(
5352
+ () => {
5353
+ var _a2;
5354
+ return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
5355
+ },
5356
+ [item == null ? void 0 : item.type, nodeType, defaultsProps]
5357
+ );
5358
+ const config = useAppStore((s) => s.config);
5200
5359
  const defaultedPropsWithSlots = useSlots(
5201
- componentConfig,
5202
- defaultsProps,
5360
+ config,
5361
+ defaultedNode,
5203
5362
  DropZoneEditPure,
5204
5363
  (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
5205
5364
  nodeReadOnly,
@@ -5211,7 +5370,7 @@ var DropZoneChild = ({
5211
5370
  item.type
5212
5371
  ] });
5213
5372
  let componentType = item.type;
5214
- const isInserting = item.previewType === "insert";
5373
+ const isInserting = "previewType" in item ? item.previewType === "insert" : false;
5215
5374
  if (isInserting) {
5216
5375
  Render2 = renderPreview;
5217
5376
  }
@@ -5260,7 +5419,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5260
5419
  unregisterLocalZone
5261
5420
  } = ctx != null ? ctx : {};
5262
5421
  const path = useAppStore(
5263
- (0, import_shallow3.useShallow)((s) => {
5422
+ (0, import_shallow4.useShallow)((s) => {
5264
5423
  var _a;
5265
5424
  return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
5266
5425
  })
@@ -5277,13 +5436,13 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5277
5436
  (s) => s.nextAreaDepthIndex[areaId || ""]
5278
5437
  );
5279
5438
  const zoneContentIds = useAppStore(
5280
- (0, import_shallow3.useShallow)((s) => {
5439
+ (0, import_shallow4.useShallow)((s) => {
5281
5440
  var _a;
5282
5441
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
5283
5442
  })
5284
5443
  );
5285
5444
  const zoneType = useAppStore(
5286
- (0, import_shallow3.useShallow)((s) => {
5445
+ (0, import_shallow4.useShallow)((s) => {
5287
5446
  var _a;
5288
5447
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
5289
5448
  })
@@ -5440,7 +5599,7 @@ var DropZoneRenderItem = ({
5440
5599
  metadata
5441
5600
  }) => {
5442
5601
  const Component = config.components[item.type];
5443
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5602
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5444
5603
  const nextContextValue = (0, import_react35.useMemo)(
5445
5604
  () => ({
5446
5605
  areaId: props.id,
@@ -6376,7 +6535,7 @@ Drawer.Item = DrawerItem;
6376
6535
 
6377
6536
  // components/Puck/index.tsx
6378
6537
  init_react_import();
6379
- var import_react55 = require("react");
6538
+ var import_react56 = require("react");
6380
6539
 
6381
6540
  // components/SidebarSection/index.tsx
6382
6541
  init_react_import();
@@ -6471,70 +6630,26 @@ var SidebarSection = ({
6471
6630
  );
6472
6631
  };
6473
6632
 
6474
- // components/MenuBar/index.tsx
6475
- init_react_import();
6476
-
6477
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
6478
- init_react_import();
6479
- 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" };
6480
-
6481
- // components/MenuBar/index.tsx
6482
- var import_jsx_runtime29 = require("react/jsx-runtime");
6483
- var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
6484
- function MenuBar({
6485
- menuOpen = false,
6486
- renderHeaderActions,
6487
- setMenuOpen
6488
- }) {
6489
- const back = useAppStore((s) => s.history.back);
6490
- const forward = useAppStore((s) => s.history.forward);
6491
- const hasFuture = useAppStore((s) => s.history.hasFuture());
6492
- const hasPast = useAppStore((s) => s.history.hasPast());
6493
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6494
- "div",
6495
- {
6496
- className: getClassName20({ menuOpen }),
6497
- onClick: (event) => {
6498
- var _a;
6499
- const element = event.target;
6500
- if (window.matchMedia("(min-width: 638px)").matches) {
6501
- return;
6502
- }
6503
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
6504
- setMenuOpen(false);
6505
- }
6506
- },
6507
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("inner"), children: [
6508
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("history"), children: [
6509
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Undo2, { size: 21 }) }),
6510
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Redo2, { size: 21 }) })
6511
- ] }),
6512
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: renderHeaderActions && renderHeaderActions() })
6513
- ] })
6514
- }
6515
- );
6516
- }
6517
-
6518
6633
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6519
6634
  init_react_import();
6520
- var styles_module_default15 = { "Puck": "_Puck_11o75_19", "Puck-portal": "_Puck-portal_11o75_24", "PuckLayout-inner": "_PuckLayout-inner_11o75_31", "PuckLayout--mounted": "_PuckLayout--mounted_11o75_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_11o75_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_11o75_53", "PuckLayout-mounted": "_PuckLayout-mounted_11o75_67", "PuckLayout": "_PuckLayout_11o75_31", "PuckLayout-header": "_PuckLayout-header_11o75_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_11o75_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_11o75_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_11o75_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_11o75_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_11o75_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_11o75_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_11o75_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_11o75_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_11o75_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_11o75_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_11o75_134" };
6635
+ var styles_module_default14 = { "Puck": "_Puck_mc1k2_19", "Puck-portal": "_Puck-portal_mc1k2_24", "PuckLayout-inner": "_PuckLayout-inner_mc1k2_31", "PuckLayout--mounted": "_PuckLayout--mounted_mc1k2_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_mc1k2_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_mc1k2_53", "PuckLayout-mounted": "_PuckLayout-mounted_mc1k2_67", "PuckLayout": "_PuckLayout_mc1k2_31", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_mc1k2_108", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_mc1k2_117" };
6521
6636
 
6522
6637
  // components/Puck/components/Fields/index.tsx
6523
6638
  init_react_import();
6524
6639
 
6525
6640
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
6526
6641
  init_react_import();
6527
- var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
6642
+ var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
6528
6643
 
6529
6644
  // components/Puck/components/Fields/index.tsx
6530
6645
  var import_react42 = require("react");
6531
- var import_shallow4 = require("zustand/react/shallow");
6532
- var import_jsx_runtime30 = require("react/jsx-runtime");
6533
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
6646
+ var import_shallow5 = require("zustand/react/shallow");
6647
+ var import_jsx_runtime29 = require("react/jsx-runtime");
6648
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
6534
6649
  var DefaultFields = ({
6535
6650
  children
6536
6651
  }) => {
6537
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
6652
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
6538
6653
  };
6539
6654
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6540
6655
  let currentProps;
@@ -6594,7 +6709,7 @@ var FieldsChild = ({ fieldName }) => {
6594
6709
  return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
6595
6710
  });
6596
6711
  const permissions = useAppStore(
6597
- (0, import_shallow4.useShallow)((s) => {
6712
+ (0, import_shallow5.useShallow)((s) => {
6598
6713
  const { selectedItem, permissions: permissions2 } = s;
6599
6714
  return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
6600
6715
  })
@@ -6603,9 +6718,10 @@ var FieldsChild = ({ fieldName }) => {
6603
6718
  const onChange = (0, import_react42.useCallback)(createOnChange(fieldName, appStore), [
6604
6719
  fieldName
6605
6720
  ]);
6606
- if (!field || !id) return null;
6721
+ const { visible = true } = field != null ? field : {};
6722
+ if (!field || !id || !visible) return null;
6607
6723
  if (field.type === "slot") return null;
6608
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6724
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("field"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6609
6725
  AutoFieldPrivate,
6610
6726
  {
6611
6727
  field,
@@ -6617,14 +6733,15 @@ var FieldsChild = ({ fieldName }) => {
6617
6733
  }
6618
6734
  ) }, id);
6619
6735
  };
6620
- var Fields = ({ wrapFields = true }) => {
6736
+ var FieldsChildMemo = (0, import_react42.memo)(FieldsChild);
6737
+ var FieldsInternal = ({ wrapFields = true }) => {
6621
6738
  const overrides = useAppStore((s) => s.overrides);
6622
6739
  const componentResolving = useAppStore((s) => {
6623
6740
  var _a, _b;
6624
6741
  const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
6625
6742
  return (loadingCount != null ? loadingCount : 0) > 0;
6626
6743
  });
6627
- const itemSelector = useAppStore((0, import_shallow4.useShallow)((s) => s.state.ui.itemSelector));
6744
+ const itemSelector = useAppStore((0, import_shallow5.useShallow)((s) => s.state.ui.itemSelector));
6628
6745
  const id = useAppStore((s) => {
6629
6746
  var _a;
6630
6747
  return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
@@ -6633,7 +6750,7 @@ var Fields = ({ wrapFields = true }) => {
6633
6750
  useRegisterFieldsSlice(appStore, id);
6634
6751
  const fieldsLoading = useAppStore((s) => s.fields.loading);
6635
6752
  const fieldNames = useAppStore(
6636
- (0, import_shallow4.useShallow)((s) => {
6753
+ (0, import_shallow5.useShallow)((s) => {
6637
6754
  if (s.fields.id === id) {
6638
6755
  return Object.keys(s.fields.fields);
6639
6756
  }
@@ -6642,20 +6759,21 @@ var Fields = ({ wrapFields = true }) => {
6642
6759
  );
6643
6760
  const isLoading = fieldsLoading || componentResolving;
6644
6761
  const Wrapper = (0, import_react42.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6645
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6762
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6646
6763
  "form",
6647
6764
  {
6648
- className: getClassName21({ wrapFields }),
6765
+ className: getClassName20({ wrapFields }),
6649
6766
  onSubmit: (e) => {
6650
6767
  e.preventDefault();
6651
6768
  },
6652
6769
  children: [
6653
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChild, { fieldName }, fieldName)) }),
6654
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 16 }) }) })
6770
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
6771
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) }) })
6655
6772
  ]
6656
6773
  }
6657
6774
  );
6658
6775
  };
6776
+ var Fields = (0, import_react42.memo)(FieldsInternal);
6659
6777
 
6660
6778
  // components/Puck/components/Components/index.tsx
6661
6779
  init_react_import();
@@ -6669,11 +6787,11 @@ init_react_import();
6669
6787
 
6670
6788
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6671
6789
  init_react_import();
6672
- var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
6790
+ var styles_module_default16 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
6673
6791
 
6674
6792
  // components/ComponentList/index.tsx
6675
- var import_jsx_runtime31 = require("react/jsx-runtime");
6676
- var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
6793
+ var import_jsx_runtime30 = require("react/jsx-runtime");
6794
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6677
6795
  var ComponentListItem = ({
6678
6796
  name,
6679
6797
  label
@@ -6684,7 +6802,7 @@ var ComponentListItem = ({
6684
6802
  type: name
6685
6803
  }).insert
6686
6804
  );
6687
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6805
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6688
6806
  };
6689
6807
  var ComponentList = ({
6690
6808
  children,
@@ -6695,12 +6813,12 @@ var ComponentList = ({
6695
6813
  const setUi = useAppStore((s) => s.setUi);
6696
6814
  const componentList = useAppStore((s) => s.state.ui.componentList);
6697
6815
  const { expanded = true } = componentList[id] || {};
6698
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
6699
- title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
6816
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName21({ isExpanded: expanded }), children: [
6817
+ title && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6700
6818
  "button",
6701
6819
  {
6702
6820
  type: "button",
6703
- className: getClassName22("title"),
6821
+ className: getClassName21("title"),
6704
6822
  onClick: () => setUi({
6705
6823
  componentList: __spreadProps(__spreadValues({}, componentList), {
6706
6824
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6710,14 +6828,14 @@ var ComponentList = ({
6710
6828
  }),
6711
6829
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6712
6830
  children: [
6713
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
6714
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: 12 }) })
6831
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { children: title }),
6832
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronDown, { size: 12 }) })
6715
6833
  ]
6716
6834
  }
6717
6835
  ),
6718
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6836
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("content"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6719
6837
  var _a;
6720
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6838
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6721
6839
  ComponentListItem,
6722
6840
  {
6723
6841
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6731,7 +6849,7 @@ var ComponentList = ({
6731
6849
  ComponentList.Item = ComponentListItem;
6732
6850
 
6733
6851
  // lib/use-component-list.tsx
6734
- var import_jsx_runtime32 = require("react/jsx-runtime");
6852
+ var import_jsx_runtime31 = require("react/jsx-runtime");
6735
6853
  var useComponentList = () => {
6736
6854
  const [componentList, setComponentList] = (0, import_react43.useState)();
6737
6855
  const config = useAppStore((s) => s.config);
@@ -6746,7 +6864,7 @@ var useComponentList = () => {
6746
6864
  if (category.visible === false || !category.components) {
6747
6865
  return null;
6748
6866
  }
6749
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6867
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6750
6868
  ComponentList,
6751
6869
  {
6752
6870
  id: categoryKey,
@@ -6755,7 +6873,7 @@ var useComponentList = () => {
6755
6873
  var _a2;
6756
6874
  matchedComponents.push(componentName);
6757
6875
  const componentConf = config.components[componentName] || {};
6758
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6876
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6759
6877
  ComponentList.Item,
6760
6878
  {
6761
6879
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6775,7 +6893,7 @@ var useComponentList = () => {
6775
6893
  );
6776
6894
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6777
6895
  _componentList.push(
6778
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6896
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6779
6897
  ComponentList,
6780
6898
  {
6781
6899
  id: "other",
@@ -6783,7 +6901,7 @@ var useComponentList = () => {
6783
6901
  children: remainingComponents.map((componentName, i) => {
6784
6902
  var _a2;
6785
6903
  const componentConf = config.components[componentName] || {};
6786
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6904
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6787
6905
  ComponentList.Item,
6788
6906
  {
6789
6907
  name: componentName,
@@ -6806,12 +6924,12 @@ var useComponentList = () => {
6806
6924
 
6807
6925
  // components/Puck/components/Components/index.tsx
6808
6926
  var import_react44 = require("react");
6809
- var import_jsx_runtime33 = require("react/jsx-runtime");
6927
+ var import_jsx_runtime32 = require("react/jsx-runtime");
6810
6928
  var Components = () => {
6811
6929
  const overrides = useAppStore((s) => s.overrides);
6812
6930
  const componentList = useComponentList();
6813
6931
  const Wrapper = (0, import_react44.useMemo)(() => overrides.components || "div", [overrides]);
6814
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
6932
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
6815
6933
  };
6816
6934
 
6817
6935
  // components/Puck/components/Preview/index.tsx
@@ -6823,7 +6941,7 @@ init_react_import();
6823
6941
  var import_react45 = require("react");
6824
6942
  var import_object_hash = __toESM(require("object-hash"));
6825
6943
  var import_react_dom3 = require("react-dom");
6826
- var import_jsx_runtime34 = require("react/jsx-runtime");
6944
+ var import_jsx_runtime33 = require("react/jsx-runtime");
6827
6945
  var styleSelector = 'style, link[rel="stylesheet"]';
6828
6946
  var collectStyles = (doc) => {
6829
6947
  const collected = [];
@@ -7023,7 +7141,7 @@ var CopyHostStyles = ({
7023
7141
  observer.disconnect();
7024
7142
  };
7025
7143
  }, []);
7026
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
7144
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
7027
7145
  };
7028
7146
  var autoFrameContext = (0, import_react45.createContext)({});
7029
7147
  var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
@@ -7070,7 +7188,7 @@ function AutoFrame(_a) {
7070
7188
  }
7071
7189
  }
7072
7190
  }, [frameRef, loaded, stylesLoaded]);
7073
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7191
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7074
7192
  "iframe",
7075
7193
  __spreadProps(__spreadValues({}, props), {
7076
7194
  className,
@@ -7080,7 +7198,7 @@ function AutoFrame(_a) {
7080
7198
  onLoad: () => {
7081
7199
  setLoaded(true);
7082
7200
  },
7083
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7201
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7084
7202
  CopyHostStyles,
7085
7203
  {
7086
7204
  debug,
@@ -7096,11 +7214,11 @@ var AutoFrame_default = AutoFrame;
7096
7214
 
7097
7215
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
7098
7216
  init_react_import();
7099
- var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7217
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7100
7218
 
7101
7219
  // components/Puck/components/Preview/index.tsx
7102
- var import_jsx_runtime35 = require("react/jsx-runtime");
7103
- var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
7220
+ var import_jsx_runtime34 = require("react/jsx-runtime");
7221
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
7104
7222
  var useBubbleIframeEvents = (ref) => {
7105
7223
  const status = useAppStore((s) => s.status);
7106
7224
  (0, import_react46.useEffect)(() => {
@@ -7155,19 +7273,22 @@ var Preview2 = ({ id = "puck-preview" }) => {
7155
7273
  const Page = (0, import_react46.useCallback)(
7156
7274
  (pageProps) => {
7157
7275
  var _a, _b;
7158
- const rootConfig = config.root;
7159
- const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
7276
+ const propsWithSlots = useSlots(
7277
+ config,
7278
+ { type: "root", props: pageProps },
7279
+ DropZoneEditPure
7280
+ );
7160
7281
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7161
7282
  id: "puck-root"
7162
- }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
7283
+ }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: propsWithSlots.children });
7163
7284
  },
7164
- [config.root]
7285
+ [config]
7165
7286
  );
7166
7287
  const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
7167
7288
  const rootProps = root.props || root;
7168
7289
  const ref = (0, import_react46.useRef)(null);
7169
7290
  useBubbleIframeEvents(ref);
7170
- const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7291
+ const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7171
7292
  Page,
7172
7293
  __spreadProps(__spreadValues({}, rootProps), {
7173
7294
  puck: {
@@ -7177,28 +7298,28 @@ var Preview2 = ({ id = "puck-preview" }) => {
7177
7298
  metadata
7178
7299
  },
7179
7300
  editMode: true,
7180
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
7301
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7181
7302
  })
7182
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
7303
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config });
7183
7304
  (0, import_react46.useEffect)(() => {
7184
7305
  if (!iframe.enabled) {
7185
7306
  setStatus("READY");
7186
7307
  }
7187
7308
  }, [iframe.enabled]);
7188
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7309
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7189
7310
  "div",
7190
7311
  {
7191
- className: getClassName23(),
7312
+ className: getClassName22(),
7192
7313
  id,
7193
7314
  "data-puck-preview": true,
7194
7315
  onClick: () => {
7195
7316
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7196
7317
  },
7197
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7318
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7198
7319
  AutoFrame_default,
7199
7320
  {
7200
7321
  id: "preview-frame",
7201
- className: getClassName23("frame"),
7322
+ className: getClassName22("frame"),
7202
7323
  "data-rfd-iframe": true,
7203
7324
  onReady: () => {
7204
7325
  setStatus("READY");
@@ -7207,18 +7328,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
7207
7328
  setStatus("MOUNTED");
7208
7329
  },
7209
7330
  frameRef: ref,
7210
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7331
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7211
7332
  if (Frame) {
7212
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
7333
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Frame, { document: document2, children: inner });
7213
7334
  }
7214
7335
  return inner;
7215
7336
  } })
7216
7337
  }
7217
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7338
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7218
7339
  "div",
7219
7340
  {
7220
7341
  id: "preview-frame",
7221
- className: getClassName23("frame"),
7342
+ className: getClassName22("frame"),
7222
7343
  ref,
7223
7344
  "data-puck-entry": true,
7224
7345
  children: inner
@@ -7236,7 +7357,7 @@ init_react_import();
7236
7357
 
7237
7358
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
7238
7359
  init_react_import();
7239
- var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7360
+ var styles_module_default18 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7240
7361
 
7241
7362
  // lib/scroll-into-view.ts
7242
7363
  init_react_import();
@@ -7272,10 +7393,10 @@ var onScrollEnd = (frame, cb) => {
7272
7393
  };
7273
7394
 
7274
7395
  // components/LayerTree/index.tsx
7275
- var import_shallow5 = require("zustand/react/shallow");
7276
- var import_jsx_runtime36 = require("react/jsx-runtime");
7277
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7278
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
7396
+ var import_shallow6 = require("zustand/react/shallow");
7397
+ var import_jsx_runtime35 = require("react/jsx-runtime");
7398
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
7399
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
7279
7400
  var Layer = ({
7280
7401
  index,
7281
7402
  itemId,
@@ -7299,7 +7420,7 @@ var Layer = ({
7299
7420
  const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
7300
7421
  const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
7301
7422
  const zonesForItem = useAppStore(
7302
- (0, import_shallow5.useShallow)(
7423
+ (0, import_shallow6.useShallow)(
7303
7424
  (s) => Object.keys(s.state.indexes.zones).filter(
7304
7425
  (z) => z.split(":")[0] === itemId
7305
7426
  )
@@ -7321,7 +7442,7 @@ var Layer = ({
7321
7442
  });
7322
7443
  const componentConfig = config.components[nodeData.data.type];
7323
7444
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7324
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7445
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7325
7446
  "li",
7326
7447
  {
7327
7448
  className: getClassNameLayer({
@@ -7331,7 +7452,7 @@ var Layer = ({
7331
7452
  childIsSelected
7332
7453
  }),
7333
7454
  children: [
7334
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7455
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7335
7456
  "button",
7336
7457
  {
7337
7458
  type: "button",
@@ -7346,7 +7467,10 @@ var Layer = ({
7346
7467
  `[data-puck-component="${itemId}"]`
7347
7468
  );
7348
7469
  if (!el) {
7349
- console.error("Scroll failed. No element was found for", itemId);
7470
+ setItemSelector({
7471
+ index,
7472
+ zone: zoneCompound
7473
+ });
7350
7474
  return;
7351
7475
  }
7352
7476
  scrollIntoView(el);
@@ -7366,22 +7490,22 @@ var Layer = ({
7366
7490
  zoneStore.setState({ hoveringComponent: null });
7367
7491
  },
7368
7492
  children: [
7369
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7493
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7370
7494
  "div",
7371
7495
  {
7372
7496
  className: getClassNameLayer("chevron"),
7373
7497
  title: isSelected ? "Collapse" : "Expand",
7374
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
7498
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { size: "12" })
7375
7499
  }
7376
7500
  ),
7377
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
7378
- /* @__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" }) }),
7379
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
7501
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassNameLayer("title"), children: [
7502
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayoutGrid, { size: "16" }) }),
7503
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("name"), children: label })
7380
7504
  ] })
7381
7505
  ]
7382
7506
  }
7383
7507
  ) }),
7384
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7508
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7385
7509
  ]
7386
7510
  }
7387
7511
  );
@@ -7392,22 +7516,22 @@ var LayerTree = ({
7392
7516
  }) => {
7393
7517
  const label = _label != null ? _label : zoneCompound.split(":")[1];
7394
7518
  const contentIds = useAppStore(
7395
- (0, import_shallow5.useShallow)(
7519
+ (0, import_shallow6.useShallow)(
7396
7520
  (s) => {
7397
7521
  var _a, _b;
7398
7522
  return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
7399
7523
  }
7400
7524
  )
7401
7525
  );
7402
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
7403
- label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
7404
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
7526
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
7527
+ label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
7528
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
7405
7529
  label
7406
7530
  ] }),
7407
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
7408
- contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
7531
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
7532
+ contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
7409
7533
  contentIds.map((itemId, i) => {
7410
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7534
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7411
7535
  Layer,
7412
7536
  {
7413
7537
  index: i,
@@ -7433,15 +7557,15 @@ var findZonesForArea = (state, area) => {
7433
7557
  };
7434
7558
 
7435
7559
  // components/Puck/components/Outline/index.tsx
7436
- var import_shallow6 = require("zustand/react/shallow");
7437
- var import_jsx_runtime37 = require("react/jsx-runtime");
7560
+ var import_shallow7 = require("zustand/react/shallow");
7561
+ var import_jsx_runtime36 = require("react/jsx-runtime");
7438
7562
  var Outline = () => {
7439
7563
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7440
7564
  const rootZones = useAppStore(
7441
- (0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
7565
+ (0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
7442
7566
  );
7443
7567
  const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7444
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7568
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7445
7569
  LayerTree,
7446
7570
  {
7447
7571
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -7582,17 +7706,17 @@ var import_react49 = require("react");
7582
7706
 
7583
7707
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7584
7708
  init_react_import();
7585
- var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
7709
+ var styles_module_default19 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
7586
7710
 
7587
7711
  // components/ViewportControls/index.tsx
7588
- var import_jsx_runtime38 = require("react/jsx-runtime");
7712
+ var import_jsx_runtime37 = require("react/jsx-runtime");
7589
7713
  var icons = {
7590
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
7591
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
7592
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
7714
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Smartphone, { size: 16 }),
7715
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Tablet, { size: 16 }),
7716
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Monitor, { size: 16 })
7593
7717
  };
7594
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7595
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
7718
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7719
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7596
7720
  var ViewportButton = ({
7597
7721
  children,
7598
7722
  height = "auto",
@@ -7605,7 +7729,7 @@ var ViewportButton = ({
7605
7729
  (0, import_react49.useEffect)(() => {
7606
7730
  setIsActive(width === viewports.current.width);
7607
7731
  }, [width, viewports.current.width]);
7608
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7732
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7609
7733
  IconButton,
7610
7734
  {
7611
7735
  title,
@@ -7614,7 +7738,7 @@ var ViewportButton = ({
7614
7738
  e.stopPropagation();
7615
7739
  onClick({ width, height });
7616
7740
  },
7617
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
7741
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton("inner"), children })
7618
7742
  }
7619
7743
  ) });
7620
7744
  };
@@ -7650,8 +7774,8 @@ var ViewportControls = ({
7650
7774
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7651
7775
  [autoZoom]
7652
7776
  );
7653
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
7654
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7777
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName24(), children: [
7778
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7655
7779
  ViewportButton,
7656
7780
  {
7657
7781
  height: viewport.height,
@@ -7662,8 +7786,8 @@ var ViewportControls = ({
7662
7786
  },
7663
7787
  i
7664
7788
  )),
7665
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7666
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7789
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7790
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7667
7791
  IconButton,
7668
7792
  {
7669
7793
  title: "Zoom viewport out",
@@ -7677,10 +7801,10 @@ var ViewportControls = ({
7677
7801
  )].value
7678
7802
  );
7679
7803
  },
7680
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
7804
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomOut, { size: 16 })
7681
7805
  }
7682
7806
  ),
7683
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7807
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7684
7808
  IconButton,
7685
7809
  {
7686
7810
  title: "Zoom viewport in",
@@ -7694,19 +7818,19 @@ var ViewportControls = ({
7694
7818
  )].value
7695
7819
  );
7696
7820
  },
7697
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
7821
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomIn, { size: 16 })
7698
7822
  }
7699
7823
  ),
7700
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7701
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7824
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7825
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7702
7826
  "select",
7703
7827
  {
7704
- className: getClassName25("zoomSelect"),
7828
+ className: getClassName24("zoomSelect"),
7705
7829
  value: zoom.toString(),
7706
7830
  onChange: (e) => {
7707
7831
  onZoom(parseFloat(e.currentTarget.value));
7708
7832
  },
7709
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7833
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7710
7834
  "option",
7711
7835
  {
7712
7836
  value: option.value,
@@ -7721,7 +7845,7 @@ var ViewportControls = ({
7721
7845
 
7722
7846
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7723
7847
  init_react_import();
7724
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7848
+ var styles_module_default20 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7725
7849
 
7726
7850
  // lib/get-zoom-config.ts
7727
7851
  init_react_import();
@@ -7754,9 +7878,9 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7754
7878
  };
7755
7879
 
7756
7880
  // components/Puck/components/Canvas/index.tsx
7757
- var import_shallow7 = require("zustand/react/shallow");
7758
- var import_jsx_runtime39 = require("react/jsx-runtime");
7759
- var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
7881
+ var import_shallow8 = require("zustand/react/shallow");
7882
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7883
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7760
7884
  var ZOOM_ON_CHANGE = true;
7761
7885
  var Canvas = () => {
7762
7886
  const {
@@ -7768,7 +7892,7 @@ var Canvas = () => {
7768
7892
  status,
7769
7893
  iframe
7770
7894
  } = useAppStore(
7771
- (0, import_shallow7.useShallow)((s) => ({
7895
+ (0, import_shallow8.useShallow)((s) => ({
7772
7896
  dispatch: s.dispatch,
7773
7897
  overrides: s.overrides,
7774
7898
  setUi: s.setUi,
@@ -7779,7 +7903,7 @@ var Canvas = () => {
7779
7903
  }))
7780
7904
  );
7781
7905
  const { leftSideBarVisible, rightSideBarVisible, viewports } = useAppStore(
7782
- (0, import_shallow7.useShallow)((s) => ({
7906
+ (0, import_shallow8.useShallow)((s) => ({
7783
7907
  leftSideBarVisible: s.state.ui.leftSideBarVisible,
7784
7908
  rightSideBarVisible: s.state.ui.rightSideBarVisible,
7785
7909
  viewports: s.state.ui.viewports
@@ -7788,7 +7912,7 @@ var Canvas = () => {
7788
7912
  const frameRef = (0, import_react50.useRef)(null);
7789
7913
  const [showTransition, setShowTransition] = (0, import_react50.useState)(false);
7790
7914
  const defaultRender = (0, import_react50.useMemo)(() => {
7791
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
7915
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
7792
7916
  return PuckDefault;
7793
7917
  }, []);
7794
7918
  const CustomPreview = (0, import_react50.useMemo)(
@@ -7851,10 +7975,10 @@ var Canvas = () => {
7851
7975
  setShowLoader(true);
7852
7976
  }, 500);
7853
7977
  }, []);
7854
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
7978
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
7855
7979
  "div",
7856
7980
  {
7857
- className: getClassName26({
7981
+ className: getClassName25({
7858
7982
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7859
7983
  showLoader
7860
7984
  }),
@@ -7864,7 +7988,7 @@ var Canvas = () => {
7864
7988
  recordHistory: true
7865
7989
  }),
7866
7990
  children: [
7867
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7991
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7868
7992
  ViewportControls,
7869
7993
  {
7870
7994
  autoZoom: zoomConfig.autoZoom,
@@ -7890,11 +8014,11 @@ var Canvas = () => {
7890
8014
  }
7891
8015
  }
7892
8016
  ) }),
7893
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
7894
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8017
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
8018
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7895
8019
  "div",
7896
8020
  {
7897
- className: getClassName26("root"),
8021
+ className: getClassName25("root"),
7898
8022
  style: {
7899
8023
  width: iframe.enabled ? viewports.current.width : "100%",
7900
8024
  height: zoomConfig.rootHeight,
@@ -7912,10 +8036,10 @@ var Canvas = () => {
7912
8036
  })
7913
8037
  );
7914
8038
  },
7915
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview2, {}) })
8039
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Preview2, {}) })
7916
8040
  }
7917
8041
  ),
7918
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
8042
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { size: 24 }) })
7919
8043
  ] })
7920
8044
  ]
7921
8045
  }
@@ -7970,8 +8094,8 @@ var useLoadedOverrides = ({
7970
8094
 
7971
8095
  // components/DefaultOverride/index.tsx
7972
8096
  init_react_import();
7973
- var import_jsx_runtime40 = require("react/jsx-runtime");
7974
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
8097
+ var import_jsx_runtime39 = require("react/jsx-runtime");
8098
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
7975
8099
 
7976
8100
  // lib/use-inject-css.ts
7977
8101
  init_react_import();
@@ -8113,10 +8237,225 @@ function useGetPuck() {
8113
8237
  }
8114
8238
 
8115
8239
  // components/Puck/index.tsx
8116
- var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
8240
+ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
8241
+
8242
+ // components/Puck/components/Header/index.tsx
8243
+ init_react_import();
8244
+ var import_react55 = require("react");
8245
+
8246
+ // components/MenuBar/index.tsx
8247
+ init_react_import();
8248
+
8249
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
8250
+ init_react_import();
8251
+ var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
8252
+
8253
+ // components/MenuBar/index.tsx
8254
+ var import_jsx_runtime40 = require("react/jsx-runtime");
8255
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
8256
+ function MenuBar({
8257
+ menuOpen = false,
8258
+ renderHeaderActions,
8259
+ setMenuOpen
8260
+ }) {
8261
+ const back = useAppStore((s) => s.history.back);
8262
+ const forward = useAppStore((s) => s.history.forward);
8263
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
8264
+ const hasPast = useAppStore((s) => s.history.hasPast());
8265
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8266
+ "div",
8267
+ {
8268
+ className: getClassName26({ menuOpen }),
8269
+ onClick: (event) => {
8270
+ var _a;
8271
+ const element = event.target;
8272
+ if (window.matchMedia("(min-width: 638px)").matches) {
8273
+ return;
8274
+ }
8275
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
8276
+ setMenuOpen(false);
8277
+ }
8278
+ },
8279
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("inner"), children: [
8280
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("history"), children: [
8281
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Undo2, { size: 21 }) }),
8282
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Redo2, { size: 21 }) })
8283
+ ] }),
8284
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: renderHeaderActions && renderHeaderActions() })
8285
+ ] })
8286
+ }
8287
+ );
8288
+ }
8289
+
8290
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
8291
+ init_react_import();
8292
+ var styles_module_default22 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
8293
+
8294
+ // components/Puck/components/Header/index.tsx
8117
8295
  var import_jsx_runtime41 = require("react/jsx-runtime");
8118
- var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
8119
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
8296
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
8297
+ var HeaderInner = () => {
8298
+ const {
8299
+ onPublish,
8300
+ renderHeader,
8301
+ renderHeaderActions,
8302
+ headerTitle,
8303
+ headerPath,
8304
+ iframe: _iframe
8305
+ } = usePropsContext();
8306
+ const dispatch = useAppStore((s) => s.dispatch);
8307
+ const appStore = useAppStoreApi();
8308
+ const defaultHeaderRender = (0, import_react55.useMemo)(() => {
8309
+ if (renderHeader) {
8310
+ console.warn(
8311
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8312
+ );
8313
+ const RenderHeader = (_a) => {
8314
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8315
+ const Comp = renderHeader;
8316
+ const appState = useAppStore((s) => s.state);
8317
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8318
+ };
8319
+ return RenderHeader;
8320
+ }
8321
+ return DefaultOverride;
8322
+ }, [renderHeader]);
8323
+ const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
8324
+ if (renderHeaderActions) {
8325
+ console.warn(
8326
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8327
+ );
8328
+ const RenderHeader = (props) => {
8329
+ const Comp = renderHeaderActions;
8330
+ const appState = useAppStore((s) => s.state);
8331
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8332
+ };
8333
+ return RenderHeader;
8334
+ }
8335
+ return DefaultOverride;
8336
+ }, [renderHeader]);
8337
+ const CustomHeader = useAppStore(
8338
+ (s) => s.overrides.header || defaultHeaderRender
8339
+ );
8340
+ const CustomHeaderActions = useAppStore(
8341
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
8342
+ );
8343
+ const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
8344
+ const rootTitle = useAppStore((s) => {
8345
+ var _a, _b;
8346
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
8347
+ return (_b = rootData.props.title) != null ? _b : "";
8348
+ });
8349
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8350
+ const rightSideBarVisible = useAppStore(
8351
+ (s) => s.state.ui.rightSideBarVisible
8352
+ );
8353
+ const toggleSidebars = (0, import_react55.useCallback)(
8354
+ (sidebar) => {
8355
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8356
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8357
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8358
+ dispatch({
8359
+ type: "setUi",
8360
+ ui: __spreadValues({
8361
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
8362
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
8363
+ });
8364
+ },
8365
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
8366
+ );
8367
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8368
+ CustomHeader,
8369
+ {
8370
+ actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8371
+ Button,
8372
+ {
8373
+ onClick: () => {
8374
+ const data = appStore.getState().state.data;
8375
+ onPublish && onPublish(data);
8376
+ },
8377
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8378
+ children: "Publish"
8379
+ }
8380
+ ) }) }),
8381
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8382
+ "header",
8383
+ {
8384
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
8385
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("inner"), children: [
8386
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("toggle"), children: [
8387
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8388
+ IconButton,
8389
+ {
8390
+ onClick: () => {
8391
+ toggleSidebars("left");
8392
+ },
8393
+ title: "Toggle left sidebar",
8394
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8395
+ }
8396
+ ) }),
8397
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8398
+ IconButton,
8399
+ {
8400
+ onClick: () => {
8401
+ toggleSidebars("right");
8402
+ },
8403
+ title: "Toggle right sidebar",
8404
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8405
+ }
8406
+ ) })
8407
+ ] }),
8408
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8409
+ headerTitle || rootTitle || "Page",
8410
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8411
+ " ",
8412
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("code", { className: getClassName27("path"), children: headerPath })
8413
+ ] })
8414
+ ] }) }),
8415
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("tools"), children: [
8416
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8417
+ IconButton,
8418
+ {
8419
+ onClick: () => {
8420
+ return setMenuOpen(!menuOpen);
8421
+ },
8422
+ title: "Toggle menu bar",
8423
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8424
+ }
8425
+ ) }),
8426
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8427
+ MenuBar,
8428
+ {
8429
+ dispatch,
8430
+ onPublish,
8431
+ menuOpen,
8432
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8433
+ Button,
8434
+ {
8435
+ onClick: () => {
8436
+ const data = appStore.getState().state.data;
8437
+ onPublish && onPublish(data);
8438
+ },
8439
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8440
+ children: "Publish"
8441
+ }
8442
+ ) }),
8443
+ setMenuOpen
8444
+ }
8445
+ )
8446
+ ] })
8447
+ ] })
8448
+ }
8449
+ )
8450
+ }
8451
+ );
8452
+ };
8453
+ var Header = (0, import_react55.memo)(HeaderInner);
8454
+
8455
+ // components/Puck/index.tsx
8456
+ var import_jsx_runtime42 = require("react/jsx-runtime");
8457
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
8458
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
8120
8459
  var FieldSideBar = () => {
8121
8460
  const title = useAppStore(
8122
8461
  (s) => {
@@ -8124,13 +8463,13 @@ var FieldSideBar = () => {
8124
8463
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
8125
8464
  }
8126
8465
  );
8127
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
8466
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
8128
8467
  };
8129
- var propsContext = (0, import_react55.createContext)({});
8468
+ var propsContext = (0, import_react56.createContext)({});
8130
8469
  function PropsProvider(props) {
8131
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
8470
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
8132
8471
  }
8133
- var usePropsContext = () => (0, import_react55.useContext)(propsContext);
8472
+ var usePropsContext = () => (0, import_react56.useContext)(propsContext);
8134
8473
  function PuckProvider({ children }) {
8135
8474
  const {
8136
8475
  config,
@@ -8146,11 +8485,14 @@ function PuckProvider({ children }) {
8146
8485
  metadata,
8147
8486
  onAction
8148
8487
  } = usePropsContext();
8149
- const iframe = __spreadValues({
8150
- enabled: true,
8151
- waitForStyles: true
8152
- }, _iframe);
8153
- const [generatedAppState] = (0, import_react55.useState)(() => {
8488
+ const iframe = (0, import_react56.useMemo)(
8489
+ () => __spreadValues({
8490
+ enabled: true,
8491
+ waitForStyles: true
8492
+ }, _iframe),
8493
+ [_iframe]
8494
+ );
8495
+ const [generatedAppState] = (0, import_react56.useState)(() => {
8154
8496
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8155
8497
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8156
8498
  let clientUiState = {};
@@ -8210,7 +8552,7 @@ function PuckProvider({ children }) {
8210
8552
  return walkAppState(newAppState, config);
8211
8553
  });
8212
8554
  const { appendData = true } = _initialHistory || {};
8213
- const [blendedHistories] = (0, import_react55.useState)(
8555
+ const [blendedHistories] = (0, import_react56.useState)(
8214
8556
  [
8215
8557
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8216
8558
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8230,7 +8572,7 @@ function PuckProvider({ children }) {
8230
8572
  overrides,
8231
8573
  plugins
8232
8574
  });
8233
- const generateAppStore = (0, import_react55.useCallback)(
8575
+ const generateAppStore = (0, import_react56.useCallback)(
8234
8576
  (state) => {
8235
8577
  return {
8236
8578
  state,
@@ -8254,10 +8596,15 @@ function PuckProvider({ children }) {
8254
8596
  metadata
8255
8597
  ]
8256
8598
  );
8257
- const [appStore] = (0, import_react55.useState)(
8599
+ const [appStore] = (0, import_react56.useState)(
8258
8600
  () => createAppStore(generateAppStore(initialAppState))
8259
8601
  );
8260
- (0, import_react55.useEffect)(() => {
8602
+ (0, import_react56.useEffect)(() => {
8603
+ if (process.env.NODE_ENV !== "production") {
8604
+ window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
8605
+ }
8606
+ }, [appStore]);
8607
+ (0, import_react56.useEffect)(() => {
8261
8608
  const state = appStore.getState().state;
8262
8609
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8263
8610
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8266,13 +8613,13 @@ function PuckProvider({ children }) {
8266
8613
  index: initialHistoryIndex,
8267
8614
  initialAppState
8268
8615
  });
8269
- const previousData = (0, import_react55.useRef)(null);
8270
- (0, import_react55.useEffect)(() => {
8616
+ const previousData = (0, import_react56.useRef)(null);
8617
+ (0, import_react56.useEffect)(() => {
8271
8618
  appStore.subscribe(
8272
8619
  (s) => s.state.data,
8273
8620
  (data) => {
8274
8621
  if (onChange) {
8275
- if ((0, import_fast_deep_equal2.default)(data, previousData.current)) return;
8622
+ if ((0, import_fast_deep_equal3.default)(data, previousData.current)) return;
8276
8623
  onChange(data);
8277
8624
  previousData.current = data;
8278
8625
  }
@@ -8281,53 +8628,32 @@ function PuckProvider({ children }) {
8281
8628
  }, []);
8282
8629
  useRegisterPermissionsSlice(appStore, permissions);
8283
8630
  const uPuckStore = useRegisterUsePuckStore(appStore);
8284
- (0, import_react55.useEffect)(() => {
8631
+ (0, import_react56.useEffect)(() => {
8285
8632
  const { resolveAndCommitData } = appStore.getState();
8286
8633
  resolveAndCommitData();
8287
8634
  }, []);
8288
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8635
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8289
8636
  }
8290
8637
  function PuckLayout({ children }) {
8291
8638
  const {
8292
- onPublish,
8293
- renderHeader,
8294
- renderHeaderActions,
8295
- headerTitle,
8296
- headerPath,
8297
8639
  iframe: _iframe,
8298
8640
  dnd,
8299
8641
  initialHistory: _initialHistory
8300
8642
  } = usePropsContext();
8301
- const iframe = __spreadValues({
8302
- enabled: true,
8303
- waitForStyles: true
8304
- }, _iframe);
8643
+ const iframe = (0, import_react56.useMemo)(
8644
+ () => __spreadValues({
8645
+ enabled: true,
8646
+ waitForStyles: true
8647
+ }, _iframe),
8648
+ [_iframe]
8649
+ );
8305
8650
  useInjectGlobalCss(iframe.enabled);
8306
8651
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8307
8652
  const rightSideBarVisible = useAppStore(
8308
8653
  (s) => s.state.ui.rightSideBarVisible
8309
8654
  );
8310
- const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
8311
- const appStore = useAppStoreApi();
8312
- const rootProps = useAppStore(
8313
- (s) => s.state.data.root.props || s.state.data.root.props
8314
- );
8315
8655
  const dispatch = useAppStore((s) => s.dispatch);
8316
- const toggleSidebars = (0, import_react55.useCallback)(
8317
- (sidebar) => {
8318
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8319
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8320
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8321
- dispatch({
8322
- type: "setUi",
8323
- ui: __spreadValues({
8324
- [`${sidebar}SideBarVisible`]: !sideBarVisible
8325
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
8326
- });
8327
- },
8328
- [dispatch, leftSideBarVisible, rightSideBarVisible]
8329
- );
8330
- (0, import_react55.useEffect)(() => {
8656
+ (0, import_react56.useEffect)(() => {
8331
8657
  if (!window.matchMedia("(min-width: 638px)").matches) {
8332
8658
  dispatch({
8333
8659
  type: "setUi",
@@ -8350,55 +8676,18 @@ function PuckLayout({ children }) {
8350
8676
  window.removeEventListener("resize", handleResize);
8351
8677
  };
8352
8678
  }, []);
8353
- const defaultHeaderRender = (0, import_react55.useMemo)(() => {
8354
- if (renderHeader) {
8355
- console.warn(
8356
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8357
- );
8358
- const RenderHeader = (_a) => {
8359
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8360
- const Comp = renderHeader;
8361
- const appState = useAppStore((s) => s.state);
8362
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8363
- };
8364
- return RenderHeader;
8365
- }
8366
- return DefaultOverride;
8367
- }, [renderHeader]);
8368
- const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
8369
- if (renderHeaderActions) {
8370
- console.warn(
8371
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8372
- );
8373
- const RenderHeader = (props) => {
8374
- const Comp = renderHeaderActions;
8375
- const appState = useAppStore((s) => s.state);
8376
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8377
- };
8378
- return RenderHeader;
8379
- }
8380
- return DefaultOverride;
8381
- }, [renderHeader]);
8382
8679
  const overrides = useAppStore((s) => s.overrides);
8383
- const CustomPuck = (0, import_react55.useMemo)(
8680
+ const CustomPuck = (0, import_react56.useMemo)(
8384
8681
  () => overrides.puck || DefaultOverride,
8385
8682
  [overrides]
8386
8683
  );
8387
- const CustomHeader = (0, import_react55.useMemo)(
8388
- () => overrides.header || defaultHeaderRender,
8389
- [overrides]
8390
- );
8391
- const CustomHeaderActions = (0, import_react55.useMemo)(
8392
- () => overrides.headerActions || defaultHeaderActionsRender,
8393
- [overrides]
8394
- );
8395
- const [mounted, setMounted] = (0, import_react55.useState)(false);
8396
- (0, import_react55.useEffect)(() => {
8684
+ const [mounted, setMounted] = (0, import_react56.useState)(false);
8685
+ (0, import_react56.useEffect)(() => {
8397
8686
  setMounted(true);
8398
8687
  }, []);
8399
8688
  const ready = useAppStore((s) => s.status === "READY");
8400
8689
  useMonitorHotkeys();
8401
- (0, import_react55.useEffect)(() => {
8690
+ (0, import_react56.useEffect)(() => {
8402
8691
  if (ready && iframe.enabled) {
8403
8692
  const frameDoc = getFrame();
8404
8693
  if (frameDoc) {
@@ -8407,128 +8696,31 @@ function PuckLayout({ children }) {
8407
8696
  }
8408
8697
  }, [ready, iframe.enabled]);
8409
8698
  usePreviewModeHotkeys();
8410
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
8411
- /* @__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)(
8699
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `Puck ${getClassName28()}`, children: [
8700
+ /* @__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)(
8412
8701
  "div",
8413
8702
  {
8414
8703
  className: getLayoutClassName({
8415
8704
  leftSideBarVisible,
8416
- menuOpen,
8417
8705
  mounted,
8418
8706
  rightSideBarVisible
8419
8707
  }),
8420
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8421
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8422
- CustomHeader,
8423
- {
8424
- 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)(
8425
- Button,
8426
- {
8427
- onClick: () => {
8428
- const data = appStore.getState().state.data;
8429
- onPublish && onPublish(data);
8430
- },
8431
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8432
- children: "Publish"
8433
- }
8434
- ) }) }),
8435
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
8436
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
8437
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8438
- "div",
8439
- {
8440
- className: getLayoutClassName("leftSideBarToggle"),
8441
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8442
- IconButton,
8443
- {
8444
- onClick: () => {
8445
- toggleSidebars("left");
8446
- },
8447
- title: "Toggle left sidebar",
8448
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8449
- }
8450
- )
8451
- }
8452
- ),
8453
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8454
- "div",
8455
- {
8456
- className: getLayoutClassName("rightSideBarToggle"),
8457
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8458
- IconButton,
8459
- {
8460
- onClick: () => {
8461
- toggleSidebars("right");
8462
- },
8463
- title: "Toggle right sidebar",
8464
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8465
- }
8466
- )
8467
- }
8468
- )
8469
- ] }),
8470
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8471
- headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
8472
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8473
- " ",
8474
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8475
- "code",
8476
- {
8477
- className: getLayoutClassName("headerPath"),
8478
- children: headerPath
8479
- }
8480
- )
8481
- ] })
8482
- ] }) }),
8483
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
8484
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8485
- IconButton,
8486
- {
8487
- onClick: () => {
8488
- return setMenuOpen(!menuOpen);
8489
- },
8490
- title: "Toggle menu bar",
8491
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8492
- }
8493
- ) }),
8494
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8495
- MenuBar,
8496
- {
8497
- dispatch,
8498
- onPublish,
8499
- menuOpen,
8500
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8501
- Button,
8502
- {
8503
- onClick: () => {
8504
- const data = appStore.getState().state.data;
8505
- onPublish && onPublish(data);
8506
- },
8507
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8508
- children: "Publish"
8509
- }
8510
- ) }),
8511
- setMenuOpen
8512
- }
8513
- )
8514
- ] })
8515
- ] }) })
8516
- }
8517
- ),
8518
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8519
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Components, {}) }),
8520
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Outline, {}) })
8708
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8709
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Header, {}),
8710
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8711
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Components, {}) }),
8712
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Outline, {}) })
8521
8713
  ] }),
8522
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Canvas, {}),
8523
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FieldSideBar, {}) })
8714
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Canvas, {}),
8715
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FieldSideBar, {}) })
8524
8716
  ] })
8525
8717
  }
8526
8718
  ) }) }),
8527
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
8719
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { id: "puck-portal-root", className: getClassName28("portal") })
8528
8720
  ] });
8529
8721
  }
8530
8722
  function Puck(props) {
8531
- 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)) })) }));
8723
+ 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)) })) }));
8532
8724
  }
8533
8725
  Puck.Components = Components;
8534
8726
  Puck.Fields = Fields;
@@ -8683,13 +8875,12 @@ function resolveAllData(_0, _1) {
8683
8875
  },
8684
8876
  () => {
8685
8877
  },
8686
- "force",
8687
- false
8878
+ "force"
8688
8879
  )).node;
8689
- const resolvedDeep = yield mapSlotsAsync(
8880
+ const resolvedDeep = yield mapSlots(
8690
8881
  resolved,
8691
8882
  processContent,
8692
- false
8883
+ config
8693
8884
  );
8694
8885
  onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
8695
8886
  return resolvedDeep;