@measured/puck 0.19.0-canary.d9be813b → 0.19.0-canary.e52d3b85

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.
@@ -226,6 +226,68 @@ ActionBar.Action = Action;
226
226
  ActionBar.Label = Label;
227
227
  ActionBar.Group = Group;
228
228
 
229
+ // lib/data/map-slots.ts
230
+ init_react_import();
231
+
232
+ // lib/data/is-slot.ts
233
+ init_react_import();
234
+ var isSlot = (prop) => {
235
+ var _a, _b;
236
+ return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
237
+ };
238
+ var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
239
+ var _a, _b;
240
+ const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
241
+ if (!configForComponent) return isSlot(propValue);
242
+ return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
243
+ };
244
+
245
+ // lib/data/map-slots.ts
246
+ function mapSlotsAsync(_0, _1) {
247
+ return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
248
+ const props = __spreadValues({}, item.props);
249
+ const propKeys = Object.keys(props);
250
+ for (let i = 0; i < propKeys.length; i++) {
251
+ const propKey = propKeys[i];
252
+ const itemType = "type" in item ? item.type : "root";
253
+ if (isSlot2(itemType, propKey, props[propKey])) {
254
+ const content = props[propKey];
255
+ const mappedContent = recursive ? yield Promise.all(
256
+ content.map((item2) => __async(this, null, function* () {
257
+ return yield mapSlotsAsync(item2, map, recursive, isSlot2);
258
+ }))
259
+ ) : content;
260
+ props[propKey] = yield map(mappedContent, propKey);
261
+ }
262
+ }
263
+ return __spreadProps(__spreadValues({}, item), { props });
264
+ });
265
+ }
266
+ function mapSlotsSync(item, map, isSlot2 = isSlot) {
267
+ const props = __spreadValues({}, item.props);
268
+ const propKeys = Object.keys(props);
269
+ for (let i = 0; i < propKeys.length; i++) {
270
+ const propKey = propKeys[i];
271
+ const itemType = "type" in item ? item.type : "root";
272
+ if (isSlot2(itemType, propKey, props[propKey])) {
273
+ const content = props[propKey];
274
+ const mappedContent = content.map((item2) => {
275
+ return mapSlotsSync(item2, map, isSlot2);
276
+ });
277
+ props[propKey] = map(mappedContent, props.id, propKey);
278
+ }
279
+ }
280
+ return __spreadProps(__spreadValues({}, item), { props });
281
+ }
282
+ function mapSlotsPublic(item, config, map) {
283
+ const isSlot2 = createIsSlotConfig(config);
284
+ return mapSlotsSync(
285
+ item,
286
+ (content, parentId, propName) => map(content, { parentId, propName }),
287
+ isSlot2
288
+ );
289
+ }
290
+
229
291
  // components/Render/index.tsx
230
292
  init_react_import();
231
293
 
@@ -235,36 +297,44 @@ var rootAreaId = "root";
235
297
  var rootZone = "default-zone";
236
298
  var rootDroppableId = `${rootAreaId}:${rootZone}`;
237
299
 
238
- // lib/use-slots.ts
300
+ // lib/use-slots.tsx
239
301
  init_react_import();
240
302
  import { useMemo } from "react";
241
- function useSlots(config, props, renderSlot) {
242
- return useMemo(() => {
303
+ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
304
+ const slotProps = useMemo(() => {
243
305
  if (!(config == null ? void 0 : config.fields)) return props;
244
- const newProps = __spreadValues({}, props);
306
+ const slotProps2 = {};
245
307
  const fieldKeys = Object.keys(config.fields);
246
308
  for (let i = 0; i < fieldKeys.length; i++) {
247
309
  const fieldKey = fieldKeys[i];
248
310
  const field = config.fields[fieldKey];
249
311
  if ((field == null ? void 0 : field.type) === "slot") {
250
- newProps[fieldKey] = (dzProps) => renderSlot(__spreadProps(__spreadValues({}, dzProps), {
312
+ const content = props[fieldKey] || [];
313
+ const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
314
+ const Slot = (dzProps) => render(__spreadProps(__spreadValues({
315
+ allow: field.allow,
316
+ disallow: field.disallow
317
+ }, dzProps), {
251
318
  zone: fieldKey,
252
- content: props[fieldKey] || []
319
+ content
253
320
  }));
321
+ slotProps2[fieldKey] = Slot;
254
322
  }
255
323
  }
256
- return newProps;
257
- }, [config, props]);
324
+ return slotProps2;
325
+ }, [config, readOnly, forceReadOnly]);
326
+ return __spreadValues(__spreadValues({}, props), slotProps);
258
327
  }
259
328
 
260
329
  // components/DropZone/index.tsx
261
330
  init_react_import();
262
331
  import {
263
332
  forwardRef as forwardRef4,
333
+ memo,
264
334
  useCallback as useCallback7,
265
335
  useContext as useContext5,
266
336
  useEffect as useEffect10,
267
- useMemo as useMemo5,
337
+ useMemo as useMemo6,
268
338
  useRef as useRef3
269
339
  } from "react";
270
340
 
@@ -281,7 +351,7 @@ import {
281
351
 
282
352
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
283
353
  init_react_import();
284
- var styles_module_default2 = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
354
+ var styles_module_default2 = { "DraggableComponent": "_DraggableComponent_qzbgx_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_qzbgx_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_qzbgx_29", "DraggableComponent--hover": "_DraggableComponent--hover_qzbgx_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_qzbgx_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_qzbgx_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_qzbgx_66", "DraggableComponent-actions": "_DraggableComponent-actions_qzbgx_66" };
285
355
 
286
356
  // ../../node_modules/lucide-react/dist/esm/lucide-react.js
287
357
  init_react_import();
@@ -616,75 +686,15 @@ init_react_import();
616
686
  // reducer/index.ts
617
687
  init_react_import();
618
688
 
619
- // reducer/reduce.ts
620
- init_react_import();
621
-
622
- // lib/reorder.ts
623
- init_react_import();
624
- var reorder = (list, startIndex, endIndex) => {
625
- const result = Array.from(list);
626
- const [removed] = result.splice(startIndex, 1);
627
- result.splice(endIndex, 0, removed);
628
- return result;
629
- };
630
-
631
- // lib/insert.ts
632
- init_react_import();
633
- var insert = (list, index, item) => {
634
- const result = Array.from(list || []);
635
- result.splice(index, 0, item);
636
- return result;
637
- };
638
-
639
- // lib/remove.ts
640
- init_react_import();
641
- var remove = (list, index) => {
642
- const result = Array.from(list);
643
- result.splice(index, 1);
644
- return result;
645
- };
646
-
647
- // lib/setup-zone.ts
648
- init_react_import();
649
- var setupZone = (data, zoneKey) => {
650
- if (zoneKey === rootDroppableId) {
651
- return data;
652
- }
653
- const newData = __spreadProps(__spreadValues({}, data), {
654
- zones: data.zones ? __spreadValues({}, data.zones) : {}
655
- });
656
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
657
- return newData;
658
- };
659
-
660
- // lib/get-item.ts
661
- init_react_import();
662
- function getItem(selector, state) {
663
- var _a, _b;
664
- const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
665
- return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
666
- }
667
-
668
- // lib/generate-id.ts
669
- init_react_import();
670
- import { v4 as uuidv4 } from "uuid";
671
- var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
672
-
673
- // lib/walk-tree.ts
689
+ // reducer/actions/set.ts
674
690
  init_react_import();
675
691
 
676
- // lib/for-each-slot.ts
692
+ // lib/data/walk-tree.ts
677
693
  init_react_import();
678
694
 
679
- // lib/is-slot.ts
695
+ // lib/data/for-each-slot.ts
680
696
  init_react_import();
681
- var isSlot = (prop) => {
682
- var _a, _b;
683
- return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
684
- };
685
-
686
- // lib/for-each-slot.ts
687
- var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, cb, recursive = false, isSlot2 = isSlot) {
697
+ var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
688
698
  const props = item.props || {};
689
699
  const propKeys = Object.keys(props);
690
700
  for (let i = 0; i < propKeys.length; i++) {
@@ -692,19 +702,19 @@ var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function*
692
702
  const itemType = "type" in item ? item.type : "root";
693
703
  if (isSlot2(itemType, propKey, props[propKey])) {
694
704
  const content = props[propKey];
695
- yield cb(props.id, propKey, content);
705
+ cb(props.id, propKey, content);
696
706
  if (recursive) {
697
707
  content.forEach(
698
708
  (childItem) => __async(void 0, null, function* () {
699
- return yield forEachSlot(childItem, cb, true, isSlot2);
709
+ return forEachSlot(childItem, cb, true, isSlot2);
700
710
  })
701
711
  );
702
712
  }
703
713
  }
704
714
  }
705
- });
715
+ };
706
716
 
707
- // lib/for-related-zones.ts
717
+ // lib/data/for-related-zones.ts
708
718
  init_react_import();
709
719
 
710
720
  // lib/get-zone-id.ts
@@ -719,19 +729,17 @@ var getZoneId = (zoneCompound) => {
719
729
  return [rootDroppableId, zoneCompound];
720
730
  };
721
731
 
722
- // lib/for-related-zones.ts
732
+ // lib/data/for-related-zones.ts
723
733
  function forRelatedZones(item, data, cb, path = []) {
724
734
  Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
725
735
  const [parentId] = getZoneId(zoneCompound);
726
736
  if (parentId === item.props.id) {
727
- const newPath = [...path, zoneCompound];
728
- content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
729
737
  cb(path, zoneCompound, content);
730
738
  }
731
739
  });
732
740
  }
733
741
 
734
- // lib/strip-slots.ts
742
+ // lib/data/strip-slots.ts
735
743
  init_react_import();
736
744
  var stripSlots = (data) => {
737
745
  return __spreadProps(__spreadValues({}, data), {
@@ -747,7 +755,7 @@ var stripSlots = (data) => {
747
755
  });
748
756
  };
749
757
 
750
- // lib/walk-tree.ts
758
+ // lib/data/walk-tree.ts
751
759
  function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
752
760
  var _a;
753
761
  let newZones = {};
@@ -789,7 +797,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
789
797
  const mappedItem = mapNodeOrSkip(item, path, index);
790
798
  if (!mappedItem) return item;
791
799
  const id = mappedItem.props.id;
792
- processRelatedZones(item, id, path);
793
800
  const newProps = __spreadValues({}, mappedItem.props);
794
801
  forEachSlot(
795
802
  mappedItem,
@@ -805,13 +812,9 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
805
812
  newProps[slotId] = newContent2;
806
813
  },
807
814
  false,
808
- (itemType, propName, propValue) => {
809
- var _a2, _b;
810
- const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
811
- if (!configForComponent) return isSlot(propValue);
812
- return ((_b = (_a2 = configForComponent.fields) == null ? void 0 : _a2[propName]) == null ? void 0 : _b.type) === "slot";
813
- }
815
+ createIsSlotConfig(config)
814
816
  );
