@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.
- package/README.md +1 -0
- package/dist/{chunk-SYX4T2Z2.mjs → chunk-ZOHJNF5K.mjs} +899 -746
- package/dist/index.css +44 -38
- package/dist/index.d.mts +18 -8
- package/dist/index.d.ts +18 -8
- package/dist/index.js +997 -795
- package/dist/index.mjs +131 -77
- package/dist/{resolve-all-data-Cs8PfTrg.d.mts → resolve-all-data-BFRAghCj.d.mts} +5 -1
- package/dist/{resolve-all-data-Cs8PfTrg.d.ts → resolve-all-data-BFRAghCj.d.ts} +5 -1
- package/dist/rsc.css +12 -11
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +804 -672
- package/dist/rsc.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -176,6 +176,7 @@ __export(core_exports, {
|
|
176
176
|
Puck: () => Puck,
|
177
177
|
Render: () => Render,
|
178
178
|
createUsePuck: () => createUsePuck,
|
179
|
+
mapSlots: () => mapSlotsPublic,
|
179
180
|
migrate: () => migrate,
|
180
181
|
overrideKeys: () => overrideKeys,
|
181
182
|
renderContext: () => renderContext,
|
@@ -308,7 +309,7 @@ init_react_import();
|
|
308
309
|
|
309
310
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
310
311
|
init_react_import();
|
311
|
-
var styles_module_default2 = { "InputWrapper": "
|
312
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_4xor1_1", "Input-label": "_Input-label_4xor1_5", "Input-labelIcon": "_Input-labelIcon_4xor1_14", "Input-disabledIcon": "_Input-disabledIcon_4xor1_21", "Input-input": "_Input-input_4xor1_26", "Input": "_Input_4xor1_1", "Input--readOnly": "_Input--readOnly_4xor1_75", "Input-radioGroupItems": "_Input-radioGroupItems_4xor1_86", "Input-radio": "_Input-radio_4xor1_86", "Input-radioInner": "_Input-radioInner_4xor1_103", "Input-radioInput": "_Input-radioInput_4xor1_148" };
|
312
313
|
|
313
314
|
// components/AutoField/index.tsx
|
314
315
|
var import_react22 = require("react");
|
@@ -670,7 +671,7 @@ init_react_import();
|
|
670
671
|
// lib/filter.ts
|
671
672
|
init_react_import();
|
672
673
|
|
673
|
-
// lib/reorder.ts
|
674
|
+
// lib/data/reorder.ts
|
674
675
|
init_react_import();
|
675
676
|
var reorder = (list, startIndex, endIndex) => {
|
676
677
|
const result = Array.from(list);
|
@@ -679,7 +680,7 @@ var reorder = (list, startIndex, endIndex) => {
|
|
679
680
|
return result;
|
680
681
|
};
|
681
682
|
|
682
|
-
// lib/replace.ts
|
683
|
+
// lib/data/replace.ts
|
683
684
|
init_react_import();
|
684
685
|
var replace = (list, index, newItem) => {
|
685
686
|
const result = Array.from(list);
|
@@ -791,74 +792,30 @@ init_react_import();
|
|
791
792
|
// reducer/index.ts
|
792
793
|
init_react_import();
|
793
794
|
|
794
|
-
// reducer/
|
795
|
+
// reducer/actions/set.ts
|
795
796
|
init_react_import();
|
796
797
|
|
797
|
-
// lib/
|
798
|
+
// lib/data/walk-tree.ts
|
798
799
|
init_react_import();
|
799
|
-
var insert = (list, index, item) => {
|
800
|
-
const result = Array.from(list || []);
|
801
|
-
result.splice(index, 0, item);
|
802
|
-
return result;
|
803
|
-
};
|
804
800
|
|
805
|
-
// lib/
|
801
|
+
// lib/data/for-each-slot.ts
|
806
802
|
init_react_import();
|
807
|
-
var remove = (list, index) => {
|
808
|
-
const result = Array.from(list);
|
809
|
-
result.splice(index, 1);
|
810
|
-
return result;
|
811
|
-
};
|
812
803
|
|
813
|
-
// lib/
|
814
|
-
init_react_import();
|
815
|
-
|
816
|
-
// lib/root-droppable-id.ts
|
817
|
-
init_react_import();
|
818
|
-
var rootAreaId = "root";
|
819
|
-
var rootZone = "default-zone";
|
820
|
-
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
821
|
-
|
822
|
-
// lib/setup-zone.ts
|
823
|
-
var setupZone = (data, zoneKey) => {
|
824
|
-
if (zoneKey === rootDroppableId) {
|
825
|
-
return data;
|
826
|
-
}
|
827
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
828
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
829
|
-
});
|
830
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
831
|
-
return newData;
|
832
|
-
};
|
833
|
-
|
834
|
-
// lib/get-item.ts
|
835
|
-
init_react_import();
|
836
|
-
function getItem(selector, state) {
|
837
|
-
var _a, _b;
|
838
|
-
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
839
|
-
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
840
|
-
}
|
841
|
-
|
842
|
-
// lib/generate-id.ts
|
843
|
-
init_react_import();
|
844
|
-
var import_uuid = require("uuid");
|
845
|
-
var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, import_uuid.v4)();
|
846
|
-
|
847
|
-
// lib/walk-tree.ts
|
848
|
-
init_react_import();
|
849
|
-
|
850
|
-
// lib/for-each-slot.ts
|
851
|
-
init_react_import();
|
852
|
-
|
853
|
-
// lib/is-slot.ts
|
804
|
+
// lib/data/is-slot.ts
|
854
805
|
init_react_import();
|
855
806
|
var isSlot = (prop) => {
|
856
807
|
var _a, _b;
|
857
808
|
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
858
809
|
};
|
810
|
+
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
811
|
+
var _a, _b;
|
812
|
+
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
813
|
+
if (!configForComponent) return isSlot(propValue);
|
814
|
+
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
815
|
+
};
|
859
816
|
|
860
|
-
// lib/for-each-slot.ts
|
861
|
-
var forEachSlot = (
|
817
|
+
// lib/data/for-each-slot.ts
|
818
|
+
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
862
819
|
const props = item.props || {};
|
863
820
|
const propKeys = Object.keys(props);
|
864
821
|
for (let i = 0; i < propKeys.length; i++) {
|
@@ -866,23 +823,31 @@ var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function*
|
|
866
823
|
const itemType = "type" in item ? item.type : "root";
|
867
824
|
if (isSlot2(itemType, propKey, props[propKey])) {
|
868
825
|
const content = props[propKey];
|
869
|
-
|
826
|
+
cb(props.id, propKey, content);
|
870
827
|
if (recursive) {
|
871
828
|
content.forEach(
|
872
829
|
(childItem) => __async(void 0, null, function* () {
|
873
|
-
return
|
830
|
+
return forEachSlot(childItem, cb, true, isSlot2);
|
874
831
|
})
|
875
832
|
);
|
876
833
|
}
|
877
834
|
}
|
878
835
|
}
|
879
|
-
}
|
836
|
+
};
|
880
837
|
|
881
|
-
// lib/for-related-zones.ts
|
838
|
+
// lib/data/for-related-zones.ts
|
882
839
|
init_react_import();
|
883
840
|
|
884
841
|
// lib/get-zone-id.ts
|
885
842
|
init_react_import();
|
843
|
+
|
844
|
+
// lib/root-droppable-id.ts
|
845
|
+
init_react_import();
|
846
|
+
var rootAreaId = "root";
|
847
|
+
var rootZone = "default-zone";
|
848
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
849
|
+
|
850
|
+
// lib/get-zone-id.ts
|
886
851
|
var getZoneId = (zoneCompound) => {
|
887
852
|
if (!zoneCompound) {
|
888
853
|
return [];
|
@@ -893,19 +858,17 @@ var getZoneId = (zoneCompound) => {
|
|
893
858
|
return [rootDroppableId, zoneCompound];
|
894
859
|
};
|
895
860
|
|
896
|
-
// lib/for-related-zones.ts
|
861
|
+
// lib/data/for-related-zones.ts
|
897
862
|
function forRelatedZones(item, data, cb, path = []) {
|
898
863
|
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
899
864
|
const [parentId] = getZoneId(zoneCompound);
|
900
865
|
if (parentId === item.props.id) {
|
901
|
-
const newPath = [...path, zoneCompound];
|
902
|
-
content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
|
903
866
|
cb(path, zoneCompound, content);
|
904
867
|
}
|
905
868
|
});
|
906
869
|
}
|
907
870
|
|
908
|
-
// lib/strip-slots.ts
|
871
|
+
// lib/data/strip-slots.ts
|
909
872
|
init_react_import();
|
910
873
|
var stripSlots = (data) => {
|
911
874
|
return __spreadProps(__spreadValues({}, data), {
|
@@ -921,7 +884,7 @@ var stripSlots = (data) => {
|
|
921
884
|
});
|
922
885
|
};
|
923
886
|
|
924
|
-
// lib/walk-tree.ts
|
887
|
+
// lib/data/walk-tree.ts
|
925
888
|
function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
926
889
|
var _a;
|
927
890
|
let newZones = {};
|
@@ -963,7 +926,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
963
926
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
964
927
|
if (!mappedItem) return item;
|
965
928
|
const id = mappedItem.props.id;
|
966
|
-
processRelatedZones(item, id, path);
|
967
929
|
const newProps = __spreadValues({}, mappedItem.props);
|
968
930
|
forEachSlot(
|
969
931
|
mappedItem,
|
@@ -979,13 +941,9 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
979
941
|
newProps[slotId] = newContent2;
|
980
942
|
},
|
981
943
|
false,
|
982
|
-
(
|
983
|
-
var _a2, _b;
|
984
|
-
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
985
|
-
if (!configForComponent) return isSlot(propValue);
|
986
|
-
return ((_b = (_a2 = configForComponent.fields) == null ? void 0 : _a2[propName]) == null ? void 0 : _b.type) === "slot";
|
987
|
-
}
|
944
|
+
createIsSlotConfig(config)
|
988
945
|
);
|
946
|
+
processRelatedZones(item, id, path);
|
989
947
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
990
948
|
const thisZoneCompound = path[path.length - 1];
|
991
949
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
@@ -996,7 +954,7 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
996
954
|
parentId,
|
997
955
|
zone
|
998
956
|
};
|
999
|
-
const finalData = newItem;
|
957
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
1000
958
|
if (newProps.id === "root") {
|
1001
959
|
delete finalData["type"];
|
1002
960
|
delete finalData.props["id"];
|
@@ -1011,8 +969,12 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
1011
969
|
"root"
|
1012
970
|
);
|
1013
971
|
const processedContent = newContent;
|
972
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
1014
973
|
Object.keys(zones || {}).forEach((zoneCompound) => {
|
1015
974
|
const [parentId] = zoneCompound.split(":");
|
975
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
976
|
+
return;
|
977
|
+
}
|
1016
978
|
const [_2, newContent2] = processContent(
|
1017
979
|
[rootDroppableId],
|
1018
980
|
zoneCompound,
|
@@ -1036,7 +998,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
1036
998
|
return __spreadProps(__spreadValues({}, state), {
|
1037
999
|
data: {
|
1038
1000
|
root,
|
1039
|
-
// root: state.data.root, // TODO changing root causes it's entire subtree to re-render. Let's keep this disabled until the performance issues are resolved in #644.
|
1040
1001
|
content: processedContent,
|
1041
1002
|
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
1042
1003
|
},
|
@@ -1047,59 +1008,59 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
1047
1008
|
});
|
1048
1009
|
}
|
1049
1010
|
|
1050
|
-
//
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
delete nodes[subItem.props.id];
|
1060
|
-
});
|
1061
|
-
delete zones[zoneCompound];
|
1062
|
-
});
|
1063
|
-
};
|
1064
|
-
const dindexChildren = (item) => {
|
1065
|
-
forEachSlot(
|
1066
|
-
item,
|
1067
|
-
(parentId, slotId, content) => {
|
1068
|
-
const zoneCompound = `${parentId}:${slotId}`;
|
1069
|
-
delete zones[zoneCompound];
|
1070
|
-
content.forEach((item2) => {
|
1071
|
-
dindexRelatedZones(item2);
|
1072
|
-
delete nodes[item2.props.id];
|
1073
|
-
});
|
1074
|
-
},
|
1075
|
-
true
|
1011
|
+
// reducer/actions/set.ts
|
1012
|
+
var setAction = (state, action, appStore) => {
|
1013
|
+
if (typeof action.state === "object") {
|
1014
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
1015
|
+
if (action.state.indexes) {
|
1016
|
+
return newState;
|
1017
|
+
}
|
1018
|
+
console.warn(
|
1019
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1076
1020
|
);
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
delete nodes[componentData.props.id];
|
1081
|
-
return { nodes, zones };
|
1021
|
+
return walkTree(newState, appStore.config);
|
1022
|
+
}
|
1023
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
1082
1024
|
};
|
1083
1025
|
|
1084
|
-
// reducer/
|
1085
|
-
|
1026
|
+
// reducer/actions/insert.ts
|
1027
|
+
init_react_import();
|
1028
|
+
|
1029
|
+
// lib/data/insert.ts
|
1030
|
+
init_react_import();
|
1031
|
+
var insert = (list, index, item) => {
|
1032
|
+
const result = Array.from(list || []);
|
1033
|
+
result.splice(index, 0, item);
|
1034
|
+
return result;
|
1035
|
+
};
|
1036
|
+
|
1037
|
+
// lib/generate-id.ts
|
1038
|
+
init_react_import();
|
1039
|
+
var import_uuid = require("uuid");
|
1040
|
+
var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, import_uuid.v4)();
|
1041
|
+
|
1042
|
+
// lib/data/get-ids-for-parent.ts
|
1043
|
+
init_react_import();
|
1086
1044
|
var getIdsForParent = (zoneCompound, state) => {
|
1087
1045
|
const [parentId] = zoneCompound.split(":");
|
1088
1046
|
const node = state.indexes.nodes[parentId];
|
1089
1047
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
1090
1048
|
};
|
1091
|
-
|
1049
|
+
|
1050
|
+
// reducer/actions/insert.ts
|
1051
|
+
function insertAction(state, action, appStore) {
|
1092
1052
|
const id = action.id || generateId(action.componentType);
|
1093
1053
|
const emptyComponentData = {
|
1094
1054
|
type: action.componentType,
|
1095
|
-
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
1055
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
1096
1056
|
id
|
1097
1057
|
})
|
1098
1058
|
};
|
1099
1059
|
const [parentId] = action.destinationZone.split(":");
|
1060
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1100
1061
|
return walkTree(
|
1101
1062
|
state,
|
1102
|
-
config,
|
1063
|
+
appStore.config,
|
1103
1064
|
(content, zoneCompound) => {
|
1104
1065
|
if (zoneCompound === action.destinationZone) {
|
1105
1066
|
return insert(
|
@@ -1110,44 +1071,41 @@ function insertAction(state, action, config) {
|
|
1110
1071
|
}
|
1111
1072
|
return content;
|
1112
1073
|
},
|
1113
|
-
(childItem) => {
|
1074
|
+
(childItem, path) => {
|
1114
1075
|
if (childItem.props.id === id || childItem.props.id === parentId) {
|
1115
1076
|
return childItem;
|
1077
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
1078
|
+
return childItem;
|
1079
|
+
} else if (path.includes(action.destinationZone)) {
|
1080
|
+
return childItem;
|
1116
1081
|
}
|
1117
1082
|
return null;
|
1118
1083
|
}
|
1119
1084
|
);
|
1120
1085
|
}
|
1121
|
-
|
1086
|
+
|
1087
|
+
// reducer/actions/replace.ts
|
1088
|
+
init_react_import();
|
1089
|
+
var replaceAction = (state, action, appStore) => {
|
1090
|
+
const [parentId] = action.destinationZone.split(":");
|
1091
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1092
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
1093
|
+
const idChanged = originalId !== action.data.props.id;
|
1094
|
+
if (idChanged) {
|
1095
|
+
throw new Error(
|
1096
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1097
|
+
);
|
1098
|
+
}
|
1122
1099
|
return walkTree(
|
1123
1100
|
state,
|
1124
1101
|
appStore.config,
|
1125
1102
|
(content, zoneCompound) => {
|
1103
|
+
const newContent = [...content];
|
1126
1104
|
if (zoneCompound === action.destinationZone) {
|
1127
|
-
|
1128
|
-
content || [],
|
1129
|
-
action.sourceIndex,
|
1130
|
-
action.destinationIndex
|
1131
|
-
);
|
1105
|
+
newContent[action.destinationIndex] = action.data;
|
1132
1106
|
}
|
1133
|
-
return
|
1107
|
+
return newContent;
|
1134
1108
|
},
|
1135
|
-
(childItem, path, index) => {
|
1136
|
-
const zoneCompound = path[path.length - 1];
|
1137
|
-
if (index === action.sourceIndex && zoneCompound === action.destinationZone || index === action.destinationIndex && zoneCompound === action.destinationZone) {
|
1138
|
-
return childItem;
|
1139
|
-
}
|
1140
|
-
return null;
|
1141
|
-
}
|
1142
|
-
);
|
1143
|
-
};
|
1144
|
-
var replaceAction = (state, action, appStore) => {
|
1145
|
-
const [parentId] = action.destinationZone.split(":");
|
1146
|
-
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1147
|
-
return walkTree(
|
1148
|
-
state,
|
1149
|
-
appStore.config,
|
1150
|
-
(content) => content,
|
1151
1109
|
(childItem, path) => {
|
1152
1110
|
const pathIds = path.map((p) => p.split(":")[0]);
|
1153
1111
|
if (childItem.props.id === action.data.props.id) {
|
@@ -1163,226 +1121,297 @@ var replaceAction = (state, action, appStore) => {
|
|
1163
1121
|
}
|
1164
1122
|
);
|
1165
1123
|
};
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1124
|
+
|
1125
|
+
// reducer/actions/replace-root.ts
|
1126
|
+
init_react_import();
|
1127
|
+
var replaceRootAction = (state, action, appStore) => {
|
1128
|
+
return walkTree(
|
1129
|
+
state,
|
1130
|
+
appStore.config,
|
1131
|
+
(content) => content,
|
1132
|
+
(childItem) => {
|
1133
|
+
if (childItem.props.id === "root") {
|
1134
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1135
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1136
|
+
readOnly: action.root.readOnly
|
1137
|
+
});
|
1138
|
+
}
|
1139
|
+
return childItem;
|
1174
1140
|
}
|
1175
|
-
|
1176
|
-
}
|
1177
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
1141
|
+
);
|
1178
1142
|
};
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1143
|
+
|
1144
|
+
// reducer/actions/duplicate.ts
|
1145
|
+
init_react_import();
|
1146
|
+
|
1147
|
+
// lib/data/get-item.ts
|
1148
|
+
init_react_import();
|
1149
|
+
function getItem(selector, state) {
|
1150
|
+
var _a, _b;
|
1151
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1152
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
// reducer/actions/duplicate.ts
|
1156
|
+
function duplicateAction(state, action, appStore) {
|
1157
|
+
const item = getItem(
|
1158
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1159
|
+
state
|
1160
|
+
);
|
1161
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1162
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1163
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1164
|
+
id: generateId(item.type)
|
1165
|
+
})
|
1166
|
+
});
|
1167
|
+
const modified = walkTree(
|
1168
|
+
state,
|
1169
|
+
appStore.config,
|
1170
|
+
(content, zoneCompound) => {
|
1171
|
+
if (zoneCompound === action.sourceZone) {
|
1172
|
+
return insert(content, action.sourceIndex + 1, item);
|
1173
|
+
}
|
1174
|
+
return content;
|
1175
|
+
},
|
1176
|
+
(childItem, path, index) => {
|
1177
|
+
const zoneCompound = path[path.length - 1];
|
1178
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1179
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1180
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1181
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1182
|
+
id: generateId(childItem.type)
|
1183
|
+
})
|
1184
|
+
});
|
1185
|
+
}
|
1186
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1187
|
+
return newItem;
|
1188
|
+
}
|
1189
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1190
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1201
1191
|
return childItem;
|
1202
1192
|
}
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
1212
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
1213
|
-
id: generateId(item.type)
|
1214
|
-
})
|
1215
|
-
});
|
1216
|
-
const modified = walkTree(
|
1217
|
-
state,
|
1218
|
-
appStore.config,
|
1219
|
-
(content, zoneCompound) => {
|
1220
|
-
if (zoneCompound === action.sourceZone) {
|
1221
|
-
return insert(content, action.sourceIndex + 1, item);
|
1222
|
-
}
|
1223
|
-
return content;
|
1224
|
-
},
|
1225
|
-
(childItem, path, index) => {
|
1226
|
-
const zoneCompound = path[path.length - 1];
|
1227
|
-
const parents = path.map((p) => p.split(":")[0]);
|
1228
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
1229
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
1230
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1231
|
-
id: generateId(childItem.type)
|
1232
|
-
})
|
1233
|
-
});
|
1234
|
-
}
|
1235
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1236
|
-
return newItem;
|
1237
|
-
}
|
1238
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
1239
|
-
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1240
|
-
return childItem;
|
1241
|
-
}
|
1242
|
-
return null;
|
1193
|
+
return null;
|
1194
|
+
}
|
1195
|
+
);
|
1196
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1197
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1198
|
+
itemSelector: {
|
1199
|
+
index: action.sourceIndex + 1,
|
1200
|
+
zone: action.sourceZone
|
1243
1201
|
}
|
1244
|
-
)
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1202
|
+
})
|
1203
|
+
});
|
1204
|
+
}
|
1205
|
+
|
1206
|
+
// reducer/actions/reorder.ts
|
1207
|
+
init_react_import();
|
1208
|
+
|
1209
|
+
// reducer/actions/move.ts
|
1210
|
+
init_react_import();
|
1211
|
+
|
1212
|
+
// lib/data/remove.ts
|
1213
|
+
init_react_import();
|
1214
|
+
var remove = (list, index) => {
|
1215
|
+
const result = Array.from(list);
|
1216
|
+
result.splice(index, 1);
|
1217
|
+
return result;
|
1218
|
+
};
|
1219
|
+
|
1220
|
+
// reducer/actions/move.ts
|
1221
|
+
var moveAction = (state, action, appStore) => {
|
1222
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1223
|
+
return state;
|
1256
1224
|
}
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1225
|
+
const item = getItem(
|
1226
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
1227
|
+
state
|
1228
|
+
);
|
1229
|
+
if (!item) return state;
|
1230
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1231
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1232
|
+
return walkTree(
|
1233
|
+
state,
|
1234
|
+
appStore.config,
|
1235
|
+
(content, zoneCompound) => {
|
1236
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1237
|
+
return insert(
|
1238
|
+
remove(content, action.sourceIndex),
|
1239
|
+
action.destinationIndex,
|
1240
|
+
item
|
1241
|
+
);
|
1242
|
+
} else if (zoneCompound === action.sourceZone) {
|
1243
|
+
return remove(content, action.sourceIndex);
|
1244
|
+
} else if (zoneCompound === action.destinationZone) {
|
1245
|
+
return insert(content, action.destinationIndex, item);
|
1246
|
+
}
|
1247
|
+
return content;
|
1248
|
+
},
|
1249
|
+
(childItem, path) => {
|
1250
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1251
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
1252
|
+
const childId = childItem.props.id;
|
1253
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
1254
|
+
return childItem;
|
1255
|
+
}
|
1256
|
+
return null;
|
1260
1257
|
}
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
(
|
1286
|
-
|
1287
|
-
|
1288
|
-
const childId = childItem.props.id;
|
1289
|
-
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1) {
|
1290
|
-
return childItem;
|
1291
|
-
}
|
1292
|
-
return null;
|
1258
|
+
);
|
1259
|
+
};
|
1260
|
+
|
1261
|
+
// reducer/actions/reorder.ts
|
1262
|
+
var reorderAction = (state, action, appStore) => {
|
1263
|
+
return moveAction(
|
1264
|
+
state,
|
1265
|
+
{
|
1266
|
+
type: "move",
|
1267
|
+
sourceIndex: action.sourceIndex,
|
1268
|
+
sourceZone: action.destinationZone,
|
1269
|
+
destinationIndex: action.destinationIndex,
|
1270
|
+
destinationZone: action.destinationZone
|
1271
|
+
},
|
1272
|
+
appStore
|
1273
|
+
);
|
1274
|
+
};
|
1275
|
+
|
1276
|
+
// reducer/actions/remove.ts
|
1277
|
+
init_react_import();
|
1278
|
+
var removeAction = (state, action, appStore) => {
|
1279
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1280
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1281
|
+
(acc, [nodeId, nodeData]) => {
|
1282
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1283
|
+
if (pathIds.includes(item.props.id)) {
|
1284
|
+
return [...acc, nodeId];
|
1293
1285
|
}
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
if (zoneCompound === action.zone) {
|
1305
|
-
return remove(content, action.index);
|
1306
|
-
}
|
1307
|
-
return content;
|
1308
|
-
},
|
1309
|
-
(childItem, path) => {
|
1310
|
-
const parentIds = path.map((p) => p.split(":")[0]);
|
1311
|
-
if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
|
1312
|
-
return childItem;
|
1313
|
-
}
|
1314
|
-
return null;
|
1286
|
+
return acc;
|
1287
|
+
},
|
1288
|
+
[item.props.id]
|
1289
|
+
);
|
1290
|
+
const newState = walkTree(
|
1291
|
+
state,
|
1292
|
+
appStore.config,
|
1293
|
+
(content, zoneCompound) => {
|
1294
|
+
if (zoneCompound === action.zone) {
|
1295
|
+
return remove(content, action.index);
|
1315
1296
|
}
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
[action.zone]: zoneCache[action.zone]
|
1324
|
-
})
|
1325
|
-
}),
|
1326
|
-
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1327
|
-
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1328
|
-
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1329
|
-
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1330
|
-
type: "dropzone"
|
1331
|
-
})
|
1332
|
-
})
|
1333
|
-
})
|
1334
|
-
});
|
1297
|
+
return content;
|
1298
|
+
}
|
1299
|
+
);
|
1300
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1301
|
+
const parentId = zoneCompound.split(":")[0];
|
1302
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1303
|
+
delete newState.data.zones[zoneCompound];
|
1335
1304
|
}
|
1336
|
-
|
1305
|
+
});
|
1306
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1307
|
+
const parentId = zoneCompound.split(":")[0];
|
1308
|
+
if (nodesToDelete.includes(parentId)) {
|
1309
|
+
delete newState.indexes.zones[zoneCompound];
|
1310
|
+
}
|
1311
|
+
});
|
1312
|
+
nodesToDelete.forEach((id) => {
|
1313
|
+
delete newState.indexes.nodes[id];
|
1314
|
+
});
|
1315
|
+
return newState;
|
1316
|
+
};
|
1317
|
+
|
1318
|
+
// reducer/actions/register-zone.ts
|
1319
|
+
init_react_import();
|
1320
|
+
|
1321
|
+
// lib/data/setup-zone.ts
|
1322
|
+
init_react_import();
|
1323
|
+
var setupZone = (data, zoneKey) => {
|
1324
|
+
if (zoneKey === rootDroppableId) {
|
1325
|
+
return data;
|
1337
1326
|
}
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1327
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1328
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1329
|
+
});
|
1330
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1331
|
+
return newData;
|
1332
|
+
};
|
1333
|
+
|
1334
|
+
// reducer/actions/register-zone.ts
|
1335
|
+
var zoneCache = {};
|
1336
|
+
function registerZoneAction(state, action) {
|
1337
|
+
if (zoneCache[action.zone]) {
|
1346
1338
|
return __spreadProps(__spreadValues({}, state), {
|
1347
1339
|
data: __spreadProps(__spreadValues({}, state.data), {
|
1348
|
-
zones:
|
1340
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1341
|
+
[action.zone]: zoneCache[action.zone]
|
1342
|
+
})
|
1349
1343
|
}),
|
1350
1344
|
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1351
|
-
zones:
|
1345
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1346
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1347
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1348
|
+
type: "dropzone"
|
1349
|
+
})
|
1350
|
+
})
|
1352
1351
|
})
|
1353
1352
|
});
|
1354
1353
|
}
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
}
|
1354
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1355
|
+
}
|
1356
|
+
function unregisterZoneAction(state, action) {
|
1357
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1358
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1359
|
+
if (_zones[action.zone]) {
|
1360
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1361
|
+
delete _zones[action.zone];
|
1362
|
+
}
|
1363
|
+
delete zoneIndex[action.zone];
|
1364
|
+
return __spreadProps(__spreadValues({}, state), {
|
1365
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1366
|
+
zones: _zones
|
1367
|
+
}),
|
1368
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1369
|
+
zones: zoneIndex
|
1370
|
+
})
|
1371
|
+
});
|
1372
|
+
}
|
1373
|
+
|
1374
|
+
// reducer/actions/set-data.ts
|
1375
|
+
init_react_import();
|
1376
|
+
var setDataAction = (state, action, appStore) => {
|
1377
|
+
if (typeof action.data === "object") {
|
1378
|
+
console.warn(
|
1379
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1380
|
+
);
|
1367
1381
|
return walkTree(
|
1368
1382
|
__spreadProps(__spreadValues({}, state), {
|
1369
|
-
data: __spreadValues(__spreadValues({}, state.data), action.data
|
1383
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1370
1384
|
}),
|
1371
1385
|
appStore.config
|
1372
1386
|
);
|
1373
1387
|
}
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1388
|
+
return walkTree(
|
1389
|
+
__spreadProps(__spreadValues({}, state), {
|
1390
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1391
|
+
}),
|
1392
|
+
appStore.config
|
1393
|
+
);
|
1394
|
+
};
|
1395
|
+
|
1396
|
+
// reducer/actions/set-ui.ts
|
1397
|
+
init_react_import();
|
1398
|
+
var setUiAction = (state, action) => {
|
1399
|
+
if (typeof action.ui === "object") {
|
1380
1400
|
return __spreadProps(__spreadValues({}, state), {
|
1381
|
-
ui: __spreadValues(__spreadValues({}, state.ui), action.ui
|
1401
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1382
1402
|
});
|
1383
1403
|
}
|
1384
|
-
return state
|
1385
|
-
}
|
1404
|
+
return __spreadProps(__spreadValues({}, state), {
|
1405
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1406
|
+
});
|
1407
|
+
};
|
1408
|
+
|
1409
|
+
// lib/data/make-state-public.ts
|
1410
|
+
init_react_import();
|
1411
|
+
var makeStatePublic = (state) => {
|
1412
|
+
const { data, ui } = state;
|
1413
|
+
return { data, ui };
|
1414
|
+
};
|
1386
1415
|
|
1387
1416
|
// reducer/actions.tsx
|
1388
1417
|
init_react_import();
|
@@ -1401,21 +1430,54 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1401
1430
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1402
1431
|
if (record) record(newAppState);
|
1403
1432
|
}
|
1404
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1433
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1405
1434
|
return newAppState;
|
1406
1435
|
};
|
1407
1436
|
}
|
1408
1437
|
function createReducer({
|
1409
|
-
config,
|
1410
1438
|
record,
|
1411
1439
|
onAction,
|
1412
1440
|
appStore
|
1413
1441
|
}) {
|
1414
1442
|
return storeInterceptor(
|
1415
1443
|
(state, action) => {
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1444
|
+
if (action.type === "set") {
|
1445
|
+
return setAction(state, action, appStore);
|
1446
|
+
}
|
1447
|
+
if (action.type === "insert") {
|
1448
|
+
return insertAction(state, action, appStore);
|
1449
|
+
}
|
1450
|
+
if (action.type === "replace") {
|
1451
|
+
return replaceAction(state, action, appStore);
|
1452
|
+
}
|
1453
|
+
if (action.type === "replaceRoot") {
|
1454
|
+
return replaceRootAction(state, action, appStore);
|
1455
|
+
}
|
1456
|
+
if (action.type === "duplicate") {
|
1457
|
+
return duplicateAction(state, action, appStore);
|
1458
|
+
}
|
1459
|
+
if (action.type === "reorder") {
|
1460
|
+
return reorderAction(state, action, appStore);
|
1461
|
+
}
|
1462
|
+
if (action.type === "move") {
|
1463
|
+
return moveAction(state, action, appStore);
|
1464
|
+
}
|
1465
|
+
if (action.type === "remove") {
|
1466
|
+
return removeAction(state, action, appStore);
|
1467
|
+
}
|
1468
|
+
if (action.type === "registerZone") {
|
1469
|
+
return registerZoneAction(state, action);
|
1470
|
+
}
|
1471
|
+
if (action.type === "unregisterZone") {
|
1472
|
+
return unregisterZoneAction(state, action);
|
1473
|
+
}
|
1474
|
+
if (action.type === "setData") {
|
1475
|
+
return setDataAction(state, action, appStore);
|
1476
|
+
}
|
1477
|
+
if (action.type === "setUi") {
|
1478
|
+
return setUiAction(state, action);
|
1479
|
+
}
|
1480
|
+
return state;
|
1419
1481
|
},
|
1420
1482
|
record,
|
1421
1483
|
onAction
|
@@ -1627,7 +1689,7 @@ var createHistorySlice = (set, get) => {
|
|
1627
1689
|
const { dispatch, history } = get();
|
1628
1690
|
dispatch({
|
1629
1691
|
type: "set",
|
1630
|
-
state: ((_a = history.histories[
|
1692
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1631
1693
|
});
|
1632
1694
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1633
1695
|
},
|
@@ -1704,7 +1766,7 @@ var createNodesSlice = (set, get) => ({
|
|
1704
1766
|
init_react_import();
|
1705
1767
|
var import_react7 = require("react");
|
1706
1768
|
|
1707
|
-
// lib/flatten-data.ts
|
1769
|
+
// lib/data/flatten-data.ts
|
1708
1770
|
init_react_import();
|
1709
1771
|
var flattenData = (state, config) => {
|
1710
1772
|
const data = [];
|
@@ -1739,12 +1801,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1739
1801
|
const { cache: cache2, globalPermissions } = permissions;
|
1740
1802
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1741
1803
|
var _a, _b, _c;
|
1742
|
-
const {
|
1743
|
-
config: config2,
|
1744
|
-
state: appState,
|
1745
|
-
setComponentLoading,
|
1746
|
-
unsetComponentLoading
|
1747
|
-
} = get();
|
1804
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1748
1805
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1749
1806
|
if (!componentConfig) {
|
1750
1807
|
return;
|
@@ -1753,14 +1810,14 @@ var createPermissionsSlice = (set, get) => {
|
|
1753
1810
|
if (componentConfig.resolvePermissions) {
|
1754
1811
|
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1755
1812
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1756
|
-
setComponentLoading(item2.props.id);
|
1813
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1757
1814
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1758
1815
|
item2,
|
1759
1816
|
{
|
1760
1817
|
changed,
|
1761
1818
|
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1762
1819
|
permissions: initialPermissions,
|
1763
|
-
appState,
|
1820
|
+
appState: makeStatePublic(appState),
|
1764
1821
|
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1765
1822
|
}
|
1766
1823
|
);
|
@@ -1778,7 +1835,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1778
1835
|
})
|
1779
1836
|
})
|
1780
1837
|
});
|
1781
|
-
|
1838
|
+
clearTimeout2();
|
1782
1839
|
}
|
1783
1840
|
}
|
1784
1841
|
});
|
@@ -1788,7 +1845,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1788
1845
|
// Shim the root data in by conforming to component data shape
|
1789
1846
|
{
|
1790
1847
|
type: "root",
|
1791
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1848
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1792
1849
|
},
|
1793
1850
|
force2
|
1794
1851
|
);
|
@@ -1803,7 +1860,6 @@ var createPermissionsSlice = (set, get) => {
|
|
1803
1860
|
} else if (root) {
|
1804
1861
|
resolveDataForRoot(force);
|
1805
1862
|
} else {
|
1806
|
-
resolveDataForRoot(force);
|
1807
1863
|
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1808
1864
|
yield resolveDataForItem(item2, force);
|
1809
1865
|
}));
|
@@ -1834,7 +1890,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1834
1890
|
} else if (root) {
|
1835
1891
|
const rootConfig = config.root;
|
1836
1892
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1837
|
-
const resolvedForItem = resolvedPermissions["
|
1893
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1838
1894
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1839
1895
|
}
|
1840
1896
|
return globalPermissions;
|
@@ -1917,7 +1973,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1917
1973
|
fields: defaultFields,
|
1918
1974
|
lastFields,
|
1919
1975
|
lastData,
|
1920
|
-
appState: state,
|
1976
|
+
appState: makeStatePublic(state),
|
1921
1977
|
parent
|
1922
1978
|
});
|
1923
1979
|
clearTimeout(timeout3);
|
@@ -1951,38 +2007,63 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1951
2007
|
// lib/resolve-component-data.ts
|
1952
2008
|
init_react_import();
|
1953
2009
|
|
1954
|
-
// lib/map-slots.ts
|
2010
|
+
// lib/data/map-slots.ts
|
1955
2011
|
init_react_import();
|
1956
|
-
function
|
1957
|
-
return __async(this,
|
2012
|
+
function mapSlotsAsync(_0, _1) {
|
2013
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1958
2014
|
const props = __spreadValues({}, item.props);
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
2015
|
+
const propKeys = Object.keys(props);
|
2016
|
+
for (let i = 0; i < propKeys.length; i++) {
|
2017
|
+
const propKey = propKeys[i];
|
2018
|
+
const itemType = "type" in item ? item.type : "root";
|
2019
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
2020
|
+
const content = props[propKey];
|
1962
2021
|
const mappedContent = recursive ? yield Promise.all(
|
1963
2022
|
content.map((item2) => __async(this, null, function* () {
|
1964
|
-
return yield
|
2023
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1965
2024
|
}))
|
1966
2025
|
) : content;
|
1967
|
-
props[
|
1968
|
-
}
|
1969
|
-
|
1970
|
-
isSlot2
|
1971
|
-
);
|
2026
|
+
props[propKey] = yield map(mappedContent, propKey);
|
2027
|
+
}
|
2028
|
+
}
|
1972
2029
|
return __spreadProps(__spreadValues({}, item), { props });
|
1973
2030
|
});
|
1974
2031
|
}
|
2032
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
2033
|
+
const props = __spreadValues({}, item.props);
|
2034
|
+
const propKeys = Object.keys(props);
|
2035
|
+
for (let i = 0; i < propKeys.length; i++) {
|
2036
|
+
const propKey = propKeys[i];
|
2037
|
+
const itemType = "type" in item ? item.type : "root";
|
2038
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
2039
|
+
const content = props[propKey];
|
2040
|
+
const mappedContent = content.map((item2) => {
|
2041
|
+
return mapSlotsSync(item2, map, isSlot2);
|
2042
|
+
});
|
2043
|
+
props[propKey] = map(mappedContent, props.id, propKey);
|
2044
|
+
}
|
2045
|
+
}
|
2046
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
2047
|
+
}
|
2048
|
+
function mapSlotsPublic(item, config, map) {
|
2049
|
+
const isSlot2 = createIsSlotConfig(config);
|
2050
|
+
return mapSlotsSync(
|
2051
|
+
item,
|
2052
|
+
(content, parentId, propName) => map(content, { parentId, propName }),
|
2053
|
+
isSlot2
|
2054
|
+
);
|
2055
|
+
}
|
1975
2056
|
|
1976
2057
|
// lib/resolve-component-data.ts
|
1977
2058
|
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
1978
2059
|
var cache = { lastChange: {} };
|
1979
2060
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
1980
|
-
const configForItem = "type" in item ? config.components[item.type] : config.root;
|
2061
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1981
2062
|
if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
|
1982
2063
|
const id = "id" in item.props ? item.props.id : "root";
|
1983
2064
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1984
|
-
if (item && item
|
1985
|
-
return resolved;
|
2065
|
+
if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
|
2066
|
+
return { node: resolved, didChange: false };
|
1986
2067
|
}
|
1987
2068
|
const changed = getChanged(item, oldItem);
|
1988
2069
|
if (onResolveStart) {
|
@@ -1991,30 +2072,35 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1991
2072
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1992
2073
|
changed,
|
1993
2074
|
lastData: oldItem,
|
1994
|
-
metadata,
|
2075
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1995
2076
|
trigger
|
1996
2077
|
});
|
1997
2078
|
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
1998
2079
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1999
2080
|
});
|
2000
2081
|
if (recursive) {
|
2001
|
-
resolvedItem = yield
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2082
|
+
resolvedItem = yield mapSlotsAsync(
|
2083
|
+
resolvedItem,
|
2084
|
+
(content) => __async(void 0, null, function* () {
|
2085
|
+
return Promise.all(
|
2086
|
+
content.map(
|
2087
|
+
(childItem) => __async(void 0, null, function* () {
|
2088
|
+
return (yield resolveComponentData(
|
2089
|
+
childItem,
|
2090
|
+
config,
|
2091
|
+
metadata,
|
2092
|
+
onResolveStart,
|
2093
|
+
onResolveEnd,
|
2094
|
+
trigger,
|
2095
|
+
false
|
2096
|
+
)).node;
|
2097
|
+
})
|
2098
|
+
)
|
2099
|
+
);
|
2100
|
+
}),
|
2101
|
+
false,
|
2102
|
+
createIsSlotConfig(config)
|
2103
|
+
);
|
2018
2104
|
}
|
2019
2105
|
if (Object.keys(readOnly).length) {
|
2020
2106
|
resolvedItem.readOnly = readOnly;
|
@@ -2031,7 +2117,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
2031
2117
|
return { node: item, didChange: false };
|
2032
2118
|
});
|
2033
2119
|
|
2034
|
-
// lib/to-root.ts
|
2120
|
+
// lib/data/to-root.ts
|
2035
2121
|
init_react_import();
|
2036
2122
|
var toRoot = (item) => {
|
2037
2123
|
if ("type" in item && item.type !== "root") {
|
@@ -2078,174 +2164,176 @@ var defaultPageFields = {
|
|
2078
2164
|
title: { type: "text" }
|
2079
2165
|
};
|
2080
2166
|
var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
2081
|
-
(0, import_middleware2.subscribeWithSelector)((set, get) =>
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
setComponentState
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2167
|
+
(0, import_middleware2.subscribeWithSelector)((set, get) => {
|
2168
|
+
var _a, _b;
|
2169
|
+
return __spreadProps(__spreadValues({
|
2170
|
+
state: defaultAppState,
|
2171
|
+
config: { components: {} },
|
2172
|
+
componentState: {},
|
2173
|
+
plugins: [],
|
2174
|
+
overrides: {},
|
2175
|
+
viewports: defaultViewports,
|
2176
|
+
zoomConfig: {
|
2177
|
+
autoZoom: 1,
|
2178
|
+
rootHeight: 0,
|
2179
|
+
zoom: 1
|
2180
|
+
},
|
2181
|
+
status: "LOADING",
|
2182
|
+
iframe: {},
|
2183
|
+
metadata: {}
|
2184
|
+
}, initialAppStore), {
|
2185
|
+
fields: createFieldsSlice(set, get),
|
2186
|
+
history: createHistorySlice(set, get),
|
2187
|
+
nodes: createNodesSlice(set, get),
|
2188
|
+
permissions: createPermissionsSlice(set, get),
|
2189
|
+
getComponentConfig: (type) => {
|
2190
|
+
var _a2;
|
2191
|
+
const { config, selectedItem } = get();
|
2192
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
2193
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
2194
|
+
},
|
2195
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
2196
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
2197
|
+
initialAppStore.state
|
2198
|
+
) : null,
|
2199
|
+
dispatch: (action) => set((s) => {
|
2200
|
+
var _a2, _b2;
|
2201
|
+
const { record } = get().history;
|
2202
|
+
const dispatch = createReducer({
|
2203
|
+
record,
|
2204
|
+
appStore: s
|
2205
|
+
});
|
2206
|
+
const state = dispatch(s.state, action);
|
2207
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2208
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
2209
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2210
|
+
}),
|
2211
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
2212
|
+
setStatus: (status) => set({ status }),
|
2213
|
+
setComponentState: (componentState) => set({ componentState }),
|
2214
|
+
pendingLoadTimeouts: {},
|
2215
|
+
setComponentLoading: (id, loading = true, defer2 = 0) => {
|
2216
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
2217
|
+
const loadId = generateId();
|
2218
|
+
const setLoading = () => {
|
2219
|
+
var _a2;
|
2220
|
+
const { componentState } = get();
|
2221
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
2222
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
2223
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
2224
|
+
})
|
2225
|
+
}));
|
2226
|
+
};
|
2227
|
+
const unsetLoading = () => {
|
2228
|
+
var _a2;
|
2229
|
+
const { componentState } = get();
|
2230
|
+
clearTimeout(timeout3);
|
2231
|
+
delete pendingLoadTimeouts[loadId];
|
2232
|
+
set({ pendingLoadTimeouts });
|
2233
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
2234
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
2235
|
+
loadingCount: Math.max(
|
2236
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
2237
|
+
0
|
2238
|
+
)
|
2239
|
+
})
|
2240
|
+
}));
|
2241
|
+
};
|
2242
|
+
const timeout3 = setTimeout(() => {
|
2243
|
+
if (loading) {
|
2244
|
+
setLoading();
|
2245
|
+
} else {
|
2246
|
+
unsetLoading();
|
2247
|
+
}
|
2248
|
+
delete pendingLoadTimeouts[loadId];
|
2249
|
+
set({ pendingLoadTimeouts });
|
2250
|
+
}, defer2);
|
2251
|
+
set({
|
2252
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
2253
|
+
[id]: timeout3
|
2145
2254
|
})
|
2146
|
-
})
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
}
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2186
|
-
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2187
|
-
}),
|
2188
|
-
// resolveDataRuns: 0,
|
2189
|
-
// resolveData: (newAppState) =>
|
2190
|
-
// set((s) => {
|
2191
|
-
// resolveData(newAppState, get);
|
2192
|
-
// return { ...s, resolveDataRuns: s.resolveDataRuns + 1 };
|
2193
|
-
// }),
|
2194
|
-
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
2195
|
-
const { config, metadata, setComponentLoading } = get();
|
2196
|
-
return yield resolveComponentData(
|
2197
|
-
componentData,
|
2198
|
-
config,
|
2199
|
-
metadata,
|
2200
|
-
(item) => setComponentLoading(
|
2201
|
-
"id" in item.props ? item.props.id : "root",
|
2202
|
-
true,
|
2203
|
-
50
|
2204
|
-
),
|
2205
|
-
(item) => setComponentLoading(
|
2206
|
-
"id" in item.props ? item.props.id : "root",
|
2207
|
-
false,
|
2208
|
-
0
|
2209
|
-
),
|
2210
|
-
trigger
|
2211
|
-
);
|
2212
|
-
}),
|
2213
|
-
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2214
|
-
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2215
|
-
walkTree(
|
2216
|
-
state,
|
2217
|
-
config,
|
2218
|
-
(content) => content,
|
2219
|
-
(childItem) => {
|
2220
|
-
resolveComponentData2(childItem, "load").then((resolved) => {
|
2221
|
-
const { state: state2 } = get();
|
2222
|
-
const node = state2.indexes.nodes[resolved.node.props.id];
|
2223
|
-
if (node && resolved.didChange) {
|
2224
|
-
if (resolved.node.props.id === "root") {
|
2225
|
-
dispatch({
|
2226
|
-
type: "replaceRoot",
|
2227
|
-
root: toRoot(resolved.node)
|
2228
|
-
});
|
2229
|
-
} else {
|
2230
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2231
|
-
const parentZone = state2.indexes.zones[zoneCompound];
|
2232
|
-
const index = parentZone.contentIds.indexOf(
|
2233
|
-
resolved.node.props.id
|
2234
|
-
);
|
2235
|
-
dispatch({
|
2236
|
-
type: "replace",
|
2237
|
-
data: resolved.node,
|
2238
|
-
destinationIndex: index,
|
2239
|
-
destinationZone: zoneCompound
|
2240
|
-
});
|
2241
|
-
}
|
2255
|
+
});
|
2256
|
+
return unsetLoading;
|
2257
|
+
},
|
2258
|
+
unsetComponentLoading: (id) => {
|
2259
|
+
const { setComponentLoading } = get();
|
2260
|
+
setComponentLoading(id, false);
|
2261
|
+
},
|
2262
|
+
// Helper
|
2263
|
+
setUi: (ui, recordHistory) => set((s) => {
|
2264
|
+
const dispatch = createReducer({
|
2265
|
+
record: () => {
|
2266
|
+
},
|
2267
|
+
appStore: s
|
2268
|
+
});
|
2269
|
+
const state = dispatch(s.state, {
|
2270
|
+
type: "setUi",
|
2271
|
+
ui,
|
2272
|
+
recordHistory
|
2273
|
+
});
|
2274
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2275
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2276
|
+
}),
|
2277
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
2278
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
2279
|
+
const timeouts = {};
|
2280
|
+
return yield resolveComponentData(
|
2281
|
+
componentData,
|
2282
|
+
config,
|
2283
|
+
metadata,
|
2284
|
+
(item) => {
|
2285
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2286
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
2287
|
+
},
|
2288
|
+
(item) => __async(void 0, null, function* () {
|
2289
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2290
|
+
if ("type" in item) {
|
2291
|
+
yield permissions.refreshPermissions({ item });
|
2292
|
+
} else {
|
2293
|
+
yield permissions.refreshPermissions({ root: true });
|
2242
2294
|
}
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2295
|
+
timeouts[id]();
|
2296
|
+
}),
|
2297
|
+
trigger
|
2298
|
+
);
|
2299
|
+
}),
|
2300
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2301
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2302
|
+
walkTree(
|
2303
|
+
state,
|
2304
|
+
config,
|
2305
|
+
(content) => content,
|
2306
|
+
(childItem) => {
|
2307
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2308
|
+
const { state: state2 } = get();
|
2309
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2310
|
+
if (node && resolved.didChange) {
|
2311
|
+
if (resolved.node.props.id === "root") {
|
2312
|
+
dispatch({
|
2313
|
+
type: "replaceRoot",
|
2314
|
+
root: toRoot(resolved.node)
|
2315
|
+
});
|
2316
|
+
} else {
|
2317
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2318
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2319
|
+
const index = parentZone.contentIds.indexOf(
|
2320
|
+
resolved.node.props.id
|
2321
|
+
);
|
2322
|
+
dispatch({
|
2323
|
+
type: "replace",
|
2324
|
+
data: resolved.node,
|
2325
|
+
destinationIndex: index,
|
2326
|
+
destinationZone: zoneCompound
|
2327
|
+
});
|
2328
|
+
}
|
2329
|
+
}
|
2330
|
+
});
|
2331
|
+
return childItem;
|
2332
|
+
}
|
2333
|
+
);
|
2334
|
+
})
|
2335
|
+
});
|
2336
|
+
})
|
2249
2337
|
);
|
2250
2338
|
var appStoreContext = (0, import_react9.createContext)(createAppStore());
|
2251
2339
|
function useAppStore(selector) {
|
@@ -4340,7 +4428,7 @@ var import_react25 = require("react");
|
|
4340
4428
|
|
4341
4429
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
4342
4430
|
init_react_import();
|
4343
|
-
var styles_module_default11 = { "DraggableComponent": "
|
4431
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_qzbgx_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_qzbgx_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_qzbgx_29", "DraggableComponent--hover": "_DraggableComponent--hover_qzbgx_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_qzbgx_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_qzbgx_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_qzbgx_66", "DraggableComponent-actions": "_DraggableComponent-actions_qzbgx_66" };
|
4344
4432
|
|
4345
4433
|
// components/DraggableComponent/index.tsx
|
4346
4434
|
var import_react_dom2 = require("react-dom");
|
@@ -4391,7 +4479,6 @@ var DropZoneProvider = ({
|
|
4391
4479
|
value
|
4392
4480
|
}) => {
|
4393
4481
|
const [hoveringComponent, setHoveringComponent] = (0, import_react23.useState)();
|
4394
|
-
const [activeZones, setActiveZones] = (0, import_react23.useState)({});
|
4395
4482
|
const dispatch = useAppStore((s) => s.dispatch);
|
4396
4483
|
const registerZone = (0, import_react23.useCallback)(
|
4397
4484
|
(zoneCompound) => {
|
@@ -4400,7 +4487,7 @@ var DropZoneProvider = ({
|
|
4400
4487
|
zone: zoneCompound
|
4401
4488
|
});
|
4402
4489
|
},
|
4403
|
-
[
|
4490
|
+
[dispatch]
|
4404
4491
|
);
|
4405
4492
|
const unregisterZone = (0, import_react23.useCallback)(
|
4406
4493
|
(zoneCompound) => {
|
@@ -4409,17 +4496,16 @@ var DropZoneProvider = ({
|
|
4409
4496
|
zone: zoneCompound
|
4410
4497
|
});
|
4411
4498
|
},
|
4412
|
-
[
|
4499
|
+
[dispatch]
|
4413
4500
|
);
|
4414
4501
|
const memoValue = (0, import_react23.useMemo)(
|
4415
4502
|
() => __spreadValues({
|
4416
4503
|
hoveringComponent,
|
4417
4504
|
setHoveringComponent,
|
4418
4505
|
registerZone,
|
4419
|
-
unregisterZone
|
4420
|
-
activeZones
|
4506
|
+
unregisterZone
|
4421
4507
|
}, value),
|
4422
|
-
[value, hoveringComponent
|
4508
|
+
[value, hoveringComponent]
|
4423
4509
|
);
|
4424
4510
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
4425
4511
|
};
|
@@ -4512,8 +4598,10 @@ var DraggableComponent = ({
|
|
4512
4598
|
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
4513
4599
|
}));
|
4514
4600
|
const permissions = useAppStore(
|
4515
|
-
(0, import_shallow2.useShallow)((s) =>
|
4516
|
-
|
4601
|
+
(0, import_shallow2.useShallow)((s) => {
|
4602
|
+
const item = getItem({ index, zone: zoneCompound }, s.state);
|
4603
|
+
return s.permissions.getPermissions({ item });
|
4604
|
+
})
|
4517
4605
|
);
|
4518
4606
|
const userIsDragging = useContextStore(
|
4519
4607
|
ZoneStoreContext,
|
@@ -4767,76 +4855,82 @@ var DraggableComponent = ({
|
|
4767
4855
|
setDragAxis(autoDragAxis);
|
4768
4856
|
}, [ref, userDragAxis, autoDragAxis]);
|
4769
4857
|
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) });
|
4770
|
-
|
4771
|
-
|
4772
|
-
|
4773
|
-
|
4774
|
-
|
4775
|
-
|
4776
|
-
|
4777
|
-
|
4778
|
-
|
4779
|
-
|
4780
|
-
|
4781
|
-
|
4782
|
-
|
4783
|
-
|
4784
|
-
|
4785
|
-
|
4786
|
-
|
4787
|
-
|
4788
|
-
|
4789
|
-
|
4790
|
-
|
4791
|
-
|
4792
|
-
|
4793
|
-
|
4794
|
-
|
4795
|
-
|
4796
|
-
|
4858
|
+
const nextContextValue = (0, import_react25.useMemo)(
|
4859
|
+
() => __spreadProps(__spreadValues({}, ctx), {
|
4860
|
+
areaId: id,
|
4861
|
+
zoneCompound,
|
4862
|
+
index,
|
4863
|
+
depth: depth + 1,
|
4864
|
+
registerLocalZone,
|
4865
|
+
unregisterLocalZone
|
4866
|
+
}),
|
4867
|
+
[
|
4868
|
+
ctx,
|
4869
|
+
id,
|
4870
|
+
zoneCompound,
|
4871
|
+
index,
|
4872
|
+
depth,
|
4873
|
+
registerLocalZone,
|
4874
|
+
unregisterLocalZone
|
4875
|
+
]
|
4876
|
+
);
|
4877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
|
4878
|
+
isVisible && (0, import_react_dom2.createPortal)(
|
4879
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
4880
|
+
"div",
|
4881
|
+
{
|
4882
|
+
className: getClassName16({
|
4883
|
+
isSelected,
|
4884
|
+
isDragging: thisIsDragging,
|
4885
|
+
hover: hover || indicativeHover
|
4886
|
+
}),
|
4887
|
+
style: __spreadValues({}, style),
|
4888
|
+
"data-puck-overlay": true,
|
4889
|
+
children: [
|
4890
|
+
debug,
|
4891
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
|
4892
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4893
|
+
"div",
|
4894
|
+
{
|
4895
|
+
className: getClassName16("actionsOverlay"),
|
4896
|
+
style: {
|
4897
|
+
top: actionsOverlayTop / zoom
|
4898
|
+
},
|
4899
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4797
4900
|
"div",
|
4798
4901
|
{
|
4799
|
-
className: getClassName16("
|
4902
|
+
className: getClassName16("actions"),
|
4800
4903
|
style: {
|
4801
|
-
|
4904
|
+
transform: `scale(${1 / zoom}`,
|
4905
|
+
top: actionsTop / zoom,
|
4906
|
+
right: 0,
|
4907
|
+
paddingLeft: actionsSide,
|
4908
|
+
paddingRight: actionsSide
|
4802
4909
|
},
|
4803
|
-
|
4804
|
-
|
4910
|
+
ref: syncActionsPosition,
|
4911
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
4912
|
+
CustomActionBar,
|
4805
4913
|
{
|
4806
|
-
|
4807
|
-
|
4808
|
-
|
4809
|
-
|
4810
|
-
|
4811
|
-
|
4812
|
-
paddingRight: actionsSide
|
4813
|
-
},
|
4814
|
-
ref: syncActionsPosition,
|
4815
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
4816
|
-
CustomActionBar,
|
4817
|
-
{
|
4818
|
-
parentAction,
|
4819
|
-
label: DEBUG2 ? id : label,
|
4820
|
-
children: [
|
4821
|
-
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
|
4822
|
-
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
|
4823
|
-
]
|
4824
|
-
}
|
4825
|
-
)
|
4914
|
+
parentAction,
|
4915
|
+
label: DEBUG2 ? id : label,
|
4916
|
+
children: [
|
4917
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
|
4918
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
|
4919
|
+
]
|
4826
4920
|
}
|
4827
4921
|
)
|
4828
4922
|
}
|
4829
|
-
)
|
4830
|
-
|
4831
|
-
|
4832
|
-
}
|
4833
|
-
|
4834
|
-
|
4835
|
-
|
4836
|
-
|
4837
|
-
|
4838
|
-
|
4839
|
-
);
|
4923
|
+
)
|
4924
|
+
}
|
4925
|
+
),
|
4926
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
4927
|
+
]
|
4928
|
+
}
|
4929
|
+
),
|
4930
|
+
portalEl || document.body
|
4931
|
+
),
|
4932
|
+
children(refSetter)
|
4933
|
+
] });
|
4840
4934
|
};
|
4841
4935
|
|
4842
4936
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
|
@@ -5022,26 +5116,33 @@ var import_shallow3 = require("zustand/react/shallow");
|
|
5022
5116
|
// components/Render/index.tsx
|
5023
5117
|
init_react_import();
|
5024
5118
|
|
5025
|
-
// lib/use-slots.
|
5119
|
+
// lib/use-slots.tsx
|
5026
5120
|
init_react_import();
|
5027
5121
|
var import_react31 = require("react");
|
5028
|
-
function useSlots(config, props,
|
5029
|
-
|
5122
|
+
function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
5123
|
+
const slotProps = (0, import_react31.useMemo)(() => {
|
5030
5124
|
if (!(config == null ? void 0 : config.fields)) return props;
|
5031
|
-
const
|
5125
|
+
const slotProps2 = {};
|
5032
5126
|
const fieldKeys = Object.keys(config.fields);
|
5033
5127
|
for (let i = 0; i < fieldKeys.length; i++) {
|
5034
5128
|
const fieldKey = fieldKeys[i];
|
5035
5129
|
const field = config.fields[fieldKey];
|
5036
5130
|
if ((field == null ? void 0 : field.type) === "slot") {
|
5037
|
-
|
5131
|
+
const content = props[fieldKey] || [];
|
5132
|
+
const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
|
5133
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
5134
|
+
allow: field.allow,
|
5135
|
+
disallow: field.disallow
|
5136
|
+
}, dzProps), {
|
5038
5137
|
zone: fieldKey,
|
5039
|
-
content
|
5138
|
+
content
|
5040
5139
|
}));
|
5140
|
+
slotProps2[fieldKey] = Slot;
|
5041
5141
|
}
|
5042
5142
|
}
|
5043
|
-
return
|
5044
|
-
}, [config,
|
5143
|
+
return slotProps2;
|
5144
|
+
}, [config, readOnly, forceReadOnly]);
|
5145
|
+
return __spreadValues(__spreadValues({}, props), slotProps);
|
5045
5146
|
}
|
5046
5147
|
|
5047
5148
|
// components/Render/index.tsx
|
@@ -5052,30 +5153,60 @@ init_react_import();
|
|
5052
5153
|
var import_react32 = require("react");
|
5053
5154
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
5054
5155
|
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRender, __spreadValues({}, props));
|
5156
|
+
var ContextSlotRender = ({
|
5157
|
+
componentId,
|
5158
|
+
zone
|
5159
|
+
}) => {
|
5160
|
+
const config = useAppStore((s) => s.config);
|
5161
|
+
const metadata = useAppStore((s) => s.metadata);
|
5162
|
+
const slotContent = useAppStore(
|
5163
|
+
(s) => {
|
5164
|
+
var _a, _b;
|
5165
|
+
return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
|
5166
|
+
}
|
5167
|
+
);
|
5168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5169
|
+
SlotRenderPure,
|
5170
|
+
{
|
5171
|
+
content: slotContent,
|
5172
|
+
zone,
|
5173
|
+
config,
|
5174
|
+
metadata
|
5175
|
+
}
|
5176
|
+
);
|
5177
|
+
};
|
5178
|
+
var Item = ({
|
5179
|
+
config,
|
5180
|
+
item,
|
5181
|
+
metadata
|
5182
|
+
}) => {
|
5183
|
+
const Component = config.components[item.type];
|
5184
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5186
|
+
Component.render,
|
5187
|
+
__spreadProps(__spreadValues({}, props), {
|
5188
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
5189
|
+
renderDropZone: DropZoneRenderPure,
|
5190
|
+
metadata: metadata || {}
|
5191
|
+
})
|
5192
|
+
})
|
5193
|
+
);
|
5194
|
+
};
|
5055
5195
|
var SlotRender = (0, import_react32.forwardRef)(
|
5056
5196
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
5057
5197
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
|
5058
|
-
|
5059
|
-
|
5060
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5061
|
-
SlotRenderPure,
|
5062
|
-
__spreadProps(__spreadValues({}, slotProps), {
|
5063
|
-
config,
|
5064
|
-
metadata
|
5065
|
-
})
|
5066
|
-
));
|
5067
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5068
|
-
Component.render,
|
5069
|
-
__spreadProps(__spreadValues({}, props), {
|
5070
|
-
puck: {
|
5071
|
-
renderDropZone: DropZoneRenderPure,
|
5072
|
-
metadata: metadata || {}
|
5073
|
-
}
|
5074
|
-
}),
|
5075
|
-
props.id
|
5076
|
-
);
|
5198
|
+
if (!config.components[item.type]) {
|
5199
|
+
return null;
|
5077
5200
|
}
|
5078
|
-
return
|
5201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5202
|
+
Item,
|
5203
|
+
{
|
5204
|
+
config,
|
5205
|
+
item,
|
5206
|
+
metadata
|
5207
|
+
},
|
5208
|
+
item.props.id
|
5209
|
+
);
|
5079
5210
|
}) });
|
5080
5211
|
}
|
5081
5212
|
);
|
@@ -5111,28 +5242,17 @@ function Render({
|
|
5111
5242
|
id: "puck-root"
|
5112
5243
|
});
|
5113
5244
|
const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
|
5245
|
+
const nextContextValue = (0, import_react33.useMemo)(
|
5246
|
+
() => ({
|
5247
|
+
mode: "render",
|
5248
|
+
depth: 0
|
5249
|
+
}),
|
5250
|
+
[]
|
5251
|
+
);
|
5114
5252
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5115
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5116
|
-
DropZoneProvider,
|
5117
|
-
{
|
5118
|
-
value: {
|
5119
|
-
mode: "render",
|
5120
|
-
depth: 0
|
5121
|
-
},
|
5122
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone }) }))
|
5123
|
-
}
|
5124
|
-
) });
|
5253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone }) })) }) });
|
5125
5254
|
}
|
5126
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5127
|
-
DropZoneProvider,
|
5128
|
-
{
|
5129
|
-
value: {
|
5130
|
-
mode: "render",
|
5131
|
-
depth: 0
|
5132
|
-
},
|
5133
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone })
|
5134
|
-
}
|
5135
|
-
) });
|
5255
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone }) }) });
|
5136
5256
|
}
|
5137
5257
|
|
5138
5258
|
// components/DropZone/index.tsx
|
@@ -5153,14 +5273,8 @@ var DropZoneChild = ({
|
|
5153
5273
|
}) => {
|
5154
5274
|
var _a, _b;
|
5155
5275
|
const metadata = useAppStore((s) => s.metadata);
|
5156
|
-
const puckProps = {
|
5157
|
-
renderDropZone: DropZoneEditPure,
|
5158
|
-
isEditing: true,
|
5159
|
-
dragRef: null,
|
5160
|
-
metadata
|
5161
|
-
};
|
5162
5276
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
5163
|
-
const { depth } = ctx;
|
5277
|
+
const { depth = 1 } = ctx != null ? ctx : {};
|
5164
5278
|
const nodeProps = useAppStore(
|
5165
5279
|
(0, import_shallow3.useShallow)((s) => {
|
5166
5280
|
var _a2;
|
@@ -5173,11 +5287,23 @@ var DropZoneChild = ({
|
|
5173
5287
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
|
5174
5288
|
}
|
5175
5289
|
);
|
5290
|
+
const nodeReadOnly = useAppStore(
|
5291
|
+
(0, import_shallow3.useShallow)((s) => {
|
5292
|
+
var _a2;
|
5293
|
+
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
5294
|
+
})
|
5295
|
+
);
|
5176
5296
|
const node = { type: nodeType, props: nodeProps };
|
5177
5297
|
const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
|
5178
5298
|
const componentConfig = useAppStore(
|
5179
5299
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
5180
5300
|
);
|
5301
|
+
const puckProps = {
|
5302
|
+
renderDropZone: DropZoneEditPure,
|
5303
|
+
isEditing: true,
|
5304
|
+
dragRef: null,
|
5305
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
|
5306
|
+
};
|
5181
5307
|
const overrides = useAppStore((s) => s.overrides);
|
5182
5308
|
const isLoading = useAppStore(
|
5183
5309
|
(s) => {
|
@@ -5209,7 +5335,10 @@ var DropZoneChild = ({
|
|
5209
5335
|
const defaultedPropsWithSlots = useSlots(
|
5210
5336
|
componentConfig,
|
5211
5337
|
defaultsProps,
|
5212
|
-
DropZoneEditPure
|
5338
|
+
DropZoneEditPure,
|
5339
|
+
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
5340
|
+
nodeReadOnly,
|
5341
|
+
isLoading
|
5213
5342
|
);
|
5214
5343
|
if (!item) return;
|
5215
5344
|
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
@@ -5247,6 +5376,7 @@ var DropZoneChild = ({
|
|
5247
5376
|
}
|
5248
5377
|
);
|
5249
5378
|
};
|
5379
|
+
var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
|
5250
5380
|
var DropZoneEdit = (0, import_react34.forwardRef)(
|
5251
5381
|
function DropZoneEditInternal({
|
5252
5382
|
zone,
|
@@ -5261,10 +5391,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5261
5391
|
const {
|
5262
5392
|
// These all need setting via context
|
5263
5393
|
areaId,
|
5264
|
-
depth,
|
5394
|
+
depth = 0,
|
5265
5395
|
registerLocalZone,
|
5266
5396
|
unregisterLocalZone
|
5267
|
-
} = ctx;
|
5397
|
+
} = ctx != null ? ctx : {};
|
5268
5398
|
const path = useAppStore(
|
5269
5399
|
(0, import_shallow3.useShallow)((s) => {
|
5270
5400
|
var _a;
|
@@ -5306,6 +5436,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5306
5436
|
);
|
5307
5437
|
(0, import_react34.useEffect)(() => {
|
5308
5438
|
if (!zoneType || zoneType === "dropzone") {
|
5439
|
+
if (zoneCompound !== rootDroppableId) {
|
5440
|
+
console.warn(
|
5441
|
+
"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"
|
5442
|
+
);
|
5443
|
+
}
|
5309
5444
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5310
5445
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5311
5446
|
}
|
@@ -5411,7 +5546,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5411
5546
|
}),
|
5412
5547
|
children: contentIdsWithPreview.map((componentId, i) => {
|
5413
5548
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5414
|
-
|
5549
|
+
DropZoneChildMemo,
|
5415
5550
|
{
|
5416
5551
|
zoneCompound,
|
5417
5552
|
componentId,
|
@@ -5429,6 +5564,30 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5429
5564
|
);
|
5430
5565
|
}
|
5431
5566
|
);
|
5567
|
+
var DropZoneRenderItem = ({
|
5568
|
+
config,
|
5569
|
+
item,
|
5570
|
+
metadata
|
5571
|
+
}) => {
|
5572
|
+
const Component = config.components[item.type];
|
5573
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5574
|
+
const nextContextValue = (0, import_react34.useMemo)(
|
5575
|
+
() => ({
|
5576
|
+
areaId: props.id,
|
5577
|
+
depth: 1
|
5578
|
+
}),
|
5579
|
+
[props]
|
5580
|
+
);
|
5581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5582
|
+
Component.render,
|
5583
|
+
__spreadProps(__spreadValues({}, props), {
|
5584
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
5585
|
+
renderDropZone: DropZoneRenderPure,
|
5586
|
+
metadata: __spreadValues(__spreadValues({}, metadata), Component.metadata)
|
5587
|
+
})
|
5588
|
+
})
|
5589
|
+
) }, props.id);
|
5590
|
+
};
|
5432
5591
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneRender, __spreadValues({}, props));
|
5433
5592
|
var DropZoneRender = (0, import_react34.forwardRef)(
|
5434
5593
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
@@ -5459,31 +5618,14 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5459
5618
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className, style, ref, children: content.map((item) => {
|
5460
5619
|
const Component = config.components[item.type];
|
5461
5620
|
if (Component) {
|
5462
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5463
|
-
SlotRenderPure,
|
5464
|
-
__spreadProps(__spreadValues({}, slotProps), {
|
5465
|
-
config,
|
5466
|
-
metadata
|
5467
|
-
})
|
5468
|
-
));
|
5469
5621
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5470
|
-
|
5622
|
+
DropZoneRenderItem,
|
5471
5623
|
{
|
5472
|
-
|
5473
|
-
|
5474
|
-
|
5475
|
-
},
|
5476
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5477
|
-
Component.render,
|
5478
|
-
__spreadProps(__spreadValues({}, props), {
|
5479
|
-
puck: {
|
5480
|
-
renderDropZone: DropZoneRenderPure,
|
5481
|
-
metadata: metadata || {}
|
5482
|
-
}
|
5483
|
-
})
|
5484
|
-
)
|
5624
|
+
config,
|
5625
|
+
item,
|
5626
|
+
metadata
|
5485
5627
|
},
|
5486
|
-
props.id
|
5628
|
+
item.props.id
|
5487
5629
|
);
|
5488
5630
|
}
|
5489
5631
|
return null;
|
@@ -5771,8 +5913,8 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
|
|
5771
5913
|
destinationZone: zone,
|
5772
5914
|
id
|
5773
5915
|
};
|
5774
|
-
const { state,
|
5775
|
-
const insertedState = insertAction(state, insertActionData,
|
5916
|
+
const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
|
5917
|
+
const insertedState = insertAction(state, insertActionData, appStore);
|
5776
5918
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
5777
5919
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
5778
5920
|
// We must always record history here so the insert is added to user history
|
@@ -5974,6 +6116,14 @@ var DragDropContextClient = ({
|
|
5974
6116
|
const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
|
5975
6117
|
const dragMode = (0, import_react36.useRef)(null);
|
5976
6118
|
const initialSelector = (0, import_react36.useRef)(void 0);
|
6119
|
+
const nextContextValue = (0, import_react36.useMemo)(
|
6120
|
+
() => ({
|
6121
|
+
mode: "edit",
|
6122
|
+
areaId: "root",
|
6123
|
+
depth: 0
|
6124
|
+
}),
|
6125
|
+
[]
|
6126
|
+
);
|
5977
6127
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
5978
6128
|
dragListenerContext.Provider,
|
5979
6129
|
{
|
@@ -6015,7 +6165,6 @@ var DragDropContextClient = ({
|
|
6015
6165
|
}
|
6016
6166
|
if (thisPreview) {
|
6017
6167
|
zoneStore.setState({ previewIndex: {} });
|
6018
|
-
const state = appStore.getState().state;
|
6019
6168
|
if (thisPreview.type === "insert") {
|
6020
6169
|
insertComponent(
|
6021
6170
|
thisPreview.componentType,
|
@@ -6172,17 +6321,7 @@ var DragDropContextClient = ({
|
|
6172
6321
|
initialSelector.current = void 0;
|
6173
6322
|
zoneStore.setState({ draggedItem: event.operation.source });
|
6174
6323
|
},
|
6175
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
6176
|
-
DropZoneProvider,
|
6177
|
-
{
|
6178
|
-
value: {
|
6179
|
-
mode: "edit",
|
6180
|
-
areaId: "root",
|
6181
|
-
depth: 0
|
6182
|
-
},
|
6183
|
-
children
|
6184
|
-
}
|
6185
|
-
) })
|
6324
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
|
6186
6325
|
}
|
6187
6326
|
)
|
6188
6327
|
}
|
@@ -7366,7 +7505,7 @@ var LayerTree = ({
|
|
7366
7505
|
// components/Puck/components/Outline/index.tsx
|
7367
7506
|
var import_react45 = require("react");
|
7368
7507
|
|
7369
|
-
// lib/find-zones-for-area.ts
|
7508
|
+
// lib/data/find-zones-for-area.ts
|
7370
7509
|
init_react_import();
|
7371
7510
|
var findZonesForArea = (state, area) => {
|
7372
7511
|
return Object.keys(state.indexes.zones).filter(
|
@@ -7976,13 +8115,22 @@ var generateUsePuck = (store) => {
|
|
7976
8115
|
index: store.history.index
|
7977
8116
|
};
|
7978
8117
|
const storeData = {
|
7979
|
-
appState: store.state,
|
8118
|
+
appState: makeStatePublic(store.state),
|
7980
8119
|
config: store.config,
|
7981
8120
|
dispatch: store.dispatch,
|
7982
8121
|
getPermissions: store.permissions.getPermissions,
|
7983
8122
|
refreshPermissions: store.permissions.refreshPermissions,
|
7984
8123
|
history,
|
7985
|
-
selectedItem: store.selectedItem || null
|
8124
|
+
selectedItem: store.selectedItem || null,
|
8125
|
+
getItemBySelector: (selector) => getItem(selector, store.state),
|
8126
|
+
getItemById: (id) => store.state.indexes.nodes[id].data,
|
8127
|
+
getSelectorForId: (id) => {
|
8128
|
+
const node = store.state.indexes.nodes[id];
|
8129
|
+
if (!node) return;
|
8130
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
8131
|
+
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
8132
|
+
return { zone: zoneCompound, index };
|
8133
|
+
}
|
7986
8134
|
};
|
7987
8135
|
const get = () => storeData;
|
7988
8136
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
@@ -7990,23 +8138,25 @@ var generateUsePuck = (store) => {
|
|
7990
8138
|
var UsePuckStoreContext = (0, import_react51.createContext)(
|
7991
8139
|
null
|
7992
8140
|
);
|
8141
|
+
var convertToPickedStore = (store) => {
|
8142
|
+
return {
|
8143
|
+
state: store.state,
|
8144
|
+
config: store.config,
|
8145
|
+
dispatch: store.dispatch,
|
8146
|
+
permissions: store.permissions,
|
8147
|
+
history: store.history,
|
8148
|
+
selectedItem: store.selectedItem
|
8149
|
+
};
|
8150
|
+
};
|
7993
8151
|
var useRegisterUsePuckStore = (appStore) => {
|
7994
8152
|
const [usePuckStore] = (0, import_react51.useState)(
|
7995
|
-
() => (0, import_zustand6.createStore)(
|
8153
|
+
() => (0, import_zustand6.createStore)(
|
8154
|
+
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
8155
|
+
)
|
7996
8156
|
);
|
7997
8157
|
(0, import_react51.useEffect)(() => {
|
7998
8158
|
return appStore.subscribe(
|
7999
|
-
(store) =>
|
8000
|
-
const pickedStore = {
|
8001
|
-
state: store.state,
|
8002
|
-
config: store.config,
|
8003
|
-
dispatch: store.dispatch,
|
8004
|
-
permissions: store.permissions,
|
8005
|
-
history: store.history,
|
8006
|
-
selectedItem: store.selectedItem
|
8007
|
-
};
|
8008
|
-
return pickedStore;
|
8009
|
-
},
|
8159
|
+
(store) => convertToPickedStore(store),
|
8010
8160
|
(pickedStore) => {
|
8011
8161
|
usePuckStore.setState(generateUsePuck(pickedStore));
|
8012
8162
|
}
|
@@ -8049,29 +8199,11 @@ var FieldSideBar = () => {
|
|
8049
8199
|
);
|
8050
8200
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Fields, {}) });
|
8051
8201
|
};
|
8052
|
-
var DEBUG4 = false;
|
8053
8202
|
var propsContext = (0, import_react52.createContext)({});
|
8054
8203
|
function PropsProvider(props) {
|
8055
8204
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(propsContext.Provider, { value: props, children: props.children });
|
8056
8205
|
}
|
8057
8206
|
var usePropsContext = () => (0, import_react52.useContext)(propsContext);
|
8058
|
-
var debugPlugin = {
|
8059
|
-
overrides: {
|
8060
|
-
fields: ({ children }) => {
|
8061
|
-
const state = useAppStore((s) => s.state);
|
8062
|
-
const selectedItem = useAppStore((s) => s.selectedItem);
|
8063
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
8064
|
-
children,
|
8065
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Debug: Data", children: JSON.stringify(state.data) }),
|
8066
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Debug: UI", children: JSON.stringify(state.ui) }),
|
8067
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Debug: Other", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("ul", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("li", { children: [
|
8068
|
-
"Selected Item: ",
|
8069
|
-
JSON.stringify(selectedItem)
|
8070
|
-
] }) }) })
|
8071
|
-
] });
|
8072
|
-
}
|
8073
|
-
}
|
8074
|
-
};
|
8075
8207
|
function PuckProvider({ children }) {
|
8076
8208
|
const {
|
8077
8209
|
config,
|
@@ -8079,7 +8211,7 @@ function PuckProvider({ children }) {
|
|
8079
8211
|
ui: initialUi,
|
8080
8212
|
onChange,
|
8081
8213
|
permissions = {},
|
8082
|
-
plugins
|
8214
|
+
plugins,
|
8083
8215
|
overrides,
|
8084
8216
|
viewports = defaultViewports,
|
8085
8217
|
iframe: _iframe,
|
@@ -8151,57 +8283,57 @@ function PuckProvider({ children }) {
|
|
8151
8283
|
return walkTree(newAppState, config);
|
8152
8284
|
});
|
8153
8285
|
const { appendData = true } = _initialHistory || {};
|
8154
|
-
const blendedHistories =
|
8155
|
-
|
8156
|
-
|
8157
|
-
|
8158
|
-
|
8159
|
-
|
8160
|
-
|
8286
|
+
const [blendedHistories] = (0, import_react52.useState)(
|
8287
|
+
[
|
8288
|
+
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
8289
|
+
...appendData ? [{ state: generatedAppState }] : []
|
8290
|
+
].map((history) => {
|
8291
|
+
let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
|
8292
|
+
if (!history.state.indexes) {
|
8293
|
+
newState = walkTree(newState, config);
|
8294
|
+
}
|
8295
|
+
return __spreadProps(__spreadValues({}, history), {
|
8296
|
+
state: newState
|
8297
|
+
});
|
8298
|
+
})
|
8299
|
+
);
|
8161
8300
|
const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
|
8162
8301
|
const initialAppState = blendedHistories[initialHistoryIndex].state;
|
8163
|
-
const plugins = (0, import_react52.useMemo)(
|
8164
|
-
() => DEBUG4 ? [..._plugins || [], debugPlugin] : _plugins,
|
8165
|
-
[_plugins]
|
8166
|
-
);
|
8167
8302
|
const loadedOverrides = useLoadedOverrides({
|
8168
8303
|
overrides,
|
8169
8304
|
plugins
|
8170
8305
|
});
|
8171
|
-
const generateAppStore = (0, import_react52.useCallback)(
|
8172
|
-
|
8173
|
-
|
8306
|
+
const generateAppStore = (0, import_react52.useCallback)(
|
8307
|
+
(state) => {
|
8308
|
+
return {
|
8309
|
+
state,
|
8310
|
+
config,
|
8311
|
+
plugins: plugins || [],
|
8312
|
+
overrides: loadedOverrides,
|
8313
|
+
viewports,
|
8314
|
+
iframe,
|
8315
|
+
onAction,
|
8316
|
+
metadata
|
8317
|
+
};
|
8318
|
+
},
|
8319
|
+
[
|
8320
|
+
initialAppState,
|
8174
8321
|
config,
|
8175
|
-
plugins
|
8176
|
-
|
8322
|
+
plugins,
|
8323
|
+
loadedOverrides,
|
8177
8324
|
viewports,
|
8178
8325
|
iframe,
|
8179
8326
|
onAction,
|
8180
8327
|
metadata
|
8181
|
-
|
8182
|
-
|
8183
|
-
|
8184
|
-
|
8185
|
-
|
8186
|
-
loadedOverrides,
|
8187
|
-
viewports,
|
8188
|
-
iframe,
|
8189
|
-
onAction,
|
8190
|
-
metadata
|
8191
|
-
]);
|
8192
|
-
const [appStore] = (0, import_react52.useState)(() => createAppStore(generateAppStore()));
|
8328
|
+
]
|
8329
|
+
);
|
8330
|
+
const [appStore] = (0, import_react52.useState)(
|
8331
|
+
() => createAppStore(generateAppStore(initialAppState))
|
8332
|
+
);
|
8193
8333
|
(0, import_react52.useEffect)(() => {
|
8194
|
-
appStore.
|
8195
|
-
|
8196
|
-
|
8197
|
-
config,
|
8198
|
-
plugins,
|
8199
|
-
loadedOverrides,
|
8200
|
-
viewports,
|
8201
|
-
iframe,
|
8202
|
-
onAction,
|
8203
|
-
metadata
|
8204
|
-
]);
|
8334
|
+
const state = appStore.getState().state;
|
8335
|
+
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
8336
|
+
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
8205
8337
|
useRegisterHistorySlice(appStore, {
|
8206
8338
|
histories: blendedHistories,
|
8207
8339
|
index: initialHistoryIndex,
|
@@ -8491,16 +8623,73 @@ var migrations = [
|
|
8491
8623
|
});
|
8492
8624
|
}
|
8493
8625
|
return data;
|
8626
|
+
},
|
8627
|
+
// Migrate zones to slots
|
8628
|
+
(data, config) => {
|
8629
|
+
var _a;
|
8630
|
+
if (!config) return data;
|
8631
|
+
console.log("Migrating DropZones to slots...");
|
8632
|
+
const updatedItems = {};
|
8633
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8634
|
+
const { indexes } = walkTree(appState, config);
|
8635
|
+
const deletedCompounds = [];
|
8636
|
+
walkTree(appState, config, (content, zoneCompound, zoneType) => {
|
8637
|
+
var _a2, _b;
|
8638
|
+
if (zoneType === "dropzone") {
|
8639
|
+
const [id, slotName] = zoneCompound.split(":");
|
8640
|
+
const nodeData = indexes.nodes[id].data;
|
8641
|
+
const componentType = nodeData.type;
|
8642
|
+
const configForComponent = config.components[componentType];
|
8643
|
+
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
8644
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
8645
|
+
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
8646
|
+
[slotName]: content
|
8647
|
+
})
|
8648
|
+
});
|
8649
|
+
deletedCompounds.push(zoneCompound);
|
8650
|
+
}
|
8651
|
+
return content;
|
8652
|
+
}
|
8653
|
+
return content;
|
8654
|
+
});
|
8655
|
+
const updated = walkTree(
|
8656
|
+
appState,
|
8657
|
+
config,
|
8658
|
+
(content) => content,
|
8659
|
+
(item) => {
|
8660
|
+
var _a2;
|
8661
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
8662
|
+
}
|
8663
|
+
);
|
8664
|
+
deletedCompounds.forEach((zoneCompound) => {
|
8665
|
+
var _a2;
|
8666
|
+
const [_, propName] = zoneCompound.split(":");
|
8667
|
+
console.log(
|
8668
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
8669
|
+
);
|
8670
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
8671
|
+
});
|
8672
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
8673
|
+
const [_, propName] = zoneCompound.split(":");
|
8674
|
+
throw new Error(
|
8675
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
8676
|
+
);
|
8677
|
+
});
|
8678
|
+
delete updated.data.zones;
|
8679
|
+
return updated.data;
|
8494
8680
|
}
|
8495
8681
|
];
|
8496
|
-
function migrate(data) {
|
8497
|
-
return migrations == null ? void 0 : migrations.reduce(
|
8682
|
+
function migrate(data, config) {
|
8683
|
+
return migrations == null ? void 0 : migrations.reduce(
|
8684
|
+
(acc, migration) => migration(acc, config),
|
8685
|
+
data
|
8686
|
+
);
|
8498
8687
|
}
|
8499
8688
|
|
8500
8689
|
// lib/transform-props.ts
|
8501
8690
|
init_react_import();
|
8502
8691
|
|
8503
|
-
// lib/default-data.ts
|
8692
|
+
// lib/data/default-data.ts
|
8504
8693
|
init_react_import();
|
8505
8694
|
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
8506
8695
|
root: data.root || {},
|
@@ -8543,7 +8732,7 @@ function transformProps(data, propTransforms) {
|
|
8543
8732
|
// lib/resolve-all-data.ts
|
8544
8733
|
init_react_import();
|
8545
8734
|
|
8546
|
-
// lib/to-component.ts
|
8735
|
+
// lib/data/to-component.ts
|
8547
8736
|
init_react_import();
|
8548
8737
|
var toComponent = (item) => {
|
8549
8738
|
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
@@ -8571,17 +8760,29 @@ function resolveAllData(_0, _1) {
|
|
8571
8760
|
"force",
|
8572
8761
|
false
|
8573
8762
|
)).node;
|
8574
|
-
const resolvedDeep = yield
|
8763
|
+
const resolvedDeep = yield mapSlotsAsync(
|
8764
|
+
resolved,
|
8765
|
+
processContent,
|
8766
|
+
false
|
8767
|
+
);
|
8575
8768
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
8576
8769
|
return resolvedDeep;
|
8577
8770
|
});
|
8578
8771
|
const processContent = (content) => __async(this, null, function* () {
|
8579
8772
|
return Promise.all(content.map(resolveNode));
|
8580
8773
|
});
|
8774
|
+
const processZones = () => __async(this, null, function* () {
|
8775
|
+
var _a2;
|
8776
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
8777
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
8778
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
8779
|
+
}));
|
8780
|
+
return zones;
|
8781
|
+
});
|
8581
8782
|
const dynamic = {
|
8582
8783
|
root: yield resolveNode(defaultedData.root),
|
8583
8784
|
content: yield processContent(defaultedData.content),
|
8584
|
-
zones:
|
8785
|
+
zones: yield processZones()
|
8585
8786
|
};
|
8586
8787
|
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
8587
8788
|
const content = defaultedData.zones[zoneKey];
|
@@ -8605,6 +8806,7 @@ function resolveAllData(_0, _1) {
|
|
8605
8806
|
Puck,
|
8606
8807
|
Render,
|
8607
8808
|
createUsePuck,
|
8809
|
+
mapSlots,
|
8608
8810
|
migrate,
|
8609
8811
|
overrideKeys,
|
8610
8812
|
renderContext,
|