817
+ processRelatedZones(item, id, path);
815
818
  const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
816
819
  const thisZoneCompound = path[path.length - 1];
817
820
  const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
@@ -822,7 +825,7 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
822
825
  parentId,
823
826
  zone
824
827
  };
825
- const finalData = newItem;
828
+ const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
826
829
  if (newProps.id === "root") {
827
830
  delete finalData["type"];
828
831
  delete finalData.props["id"];
@@ -837,8 +840,12 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
837
840
  "root"
838
841
  );
839
842
  const processedContent = newContent;
843
+ const zonesAlreadyProcessed = Object.keys(newZones);
840
844
  Object.keys(zones || {}).forEach((zoneCompound) => {
841
845
  const [parentId] = zoneCompound.split(":");
846
+ if (zonesAlreadyProcessed.includes(zoneCompound)) {
847
+ return;
848
+ }
842
849
  const [_2, newContent2] = processContent(
843
850
  [rootDroppableId],
844
851
  zoneCompound,
@@ -862,7 +869,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
862
869
  return __spreadProps(__spreadValues({}, state), {
863
870
  data: {
864
871
  root,
865
- // root: state.data.root, // TODO changing root causes it's entire subtree to re-render. Let's keep this disabled until the performance issues are resolved in #644.
866
872
  content: processedContent,
867
873
  zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
868
874
  },
@@ -873,59 +879,59 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
873
879
  });
874
880
  }
875
881
 
876
- // lib/deindex.ts
877
- init_react_import();
878
- var deindex = (state, componentData) => {
879
- let zones = __spreadValues({}, state.indexes.zones);
880
- let nodes = __spreadValues({}, state.indexes.nodes);
881
- const dindexRelatedZones = (item) => {
882
- forRelatedZones(item, state.data, (_path, zoneCompound, content) => {
883
- content.forEach((subItem) => {
884
- dindexChildren(subItem);
885
- delete nodes[subItem.props.id];
886
- });
887
- delete zones[zoneCompound];
888
- });
889
- };
890
- const dindexChildren = (item) => {
891
- forEachSlot(
892
- item,
893
- (parentId, slotId, content) => {
894
- const zoneCompound = `${parentId}:${slotId}`;
895
- delete zones[zoneCompound];
896
- content.forEach((item2) => {
897
- dindexRelatedZones(item2);
898
- delete nodes[item2.props.id];
899
- });
900
- },
901
- true
882
+ // reducer/actions/set.ts
883
+ var setAction = (state, action, appStore) => {
884
+ if (typeof action.state === "object") {
885
+ const newState = __spreadValues(__spreadValues({}, state), action.state);
886
+ if (action.state.indexes) {
887
+ return newState;
888
+ }
889
+ console.warn(
890
+ "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
902
891
  );
903
- };
904
- dindexRelatedZones(componentData);
905
- dindexChildren(componentData);
906
- delete nodes[componentData.props.id];
907
- return { nodes, zones };
892
+ return walkTree(newState, appStore.config);
893
+ }
894
+ return __spreadValues(__spreadValues({}, state), action.state(state));
908
895
  };
909
896
 
910
- // reducer/reduce.ts
911
- var zoneCache = {};
897
+ // reducer/actions/insert.ts
898
+ init_react_import();
899
+
900
+ // lib/data/insert.ts
901
+ init_react_import();
902
+ var insert = (list, index, item) => {
903
+ const result = Array.from(list || []);
904
+ result.splice(index, 0, item);
905
+ return result;
906
+ };
907
+
908
+ // lib/generate-id.ts
909
+ init_react_import();
910
+ import { v4 as uuidv4 } from "uuid";
911
+ var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
912
+
913
+ // lib/data/get-ids-for-parent.ts
914
+ init_react_import();
912
915
  var getIdsForParent = (zoneCompound, state) => {
913
916
  const [parentId] = zoneCompound.split(":");
914
917
  const node = state.indexes.nodes[parentId];
915
918
  return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
916
919
  };
917
- function insertAction(state, action, config) {
920
+
921
+ // reducer/actions/insert.ts
922
+ function insertAction(state, action, appStore) {
918
923
  const id = action.id || generateId(action.componentType);
919
924
  const emptyComponentData = {
920
925
  type: action.componentType,
921
- props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
926
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
922
927
  id
923
928
  })
924
929
  };
925
930
  const [parentId] = action.destinationZone.split(":");
931
+ const idsInPath = getIdsForParent(action.destinationZone, state);
926
932
  return walkTree(
927
933
  state,
928
- config,
934
+ appStore.config,
929
935
  (content, zoneCompound) => {
930
936
  if (zoneCompound === action.destinationZone) {
931
937
  return insert(
@@ -936,44 +942,41 @@ function insertAction(state, action, config) {
936
942
  }
937
943
  return content;
938
944
  },
939
- (childItem) => {
945
+ (childItem, path) => {
940
946
  if (childItem.props.id === id || childItem.props.id === parentId) {
941
947
  return childItem;
948
+ } else if (idsInPath.includes(childItem.props.id)) {
949
+ return childItem;
950
+ } else if (path.includes(action.destinationZone)) {
951
+ return childItem;
942
952
  }
943
953
  return null;
944
954
  }
945
955
  );
946
956
  }
947
- var reorderAction = (state, action, appStore) => {
957
+
958
+ // reducer/actions/replace.ts
959
+ init_react_import();
960
+ var replaceAction = (state, action, appStore) => {
961
+ const [parentId] = action.destinationZone.split(":");
962
+ const idsInPath = getIdsForParent(action.destinationZone, state);
963
+ const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
964
+ const idChanged = originalId !== action.data.props.id;
965
+ if (idChanged) {
966
+ throw new Error(
967
+ `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
968
+ );
969
+ }
948
970
  return walkTree(
949
971
  state,
950
972
  appStore.config,
951
973
  (content, zoneCompound) => {
974
+ const newContent = [...content];
952
975
  if (zoneCompound === action.destinationZone) {
953
- return reorder(
954
- content || [],
955
- action.sourceIndex,
956
- action.destinationIndex
957
- );
976
+ newContent[action.destinationIndex] = action.data;
958
977
  }
959
- return content;
978
+ return newContent;
960
979
  },
961
- (childItem, path, index) => {
962
- const zoneCompound = path[path.length - 1];
963
- if (index === action.sourceIndex && zoneCompound === action.destinationZone || index === action.destinationIndex && zoneCompound === action.destinationZone) {
964
- return childItem;
965
- }
966
- return null;
967
- }
968
- );
969
- };
970
- var replaceAction = (state, action, appStore) => {
971
- const [parentId] = action.destinationZone.split(":");
972
- const idsInPath = getIdsForParent(action.destinationZone, state);
973
- return walkTree(
974
- state,
975
- appStore.config,
976
- (content) => content,
977
980
  (childItem, path) => {
978
981
  const pathIds = path.map((p) => p.split(":")[0]);
979
982
  if (childItem.props.id === action.data.props.id) {
@@ -989,226 +992,297 @@ var replaceAction = (state, action, appStore) => {
989
992
  }
990
993
  );
991
994
  };
992
- var setAction = (state, action, appStore) => {
993
- if (typeof action.state === "object") {
994
- const newState = __spreadValues(__spreadValues({}, state), action.state);
995
- if (action.state.indexes) {
996
- console.warn(
997
- "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
998
- );
999
- return newState;
995
+
996
+ // reducer/actions/replace-root.ts
997
+ init_react_import();
998
+ var replaceRootAction = (state, action, appStore) => {
999
+ return walkTree(
1000
+ state,
1001
+ appStore.config,
1002
+ (content) => content,
1003
+ (childItem) => {
1004
+ if (childItem.props.id === "root") {
1005
+ return __spreadProps(__spreadValues({}, childItem), {
1006
+ props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1007
+ readOnly: action.root.readOnly
1008
+ });
1009
+ }
1010
+ return childItem;
1000
1011
  }
1001
- return walkTree(newState, appStore.config);
1002
- }
1003
- return __spreadValues(__spreadValues({}, state), action.state(state));
1012
+ );
1004
1013
  };
1005
- function reduce(state, action, appStore) {
1006
- if (action.type === "set") {
1007
- return setAction(state, action, appStore);
1008
- }
1009
- if (action.type === "insert") {
1010
- return insertAction(state, action, appStore.config);
1011
- }
1012
- if (action.type === "replace") {
1013
- return replaceAction(state, action, appStore);
1014
- }
1015
- if (action.type === "replaceRoot") {
1016
- return walkTree(
1017
- state,
1018
- appStore.config,
1019
- (content) => content,
1020
- (childItem) => {
1021
- if (childItem.props.id === "root") {
1022
- return __spreadProps(__spreadValues({}, childItem), {
1023
- props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1024
- readOnly: action.root.readOnly
1025
- });
1026
- }
1014
+
1015
+ // reducer/actions/duplicate.ts
1016
+ init_react_import();
1017
+
1018
+ // lib/data/get-item.ts
1019
+ init_react_import();
1020
+ function getItem(selector, state) {
1021
+ var _a, _b;
1022
+ const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
1023
+ return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
1024
+ }
1025
+
1026
+ // reducer/actions/duplicate.ts
1027
+ function duplicateAction(state, action, appStore) {
1028
+ const item = getItem(
1029
+ { index: action.sourceIndex, zone: action.sourceZone },
1030
+ state
1031
+ );
1032
+ const idsInPath = getIdsForParent(action.sourceZone, state);
1033
+ const newItem = __spreadProps(__spreadValues({}, item), {
1034
+ props: __spreadProps(__spreadValues({}, item.props), {
1035
+ id: generateId(item.type)
1036
+ })
1037
+ });
1038
+ const modified = walkTree(
1039
+ state,
1040
+ appStore.config,
1041
+ (content, zoneCompound) => {
1042
+ if (zoneCompound === action.sourceZone) {
1043
+ return insert(content, action.sourceIndex + 1, item);
1044
+ }
1045
+ return content;
1046
+ },
1047
+ (childItem, path, index) => {
1048
+ const zoneCompound = path[path.length - 1];
1049
+ const parents = path.map((p) => p.split(":")[0]);
1050
+ if (parents.indexOf(newItem.props.id) > -1) {
1051
+ return __spreadProps(__spreadValues({}, childItem), {
1052
+ props: __spreadProps(__spreadValues({}, childItem.props), {
1053
+ id: generateId(childItem.type)
1054
+ })
1055
+ });
1056
+ }
1057
+ if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1058
+ return newItem;
1059
+ }
1060
+ const [sourceZoneParent] = action.sourceZone.split(":");
1061
+ if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1027
1062
  return childItem;
1028
1063
  }
1029
- );
1030
- }
1031
- if (action.type === "duplicate") {
1032
- const item = getItem(
1033
- { index: action.sourceIndex, zone: action.sourceZone },
1034
- state
1035
- );
1036
- const idsInPath = getIdsForParent(action.sourceZone, state);
1037
- const newItem = __spreadProps(__spreadValues({}, item), {
1038
- props: __spreadProps(__spreadValues({}, item.props), {
1039
- id: generateId(item.type)
1040
- })
1041
- });
1042
- const modified = walkTree(
1043
- state,
1044
- appStore.config,
1045
- (content, zoneCompound) => {
1046
- if (zoneCompound === action.sourceZone) {
1047
- return insert(content, action.sourceIndex + 1, item);
1048
- }
1049
- return content;
1050
- },
1051
- (childItem, path, index) => {
1052
- const zoneCompound = path[path.length - 1];
1053
- const parents = path.map((p) => p.split(":")[0]);
1054
- if (parents.indexOf(newItem.props.id) > -1) {
1055
- return __spreadProps(__spreadValues({}, childItem), {
1056
- props: __spreadProps(__spreadValues({}, childItem.props), {
1057
- id: generateId(childItem.type)
1058
- })
1059
- });
1060
- }
1061
- if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1062
- return newItem;
1063
- }
1064
- const [sourceZoneParent] = action.sourceZone.split(":");
1065
- if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1066
- return childItem;
1067
- }
1068
- return null;
1064
+ return null;
1065
+ }
1066
+ );
1067
+ return __spreadProps(__spreadValues({}, modified), {
1068
+ ui: __spreadProps(__spreadValues({}, modified.ui), {
1069
+ itemSelector: {
1070
+ index: action.sourceIndex + 1,
1071
+ zone: action.sourceZone
1069
1072
  }
1070
- );
1071
- return __spreadProps(__spreadValues({}, modified), {
1072
- ui: __spreadProps(__spreadValues({}, modified.ui), {
1073
- itemSelector: {
1074
- index: action.sourceIndex + 1,
1075
- zone: action.sourceZone
1076
- }
1077
- })
1078
- });
1079
- }
1080
- if (action.type === "reorder") {
1081
- return reorderAction(state, action, appStore);
1073
+ })
1074
+ });
1075
+ }
1076
+
1077
+ // reducer/actions/reorder.ts
1078
+ init_react_import();
1079
+
1080
+ // reducer/actions/move.ts
1081
+ init_react_import();
1082
+
1083
+ // lib/data/remove.ts
1084
+ init_react_import();
1085
+ var remove = (list, index) => {
1086
+ const result = Array.from(list);
1087
+ result.splice(index, 1);
1088
+ return result;
1089
+ };
1090
+
1091
+ // reducer/actions/move.ts
1092
+ var moveAction = (state, action, appStore) => {
1093
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
1094
+ return state;
1082
1095
  }
1083
- if (action.type === "move") {
1084
- if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
1085
- return state;
1096
+ const item = getItem(
1097
+ { zone: action.sourceZone, index: action.sourceIndex },
1098
+ state
1099
+ );
1100
+ if (!item) return state;
1101
+ const idsInSourcePath = getIdsForParent(action.sourceZone, state);
1102
+ const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
1103
+ return walkTree(
1104
+ state,
1105
+ appStore.config,
1106
+ (content, zoneCompound) => {
1107
+ if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
1108
+ return insert(
1109
+ remove(content, action.sourceIndex),
1110
+ action.destinationIndex,
1111
+ item
1112
+ );
1113
+ } else if (zoneCompound === action.sourceZone) {
1114
+ return remove(content, action.sourceIndex);
1115
+ } else if (zoneCompound === action.destinationZone) {
1116
+ return insert(content, action.destinationIndex, item);
1117
+ }
1118
+ return content;
1119
+ },
1120
+ (childItem, path) => {
1121
+ const [sourceZoneParent] = action.sourceZone.split(":");
1122
+ const [destinationZoneParent] = action.destinationZone.split(":");
1123
+ const childId = childItem.props.id;
1124
+ if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
1125
+ return childItem;
1126
+ }
1127
+ return null;
1086
1128
  }
1087
- const item = getItem(
1088
- { zone: action.sourceZone, index: action.sourceIndex },
1089
- state
1090
- );
1091
- if (!item) return state;
1092
- const idsInSourcePath = getIdsForParent(action.sourceZone, state);
1093
- const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
1094
- return walkTree(
1095
- state,
1096
- appStore.config,
1097
- (content, zoneCompound) => {
1098
- if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
1099
- return insert(
1100
- remove(content, action.sourceIndex),
1101
- action.destinationIndex,
1102
- item
1103
- );
1104
- } else if (zoneCompound === action.sourceZone) {
1105
- return remove(content, action.sourceIndex);
1106
- } else if (zoneCompound === action.destinationZone) {
1107
- return insert(content, action.destinationIndex, item);
1108
- }
1109
- return content;
1110
- },
1111
- (childItem) => {
1112
- const [sourceZoneParent] = action.sourceZone.split(":");
1113
- const [destinationZoneParent] = action.destinationZone.split(":");
1114
- const childId = childItem.props.id;
1115
- if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1) {
1116
- return childItem;
1117
- }
1118
- return null;
1129
+ );
1130
+ };
1131
+
1132
+ // reducer/actions/reorder.ts
1133
+ var reorderAction = (state, action, appStore) => {
1134
+ return moveAction(
1135
+ state,
1136
+ {
1137
+ type: "move",
1138
+ sourceIndex: action.sourceIndex,
1139
+ sourceZone: action.destinationZone,
1140
+ destinationIndex: action.destinationIndex,
1141
+ destinationZone: action.destinationZone
1142
+ },
1143
+ appStore
1144
+ );
1145
+ };
1146
+
1147
+ // reducer/actions/remove.ts
1148
+ init_react_import();
1149
+ var removeAction = (state, action, appStore) => {
1150
+ const item = getItem({ index: action.index, zone: action.zone }, state);
1151
+ const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
1152
+ (acc, [nodeId, nodeData]) => {
1153
+ const pathIds = nodeData.path.map((p) => p.split(":")[0]);
1154
+ if (pathIds.includes(item.props.id)) {
1155
+ return [...acc, nodeId];
1119
1156
  }
1120
- );
1121
- }
1122
- if (action.type === "remove") {
1123
- const item = getItem({ index: action.index, zone: action.zone }, state);
1124
- let deindexed = deindex(state, item);
1125
- const [parentId] = action.zone.split(":");
1126
- return walkTree(
1127
- __spreadProps(__spreadValues({}, state), { indexes: deindexed }),
1128
- appStore.config,
1129
- (content, zoneCompound) => {
1130
- if (zoneCompound === action.zone) {
1131
- return remove(content, action.index);
1132
- }
1133
- return content;
1134
- },
1135
- (childItem, path) => {
1136
- const parentIds = path.map((p) => p.split(":")[0]);
1137
- if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
1138
- return childItem;
1139
- }
1140
- return null;
1157
+ return acc;
1158
+ },
1159
+ [item.props.id]
1160
+ );
1161
+ const newState = walkTree(
1162
+ state,
1163
+ appStore.config,
1164
+ (content, zoneCompound) => {
1165
+ if (zoneCompound === action.zone) {
1166
+ return remove(content, action.index);
1141
1167
  }
1142
- );
1143
- }
1144
- if (action.type === "registerZone") {
1145
- if (zoneCache[action.zone]) {
1146
- return __spreadProps(__spreadValues({}, state), {
1147
- data: __spreadProps(__spreadValues({}, state.data), {
1148
- zones: __spreadProps(__spreadValues({}, state.data.zones), {
1149
- [action.zone]: zoneCache[action.zone]
1150
- })
1151
- }),
1152
- indexes: __spreadProps(__spreadValues({}, state.indexes), {
1153
- zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
1154
- [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
1155
- contentIds: zoneCache[action.zone].map((item) => item.props.id),
1156
- type: "dropzone"
1157
- })
1158
- })
1159
- })
1160
- });
1168
+ return content;
1161
1169
  }
1162
- return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
1163
- }
1164
- if (action.type === "unregisterZone") {
1165
- const _zones = __spreadValues({}, state.data.zones || {});
1166
- const zoneIndex = __spreadValues({}, state.indexes.zones || {});
1167
- if (_zones[action.zone]) {
1168
- zoneCache[action.zone] = _zones[action.zone];
1169
- delete _zones[action.zone];
1170
+ );
1171
+ Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
1172
+ const parentId = zoneCompound.split(":")[0];
1173
+ if (nodesToDelete.includes(parentId) && newState.data.zones) {
1174
+ delete newState.data.zones[zoneCompound];
1175
+ }
1176
+ });
1177
+ Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
1178
+ const parentId = zoneCompound.split(":")[0];
1179
+ if (nodesToDelete.includes(parentId)) {
1180
+ delete newState.indexes.zones[zoneCompound];
1170
1181
  }
1171
- delete zoneIndex[action.zone];
1182
+ });
1183
+ nodesToDelete.forEach((id) => {
1184
+ delete newState.indexes.nodes[id];
1185
+ });
1186
+ return newState;
1187
+ };
1188
+
1189
+ // reducer/actions/register-zone.ts
1190
+ init_react_import();
1191
+
1192
+ // lib/data/setup-zone.ts
1193
+ init_react_import();
1194
+ var setupZone = (data, zoneKey) => {
1195
+ if (zoneKey === rootDroppableId) {
1196
+ return data;
1197
+ }
1198
+ const newData = __spreadProps(__spreadValues({}, data), {
1199
+ zones: data.zones ? __spreadValues({}, data.zones) : {}
1200
+ });
1201
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1202
+ return newData;
1203
+ };
1204
+
1205
+ // reducer/actions/register-zone.ts
1206
+ var zoneCache = {};
1207
+ function registerZoneAction(state, action) {
1208
+ if (zoneCache[action.zone]) {
1172
1209
  return __spreadProps(__spreadValues({}, state), {
1173
1210
  data: __spreadProps(__spreadValues({}, state.data), {
1174
- zones: _zones
1211
+ zones: __spreadProps(__spreadValues({}, state.data.zones), {
1212
+ [action.zone]: zoneCache[action.zone]
1213
+ })
1175
1214
  }),
1176
1215
  indexes: __spreadProps(__spreadValues({}, state.indexes), {
1177
- zones: zoneIndex
1216
+ zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
1217
+ [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
1218
+ contentIds: zoneCache[action.zone].map((item) => item.props.id),
1219
+ type: "dropzone"
1220
+ })
1221
+ })
1178
1222
  })
1179
1223
  });
1180
1224
  }
1181
- if (action.type === "setData") {
1182
- if (typeof action.data === "object") {
1183
- console.warn(
1184
- "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1185
- );
1186
- return walkTree(
1187
- __spreadProps(__spreadValues({}, state), {
1188
- data: __spreadValues(__spreadValues({}, state.data), action.data)
1189
- }),
1190
- appStore.config
1191
- );
1192
- }
1225
+ return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
1226
+ }
1227
+ function unregisterZoneAction(state, action) {
1228
+ const _zones = __spreadValues({}, state.data.zones || {});
1229
+ const zoneIndex = __spreadValues({}, state.indexes.zones || {});
1230
+ if (_zones[action.zone]) {
1231
+ zoneCache[action.zone] = _zones[action.zone];
1232
+ delete _zones[action.zone];
1233
+ }
1234
+ delete zoneIndex[action.zone];
1235
+ return __spreadProps(__spreadValues({}, state), {
1236
+ data: __spreadProps(__spreadValues({}, state.data), {
1237
+ zones: _zones
1238
+ }),
1239
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
1240
+ zones: zoneIndex
1241
+ })
1242
+ });
1243
+ }
1244
+
1245
+ // reducer/actions/set-data.ts
1246
+ init_react_import();
1247
+ var setDataAction = (state, action, appStore) => {
1248
+ if (typeof action.data === "object") {
1249
+ console.warn(
1250
+ "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1251
+ );
1193
1252
  return walkTree(
1194
1253
  __spreadProps(__spreadValues({}, state), {
1195
- data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
1254
+ data: __spreadValues(__spreadValues({}, state.data), action.data)
1196
1255
  }),
1197
1256
  appStore.config
1198
1257
  );
1199
1258
  }
1200
- if (action.type === "setUi") {
1201
- if (typeof action.ui === "object") {
1202
- return __spreadProps(__spreadValues({}, state), {
1203
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
1204
- });
1205
- }
1259
+ return walkTree(
1260
+ __spreadProps(__spreadValues({}, state), {
1261
+ data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
1262
+ }),
1263
+ appStore.config
1264
+ );
1265
+ };
1266
+
1267
+ // reducer/actions/set-ui.ts
1268
+ init_react_import();
1269
+ var setUiAction = (state, action) => {
1270
+ if (typeof action.ui === "object") {
1206
1271
  return __spreadProps(__spreadValues({}, state), {
1207
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
1272
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
1208
1273
  });
1209
1274
  }
1210
- return state;
1211
- }
1275
+ return __spreadProps(__spreadValues({}, state), {
1276
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
1277
+ });
1278
+ };
1279
+
1280
+ // lib/data/make-state-public.ts
1281
+ init_react_import();
1282
+ var makeStatePublic = (state) => {
1283
+ const { data, ui } = state;
1284
+ return { data, ui };
1285
+ };
1212
1286
 
1213
1287
  // reducer/actions.tsx
1214
1288
  init_react_import();
@@ -1227,21 +1301,54 @@ function storeInterceptor(reducer, record, onAction) {
1227
1301
  if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
1228
1302
  if (record) record(newAppState);
1229
1303
  }
1230
- onAction == null ? void 0 : onAction(action, newAppState, state);
1304
+ onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
1231
1305
  return newAppState;
1232
1306
  };
1233
1307
  }
1234
1308
  function createReducer({
1235
- config,
1236
1309
  record,
1237
1310
  onAction,
1238
1311
  appStore
1239
1312
  }) {
1240
1313
  return storeInterceptor(
1241
1314
  (state, action) => {
1242
- const result = reduce(state, action, appStore);
1243
- console.log(action.type, state, result);
1244
- return result;
1315
+ if (action.type === "set") {
1316
+ return setAction(state, action, appStore);
1317
+ }
1318
+ if (action.type === "insert") {
1319
+ return insertAction(state, action, appStore);
1320
+ }
1321
+ if (action.type === "replace") {
1322
+ return replaceAction(state, action, appStore);
1323
+ }
1324
+ if (action.type === "replaceRoot") {
1325
+ return replaceRootAction(state, action, appStore);
1326
+ }
1327
+ if (action.type === "duplicate") {
1328
+ return duplicateAction(state, action, appStore);
1329
+ }
1330
+ if (action.type === "reorder") {
1331
+ return reorderAction(state, action, appStore);
1332
+ }
1333
+ if (action.type === "move") {
1334
+ return moveAction(state, action, appStore);
1335
+ }
1336
+ if (action.type === "remove") {
1337
+ return removeAction(state, action, appStore);
1338
+ }
1339
+ if (action.type === "registerZone") {
1340
+ return registerZoneAction(state, action);
1341
+ }
1342
+ if (action.type === "unregisterZone") {
1343
+ return unregisterZoneAction(state, action);
1344
+ }
1345
+ if (action.type === "setData") {
1346
+ return setDataAction(state, action, appStore);
1347
+ }
1348
+ if (action.type === "setUi") {
1349
+ return setUiAction(state, action);
1350
+ }
1351
+ return state;
1245
1352
  },
1246
1353
  record,
1247
1354
  onAction
@@ -1453,7 +1560,7 @@ var createHistorySlice = (set, get) => {
1453
1560
  const { dispatch, history } = get();
1454
1561
  dispatch({
1455
1562
  type: "set",
1456
- state: ((_a = history.histories[history.index]) == null ? void 0 : _a.state) || history.initialAppState
1563
+ state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
1457
1564
  });
1458
1565
  set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1459
1566
  },
@@ -1530,7 +1637,7 @@ var createNodesSlice = (set, get) => ({
1530
1637
  init_react_import();
1531
1638
  import { useEffect as useEffect3 } from "react";
1532
1639
 
1533
- // lib/flatten-data.ts
1640
+ // lib/data/flatten-data.ts
1534
1641
  init_react_import();
1535
1642
  var flattenData = (state, config) => {
1536
1643
  const data = [];
@@ -1565,12 +1672,7 @@ var createPermissionsSlice = (set, get) => {
1565
1672
  const { cache: cache2, globalPermissions } = permissions;
1566
1673
  const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1567
1674
  var _a, _b, _c;
1568
- const {
1569
- config: config2,
1570
- state: appState,
1571
- setComponentLoading,
1572
- unsetComponentLoading
1573
- } = get();
1675
+ const { config: config2, state: appState, setComponentLoading } = get();
1574
1676
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1575
1677
  if (!componentConfig) {
1576
1678
  return;
@@ -1579,14 +1681,14 @@ var createPermissionsSlice = (set, get) => {
1579
1681
  if (componentConfig.resolvePermissions) {
1580
1682
  const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
1581
1683
  if (Object.values(changed).some((el) => el === true) || force2) {
1582
- setComponentLoading(item2.props.id);
1684
+ const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
1583
1685
  const resolvedPermissions = yield componentConfig.resolvePermissions(
1584
1686
  item2,
1585
1687
  {
1586
1688
  changed,
1587
1689
  lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
1588
1690
  permissions: initialPermissions,
1589
- appState,
1691
+ appState: makeStatePublic(appState),
1590
1692
  lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
1591
1693
  }
1592
1694
  );
@@ -1604,7 +1706,7 @@ var createPermissionsSlice = (set, get) => {
1604
1706
  })
1605
1707
  })
1606
1708
  });
1607
- unsetComponentLoading(item2.props.id);
1709
+ clearTimeout2();
1608
1710
  }
1609
1711
  }
1610
1712
  });
@@ -1614,7 +1716,7 @@ var createPermissionsSlice = (set, get) => {
1614
1716
  // Shim the root data in by conforming to component data shape
1615
1717
  {
1616
1718
  type: "root",
1617
- props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "puck-root" })
1719
+ props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
1618
1720
  },
1619
1721
  force2
1620
1722
  );
@@ -1629,7 +1731,6 @@ var createPermissionsSlice = (set, get) => {
1629
1731
  } else if (root) {
1630
1732
  resolveDataForRoot(force);
1631
1733
  } else {
1632
- resolveDataForRoot(force);
1633
1734
  flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1634
1735
  yield resolveDataForItem(item2, force);
1635
1736
  }));
@@ -1660,7 +1761,7 @@ var createPermissionsSlice = (set, get) => {
1660
1761
  } else if (root) {
1661
1762
  const rootConfig = config.root;
1662
1763
  const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
1663
- const resolvedForItem = resolvedPermissions["puck-root"];
1764
+ const resolvedForItem = resolvedPermissions["root"];
1664
1765
  return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1665
1766
  }
1666
1767
  return globalPermissions;
@@ -1743,7 +1844,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
1743
1844
  fields: defaultFields,
1744
1845
  lastFields,
1745
1846
  lastData,
1746
- appState: state,
1847
+ appState: makeStatePublic(state),
1747
1848
  parent
1748
1849
  });
1749
1850
  clearTimeout(timeout3);
@@ -1776,39 +1877,15 @@ var useRegisterFieldsSlice = (appStore, id) => {
1776
1877
 
1777
1878
  // lib/resolve-component-data.ts
1778
1879
  init_react_import();
1779
-
1780
- // lib/map-slots.ts
1781
- init_react_import();
1782
- function mapSlots(item, map, recursive = true, isSlot2) {
1783
- return __async(this, null, function* () {
1784
- const props = __spreadValues({}, item.props);
1785
- yield forEachSlot(
1786
- item,
1787
- (_parentId, propName, content) => __async(this, null, function* () {
1788
- const mappedContent = recursive ? yield Promise.all(
1789
- content.map((item2) => __async(this, null, function* () {
1790
- return yield mapSlots(item2, map, recursive, isSlot2);
1791
- }))
1792
- ) : content;
1793
- props[propName] = yield map(mappedContent, propName);
1794
- }),
1795
- false,
1796
- isSlot2
1797
- );
1798
- return __spreadProps(__spreadValues({}, item), { props });
1799
- });
1800
- }
1801
-
1802
- // lib/resolve-component-data.ts
1803
1880
  import fdeq from "fast-deep-equal";
1804
1881
  var cache = { lastChange: {} };
1805
1882
  var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
1806
- const configForItem = "type" in item ? config.components[item.type] : config.root;
1883
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1807
1884
  if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
1808
1885
  const id = "id" in item.props ? item.props.id : "root";
1809
1886
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1810
- if (item && item === oldItem) {
1811
- return resolved;
1887
+ if (item && fdeq(item, oldItem)) {
1888
+ return { node: resolved, didChange: false };
1812
1889
  }
1813
1890
  const changed = getChanged(item, oldItem);
1814
1891
  if (onResolveStart) {
@@ -1817,30 +1894,35 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
1817
1894
  const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1818
1895
  changed,
1819
1896
  lastData: oldItem,
1820
- metadata,
1897
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1821
1898
  trigger
1822
1899
  });
1823
1900
  let resolvedItem = __spreadProps(__spreadValues({}, item), {
1824
1901
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
1825
1902
  });
1826
1903
  if (recursive) {
1827
- resolvedItem = yield mapSlots(resolvedItem, (content) => __async(void 0, null, function* () {
1828
- return Promise.all(
1829
- content.map(
1830
- (childItem) => __async(void 0, null, function* () {
1831
- return (yield resolveComponentData(
1832
- childItem,
1833
- config,
1834
- metadata,
1835
- onResolveStart,
1836
- onResolveEnd,
1837
- trigger,
1838
- false
1839
- )).node;
1840
- })
1841
- )
1842
- );
1843
- }));
1904
+ resolvedItem = yield mapSlotsAsync(
1905
+ resolvedItem,
1906
+ (content) => __async(void 0, null, function* () {
1907
+ return Promise.all(
1908
+ content.map(
1909
+ (childItem) => __async(void 0, null, function* () {
1910
+ return (yield resolveComponentData(
1911
+ childItem,
1912
+ config,
1913
+ metadata,
1914
+ onResolveStart,
1915
+ onResolveEnd,
1916
+ trigger,
1917
+ false
1918
+ )).node;
1919
+ })
1920
+ )
1921
+ );
1922
+ }),
1923
+ false,
1924
+ createIsSlotConfig(config)
1925
+ );
1844
1926
  }
1845
1927
  if (Object.keys(readOnly).length) {
1846
1928
  resolvedItem.readOnly = readOnly;
@@ -1857,7 +1939,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
1857
1939
  return { node: item, didChange: false };
1858
1940
  });
1859
1941
 
1860
- // lib/to-root.ts
1942
+ // lib/data/to-root.ts
1861
1943
  init_react_import();
1862
1944
  var toRoot = (item) => {
1863
1945
  if ("type" in item && item.type !== "root") {
@@ -1904,174 +1986,176 @@ var defaultPageFields = {
1904
1986
  title: { type: "text" }
1905
1987
  };
1906
1988
  var createAppStore = (initialAppStore) => create2()(
1907
- subscribeWithSelector2((set, get) => __spreadProps(__spreadValues({
1908
- state: defaultAppState,
1909
- config: { components: {} },
1910
- componentState: {},
1911
- plugins: [],
1912
- overrides: {},
1913
- viewports: defaultViewports,
1914
- zoomConfig: {
1915
- autoZoom: 1,
1916
- rootHeight: 0,
1917
- zoom: 1
1918
- },
1919
- status: "LOADING",
1920
- iframe: {},
1921
- metadata: {}
1922
- }, initialAppStore), {
1923
- fields: createFieldsSlice(set, get),
1924
- history: createHistorySlice(set, get),
1925
- nodes: createNodesSlice(set, get),
1926
- permissions: createPermissionsSlice(set, get),
1927
- getComponentConfig: (type) => {
1928
- var _a;
1929
- const { config, selectedItem } = get();
1930
- const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
1931
- return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
1932
- },
1933
- dispatch: (action) => set((s) => {
1934
- var _a, _b;
1935
- const { record } = get().history;
1936
- const dispatch = createReducer({
1937
- config: s.config,
1938
- record,
1939
- appStore: s
1940
- });
1941
- const state = dispatch(s.state, action);
1942
- const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1943
- (_b = (_a = get()).onAction) == null ? void 0 : _b.call(_a, action, state, get().state);
1944
- return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1945
- }),
1946
- setZoomConfig: (zoomConfig) => set({ zoomConfig }),
1947
- setStatus: (status) => set({ status }),
1948
- setComponentState: (componentState) => set({ componentState }),
1949
- pendingComponentLoads: {},
1950
- setComponentLoading: (id, loading = true, defer = 0) => {
1951
- const { setComponentState, pendingComponentLoads } = get();
1952
- const thisPendingComponentLoads = __spreadValues({}, pendingComponentLoads);
1953
- const setLoading = () => {
1954
- var _a;
1955
- const { componentState } = get();
1956
- setComponentState(__spreadProps(__spreadValues({}, componentState), {
1957
- [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1958
- loadingCount: (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) + 1
1959
- })
1960
- }));
1961
- };
1962
- const unsetLoading = () => {
1963
- var _a;
1964
- const { componentState } = get();
1965
- setComponentState(__spreadProps(__spreadValues({}, componentState), {
1966
- [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1967
- loadingCount: Math.max(
1968
- (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) - 1,
1969
- 0
1970
- )
1989
+ subscribeWithSelector2((set, get) => {
1990
+ var _a, _b;
1991
+ return __spreadProps(__spreadValues({
1992
+ state: defaultAppState,
1993
+ config: { components: {} },
1994
+ componentState: {},
1995
+ plugins: [],
1996
+ overrides: {},
1997
+ viewports: defaultViewports,
1998
+ zoomConfig: {
1999
+ autoZoom: 1,
2000
+ rootHeight: 0,
2001
+ zoom: 1
2002
+ },
2003
+ status: "LOADING",
2004
+ iframe: {},
2005
+ metadata: {}
2006
+ }, initialAppStore), {
2007
+ fields: createFieldsSlice(set, get),
2008
+ history: createHistorySlice(set, get),
2009
+ nodes: createNodesSlice(set, get),
2010
+ permissions: createPermissionsSlice(set, get),
2011
+ getComponentConfig: (type) => {
2012
+ var _a2;
2013
+ const { config, selectedItem } = get();
2014
+ const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
2015
+ return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
2016
+ },
2017
+ selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
2018
+ (_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
2019
+ initialAppStore.state
2020
+ ) : null,
2021
+ dispatch: (action) => set((s) => {
2022
+ var _a2, _b2;
2023
+ const { record } = get().history;
2024
+ const dispatch = createReducer({
2025
+ record,
2026
+ appStore: s
2027
+ });
2028
+ const state = dispatch(s.state, action);
2029
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2030
+ (_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
2031
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2032
+ }),
2033
+ setZoomConfig: (zoomConfig) => set({ zoomConfig }),
2034
+ setStatus: (status) => set({ status }),
2035
+ setComponentState: (componentState) => set({ componentState }),
2036
+ pendingLoadTimeouts: {},
2037
+ setComponentLoading: (id, loading = true, defer = 0) => {
2038
+ const { setComponentState, pendingLoadTimeouts } = get();
2039
+ const loadId = generateId();
2040
+ const setLoading = () => {
2041
+ var _a2;
2042
+ const { componentState } = get();
2043
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
2044
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2045
+ loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
2046
+ })
2047
+ }));
2048
+ };
2049
+ const unsetLoading = () => {
2050
+ var _a2;
2051
+ const { componentState } = get();
2052
+ clearTimeout(timeout3);
2053
+ delete pendingLoadTimeouts[loadId];
2054
+ set({ pendingLoadTimeouts });
2055
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
2056
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2057
+ loadingCount: Math.max(
2058
+ (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
2059
+ 0
2060
+ )
2061
+ })
2062
+ }));
2063
+ };
2064
+ const timeout3 = setTimeout(() => {
2065
+ if (loading) {
2066
+ setLoading();
2067
+ } else {
2068
+ unsetLoading();
2069
+ }
2070
+ delete pendingLoadTimeouts[loadId];
2071
+ set({ pendingLoadTimeouts });
2072
+ }, defer);
2073
+ set({
2074
+ pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
2075
+ [id]: timeout3
1971
2076
  })
1972
- }));
1973
- };
1974
- if (thisPendingComponentLoads[id]) {
1975
- clearTimeout(thisPendingComponentLoads[id]);
1976
- delete thisPendingComponentLoads[id];
1977
- set({ pendingComponentLoads: thisPendingComponentLoads });
1978
- }
1979
- const timeout3 = setTimeout(() => {
1980
- if (loading) {
1981
- setLoading();
1982
- } else {
1983
- unsetLoading();
1984
- }
1985
- delete thisPendingComponentLoads[id];
1986
- set({ pendingComponentLoads: thisPendingComponentLoads });
1987
- }, defer);
1988
- set({
1989
- pendingComponentLoads: __spreadProps(__spreadValues({}, thisPendingComponentLoads), {
1990
- [id]: timeout3
1991
- })
1992
- });
1993
- },
1994
- unsetComponentLoading: (id) => {
1995
- const { setComponentLoading } = get();
1996
- setComponentLoading(id, false);
1997
- },
1998
- // Helper
1999
- setUi: (ui, recordHistory) => set((s) => {
2000
- const dispatch = createReducer({
2001
- config: s.config,
2002
- record: () => {
2003
- },
2004
- appStore: s
2005
- });
2006
- const state = dispatch(s.state, {
2007
- type: "setUi",
2008
- ui,
2009
- recordHistory
2010
- });
2011
- const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2012
- return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2013
- }),
2014
- // resolveDataRuns: 0,
2015
- // resolveData: (newAppState) =>
2016
- // set((s) => {
2017
- // resolveData(newAppState, get);
2018
- // return { ...s, resolveDataRuns: s.resolveDataRuns + 1 };
2019
- // }),
2020
- resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
2021
- const { config, metadata, setComponentLoading } = get();
2022
- return yield resolveComponentData(
2023
- componentData,
2024
- config,
2025
- metadata,
2026
- (item) => setComponentLoading(
2027
- "id" in item.props ? item.props.id : "root",
2028
- true,
2029
- 50
2030
- ),
2031
- (item) => setComponentLoading(
2032
- "id" in item.props ? item.props.id : "root",
2033
- false,
2034
- 0
2035
- ),
2036
- trigger
2037
- );
2038
- }),
2039
- resolveAndCommitData: () => __async(void 0, null, function* () {
2040
- const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
2041
- walkTree(
2042
- state,
2043
- config,
2044
- (content) => content,
2045
- (childItem) => {
2046
- resolveComponentData2(childItem, "load").then((resolved) => {
2047
- const { state: state2 } = get();
2048
- const node = state2.indexes.nodes[resolved.node.props.id];
2049
- if (node && resolved.didChange) {
2050
- if (resolved.node.props.id === "root") {
2051
- dispatch({
2052
- type: "replaceRoot",
2053
- root: toRoot(resolved.node)
2054
- });
2055
- } else {
2056
- const zoneCompound = `${node.parentId}:${node.zone}`;
2057
- const parentZone = state2.indexes.zones[zoneCompound];
2058
- const index = parentZone.contentIds.indexOf(
2059
- resolved.node.props.id
2060
- );
2061
- dispatch({
2062
- type: "replace",
2063
- data: resolved.node,
2064
- destinationIndex: index,
2065
- destinationZone: zoneCompound
2066
- });
2067
- }
2077
+ });
2078
+ return unsetLoading;
2079
+ },
2080
+ unsetComponentLoading: (id) => {
2081
+ const { setComponentLoading } = get();
2082
+ setComponentLoading(id, false);
2083
+ },
2084
+ // Helper
2085
+ setUi: (ui, recordHistory) => set((s) => {
2086
+ const dispatch = createReducer({
2087
+ record: () => {
2088
+ },
2089
+ appStore: s
2090
+ });
2091
+ const state = dispatch(s.state, {
2092
+ type: "setUi",
2093
+ ui,
2094
+ recordHistory
2095
+ });
2096
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2097
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2098
+ }),
2099
+ resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
2100
+ const { config, metadata, setComponentLoading, permissions } = get();
2101
+ const timeouts = {};
2102
+ return yield resolveComponentData(
2103
+ componentData,
2104
+ config,
2105
+ metadata,
2106
+ (item) => {
2107
+ const id = "id" in item.props ? item.props.id : "root";
2108
+ timeouts[id] = setComponentLoading(id, true, 50);
2109
+ },
2110
+ (item) => __async(void 0, null, function* () {
2111
+ const id = "id" in item.props ? item.props.id : "root";
2112
+ if ("type" in item) {
2113
+ yield permissions.refreshPermissions({ item });
2114
+ } else {
2115
+ yield permissions.refreshPermissions({ root: true });
2068
2116
  }
2069
- });
2070
- return childItem;
2071
- }
2072
- );
2073
- })
2074
- }))
2117
+ timeouts[id]();
2118
+ }),
2119
+ trigger
2120
+ );
2121
+ }),
2122
+ resolveAndCommitData: () => __async(void 0, null, function* () {
2123
+ const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
2124
+ walkTree(
2125
+ state,
2126
+ config,
2127
+ (content) => content,
2128
+ (childItem) => {
2129
+ resolveComponentData2(childItem, "load").then((resolved) => {
2130
+ const { state: state2 } = get();
2131
+ const node = state2.indexes.nodes[resolved.node.props.id];
2132
+ if (node && resolved.didChange) {
2133
+ if (resolved.node.props.id === "root") {
2134
+ dispatch({
2135
+ type: "replaceRoot",
2136
+ root: toRoot(resolved.node)
2137
+ });
2138
+ } else {
2139
+ const zoneCompound = `${node.parentId}:${node.zone}`;
2140
+ const parentZone = state2.indexes.zones[zoneCompound];
2141
+ const index = parentZone.contentIds.indexOf(
2142
+ resolved.node.props.id
2143
+ );
2144
+ dispatch({
2145
+ type: "replace",
2146
+ data: resolved.node,
2147
+ destinationIndex: index,
2148
+ destinationZone: zoneCompound
2149
+ });
2150
+ }
2151
+ }
2152
+ });
2153
+ return childItem;
2154
+ }
2155
+ );
2156
+ })
2157
+ });
2158
+ })
2075
2159
  );
2076
2160
  var appStoreContext = createContext(createAppStore());
2077
2161
  function useAppStore(selector) {
@@ -2091,7 +2175,16 @@ init_react_import();
2091
2175
  // lib/filter.ts
2092
2176
  init_react_import();
2093
2177
 
2094
- // lib/replace.ts
2178
+ // lib/data/reorder.ts
2179
+ init_react_import();
2180
+ var reorder = (list, startIndex, endIndex) => {
2181
+ const result = Array.from(list);
2182
+ const [removed] = result.splice(startIndex, 1);
2183
+ result.splice(endIndex, 0, removed);
2184
+ return result;
2185
+ };
2186
+
2187
+ // lib/data/replace.ts
2095
2188
  init_react_import();
2096
2189
  var replace = (list, index, newItem) => {
2097
2190
  const result = Array.from(list);
@@ -2551,7 +2644,6 @@ var DropZoneProvider = ({
2551
2644
  value
2552
2645
  }) => {
2553
2646
  const [hoveringComponent, setHoveringComponent] = useState();
2554
- const [activeZones, setActiveZones] = useState({});
2555
2647
  const dispatch = useAppStore((s) => s.dispatch);
2556
2648
  const registerZone = useCallback2(
2557
2649
  (zoneCompound) => {
@@ -2560,7 +2652,7 @@ var DropZoneProvider = ({
2560
2652
  zone: zoneCompound
2561
2653
  });
2562
2654
  },
2563
- [setActiveZones, dispatch]
2655
+ [dispatch]
2564
2656
  );
2565
2657
  const unregisterZone = useCallback2(
2566
2658
  (zoneCompound) => {
@@ -2569,17 +2661,16 @@ var DropZoneProvider = ({
2569
2661
  zone: zoneCompound
2570
2662
  });
2571
2663
  },
2572
- [setActiveZones, dispatch]
2664
+ [dispatch]
2573
2665
  );
2574
2666
  const memoValue = useMemo2(
2575
2667
  () => __spreadValues({
2576
2668
  hoveringComponent,
2577
2669
  setHoveringComponent,
2578
2670
  registerZone,
2579
- unregisterZone,
2580
- activeZones
2671
+ unregisterZone
2581
2672
  }, value),
2582
- [value, hoveringComponent, activeZones]
2673
+ [value, hoveringComponent]
2583
2674
  );
2584
2675
  return /* @__PURE__ */ jsx3(Fragment, { children: memoValue && /* @__PURE__ */ jsx3(dropZoneContext.Provider, { value: memoValue, children }) });
2585
2676
  };
@@ -2672,8 +2763,10 @@ var DraggableComponent = ({
2672
2763
  return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
2673
2764
  }));
2674
2765
  const permissions = useAppStore(
2675
- useShallow2((s) => s.permissions.getPermissions())
2676
- // TODO call using id
2766
+ useShallow2((s) => {
2767
+ const item = getItem({ index, zone: zoneCompound }, s.state);
2768
+ return s.permissions.getPermissions({ item });
2769
+ })
2677
2770
  );
2678
2771
  const userIsDragging = useContextStore(
2679
2772
  ZoneStoreContext,
@@ -2927,76 +3020,82 @@ var DraggableComponent = ({
2927
3020
  setDragAxis(autoDragAxis);
2928
3021
  }, [ref, userDragAxis, autoDragAxis]);
2929
3022
  const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx4(CornerLeftUp, { size: 16 }) });
2930
- return /* @__PURE__ */ jsxs2(
2931
- DropZoneProvider,
2932
- {
2933
- value: __spreadProps(__spreadValues({}, ctx), {
2934
- areaId: id,
2935
- zoneCompound,
2936
- index,
2937
- depth: depth + 1,
2938
- registerLocalZone,
2939
- unregisterLocalZone
2940
- }),
2941
- children: [
2942
- isVisible && createPortal(
2943
- /* @__PURE__ */ jsxs2(
2944
- "div",
2945
- {
2946
- className: getClassName3({
2947
- isSelected,
2948
- isDragging: thisIsDragging,
2949
- hover: hover || indicativeHover
2950
- }),
2951
- style: __spreadValues({}, style),
2952
- "data-puck-overlay": true,
2953
- children: [
2954
- debug,
2955
- isLoading && /* @__PURE__ */ jsx4("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ jsx4(Loader, {}) }),
2956
- /* @__PURE__ */ jsx4(
3023
+ const nextContextValue = useMemo3(
3024
+ () => __spreadProps(__spreadValues({}, ctx), {
3025
+ areaId: id,
3026
+ zoneCompound,
3027
+ index,
3028
+ depth: depth + 1,
3029
+ registerLocalZone,
3030
+ unregisterLocalZone
3031
+ }),
3032
+ [
3033
+ ctx,
3034
+ id,
3035
+ zoneCompound,
3036
+ index,
3037
+ depth,
3038
+ registerLocalZone,
3039
+ unregisterLocalZone
3040
+ ]
3041
+ );
3042
+ return /* @__PURE__ */ jsxs2(DropZoneProvider, { value: nextContextValue, children: [
3043
+ isVisible && createPortal(
3044
+ /* @__PURE__ */ jsxs2(
3045
+ "div",
3046
+ {
3047
+ className: getClassName3({
3048
+ isSelected,
3049
+ isDragging: thisIsDragging,
3050
+ hover: hover || indicativeHover
3051
+ }),
3052
+ style: __spreadValues({}, style),
3053
+ "data-puck-overlay": true,
3054
+ children: [
3055
+ debug,
3056
+ isLoading && /* @__PURE__ */ jsx4("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ jsx4(Loader, {}) }),
3057
+ /* @__PURE__ */ jsx4(
3058
+ "div",
3059
+ {
3060
+ className: getClassName3("actionsOverlay"),
3061
+ style: {
3062
+ top: actionsOverlayTop / zoom
3063
+ },
3064
+ children: /* @__PURE__ */ jsx4(
2957
3065
  "div",
2958
3066
  {
2959
- className: getClassName3("actionsOverlay"),
3067
+ className: getClassName3("actions"),
2960
3068
  style: {
2961
- top: actionsOverlayTop / zoom
3069
+ transform: `scale(${1 / zoom}`,
3070
+ top: actionsTop / zoom,
3071
+ right: 0,
3072
+ paddingLeft: actionsSide,
3073
+ paddingRight: actionsSide
2962
3074
  },
2963
- children: /* @__PURE__ */ jsx4(
2964
- "div",
3075
+ ref: syncActionsPosition,
3076
+ children: /* @__PURE__ */ jsxs2(
3077
+ CustomActionBar,
2965
3078
  {
2966
- className: getClassName3("actions"),
2967
- style: {
2968
- transform: `scale(${1 / zoom}`,
2969
- top: actionsTop / zoom,
2970
- right: 0,
2971
- paddingLeft: actionsSide,
2972
- paddingRight: actionsSide
2973
- },
2974
- ref: syncActionsPosition,
2975
- children: /* @__PURE__ */ jsxs2(
2976
- CustomActionBar,
2977
- {
2978
- parentAction,
2979
- label: DEBUG2 ? id : label,
2980
- children: [
2981
- permissions.duplicate && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx4(Copy, { size: 16 }) }),
2982
- permissions.delete && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx4(Trash, { size: 16 }) })
2983
- ]
2984
- }
2985
- )
3079
+ parentAction,
3080
+ label: DEBUG2 ? id : label,
3081
+ children: [
3082
+ permissions.duplicate && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx4(Copy, { size: 16 }) }),
3083
+ permissions.delete && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx4(Trash, { size: 16 }) })
3084
+ ]
2986
3085
  }
2987
3086
  )
2988
3087
  }
2989
- ),
2990
- /* @__PURE__ */ jsx4("div", { className: getClassName3("overlay") })
2991
- ]
2992
- }
2993
- ),
2994
- portalEl || document.body
2995
- ),
2996
- children(refSetter)
2997
- ]
2998
- }
2999
- );
3088
+ )
3089
+ }
3090
+ ),
3091
+ /* @__PURE__ */ jsx4("div", { className: getClassName3("overlay") })
3092
+ ]
3093
+ }
3094
+ ),
3095
+ portalEl || document.body
3096
+ ),
3097
+ children(refSetter)
3098
+ ] });
3000
3099
  };
3001
3100
 
3002
3101
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
@@ -3023,7 +3122,7 @@ var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_def
3023
3122
  var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ jsx5("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ jsx5("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ jsx5("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
3024
3123
 
3025
3124
  // components/Drawer/index.tsx
3026
- import { useMemo as useMemo4, useState as useState6 } from "react";
3125
+ import { useMemo as useMemo5, useState as useState6 } from "react";
3027
3126
 
3028
3127
  // components/DragDropContext/index.tsx
3029
3128
  init_react_import();
@@ -3033,6 +3132,7 @@ import {
3033
3132
  useCallback as useCallback4,
3034
3133
  useContext as useContext4,
3035
3134
  useEffect as useEffect6,
3135
+ useMemo as useMemo4,
3036
3136
  useRef as useRef2,
3037
3137
  useState as useState5
3038
3138
  } from "react";
@@ -3308,8 +3408,8 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
3308
3408
  destinationZone: zone,
3309
3409
  id
3310
3410
  };
3311
- const { state, config, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
3312
- const insertedState = insertAction(state, insertActionData, config);
3411
+ const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
3412
+ const insertedState = insertAction(state, insertActionData, appStore);
3313
3413
  dispatch(__spreadProps(__spreadValues({}, insertActionData), {
3314
3414
  // Dispatch insert rather set, as user's may rely on this via onAction
3315
3415
  // We must always record history here so the insert is added to user history
@@ -3838,6 +3938,14 @@ var DragDropContextClient = ({
3838
3938
  const [dragListeners, setDragListeners] = useState5({});
3839
3939
  const dragMode = useRef2(null);
3840
3940
  const initialSelector = useRef2(void 0);
3941
+ const nextContextValue = useMemo4(
3942
+ () => ({
3943
+ mode: "edit",
3944
+ areaId: "root",
3945
+ depth: 0
3946
+ }),
3947
+ []
3948
+ );
3841
3949
  return /* @__PURE__ */ jsx6("div", { id, children: /* @__PURE__ */ jsx6(
3842
3950
  dragListenerContext.Provider,
3843
3951
  {
@@ -3879,7 +3987,6 @@ var DragDropContextClient = ({
3879
3987
  }
3880
3988
  if (thisPreview) {
3881
3989
  zoneStore.setState({ previewIndex: {} });
3882
- const state = appStore.getState().state;
3883
3990
  if (thisPreview.type === "insert") {
3884
3991
  insertComponent(
3885
3992
  thisPreview.componentType,
@@ -4036,17 +4143,7 @@ var DragDropContextClient = ({
4036
4143
  initialSelector.current = void 0;
4037
4144
  zoneStore.setState({ draggedItem: event.operation.source });
4038
4145
  },
4039
- children: /* @__PURE__ */ jsx6(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx6(
4040
- DropZoneProvider,
4041
- {
4042
- value: {
4043
- mode: "edit",
4044
- areaId: "root",
4045
- depth: 0
4046
- },
4047
- children
4048
- }
4049
- ) })
4146
+ children: /* @__PURE__ */ jsx6(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx6(DropZoneProvider, { value: nextContextValue, children }) })
4050
4147
  }
4051
4148
  )
4052
4149
  }
@@ -4074,7 +4171,7 @@ var DrawerItemInner = ({
4074
4171
  dragRef,
4075
4172
  isDragDisabled
4076
4173
  }) => {
4077
- const CustomInner = useMemo4(
4174
+ const CustomInner = useMemo5(
4078
4175
  () => children || (({ children: children2 }) => /* @__PURE__ */ jsx7("div", { className: getClassNameItem("default"), children: children2 })),
4079
4176
  [children]
4080
4177
  );
@@ -4368,30 +4465,60 @@ init_react_import();
4368
4465
  import { forwardRef as forwardRef3 } from "react";
4369
4466
  import { jsx as jsx8 } from "react/jsx-runtime";
4370
4467
  var SlotRenderPure = (props) => /* @__PURE__ */ jsx8(SlotRender, __spreadValues({}, props));
4468
+ var ContextSlotRender = ({
4469
+ componentId,
4470
+ zone
4471
+ }) => {
4472
+ const config = useAppStore((s) => s.config);
4473
+ const metadata = useAppStore((s) => s.metadata);
4474
+ const slotContent = useAppStore(
4475
+ (s) => {
4476
+ var _a, _b;
4477
+ return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
4478
+ }
4479
+ );
4480
+ return /* @__PURE__ */ jsx8(
4481
+ SlotRenderPure,
4482
+ {
4483
+ content: slotContent,
4484
+ zone,
4485
+ config,
4486
+ metadata
4487
+ }
4488
+ );
4489
+ };
4490
+ var Item = ({
4491
+ config,
4492
+ item,
4493
+ metadata
4494
+ }) => {
4495
+ const Component = config.components[item.type];
4496
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx8(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
4497
+ return /* @__PURE__ */ jsx8(
4498
+ Component.render,
4499
+ __spreadProps(__spreadValues({}, props), {
4500
+ puck: __spreadProps(__spreadValues({}, props.puck), {
4501
+ renderDropZone: DropZoneRenderPure,
4502
+ metadata: metadata || {}
4503
+ })
4504
+ })
4505
+ );
4506
+ };
4371
4507
  var SlotRender = forwardRef3(
4372
4508
  function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
4373
4509
  return /* @__PURE__ */ jsx8("div", { className, style, ref, children: content.map((item) => {
4374
- const Component = config.components[item.type];
4375
- if (Component) {
4376
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx8(
4377
- SlotRenderPure,
4378
- __spreadProps(__spreadValues({}, slotProps), {
4379
- config,
4380
- metadata
4381
- })
4382
- ));
4383
- return /* @__PURE__ */ jsx8(
4384
- Component.render,
4385
- __spreadProps(__spreadValues({}, props), {
4386
- puck: {
4387
- renderDropZone: DropZoneRenderPure,
4388
- metadata: metadata || {}
4389
- }
4390
- }),
4391
- props.id
4392
- );
4510
+ if (!config.components[item.type]) {
4511
+ return null;
4393
4512
  }
4394
- return null;
4513
+ return /* @__PURE__ */ jsx8(
4514
+ Item,
4515
+ {
4516
+ config,
4517
+ item,
4518
+ metadata
4519
+ },
4520
+ item.props.id
4521
+ );
4395
4522
  }) });
4396
4523
  }
4397
4524
  );
@@ -4414,14 +4541,8 @@ var DropZoneChild = ({
4414
4541
  }) => {
4415
4542
  var _a, _b;
4416
4543
  const metadata = useAppStore((s) => s.metadata);
4417
- const puckProps = {
4418
- renderDropZone: DropZoneEditPure,
4419
- isEditing: true,
4420
- dragRef: null,
4421
- metadata
4422
- };
4423
4544
  const ctx = useContext5(dropZoneContext);
4424
- const { depth } = ctx;
4545
+ const { depth = 1 } = ctx != null ? ctx : {};
4425
4546
  const nodeProps = useAppStore(
4426
4547
  useShallow3((s) => {
4427
4548
  var _a2;
@@ -4434,11 +4555,23 @@ var DropZoneChild = ({
4434
4555
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
4435
4556
  }
4436
4557
  );
4558
+ const nodeReadOnly = useAppStore(
4559
+ useShallow3((s) => {
4560
+ var _a2;
4561
+ return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
4562
+ })
4563
+ );
4437
4564
  const node = { type: nodeType, props: nodeProps };
4438
4565
  const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
4439
4566
  const componentConfig = useAppStore(
4440
4567
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
4441
4568
  );
4569
+ const puckProps = {
4570
+ renderDropZone: DropZoneEditPure,
4571
+ isEditing: true,
4572
+ dragRef: null,
4573
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
4574
+ };
4442
4575
  const overrides = useAppStore((s) => s.overrides);
4443
4576
  const isLoading = useAppStore(
4444
4577
  (s) => {
@@ -4453,13 +4586,13 @@ var DropZoneChild = ({
4453
4586
  }
4454
4587
  );
4455
4588
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
4456
- const renderPreview = useMemo5(
4589
+ const renderPreview = useMemo6(
4457
4590
  () => function Preview3() {
4458
4591
  return /* @__PURE__ */ jsx9(DrawerItemInner, { name: label, children: overrides.componentItem });
4459
4592
  },
4460
4593
  [componentId, label, overrides]
4461
4594
  );
4462
- const defaultsProps = useMemo5(
4595
+ const defaultsProps = useMemo6(
4463
4596
  () => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
4464
4597
  puck: puckProps,
4465
4598
  editMode: true
@@ -4470,7 +4603,10 @@ var DropZoneChild = ({
4470
4603
  const defaultedPropsWithSlots = useSlots(
4471
4604
  componentConfig,
4472
4605
  defaultsProps,
4473
- DropZoneEditPure
4606
+ DropZoneEditPure,
4607
+ (slotProps) => /* @__PURE__ */ jsx9(ContextSlotRender, { componentId, zone: slotProps.zone }),
4608
+ nodeReadOnly,
4609
+ isLoading
4474
4610
  );
4475
4611
  if (!item) return;
4476
4612
  let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ jsxs4("div", { style: { padding: 48, textAlign: "center" }, children: [
@@ -4508,6 +4644,7 @@ var DropZoneChild = ({
4508
4644
  }
4509
4645
  );
4510
4646
  };
4647
+ var DropZoneChildMemo = memo(DropZoneChild);
4511
4648
  var DropZoneEdit = forwardRef4(
4512
4649
  function DropZoneEditInternal({
4513
4650
  zone,
@@ -4522,10 +4659,10 @@ var DropZoneEdit = forwardRef4(
4522
4659
  const {
4523
4660
  // These all need setting via context
4524
4661
  areaId,
4525
- depth,
4662
+ depth = 0,
4526
4663
  registerLocalZone,
4527
4664
  unregisterLocalZone
4528
- } = ctx;
4665
+ } = ctx != null ? ctx : {};
4529
4666
  const path = useAppStore(
4530
4667
  useShallow3((s) => {
4531
4668
  var _a;
@@ -4567,6 +4704,11 @@ var DropZoneEdit = forwardRef4(
4567
4704
  );
4568
4705
  useEffect10(() => {
4569
4706
  if (!zoneType || zoneType === "dropzone") {
4707
+ if (zoneCompound !== rootDroppableId) {
4708
+ console.warn(
4709
+ "DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
4710
+ );
4711
+ }
4570
4712
  if (ctx == null ? void 0 : ctx.registerZone) {
4571
4713
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
4572
4714
  }
@@ -4577,7 +4719,7 @@ var DropZoneEdit = forwardRef4(
4577
4719
  };
4578
4720
  }
4579
4721
  }, [zoneType]);
4580
- const contentIds = useMemo5(() => {
4722
+ const contentIds = useMemo6(() => {
4581
4723
  return zoneContentIds || [];
4582
4724
  }, [zoneContentIds]);
4583
4725
  const ref = useRef3(null);
@@ -4672,7 +4814,7 @@ var DropZoneEdit = forwardRef4(
4672
4814
  }),
4673
4815
  children: contentIdsWithPreview.map((componentId, i) => {
4674
4816
  return /* @__PURE__ */ jsx9(
4675
- DropZoneChild,
4817
+ DropZoneChildMemo,
4676
4818
  {
4677
4819
  zoneCompound,
4678
4820
  componentId,
@@ -4690,6 +4832,30 @@ var DropZoneEdit = forwardRef4(
4690
4832
  );
4691
4833
  }
4692
4834
  );
4835
+ var DropZoneRenderItem = ({
4836
+ config,
4837
+ item,
4838
+ metadata
4839
+ }) => {
4840
+ const Component = config.components[item.type];
4841
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx9(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
4842
+ const nextContextValue = useMemo6(
4843
+ () => ({
4844
+ areaId: props.id,
4845
+ depth: 1
4846
+ }),
4847
+ [props]
4848
+ );
4849
+ return /* @__PURE__ */ jsx9(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx9(
4850
+ Component.render,
4851
+ __spreadProps(__spreadValues({}, props), {
4852
+ puck: __spreadProps(__spreadValues({}, props.puck), {
4853
+ renderDropZone: DropZoneRenderPure,
4854
+ metadata: __spreadValues(__spreadValues({}, metadata), Component.metadata)
4855
+ })
4856
+ })
4857
+ ) }, props.id);
4858
+ };
4693
4859
  var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx9(DropZoneRender, __spreadValues({}, props));
4694
4860
  var DropZoneRender = forwardRef4(
4695
4861
  function DropZoneRenderInternal({ className, style, zone }, ref) {
@@ -4720,31 +4886,14 @@ var DropZoneRender = forwardRef4(
4720
4886
  return /* @__PURE__ */ jsx9("div", { className, style, ref, children: content.map((item) => {
4721
4887
  const Component = config.components[item.type];
4722
4888
  if (Component) {
4723
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx9(
4724
- SlotRenderPure,
4725
- __spreadProps(__spreadValues({}, slotProps), {
4726
- config,
4727
- metadata
4728
- })
4729
- ));
4730
4889
  return /* @__PURE__ */ jsx9(
4731
- DropZoneProvider,
4890
+ DropZoneRenderItem,
4732
4891
  {
4733
- value: {
4734
- areaId: props.id,
4735
- depth: 1
4736
- },
4737
- children: /* @__PURE__ */ jsx9(
4738
- Component.render,
4739
- __spreadProps(__spreadValues({}, props), {
4740
- puck: {
4741
- renderDropZone: DropZoneRenderPure,
4742
- metadata: metadata || {}
4743
- }
4744
- })
4745
- )
4892
+ config,
4893
+ item,
4894
+ metadata
4746
4895
  },
4747
- props.id
4896
+ item.props.id
4748
4897
  );
4749
4898
  }
4750
4899
  return null;
@@ -4763,7 +4912,7 @@ var DropZone = forwardRef4(
4763
4912
  );
4764
4913
 
4765
4914
  // components/Render/index.tsx
4766
- import React3 from "react";
4915
+ import React3, { useMemo as useMemo7 } from "react";
4767
4916
  import { jsx as jsx10 } from "react/jsx-runtime";
4768
4917
  var renderContext = React3.createContext({
4769
4918
  config: { components: {} },
@@ -4794,34 +4943,23 @@ function Render({
4794
4943
  id: "puck-root"
4795
4944
  });
4796
4945
  const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ jsx10(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
4946
+ const nextContextValue = useMemo7(
4947
+ () => ({
4948
+ mode: "render",
4949
+ depth: 0
4950
+ }),
4951
+ []
4952
+ );
4797
4953
  if ((_a = config.root) == null ? void 0 : _a.render) {
4798
- return /* @__PURE__ */ jsx10(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx10(
4799
- DropZoneProvider,
4800
- {
4801
- value: {
4802
- mode: "render",
4803
- depth: 0
4804
- },
4805
- children: /* @__PURE__ */ jsx10(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx10(DropZoneRenderPure, { zone: rootZone }) }))
4806
- }
4807
- ) });
4954
+ return /* @__PURE__ */ jsx10(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx10(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx10(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx10(DropZoneRenderPure, { zone: rootZone }) })) }) });
4808
4955
  }
4809
- return /* @__PURE__ */ jsx10(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx10(
4810
- DropZoneProvider,
4811
- {
4812
- value: {
4813
- mode: "render",
4814
- depth: 0
4815
- },
4816
- children: /* @__PURE__ */ jsx10(DropZoneRenderPure, { zone: rootZone })
4817
- }
4818
- ) });
4956
+ return /* @__PURE__ */ jsx10(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx10(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx10(DropZoneRenderPure, { zone: rootZone }) }) });
4819
4957
  }
4820
4958
 
4821
4959
  // lib/transform-props.ts
4822
4960
  init_react_import();
4823
4961
 
4824
- // lib/default-data.ts
4962
+ // lib/data/default-data.ts
4825
4963
  init_react_import();
4826
4964
  var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
4827
4965
  root: data.root || {},
@@ -4864,7 +5002,7 @@ function transformProps(data, propTransforms) {
4864
5002
  // lib/resolve-all-data.ts
4865
5003
  init_react_import();
4866
5004
 
4867
- // lib/to-component.ts
5005
+ // lib/data/to-component.ts
4868
5006
  init_react_import();
4869
5007
  var toComponent = (item) => {
4870
5008
  return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
@@ -4892,17 +5030,29 @@ function resolveAllData(_0, _1) {
4892
5030
  "force",
4893
5031
  false
4894
5032
  )).node;
4895
- const resolvedDeep = yield mapSlots(resolved, processContent, false);
5033
+ const resolvedDeep = yield mapSlotsAsync(
5034
+ resolved,
5035
+ processContent,
5036
+ false
5037
+ );
4896
5038
  onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
4897
5039
  return resolvedDeep;
4898
5040
  });
4899
5041
  const processContent = (content) => __async(this, null, function* () {
4900
5042
  return Promise.all(content.map(resolveNode));
4901
5043
  });
5044
+ const processZones = () => __async(this, null, function* () {
5045
+ var _a2;
5046
+ const zones = (_a2 = data.zones) != null ? _a2 : {};
5047
+ Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
5048
+ zones[zoneKey] = yield Promise.all(content.map(resolveNode));
5049
+ }));
5050
+ return zones;
5051
+ });
4902
5052
  const dynamic = {
4903
5053
  root: yield resolveNode(defaultedData.root),
4904
5054
  content: yield processContent(defaultedData.content),
4905
- zones: {}
5055
+ zones: yield processZones()
4906
5056
  };
4907
5057
  Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
4908
5058
  const content = defaultedData.zones[zoneKey];
@@ -4958,8 +5108,10 @@ export {
4958
5108
  rootAreaId,
4959
5109
  rootZone,
4960
5110
  rootDroppableId,
4961
- setupZone,
4962
5111
  walkTree,
5112
+ getItem,
5113
+ setupZone,
5114
+ makeStatePublic,
4963
5115
  defaultViewports,
4964
5116
  monitorHotkeys,
4965
5117
  useMonitorHotkeys,
@@ -4967,6 +5119,7 @@ export {
4967
5119
  useRegisterHistorySlice,
4968
5120
  useRegisterPermissionsSlice,
4969
5121
  useRegisterFieldsSlice,
5122
+ mapSlotsPublic,
4970
5123
  defaultAppState,
4971
5124
  createAppStore,
4972
5125
  appStoreContext,