@measured/puck 0.19.0-canary.1918ad70 → 0.19.0-canary.226c08da
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 +2 -4
- package/dist/chunk-44RES7IE.mjs +566 -0
- package/dist/index.css +58 -54
- package/dist/index.d.mts +14 -9
- package/dist/index.d.ts +14 -9
- package/dist/index.js +1495 -1483
- package/dist/index.mjs +6290 -1653
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +271 -3633
- package/dist/rsc.mjs +5 -103
- package/dist/{resolve-all-data-Cs8PfTrg.d.mts → walk-tree-CM-cu7GU.d.mts} +46 -20
- package/dist/{resolve-all-data-Cs8PfTrg.d.ts → walk-tree-CM-cu7GU.d.ts} +46 -20
- package/package.json +4 -4
- package/dist/chunk-D4ZXRBOO.mjs +0 -5263
- package/dist/rsc.css +0 -338
package/dist/index.js
CHANGED
@@ -9,9 +9,6 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
9
|
var __getProtoOf = Object.getPrototypeOf;
|
10
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
11
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
12
|
-
var __typeError = (msg) => {
|
13
|
-
throw TypeError(msg);
|
14
|
-
};
|
15
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
16
13
|
var __spreadValues = (a, b) => {
|
17
14
|
for (var prop in b || (b = {}))
|
@@ -64,10 +61,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
64
61
|
mod
|
65
62
|
));
|
66
63
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
67
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
68
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
69
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
70
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
71
64
|
var __async = (__this, __arguments, generator) => {
|
72
65
|
return new Promise((resolve, reject) => {
|
73
66
|
var fulfilled = (value) => {
|
@@ -181,7 +174,8 @@ __export(core_exports, {
|
|
181
174
|
renderContext: () => renderContext,
|
182
175
|
resolveAllData: () => resolveAllData,
|
183
176
|
transformProps: () => transformProps,
|
184
|
-
usePuck: () => usePuck
|
177
|
+
usePuck: () => usePuck,
|
178
|
+
walkTree: () => walkTree
|
185
179
|
});
|
186
180
|
module.exports = __toCommonJS(core_exports);
|
187
181
|
init_react_import();
|
@@ -308,7 +302,7 @@ init_react_import();
|
|
308
302
|
|
309
303
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
310
304
|
init_react_import();
|
311
|
-
var styles_module_default2 = { "InputWrapper": "
|
305
|
+
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
306
|
|
313
307
|
// components/AutoField/index.tsx
|
314
308
|
var import_react22 = require("react");
|
@@ -670,7 +664,7 @@ init_react_import();
|
|
670
664
|
// lib/filter.ts
|
671
665
|
init_react_import();
|
672
666
|
|
673
|
-
// lib/reorder.ts
|
667
|
+
// lib/data/reorder.ts
|
674
668
|
init_react_import();
|
675
669
|
var reorder = (list, startIndex, endIndex) => {
|
676
670
|
const result = Array.from(list);
|
@@ -679,7 +673,7 @@ var reorder = (list, startIndex, endIndex) => {
|
|
679
673
|
return result;
|
680
674
|
};
|
681
675
|
|
682
|
-
// lib/replace.ts
|
676
|
+
// lib/data/replace.ts
|
683
677
|
init_react_import();
|
684
678
|
var replace = (list, index, newItem) => {
|
685
679
|
const result = Array.from(list);
|
@@ -791,74 +785,30 @@ init_react_import();
|
|
791
785
|
// reducer/index.ts
|
792
786
|
init_react_import();
|
793
787
|
|
794
|
-
// reducer/
|
795
|
-
init_react_import();
|
796
|
-
|
797
|
-
// lib/insert.ts
|
788
|
+
// reducer/actions/set.ts
|
798
789
|
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
790
|
|
805
|
-
// lib/
|
791
|
+
// lib/data/walk-app-state.ts
|
806
792
|
init_react_import();
|
807
|
-
var remove = (list, index) => {
|
808
|
-
const result = Array.from(list);
|
809
|
-
result.splice(index, 1);
|
810
|
-
return result;
|
811
|
-
};
|
812
793
|
|
813
|
-
// lib/
|
794
|
+
// lib/data/for-each-slot.ts
|
814
795
|
init_react_import();
|
815
796
|
|
816
|
-
// lib/
|
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
|
797
|
+
// lib/data/is-slot.ts
|
854
798
|
init_react_import();
|
855
799
|
var isSlot = (prop) => {
|
856
800
|
var _a, _b;
|
857
801
|
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
802
|
};
|
803
|
+
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
804
|
+
var _a, _b;
|
805
|
+
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
806
|
+
if (!configForComponent) return isSlot(propValue);
|
807
|
+
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
808
|
+
};
|
859
809
|
|
860
|
-
// lib/for-each-slot.ts
|
861
|
-
var forEachSlot = (
|
810
|
+
// lib/data/for-each-slot.ts
|
811
|
+
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
862
812
|
const props = item.props || {};
|
863
813
|
const propKeys = Object.keys(props);
|
864
814
|
for (let i = 0; i < propKeys.length; i++) {
|
@@ -866,23 +816,31 @@ var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function*
|
|
866
816
|
const itemType = "type" in item ? item.type : "root";
|
867
817
|
if (isSlot2(itemType, propKey, props[propKey])) {
|
868
818
|
const content = props[propKey];
|
869
|
-
|
819
|
+
cb(props.id, propKey, content);
|
870
820
|
if (recursive) {
|
871
821
|
content.forEach(
|
872
822
|
(childItem) => __async(void 0, null, function* () {
|
873
|
-
return
|
823
|
+
return forEachSlot(childItem, cb, true, isSlot2);
|
874
824
|
})
|
875
825
|
);
|
876
826
|
}
|
877
827
|
}
|
878
828
|
}
|
879
|
-
}
|
829
|
+
};
|
880
830
|
|
881
|
-
// lib/for-related-zones.ts
|
831
|
+
// lib/data/for-related-zones.ts
|
882
832
|
init_react_import();
|
883
833
|
|
884
834
|
// lib/get-zone-id.ts
|
885
835
|
init_react_import();
|
836
|
+
|
837
|
+
// lib/root-droppable-id.ts
|
838
|
+
init_react_import();
|
839
|
+
var rootAreaId = "root";
|
840
|
+
var rootZone = "default-zone";
|
841
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
842
|
+
|
843
|
+
// lib/get-zone-id.ts
|
886
844
|
var getZoneId = (zoneCompound) => {
|
887
845
|
if (!zoneCompound) {
|
888
846
|
return [];
|
@@ -893,19 +851,17 @@ var getZoneId = (zoneCompound) => {
|
|
893
851
|
return [rootDroppableId, zoneCompound];
|
894
852
|
};
|
895
853
|
|
896
|
-
// lib/for-related-zones.ts
|
854
|
+
// lib/data/for-related-zones.ts
|
897
855
|
function forRelatedZones(item, data, cb, path = []) {
|
898
856
|
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
899
857
|
const [parentId] = getZoneId(zoneCompound);
|
900
858
|
if (parentId === item.props.id) {
|
901
|
-
const newPath = [...path, zoneCompound];
|
902
|
-
content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
|
903
859
|
cb(path, zoneCompound, content);
|
904
860
|
}
|
905
861
|
});
|
906
862
|
}
|
907
863
|
|
908
|
-
// lib/strip-slots.ts
|
864
|
+
// lib/data/strip-slots.ts
|
909
865
|
init_react_import();
|
910
866
|
var stripSlots = (data) => {
|
911
867
|
return __spreadProps(__spreadValues({}, data), {
|
@@ -921,8 +877,8 @@ var stripSlots = (data) => {
|
|
921
877
|
});
|
922
878
|
};
|
923
879
|
|
924
|
-
// lib/walk-
|
925
|
-
function
|
880
|
+
// lib/data/walk-app-state.ts
|
881
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
926
882
|
var _a;
|
927
883
|
let newZones = {};
|
928
884
|
const newZoneIndex = {};
|
@@ -963,7 +919,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
963
919
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
964
920
|
if (!mappedItem) return item;
|
965
921
|
const id = mappedItem.props.id;
|
966
|
-
processRelatedZones(item, id, path);
|
967
922
|
const newProps = __spreadValues({}, mappedItem.props);
|
968
923
|
forEachSlot(
|
969
924
|
mappedItem,
|
@@ -979,13 +934,9 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
979
934
|
newProps[slotId] = newContent2;
|
980
935
|
},
|
981
936
|
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
|
-
}
|
937
|
+
createIsSlotConfig(config)
|
988
938
|
);
|
939
|
+
processRelatedZones(item, id, path);
|
989
940
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
990
941
|
const thisZoneCompound = path[path.length - 1];
|
991
942
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
@@ -996,7 +947,7 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
996
947
|
parentId,
|
997
948
|
zone
|
998
949
|
};
|
999
|
-
const finalData = newItem;
|
950
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
1000
951
|
if (newProps.id === "root") {
|
1001
952
|
delete finalData["type"];
|
1002
953
|
delete finalData.props["id"];
|
@@ -1011,8 +962,12 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
1011
962
|
"root"
|
1012
963
|
);
|
1013
964
|
const processedContent = newContent;
|
965
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
1014
966
|
Object.keys(zones || {}).forEach((zoneCompound) => {
|
1015
967
|
const [parentId] = zoneCompound.split(":");
|
968
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
969
|
+
return;
|
970
|
+
}
|
1016
971
|
const [_2, newContent2] = processContent(
|
1017
972
|
[rootDroppableId],
|
1018
973
|
zoneCompound,
|
@@ -1036,7 +991,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
1036
991
|
return __spreadProps(__spreadValues({}, state), {
|
1037
992
|
data: {
|
1038
993
|
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
994
|
content: processedContent,
|
1041
995
|
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
1042
996
|
},
|
@@ -1047,60 +1001,157 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
1047
1001
|
});
|
1048
1002
|
}
|
1049
1003
|
|
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
|
1004
|
+
// reducer/actions/set.ts
|
1005
|
+
var setAction = (state, action, appStore) => {
|
1006
|
+
if (typeof action.state === "object") {
|
1007
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
1008
|
+
if (action.state.indexes) {
|
1009
|
+
return newState;
|
1010
|
+
}
|
1011
|
+
console.warn(
|
1012
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1076
1013
|
);
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
delete nodes[componentData.props.id];
|
1081
|
-
return { nodes, zones };
|
1014
|
+
return walkAppState(newState, appStore.config);
|
1015
|
+
}
|
1016
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
1082
1017
|
};
|
1083
1018
|
|
1084
|
-
// reducer/
|
1085
|
-
|
1019
|
+
// reducer/actions/insert.ts
|
1020
|
+
init_react_import();
|
1021
|
+
|
1022
|
+
// lib/data/insert.ts
|
1023
|
+
init_react_import();
|
1024
|
+
var insert = (list, index, item) => {
|
1025
|
+
const result = Array.from(list || []);
|
1026
|
+
result.splice(index, 0, item);
|
1027
|
+
return result;
|
1028
|
+
};
|
1029
|
+
|
1030
|
+
// lib/generate-id.ts
|
1031
|
+
init_react_import();
|
1032
|
+
var import_uuid = require("uuid");
|
1033
|
+
var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, import_uuid.v4)();
|
1034
|
+
|
1035
|
+
// lib/data/get-ids-for-parent.ts
|
1036
|
+
init_react_import();
|
1086
1037
|
var getIdsForParent = (zoneCompound, state) => {
|
1087
1038
|
const [parentId] = zoneCompound.split(":");
|
1088
1039
|
const node = state.indexes.nodes[parentId];
|
1089
1040
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
1090
1041
|
};
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1042
|
+
|
1043
|
+
// lib/data/populate-ids.ts
|
1044
|
+
init_react_import();
|
1045
|
+
|
1046
|
+
// lib/data/walk-tree.ts
|
1047
|
+
init_react_import();
|
1048
|
+
|
1049
|
+
// lib/data/map-slots.ts
|
1050
|
+
init_react_import();
|
1051
|
+
function mapSlotsAsync(_0, _1) {
|
1052
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1053
|
+
const props = __spreadValues({}, item.props);
|
1054
|
+
const propKeys = Object.keys(props);
|
1055
|
+
for (let i = 0; i < propKeys.length; i++) {
|
1056
|
+
const propKey = propKeys[i];
|
1057
|
+
const itemType = "type" in item ? item.type : "root";
|
1058
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
1059
|
+
const content = props[propKey];
|
1060
|
+
const mappedContent = recursive ? yield Promise.all(
|
1061
|
+
content.map((item2) => __async(this, null, function* () {
|
1062
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1063
|
+
}))
|
1064
|
+
) : content;
|
1065
|
+
props[propKey] = yield map(mappedContent, propKey);
|
1066
|
+
}
|
1067
|
+
}
|
1068
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
1069
|
+
});
|
1070
|
+
}
|
1071
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
1072
|
+
var _a, _b;
|
1073
|
+
const props = __spreadValues({}, item.props);
|
1074
|
+
const propKeys = Object.keys(props);
|
1075
|
+
for (let i = 0; i < propKeys.length; i++) {
|
1076
|
+
const propKey = propKeys[i];
|
1077
|
+
const itemType = "type" in item ? item.type : "root";
|
1078
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
1079
|
+
const content = props[propKey];
|
1080
|
+
const mappedContent = content.map((item2) => {
|
1081
|
+
return mapSlotsSync(item2, map, isSlot2);
|
1082
|
+
});
|
1083
|
+
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
1084
|
+
}
|
1085
|
+
}
|
1086
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
// lib/data/walk-tree.ts
|
1090
|
+
function walkTree(data, config, callbackFn) {
|
1091
|
+
var _a, _b;
|
1092
|
+
const isSlot2 = createIsSlotConfig(config);
|
1093
|
+
const walkItem = (item) => {
|
1094
|
+
return mapSlotsSync(
|
1095
|
+
item,
|
1096
|
+
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
1097
|
+
isSlot2
|
1098
|
+
);
|
1099
|
+
};
|
1100
|
+
if ("props" in data) {
|
1101
|
+
return walkItem(data);
|
1102
|
+
}
|
1103
|
+
const _data = data;
|
1104
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
1105
|
+
const mappedContent = _data.content.map(walkItem);
|
1106
|
+
return {
|
1107
|
+
root: walkItem(_data.root),
|
1108
|
+
content: (_b = callbackFn(mappedContent, {
|
1109
|
+
parentId: "root",
|
1110
|
+
propName: "default-zone"
|
1111
|
+
})) != null ? _b : mappedContent,
|
1112
|
+
zones: Object.keys(zones).reduce(
|
1113
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
1114
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
1115
|
+
}),
|
1116
|
+
{}
|
1117
|
+
)
|
1098
1118
|
};
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
// lib/data/populate-ids.ts
|
1122
|
+
var populateIds = (data, config, override = false) => {
|
1123
|
+
const id = generateId(data.type);
|
1124
|
+
return walkTree(
|
1125
|
+
__spreadProps(__spreadValues({}, data), {
|
1126
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
1127
|
+
}),
|
1128
|
+
config,
|
1129
|
+
(contents) => contents.map((item) => {
|
1130
|
+
const id2 = generateId(item.type);
|
1131
|
+
return __spreadProps(__spreadValues({}, item), {
|
1132
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
1133
|
+
});
|
1134
|
+
})
|
1135
|
+
);
|
1136
|
+
};
|
1137
|
+
|
1138
|
+
// reducer/actions/insert.ts
|
1139
|
+
function insertAction(state, action, appStore) {
|
1140
|
+
const id = action.id || generateId(action.componentType);
|
1141
|
+
const emptyComponentData = populateIds(
|
1142
|
+
{
|
1143
|
+
type: action.componentType,
|
1144
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
1145
|
+
id
|
1146
|
+
})
|
1147
|
+
},
|
1148
|
+
appStore.config
|
1149
|
+
);
|
1099
1150
|
const [parentId] = action.destinationZone.split(":");
|
1100
1151
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1101
|
-
return
|
1152
|
+
return walkAppState(
|
1102
1153
|
state,
|
1103
|
-
config,
|
1154
|
+
appStore.config,
|
1104
1155
|
(content, zoneCompound) => {
|
1105
1156
|
if (zoneCompound === action.destinationZone) {
|
1106
1157
|
return insert(
|
@@ -1111,16 +1162,154 @@ function insertAction(state, action, config) {
|
|
1111
1162
|
}
|
1112
1163
|
return content;
|
1113
1164
|
},
|
1114
|
-
(childItem) => {
|
1165
|
+
(childItem, path) => {
|
1115
1166
|
if (childItem.props.id === id || childItem.props.id === parentId) {
|
1116
1167
|
return childItem;
|
1168
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
1169
|
+
return childItem;
|
1170
|
+
} else if (path.includes(action.destinationZone)) {
|
1171
|
+
return childItem;
|
1172
|
+
}
|
1173
|
+
return null;
|
1174
|
+
}
|
1175
|
+
);
|
1176
|
+
}
|
1177
|
+
|
1178
|
+
// reducer/actions/replace.ts
|
1179
|
+
init_react_import();
|
1180
|
+
var replaceAction = (state, action, appStore) => {
|
1181
|
+
const [parentId] = action.destinationZone.split(":");
|
1182
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1183
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
1184
|
+
const idChanged = originalId !== action.data.props.id;
|
1185
|
+
if (idChanged) {
|
1186
|
+
throw new Error(
|
1187
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1188
|
+
);
|
1189
|
+
}
|
1190
|
+
const data = populateIds(action.data, appStore.config);
|
1191
|
+
return walkAppState(
|
1192
|
+
state,
|
1193
|
+
appStore.config,
|
1194
|
+
(content, zoneCompound) => {
|
1195
|
+
const newContent = [...content];
|
1196
|
+
if (zoneCompound === action.destinationZone) {
|
1197
|
+
newContent[action.destinationIndex] = data;
|
1198
|
+
}
|
1199
|
+
return newContent;
|
1200
|
+
},
|
1201
|
+
(childItem, path) => {
|
1202
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
1203
|
+
if (childItem.props.id === data.props.id) {
|
1204
|
+
return data;
|
1205
|
+
} else if (childItem.props.id === parentId) {
|
1206
|
+
return childItem;
|
1117
1207
|
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1118
1208
|
return childItem;
|
1209
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1210
|
+
return childItem;
|
1211
|
+
}
|
1212
|
+
return null;
|
1213
|
+
}
|
1214
|
+
);
|
1215
|
+
};
|
1216
|
+
|
1217
|
+
// reducer/actions/replace-root.ts
|
1218
|
+
init_react_import();
|
1219
|
+
var replaceRootAction = (state, action, appStore) => {
|
1220
|
+
return walkAppState(
|
1221
|
+
state,
|
1222
|
+
appStore.config,
|
1223
|
+
(content) => content,
|
1224
|
+
(childItem) => {
|
1225
|
+
if (childItem.props.id === "root") {
|
1226
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1227
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1228
|
+
readOnly: action.root.readOnly
|
1229
|
+
});
|
1230
|
+
}
|
1231
|
+
return childItem;
|
1232
|
+
}
|
1233
|
+
);
|
1234
|
+
};
|
1235
|
+
|
1236
|
+
// reducer/actions/duplicate.ts
|
1237
|
+
init_react_import();
|
1238
|
+
|
1239
|
+
// lib/data/get-item.ts
|
1240
|
+
init_react_import();
|
1241
|
+
function getItem(selector, state) {
|
1242
|
+
var _a, _b;
|
1243
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1244
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
1245
|
+
}
|
1246
|
+
|
1247
|
+
// reducer/actions/duplicate.ts
|
1248
|
+
function duplicateAction(state, action, appStore) {
|
1249
|
+
const item = getItem(
|
1250
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1251
|
+
state
|
1252
|
+
);
|
1253
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1254
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1255
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1256
|
+
id: generateId(item.type)
|
1257
|
+
})
|
1258
|
+
});
|
1259
|
+
const modified = walkAppState(
|
1260
|
+
state,
|
1261
|
+
appStore.config,
|
1262
|
+
(content, zoneCompound) => {
|
1263
|
+
if (zoneCompound === action.sourceZone) {
|
1264
|
+
return insert(content, action.sourceIndex + 1, item);
|
1265
|
+
}
|
1266
|
+
return content;
|
1267
|
+
},
|
1268
|
+
(childItem, path, index) => {
|
1269
|
+
const zoneCompound = path[path.length - 1];
|
1270
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1271
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1272
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1273
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1274
|
+
id: generateId(childItem.type)
|
1275
|
+
})
|
1276
|
+
});
|
1277
|
+
}
|
1278
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1279
|
+
return newItem;
|
1280
|
+
}
|
1281
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1282
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1283
|
+
return childItem;
|
1119
1284
|
}
|
1120
1285
|
return null;
|
1121
1286
|
}
|
1122
1287
|
);
|
1288
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1289
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1290
|
+
itemSelector: {
|
1291
|
+
index: action.sourceIndex + 1,
|
1292
|
+
zone: action.sourceZone
|
1293
|
+
}
|
1294
|
+
})
|
1295
|
+
});
|
1123
1296
|
}
|
1297
|
+
|
1298
|
+
// reducer/actions/reorder.ts
|
1299
|
+
init_react_import();
|
1300
|
+
|
1301
|
+
// reducer/actions/move.ts
|
1302
|
+
init_react_import();
|
1303
|
+
|
1304
|
+
// lib/data/remove.ts
|
1305
|
+
init_react_import();
|
1306
|
+
var remove = (list, index) => {
|
1307
|
+
const result = Array.from(list);
|
1308
|
+
result.splice(index, 1);
|
1309
|
+
return result;
|
1310
|
+
};
|
1311
|
+
|
1312
|
+
// reducer/actions/move.ts
|
1124
1313
|
var moveAction = (state, action, appStore) => {
|
1125
1314
|
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1126
1315
|
return state;
|
@@ -1132,7 +1321,7 @@ var moveAction = (state, action, appStore) => {
|
|
1132
1321
|
if (!item) return state;
|
1133
1322
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1134
1323
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1135
|
-
return
|
1324
|
+
return walkAppState(
|
1136
1325
|
state,
|
1137
1326
|
appStore.config,
|
1138
1327
|
(content, zoneCompound) => {
|
@@ -1149,233 +1338,172 @@ var moveAction = (state, action, appStore) => {
|
|
1149
1338
|
}
|
1150
1339
|
return content;
|
1151
1340
|
},
|
1152
|
-
(childItem) => {
|
1341
|
+
(childItem, path) => {
|
1153
1342
|
const [sourceZoneParent] = action.sourceZone.split(":");
|
1154
1343
|
const [destinationZoneParent] = action.destinationZone.split(":");
|
1155
1344
|
const childId = childItem.props.id;
|
1156
|
-
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1) {
|
1345
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
1157
1346
|
return childItem;
|
1158
1347
|
}
|
1159
1348
|
return null;
|
1160
1349
|
}
|
1161
1350
|
);
|
1162
1351
|
};
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
return
|
1352
|
+
|
1353
|
+
// reducer/actions/reorder.ts
|
1354
|
+
var reorderAction = (state, action, appStore) => {
|
1355
|
+
return moveAction(
|
1356
|
+
state,
|
1357
|
+
{
|
1358
|
+
type: "move",
|
1359
|
+
sourceIndex: action.sourceIndex,
|
1360
|
+
sourceZone: action.destinationZone,
|
1361
|
+
destinationIndex: action.destinationIndex,
|
1362
|
+
destinationZone: action.destinationZone
|
1363
|
+
},
|
1364
|
+
appStore
|
1365
|
+
);
|
1366
|
+
};
|
1367
|
+
|
1368
|
+
// reducer/actions/remove.ts
|
1369
|
+
init_react_import();
|
1370
|
+
var removeAction = (state, action, appStore) => {
|
1371
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1372
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1373
|
+
(acc, [nodeId, nodeData]) => {
|
1374
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1375
|
+
if (pathIds.includes(item.props.id)) {
|
1376
|
+
return [...acc, nodeId];
|
1377
|
+
}
|
1378
|
+
return acc;
|
1379
|
+
},
|
1380
|
+
[item.props.id]
|
1381
|
+
);
|
1382
|
+
const newState = walkAppState(
|
1167
1383
|
state,
|
1168
1384
|
appStore.config,
|
1169
|
-
(content) =>
|
1170
|
-
|
1171
|
-
|
1172
|
-
if (childItem.props.id === action.data.props.id) {
|
1173
|
-
return action.data;
|
1174
|
-
} else if (childItem.props.id === parentId) {
|
1175
|
-
return childItem;
|
1176
|
-
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1177
|
-
return childItem;
|
1178
|
-
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
1179
|
-
return childItem;
|
1385
|
+
(content, zoneCompound) => {
|
1386
|
+
if (zoneCompound === action.zone) {
|
1387
|
+
return remove(content, action.index);
|
1180
1388
|
}
|
1181
|
-
return
|
1389
|
+
return content;
|
1182
1390
|
}
|
1183
1391
|
);
|
1184
|
-
}
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
if (action.state.indexes) {
|
1189
|
-
console.warn(
|
1190
|
-
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1191
|
-
);
|
1192
|
-
return newState;
|
1392
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1393
|
+
const parentId = zoneCompound.split(":")[0];
|
1394
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1395
|
+
delete newState.data.zones[zoneCompound];
|
1193
1396
|
}
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
if (action.type === "set") {
|
1200
|
-
return setAction(state, action, appStore);
|
1201
|
-
}
|
1202
|
-
if (action.type === "insert") {
|
1203
|
-
return insertAction(state, action, appStore.config);
|
1204
|
-
}
|
1205
|
-
if (action.type === "replace") {
|
1206
|
-
return replaceAction(state, action, appStore);
|
1207
|
-
}
|
1208
|
-
if (action.type === "replaceRoot") {
|
1209
|
-
return walkTree(
|
1210
|
-
state,
|
1211
|
-
appStore.config,
|
1212
|
-
(content) => content,
|
1213
|
-
(childItem) => {
|
1214
|
-
if (childItem.props.id === "root") {
|
1215
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
1216
|
-
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1217
|
-
readOnly: action.root.readOnly
|
1218
|
-
});
|
1219
|
-
}
|
1220
|
-
return childItem;
|
1221
|
-
}
|
1222
|
-
);
|
1223
|
-
}
|
1224
|
-
if (action.type === "duplicate") {
|
1225
|
-
const item = getItem(
|
1226
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
1227
|
-
state
|
1228
|
-
);
|
1229
|
-
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1230
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
1231
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
1232
|
-
id: generateId(item.type)
|
1233
|
-
})
|
1234
|
-
});
|
1235
|
-
const modified = walkTree(
|
1236
|
-
state,
|
1237
|
-
appStore.config,
|
1238
|
-
(content, zoneCompound) => {
|
1239
|
-
if (zoneCompound === action.sourceZone) {
|
1240
|
-
return insert(content, action.sourceIndex + 1, item);
|
1241
|
-
}
|
1242
|
-
return content;
|
1243
|
-
},
|
1244
|
-
(childItem, path, index) => {
|
1245
|
-
const zoneCompound = path[path.length - 1];
|
1246
|
-
const parents = path.map((p) => p.split(":")[0]);
|
1247
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
1248
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
1249
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1250
|
-
id: generateId(childItem.type)
|
1251
|
-
})
|
1252
|
-
});
|
1253
|
-
}
|
1254
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1255
|
-
return newItem;
|
1256
|
-
}
|
1257
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
1258
|
-
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1259
|
-
return childItem;
|
1260
|
-
}
|
1261
|
-
return null;
|
1262
|
-
}
|
1263
|
-
);
|
1264
|
-
return __spreadProps(__spreadValues({}, modified), {
|
1265
|
-
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1266
|
-
itemSelector: {
|
1267
|
-
index: action.sourceIndex + 1,
|
1268
|
-
zone: action.sourceZone
|
1269
|
-
}
|
1270
|
-
})
|
1271
|
-
});
|
1272
|
-
}
|
1273
|
-
if (action.type === "reorder") {
|
1274
|
-
return moveAction(
|
1275
|
-
state,
|
1276
|
-
{
|
1277
|
-
type: "move",
|
1278
|
-
sourceIndex: action.sourceIndex,
|
1279
|
-
sourceZone: action.destinationZone,
|
1280
|
-
destinationIndex: action.destinationIndex,
|
1281
|
-
destinationZone: action.destinationZone
|
1282
|
-
},
|
1283
|
-
appStore
|
1284
|
-
);
|
1285
|
-
}
|
1286
|
-
if (action.type === "move") {
|
1287
|
-
return moveAction(state, action, appStore);
|
1288
|
-
}
|
1289
|
-
if (action.type === "remove") {
|
1290
|
-
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1291
|
-
let deindexed = deindex(state, item);
|
1292
|
-
const [parentId] = action.zone.split(":");
|
1293
|
-
return walkTree(
|
1294
|
-
__spreadProps(__spreadValues({}, state), { indexes: deindexed }),
|
1295
|
-
appStore.config,
|
1296
|
-
(content, zoneCompound) => {
|
1297
|
-
if (zoneCompound === action.zone) {
|
1298
|
-
return remove(content, action.index);
|
1299
|
-
}
|
1300
|
-
return content;
|
1301
|
-
},
|
1302
|
-
(childItem, path) => {
|
1303
|
-
const parentIds = path.map((p) => p.split(":")[0]);
|
1304
|
-
if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
|
1305
|
-
return childItem;
|
1306
|
-
}
|
1307
|
-
return null;
|
1308
|
-
}
|
1309
|
-
);
|
1310
|
-
}
|
1311
|
-
if (action.type === "registerZone") {
|
1312
|
-
if (zoneCache[action.zone]) {
|
1313
|
-
return __spreadProps(__spreadValues({}, state), {
|
1314
|
-
data: __spreadProps(__spreadValues({}, state.data), {
|
1315
|
-
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1316
|
-
[action.zone]: zoneCache[action.zone]
|
1317
|
-
})
|
1318
|
-
}),
|
1319
|
-
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1320
|
-
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1321
|
-
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1322
|
-
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1323
|
-
type: "dropzone"
|
1324
|
-
})
|
1325
|
-
})
|
1326
|
-
})
|
1327
|
-
});
|
1397
|
+
});
|
1398
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1399
|
+
const parentId = zoneCompound.split(":")[0];
|
1400
|
+
if (nodesToDelete.includes(parentId)) {
|
1401
|
+
delete newState.indexes.zones[zoneCompound];
|
1328
1402
|
}
|
1329
|
-
|
1403
|
+
});
|
1404
|
+
nodesToDelete.forEach((id) => {
|
1405
|
+
delete newState.indexes.nodes[id];
|
1406
|
+
});
|
1407
|
+
return newState;
|
1408
|
+
};
|
1409
|
+
|
1410
|
+
// reducer/actions/register-zone.ts
|
1411
|
+
init_react_import();
|
1412
|
+
|
1413
|
+
// lib/data/setup-zone.ts
|
1414
|
+
init_react_import();
|
1415
|
+
var setupZone = (data, zoneKey) => {
|
1416
|
+
if (zoneKey === rootDroppableId) {
|
1417
|
+
return data;
|
1330
1418
|
}
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1419
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1420
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1421
|
+
});
|
1422
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1423
|
+
return newData;
|
1424
|
+
};
|
1425
|
+
|
1426
|
+
// reducer/actions/register-zone.ts
|
1427
|
+
var zoneCache = {};
|
1428
|
+
function registerZoneAction(state, action) {
|
1429
|
+
if (zoneCache[action.zone]) {
|
1339
1430
|
return __spreadProps(__spreadValues({}, state), {
|
1340
1431
|
data: __spreadProps(__spreadValues({}, state.data), {
|
1341
|
-
zones:
|
1432
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1433
|
+
[action.zone]: zoneCache[action.zone]
|
1434
|
+
})
|
1342
1435
|
}),
|
1343
1436
|
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1344
|
-
zones:
|
1437
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1438
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1439
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1440
|
+
type: "dropzone"
|
1441
|
+
})
|
1442
|
+
})
|
1345
1443
|
})
|
1346
1444
|
});
|
1347
1445
|
}
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
}
|
1360
|
-
|
1446
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1447
|
+
}
|
1448
|
+
function unregisterZoneAction(state, action) {
|
1449
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1450
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1451
|
+
if (_zones[action.zone]) {
|
1452
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1453
|
+
delete _zones[action.zone];
|
1454
|
+
}
|
1455
|
+
delete zoneIndex[action.zone];
|
1456
|
+
return __spreadProps(__spreadValues({}, state), {
|
1457
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1458
|
+
zones: _zones
|
1459
|
+
}),
|
1460
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1461
|
+
zones: zoneIndex
|
1462
|
+
})
|
1463
|
+
});
|
1464
|
+
}
|
1465
|
+
|
1466
|
+
// reducer/actions/set-data.ts
|
1467
|
+
init_react_import();
|
1468
|
+
var setDataAction = (state, action, appStore) => {
|
1469
|
+
if (typeof action.data === "object") {
|
1470
|
+
console.warn(
|
1471
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1472
|
+
);
|
1473
|
+
return walkAppState(
|
1361
1474
|
__spreadProps(__spreadValues({}, state), {
|
1362
|
-
data: __spreadValues(__spreadValues({}, state.data), action.data
|
1475
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1363
1476
|
}),
|
1364
1477
|
appStore.config
|
1365
1478
|
);
|
1366
1479
|
}
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1480
|
+
return walkAppState(
|
1481
|
+
__spreadProps(__spreadValues({}, state), {
|
1482
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1483
|
+
}),
|
1484
|
+
appStore.config
|
1485
|
+
);
|
1486
|
+
};
|
1487
|
+
|
1488
|
+
// reducer/actions/set-ui.ts
|
1489
|
+
init_react_import();
|
1490
|
+
var setUiAction = (state, action) => {
|
1491
|
+
if (typeof action.ui === "object") {
|
1373
1492
|
return __spreadProps(__spreadValues({}, state), {
|
1374
|
-
ui: __spreadValues(__spreadValues({}, state.ui), action.ui
|
1493
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1375
1494
|
});
|
1376
1495
|
}
|
1377
|
-
return state
|
1378
|
-
}
|
1496
|
+
return __spreadProps(__spreadValues({}, state), {
|
1497
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1498
|
+
});
|
1499
|
+
};
|
1500
|
+
|
1501
|
+
// lib/data/make-state-public.ts
|
1502
|
+
init_react_import();
|
1503
|
+
var makeStatePublic = (state) => {
|
1504
|
+
const { data, ui } = state;
|
1505
|
+
return { data, ui };
|
1506
|
+
};
|
1379
1507
|
|
1380
1508
|
// reducer/actions.tsx
|
1381
1509
|
init_react_import();
|
@@ -1394,7 +1522,7 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1394
1522
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1395
1523
|
if (record) record(newAppState);
|
1396
1524
|
}
|
1397
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1525
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1398
1526
|
return newAppState;
|
1399
1527
|
};
|
1400
1528
|
}
|
@@ -1405,8 +1533,43 @@ function createReducer({
|
|
1405
1533
|
}) {
|
1406
1534
|
return storeInterceptor(
|
1407
1535
|
(state, action) => {
|
1408
|
-
|
1409
|
-
|
1536
|
+
if (action.type === "set") {
|
1537
|
+
return setAction(state, action, appStore);
|
1538
|
+
}
|
1539
|
+
if (action.type === "insert") {
|
1540
|
+
return insertAction(state, action, appStore);
|
1541
|
+
}
|
1542
|
+
if (action.type === "replace") {
|
1543
|
+
return replaceAction(state, action, appStore);
|
1544
|
+
}
|
1545
|
+
if (action.type === "replaceRoot") {
|
1546
|
+
return replaceRootAction(state, action, appStore);
|
1547
|
+
}
|
1548
|
+
if (action.type === "duplicate") {
|
1549
|
+
return duplicateAction(state, action, appStore);
|
1550
|
+
}
|
1551
|
+
if (action.type === "reorder") {
|
1552
|
+
return reorderAction(state, action, appStore);
|
1553
|
+
}
|
1554
|
+
if (action.type === "move") {
|
1555
|
+
return moveAction(state, action, appStore);
|
1556
|
+
}
|
1557
|
+
if (action.type === "remove") {
|
1558
|
+
return removeAction(state, action, appStore);
|
1559
|
+
}
|
1560
|
+
if (action.type === "registerZone") {
|
1561
|
+
return registerZoneAction(state, action);
|
1562
|
+
}
|
1563
|
+
if (action.type === "unregisterZone") {
|
1564
|
+
return unregisterZoneAction(state, action);
|
1565
|
+
}
|
1566
|
+
if (action.type === "setData") {
|
1567
|
+
return setDataAction(state, action, appStore);
|
1568
|
+
}
|
1569
|
+
if (action.type === "setUi") {
|
1570
|
+
return setUiAction(state, action);
|
1571
|
+
}
|
1572
|
+
return state;
|
1410
1573
|
},
|
1411
1574
|
record,
|
1412
1575
|
onAction
|
@@ -1618,7 +1781,7 @@ var createHistorySlice = (set, get) => {
|
|
1618
1781
|
const { dispatch, history } = get();
|
1619
1782
|
dispatch({
|
1620
1783
|
type: "set",
|
1621
|
-
state: ((_a = history.histories[
|
1784
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1622
1785
|
});
|
1623
1786
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1624
1787
|
},
|
@@ -1695,11 +1858,11 @@ var createNodesSlice = (set, get) => ({
|
|
1695
1858
|
init_react_import();
|
1696
1859
|
var import_react7 = require("react");
|
1697
1860
|
|
1698
|
-
// lib/flatten-data.ts
|
1861
|
+
// lib/data/flatten-data.ts
|
1699
1862
|
init_react_import();
|
1700
1863
|
var flattenData = (state, config) => {
|
1701
1864
|
const data = [];
|
1702
|
-
|
1865
|
+
walkAppState(
|
1703
1866
|
state,
|
1704
1867
|
config,
|
1705
1868
|
(content) => content,
|
@@ -1730,12 +1893,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1730
1893
|
const { cache: cache2, globalPermissions } = permissions;
|
1731
1894
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1732
1895
|
var _a, _b, _c;
|
1733
|
-
const {
|
1734
|
-
config: config2,
|
1735
|
-
state: appState,
|
1736
|
-
setComponentLoading,
|
1737
|
-
unsetComponentLoading
|
1738
|
-
} = get();
|
1896
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1739
1897
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1740
1898
|
if (!componentConfig) {
|
1741
1899
|
return;
|
@@ -1744,14 +1902,14 @@ var createPermissionsSlice = (set, get) => {
|
|
1744
1902
|
if (componentConfig.resolvePermissions) {
|
1745
1903
|
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1746
1904
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1747
|
-
setComponentLoading(item2.props.id);
|
1905
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1748
1906
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1749
1907
|
item2,
|
1750
1908
|
{
|
1751
1909
|
changed,
|
1752
1910
|
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1753
1911
|
permissions: initialPermissions,
|
1754
|
-
appState,
|
1912
|
+
appState: makeStatePublic(appState),
|
1755
1913
|
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1756
1914
|
}
|
1757
1915
|
);
|
@@ -1769,7 +1927,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1769
1927
|
})
|
1770
1928
|
})
|
1771
1929
|
});
|
1772
|
-
|
1930
|
+
clearTimeout2();
|
1773
1931
|
}
|
1774
1932
|
}
|
1775
1933
|
});
|
@@ -1779,7 +1937,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1779
1937
|
// Shim the root data in by conforming to component data shape
|
1780
1938
|
{
|
1781
1939
|
type: "root",
|
1782
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1940
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1783
1941
|
},
|
1784
1942
|
force2
|
1785
1943
|
);
|
@@ -1794,7 +1952,6 @@ var createPermissionsSlice = (set, get) => {
|
|
1794
1952
|
} else if (root) {
|
1795
1953
|
resolveDataForRoot(force);
|
1796
1954
|
} else {
|
1797
|
-
resolveDataForRoot(force);
|
1798
1955
|
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1799
1956
|
yield resolveDataForItem(item2, force);
|
1800
1957
|
}));
|
@@ -1825,7 +1982,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1825
1982
|
} else if (root) {
|
1826
1983
|
const rootConfig = config.root;
|
1827
1984
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1828
|
-
const resolvedForItem = resolvedPermissions["
|
1985
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1829
1986
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1830
1987
|
}
|
1831
1988
|
return globalPermissions;
|
@@ -1870,7 +2027,8 @@ var createFieldsSlice = (_set, _get) => {
|
|
1870
2027
|
return {
|
1871
2028
|
fields: {},
|
1872
2029
|
loading: false,
|
1873
|
-
lastResolvedData: {}
|
2030
|
+
lastResolvedData: {},
|
2031
|
+
id: void 0
|
1874
2032
|
};
|
1875
2033
|
};
|
1876
2034
|
var useRegisterFieldsSlice = (appStore, id) => {
|
@@ -1891,7 +2049,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1891
2049
|
let lastFields = fields;
|
1892
2050
|
if (reset) {
|
1893
2051
|
appStore.setState((s) => ({
|
1894
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
2052
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1895
2053
|
}));
|
1896
2054
|
lastFields = defaultFields;
|
1897
2055
|
}
|
@@ -1908,7 +2066,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1908
2066
|
fields: defaultFields,
|
1909
2067
|
lastFields,
|
1910
2068
|
lastData,
|
1911
|
-
appState: state,
|
2069
|
+
appState: makeStatePublic(state),
|
1912
2070
|
parent
|
1913
2071
|
});
|
1914
2072
|
clearTimeout(timeout3);
|
@@ -1919,12 +2077,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1919
2077
|
fields: {
|
1920
2078
|
fields: newFields,
|
1921
2079
|
loading: false,
|
1922
|
-
lastResolvedData: componentData
|
2080
|
+
lastResolvedData: componentData,
|
2081
|
+
id
|
1923
2082
|
}
|
1924
2083
|
});
|
1925
2084
|
} else {
|
1926
2085
|
appStore.setState((s) => ({
|
1927
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
2086
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1928
2087
|
}));
|
1929
2088
|
}
|
1930
2089
|
}),
|
@@ -1941,39 +2100,15 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1941
2100
|
|
1942
2101
|
// lib/resolve-component-data.ts
|
1943
2102
|
init_react_import();
|
1944
|
-
|
1945
|
-
// lib/map-slots.ts
|
1946
|
-
init_react_import();
|
1947
|
-
function mapSlots(item, map, recursive = true, isSlot2) {
|
1948
|
-
return __async(this, null, function* () {
|
1949
|
-
const props = __spreadValues({}, item.props);
|
1950
|
-
yield forEachSlot(
|
1951
|
-
item,
|
1952
|
-
(_parentId, propName, content) => __async(this, null, function* () {
|
1953
|
-
const mappedContent = recursive ? yield Promise.all(
|
1954
|
-
content.map((item2) => __async(this, null, function* () {
|
1955
|
-
return yield mapSlots(item2, map, recursive, isSlot2);
|
1956
|
-
}))
|
1957
|
-
) : content;
|
1958
|
-
props[propName] = yield map(mappedContent, propName);
|
1959
|
-
}),
|
1960
|
-
false,
|
1961
|
-
isSlot2
|
1962
|
-
);
|
1963
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1964
|
-
});
|
1965
|
-
}
|
1966
|
-
|
1967
|
-
// lib/resolve-component-data.ts
|
1968
2103
|
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
1969
2104
|
var cache = { lastChange: {} };
|
1970
2105
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
1971
|
-
const configForItem = "type" in item ? config.components[item.type] : config.root;
|
2106
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1972
2107
|
if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
|
1973
2108
|
const id = "id" in item.props ? item.props.id : "root";
|
1974
2109
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1975
|
-
if (item && item
|
1976
|
-
return resolved;
|
2110
|
+
if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
|
2111
|
+
return { node: resolved, didChange: false };
|
1977
2112
|
}
|
1978
2113
|
const changed = getChanged(item, oldItem);
|
1979
2114
|
if (onResolveStart) {
|
@@ -1982,30 +2117,35 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1982
2117
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1983
2118
|
changed,
|
1984
2119
|
lastData: oldItem,
|
1985
|
-
metadata,
|
2120
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1986
2121
|
trigger
|
1987
2122
|
});
|
1988
2123
|
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
1989
2124
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1990
2125
|
});
|
1991
2126
|
if (recursive) {
|
1992
|
-
resolvedItem = yield
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2127
|
+
resolvedItem = yield mapSlotsAsync(
|
2128
|
+
resolvedItem,
|
2129
|
+
(content) => __async(void 0, null, function* () {
|
2130
|
+
return Promise.all(
|
2131
|
+
content.map(
|
2132
|
+
(childItem) => __async(void 0, null, function* () {
|
2133
|
+
return (yield resolveComponentData(
|
2134
|
+
childItem,
|
2135
|
+
config,
|
2136
|
+
metadata,
|
2137
|
+
onResolveStart,
|
2138
|
+
onResolveEnd,
|
2139
|
+
trigger,
|
2140
|
+
false
|
2141
|
+
)).node;
|
2142
|
+
})
|
2143
|
+
)
|
2144
|
+
);
|
2145
|
+
}),
|
2146
|
+
false,
|
2147
|
+
createIsSlotConfig(config)
|
2148
|
+
);
|
2009
2149
|
}
|
2010
2150
|
if (Object.keys(readOnly).length) {
|
2011
2151
|
resolvedItem.readOnly = readOnly;
|
@@ -2022,7 +2162,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
2022
2162
|
return { node: item, didChange: false };
|
2023
2163
|
});
|
2024
2164
|
|
2025
|
-
// lib/to-root.ts
|
2165
|
+
// lib/data/to-root.ts
|
2026
2166
|
init_react_import();
|
2027
2167
|
var toRoot = (item) => {
|
2028
2168
|
if ("type" in item && item.type !== "root") {
|
@@ -2069,172 +2209,176 @@ var defaultPageFields = {
|
|
2069
2209
|
title: { type: "text" }
|
2070
2210
|
};
|
2071
2211
|
var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
2072
|
-
(0, import_middleware2.subscribeWithSelector)((set, get) =>
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
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
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
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
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
trigger
|
2200
|
-
);
|
2201
|
-
}),
|
2202
|
-
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2203
|
-
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2204
|
-
walkTree(
|
2205
|
-
state,
|
2206
|
-
config,
|
2207
|
-
(content) => content,
|
2208
|
-
(childItem) => {
|
2209
|
-
resolveComponentData2(childItem, "load").then((resolved) => {
|
2210
|
-
const { state: state2 } = get();
|
2211
|
-
const node = state2.indexes.nodes[resolved.node.props.id];
|
2212
|
-
if (node && resolved.didChange) {
|
2213
|
-
if (resolved.node.props.id === "root") {
|
2214
|
-
dispatch({
|
2215
|
-
type: "replaceRoot",
|
2216
|
-
root: toRoot(resolved.node)
|
2217
|
-
});
|
2218
|
-
} else {
|
2219
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2220
|
-
const parentZone = state2.indexes.zones[zoneCompound];
|
2221
|
-
const index = parentZone.contentIds.indexOf(
|
2222
|
-
resolved.node.props.id
|
2223
|
-
);
|
2224
|
-
dispatch({
|
2225
|
-
type: "replace",
|
2226
|
-
data: resolved.node,
|
2227
|
-
destinationIndex: index,
|
2228
|
-
destinationZone: zoneCompound
|
2229
|
-
});
|
2230
|
-
}
|
2212
|
+
(0, import_middleware2.subscribeWithSelector)((set, get) => {
|
2213
|
+
var _a, _b;
|
2214
|
+
return __spreadProps(__spreadValues({
|
2215
|
+
state: defaultAppState,
|
2216
|
+
config: { components: {} },
|
2217
|
+
componentState: {},
|
2218
|
+
plugins: [],
|
2219
|
+
overrides: {},
|
2220
|
+
viewports: defaultViewports,
|
2221
|
+
zoomConfig: {
|
2222
|
+
autoZoom: 1,
|
2223
|
+
rootHeight: 0,
|
2224
|
+
zoom: 1
|
2225
|
+
},
|
2226
|
+
status: "LOADING",
|
2227
|
+
iframe: {},
|
2228
|
+
metadata: {}
|
2229
|
+
}, initialAppStore), {
|
2230
|
+
fields: createFieldsSlice(set, get),
|
2231
|
+
history: createHistorySlice(set, get),
|
2232
|
+
nodes: createNodesSlice(set, get),
|
2233
|
+
permissions: createPermissionsSlice(set, get),
|
2234
|
+
getComponentConfig: (type) => {
|
2235
|
+
var _a2;
|
2236
|
+
const { config, selectedItem } = get();
|
2237
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
2238
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
2239
|
+
},
|
2240
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
2241
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
2242
|
+
initialAppStore.state
|
2243
|
+
) : null,
|
2244
|
+
dispatch: (action) => set((s) => {
|
2245
|
+
var _a2, _b2;
|
2246
|
+
const { record } = get().history;
|
2247
|
+
const dispatch = createReducer({
|
2248
|
+
record,
|
2249
|
+
appStore: s
|
2250
|
+
});
|
2251
|
+
const state = dispatch(s.state, action);
|
2252
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2253
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
2254
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2255
|
+
}),
|
2256
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
2257
|
+
setStatus: (status) => set({ status }),
|
2258
|
+
setComponentState: (componentState) => set({ componentState }),
|
2259
|
+
pendingLoadTimeouts: {},
|
2260
|
+
setComponentLoading: (id, loading = true, defer2 = 0) => {
|
2261
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
2262
|
+
const loadId = generateId();
|
2263
|
+
const setLoading = () => {
|
2264
|
+
var _a2;
|
2265
|
+
const { componentState } = get();
|
2266
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
2267
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
2268
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
2269
|
+
})
|
2270
|
+
}));
|
2271
|
+
};
|
2272
|
+
const unsetLoading = () => {
|
2273
|
+
var _a2;
|
2274
|
+
const { componentState } = get();
|
2275
|
+
clearTimeout(timeout3);
|
2276
|
+
delete pendingLoadTimeouts[loadId];
|
2277
|
+
set({ pendingLoadTimeouts });
|
2278
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
2279
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
2280
|
+
loadingCount: Math.max(
|
2281
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
2282
|
+
0
|
2283
|
+
)
|
2284
|
+
})
|
2285
|
+
}));
|
2286
|
+
};
|
2287
|
+
const timeout3 = setTimeout(() => {
|
2288
|
+
if (loading) {
|
2289
|
+
setLoading();
|
2290
|
+
} else {
|
2291
|
+
unsetLoading();
|
2292
|
+
}
|
2293
|
+
delete pendingLoadTimeouts[loadId];
|
2294
|
+
set({ pendingLoadTimeouts });
|
2295
|
+
}, defer2);
|
2296
|
+
set({
|
2297
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
2298
|
+
[id]: timeout3
|
2299
|
+
})
|
2300
|
+
});
|
2301
|
+
return unsetLoading;
|
2302
|
+
},
|
2303
|
+
unsetComponentLoading: (id) => {
|
2304
|
+
const { setComponentLoading } = get();
|
2305
|
+
setComponentLoading(id, false);
|
2306
|
+
},
|
2307
|
+
// Helper
|
2308
|
+
setUi: (ui, recordHistory) => set((s) => {
|
2309
|
+
const dispatch = createReducer({
|
2310
|
+
record: () => {
|
2311
|
+
},
|
2312
|
+
appStore: s
|
2313
|
+
});
|
2314
|
+
const state = dispatch(s.state, {
|
2315
|
+
type: "setUi",
|
2316
|
+
ui,
|
2317
|
+
recordHistory
|
2318
|
+
});
|
2319
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2320
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2321
|
+
}),
|
2322
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
2323
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
2324
|
+
const timeouts = {};
|
2325
|
+
return yield resolveComponentData(
|
2326
|
+
componentData,
|
2327
|
+
config,
|
2328
|
+
metadata,
|
2329
|
+
(item) => {
|
2330
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2331
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
2332
|
+
},
|
2333
|
+
(item) => __async(void 0, null, function* () {
|
2334
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2335
|
+
if ("type" in item) {
|
2336
|
+
yield permissions.refreshPermissions({ item });
|
2337
|
+
} else {
|
2338
|
+
yield permissions.refreshPermissions({ root: true });
|
2231
2339
|
}
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2340
|
+
timeouts[id]();
|
2341
|
+
}),
|
2342
|
+
trigger
|
2343
|
+
);
|
2344
|
+
}),
|
2345
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2346
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2347
|
+
walkAppState(
|
2348
|
+
state,
|
2349
|
+
config,
|
2350
|
+
(content) => content,
|
2351
|
+
(childItem) => {
|
2352
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2353
|
+
const { state: state2 } = get();
|
2354
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2355
|
+
if (node && resolved.didChange) {
|
2356
|
+
if (resolved.node.props.id === "root") {
|
2357
|
+
dispatch({
|
2358
|
+
type: "replaceRoot",
|
2359
|
+
root: toRoot(resolved.node)
|
2360
|
+
});
|
2361
|
+
} else {
|
2362
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2363
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2364
|
+
const index = parentZone.contentIds.indexOf(
|
2365
|
+
resolved.node.props.id
|
2366
|
+
);
|
2367
|
+
dispatch({
|
2368
|
+
type: "replace",
|
2369
|
+
data: resolved.node,
|
2370
|
+
destinationIndex: index,
|
2371
|
+
destinationZone: zoneCompound
|
2372
|
+
});
|
2373
|
+
}
|
2374
|
+
}
|
2375
|
+
});
|
2376
|
+
return childItem;
|
2377
|
+
}
|
2378
|
+
);
|
2379
|
+
})
|
2380
|
+
});
|
2381
|
+
})
|
2238
2382
|
);
|
2239
2383
|
var appStoreContext = (0, import_react9.createContext)(createAppStore());
|
2240
2384
|
function useAppStore(selector) {
|
@@ -2249,314 +2393,11 @@ function useAppStoreApi() {
|
|
2249
2393
|
init_react_import();
|
2250
2394
|
var import_react12 = require("@dnd-kit/react");
|
2251
2395
|
|
2252
|
-
// lib/dnd/dnd-kit/safe.ts
|
2253
|
-
init_react_import();
|
2254
|
-
var import_react10 = require("@dnd-kit/react");
|
2255
|
-
var import_sortable = require("@dnd-kit/react/sortable");
|
2256
|
-
function useDroppableSafe(input) {
|
2257
|
-
if (typeof window === "undefined") {
|
2258
|
-
return { ref: () => {
|
2259
|
-
} };
|
2260
|
-
}
|
2261
|
-
return (0, import_react10.useDroppable)(input);
|
2262
|
-
}
|
2263
|
-
function useDraggableSafe(input) {
|
2264
|
-
if (typeof window === "undefined") {
|
2265
|
-
return { ref: () => {
|
2266
|
-
} };
|
2267
|
-
}
|
2268
|
-
return (0, import_react10.useDraggable)(input);
|
2269
|
-
}
|
2270
|
-
function useSortableSafe(input) {
|
2271
|
-
if (typeof window === "undefined") {
|
2272
|
-
return { ref: () => {
|
2273
|
-
}, status: "idle", handleRef: () => {
|
2274
|
-
} };
|
2275
|
-
}
|
2276
|
-
return (0, import_sortable.useSortable)(input);
|
2277
|
-
}
|
2278
|
-
|
2279
2396
|
// lib/dnd/use-sensors.ts
|
2280
2397
|
init_react_import();
|
2281
|
-
var
|
2282
|
-
|
2283
|
-
// lib/dnd/PointerSensor.ts
|
2284
|
-
init_react_import();
|
2285
|
-
var import_state = require("@dnd-kit/state");
|
2286
|
-
var import_abstract = require("@dnd-kit/abstract");
|
2287
|
-
var import_geometry = require("@dnd-kit/geometry");
|
2398
|
+
var import_react10 = require("react");
|
2399
|
+
var import_react11 = require("@dnd-kit/react");
|
2288
2400
|
var import_utilities = require("@dnd-kit/dom/utilities");
|
2289
|
-
var _clearTimeout;
|
2290
|
-
var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
|
2291
|
-
constructor(manager, options) {
|
2292
|
-
super(manager);
|
2293
|
-
this.manager = manager;
|
2294
|
-
this.options = options;
|
2295
|
-
this.listeners = new import_utilities.Listeners();
|
2296
|
-
this.cleanup = /* @__PURE__ */ new Set();
|
2297
|
-
this.source = void 0;
|
2298
|
-
this.started = false;
|
2299
|
-
__privateAdd(this, _clearTimeout);
|
2300
|
-
this.handleCancel = this.handleCancel.bind(this);
|
2301
|
-
this.handlePointerUp = this.handlePointerUp.bind(this);
|
2302
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
2303
|
-
(0, import_state.effect)(() => {
|
2304
|
-
const unbindGlobal = this.bindGlobal(options != null ? options : {});
|
2305
|
-
return () => {
|
2306
|
-
unbindGlobal();
|
2307
|
-
};
|
2308
|
-
});
|
2309
|
-
}
|
2310
|
-
bind(source, options = this.options) {
|
2311
|
-
const unbind = (0, import_state.effect)(() => {
|
2312
|
-
var _a;
|
2313
|
-
const target = (_a = source.handle) != null ? _a : source.element;
|
2314
|
-
const listener = (event) => {
|
2315
|
-
if ((0, import_utilities.isPointerEvent)(event)) {
|
2316
|
-
this.handlePointerDown(event, source, options);
|
2317
|
-
}
|
2318
|
-
};
|
2319
|
-
if (target) {
|
2320
|
-
patchWindow(target.ownerDocument.defaultView);
|
2321
|
-
target.addEventListener("pointerdown", listener);
|
2322
|
-
return () => {
|
2323
|
-
target.removeEventListener("pointerdown", listener);
|
2324
|
-
};
|
2325
|
-
}
|
2326
|
-
});
|
2327
|
-
return unbind;
|
2328
|
-
}
|
2329
|
-
bindGlobal(options) {
|
2330
|
-
const documents = /* @__PURE__ */ new Set();
|
2331
|
-
for (const draggable of this.manager.registry.draggables.value) {
|
2332
|
-
if (draggable.element) {
|
2333
|
-
documents.add((0, import_utilities.getDocument)(draggable.element));
|
2334
|
-
}
|
2335
|
-
}
|
2336
|
-
for (const droppable of this.manager.registry.droppables.value) {
|
2337
|
-
if (droppable.element) {
|
2338
|
-
documents.add((0, import_utilities.getDocument)(droppable.element));
|
2339
|
-
}
|
2340
|
-
}
|
2341
|
-
const unbindFns = Array.from(documents).map(
|
2342
|
-
(doc) => this.listeners.bind(doc, [
|
2343
|
-
{
|
2344
|
-
type: "pointermove",
|
2345
|
-
listener: (event) => this.handlePointerMove(event, doc, options)
|
2346
|
-
},
|
2347
|
-
{
|
2348
|
-
type: "pointerup",
|
2349
|
-
listener: this.handlePointerUp,
|
2350
|
-
options: {
|
2351
|
-
capture: true
|
2352
|
-
}
|
2353
|
-
},
|
2354
|
-
{
|
2355
|
-
// Cancel activation if there is a competing Drag and Drop interaction
|
2356
|
-
type: "dragstart",
|
2357
|
-
listener: this.handleDragStart
|
2358
|
-
}
|
2359
|
-
])
|
2360
|
-
);
|
2361
|
-
return () => {
|
2362
|
-
unbindFns.forEach((unbind) => unbind());
|
2363
|
-
};
|
2364
|
-
}
|
2365
|
-
handlePointerDown(event, source, options = {}) {
|
2366
|
-
if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
|
2367
|
-
return;
|
2368
|
-
}
|
2369
|
-
const offset = (0, import_utilities.getFrameTransform)(source.element);
|
2370
|
-
this.initialCoordinates = {
|
2371
|
-
x: event.clientX * offset.scaleX + offset.x,
|
2372
|
-
y: event.clientY * offset.scaleY + offset.y
|
2373
|
-
};
|
2374
|
-
this.source = source;
|
2375
|
-
const { activationConstraints } = options;
|
2376
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
2377
|
-
event.stopImmediatePropagation();
|
2378
|
-
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
2379
|
-
this.handleStart(source, event);
|
2380
|
-
} else {
|
2381
|
-
const { delay } = constraints;
|
2382
|
-
if (delay) {
|
2383
|
-
const timeout3 = setTimeout(
|
2384
|
-
() => this.handleStart(source, event),
|
2385
|
-
delay.value
|
2386
|
-
);
|
2387
|
-
__privateSet(this, _clearTimeout, () => {
|
2388
|
-
clearTimeout(timeout3);
|
2389
|
-
__privateSet(this, _clearTimeout, void 0);
|
2390
|
-
});
|
2391
|
-
}
|
2392
|
-
}
|
2393
|
-
const cleanup = () => {
|
2394
|
-
var _a;
|
2395
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2396
|
-
this.initialCoordinates = void 0;
|
2397
|
-
this.source = void 0;
|
2398
|
-
};
|
2399
|
-
this.cleanup.add(cleanup);
|
2400
|
-
}
|
2401
|
-
handlePointerMove(event, doc, options) {
|
2402
|
-
if (!this.source) {
|
2403
|
-
return;
|
2404
|
-
}
|
2405
|
-
const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
|
2406
|
-
if (doc !== ownerDocument) {
|
2407
|
-
return;
|
2408
|
-
}
|
2409
|
-
const coordinates = {
|
2410
|
-
x: event.clientX,
|
2411
|
-
y: event.clientY
|
2412
|
-
};
|
2413
|
-
const offset = (0, import_utilities.getFrameTransform)(this.source.element);
|
2414
|
-
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
2415
|
-
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
2416
|
-
if (this.manager.dragOperation.status.dragging) {
|
2417
|
-
event.preventDefault();
|
2418
|
-
event.stopPropagation();
|
2419
|
-
this.manager.actions.move({ to: coordinates });
|
2420
|
-
return;
|
2421
|
-
}
|
2422
|
-
if (!this.initialCoordinates) {
|
2423
|
-
return;
|
2424
|
-
}
|
2425
|
-
const delta = {
|
2426
|
-
x: coordinates.x - this.initialCoordinates.x,
|
2427
|
-
y: coordinates.y - this.initialCoordinates.y
|
2428
|
-
};
|
2429
|
-
const { activationConstraints } = options;
|
2430
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
|
2431
|
-
const { distance, delay } = constraints != null ? constraints : {};
|
2432
|
-
if (distance) {
|
2433
|
-
if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
|
2434
|
-
return this.handleCancel();
|
2435
|
-
}
|
2436
|
-
if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
|
2437
|
-
return this.handleStart(this.source, event);
|
2438
|
-
}
|
2439
|
-
}
|
2440
|
-
if (delay) {
|
2441
|
-
if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
|
2442
|
-
return this.handleCancel();
|
2443
|
-
}
|
2444
|
-
}
|
2445
|
-
}
|
2446
|
-
handlePointerUp(event) {
|
2447
|
-
if (!this.source) {
|
2448
|
-
return;
|
2449
|
-
}
|
2450
|
-
event.preventDefault();
|
2451
|
-
event.stopPropagation();
|
2452
|
-
const { status } = this.manager.dragOperation;
|
2453
|
-
if (!status.idle) {
|
2454
|
-
const canceled = !status.initialized;
|
2455
|
-
this.manager.actions.stop({ canceled });
|
2456
|
-
} else if (this.started) {
|
2457
|
-
setTimeout(() => {
|
2458
|
-
if (!this.manager.dragOperation.status.idle) {
|
2459
|
-
this.manager.actions.stop({ canceled: false });
|
2460
|
-
}
|
2461
|
-
}, 10);
|
2462
|
-
}
|
2463
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2464
|
-
this.cleanup.clear();
|
2465
|
-
}
|
2466
|
-
handleKeyDown(event) {
|
2467
|
-
if (event.key === "Escape") {
|
2468
|
-
event.preventDefault();
|
2469
|
-
this.handleCancel();
|
2470
|
-
}
|
2471
|
-
}
|
2472
|
-
handleStart(source, event) {
|
2473
|
-
var _a;
|
2474
|
-
const { manager, initialCoordinates } = this;
|
2475
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2476
|
-
if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
|
2477
|
-
return;
|
2478
|
-
}
|
2479
|
-
if (event.defaultPrevented) {
|
2480
|
-
return;
|
2481
|
-
}
|
2482
|
-
this.started = true;
|
2483
|
-
event.preventDefault();
|
2484
|
-
(0, import_state.batch)(() => {
|
2485
|
-
manager.actions.setDragSource(source.id);
|
2486
|
-
manager.actions.start({ coordinates: initialCoordinates, event });
|
2487
|
-
});
|
2488
|
-
const ownerDocument = (0, import_utilities.getDocument)(event.target);
|
2489
|
-
const unbind = this.listeners.bind(ownerDocument, [
|
2490
|
-
{
|
2491
|
-
// Prevent scrolling on touch devices
|
2492
|
-
type: "touchmove",
|
2493
|
-
listener: preventDefault,
|
2494
|
-
options: {
|
2495
|
-
passive: false
|
2496
|
-
}
|
2497
|
-
},
|
2498
|
-
{
|
2499
|
-
// Prevent click events
|
2500
|
-
type: "click",
|
2501
|
-
listener: preventDefault
|
2502
|
-
},
|
2503
|
-
{
|
2504
|
-
type: "keydown",
|
2505
|
-
listener: this.handleKeyDown
|
2506
|
-
}
|
2507
|
-
]);
|
2508
|
-
ownerDocument.body.setPointerCapture(event.pointerId);
|
2509
|
-
this.cleanup.add(unbind);
|
2510
|
-
this.cleanup.add(() => {
|
2511
|
-
this.started = false;
|
2512
|
-
});
|
2513
|
-
}
|
2514
|
-
handleDragStart(event) {
|
2515
|
-
const { target } = event;
|
2516
|
-
if (!(0, import_utilities.isElement)(target)) {
|
2517
|
-
return;
|
2518
|
-
}
|
2519
|
-
const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
|
2520
|
-
if (isNativeDraggable) {
|
2521
|
-
this.handleCancel();
|
2522
|
-
} else {
|
2523
|
-
preventDefault(event);
|
2524
|
-
}
|
2525
|
-
}
|
2526
|
-
handleCancel() {
|
2527
|
-
const { dragOperation } = this.manager;
|
2528
|
-
if (dragOperation.status.initialized) {
|
2529
|
-
this.manager.actions.stop({ canceled: true });
|
2530
|
-
}
|
2531
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2532
|
-
this.cleanup.clear();
|
2533
|
-
}
|
2534
|
-
destroy() {
|
2535
|
-
this.listeners.clear();
|
2536
|
-
}
|
2537
|
-
};
|
2538
|
-
_clearTimeout = new WeakMap();
|
2539
|
-
_PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
|
2540
|
-
var PointerSensor = _PointerSensor;
|
2541
|
-
function preventDefault(event) {
|
2542
|
-
event.preventDefault();
|
2543
|
-
}
|
2544
|
-
function noop() {
|
2545
|
-
}
|
2546
|
-
var windows = /* @__PURE__ */ new WeakSet();
|
2547
|
-
function patchWindow(window2) {
|
2548
|
-
if (!window2 || windows.has(window2)) {
|
2549
|
-
return;
|
2550
|
-
}
|
2551
|
-
window2.addEventListener("touchmove", noop, {
|
2552
|
-
capture: false,
|
2553
|
-
passive: false
|
2554
|
-
});
|
2555
|
-
windows.add(window2);
|
2556
|
-
}
|
2557
|
-
|
2558
|
-
// lib/dnd/use-sensors.ts
|
2559
|
-
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
2560
2401
|
var useSensors = ({
|
2561
2402
|
other,
|
2562
2403
|
mouse,
|
@@ -2565,12 +2406,12 @@ var useSensors = ({
|
|
2565
2406
|
touch: { delay: { value: 200, tolerance: 10 } },
|
2566
2407
|
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
2567
2408
|
}) => {
|
2568
|
-
const [sensors] = (0,
|
2569
|
-
PointerSensor.configure({
|
2409
|
+
const [sensors] = (0, import_react10.useState)(() => [
|
2410
|
+
import_react11.PointerSensor.configure({
|
2570
2411
|
activationConstraints(event, source) {
|
2571
2412
|
var _a;
|
2572
2413
|
const { pointerType, target } = event;
|
2573
|
-
if (pointerType === "mouse" && (0,
|
2414
|
+
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
2574
2415
|
return mouse;
|
2575
2416
|
}
|
2576
2417
|
if (pointerType === "touch") {
|
@@ -2585,11 +2426,11 @@ var useSensors = ({
|
|
2585
2426
|
|
2586
2427
|
// lib/dnd/collision/dynamic/index.ts
|
2587
2428
|
init_react_import();
|
2588
|
-
var
|
2429
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
2589
2430
|
|
2590
2431
|
// lib/dnd/collision/directional/index.ts
|
2591
2432
|
init_react_import();
|
2592
|
-
var
|
2433
|
+
var import_abstract = require("@dnd-kit/abstract");
|
2593
2434
|
|
2594
2435
|
// lib/dnd/collision/collision-debug.ts
|
2595
2436
|
init_react_import();
|
@@ -2667,7 +2508,7 @@ var directionalCollision = (input, previous) => {
|
|
2667
2508
|
return {
|
2668
2509
|
id: droppable.id,
|
2669
2510
|
value: 1,
|
2670
|
-
type:
|
2511
|
+
type: import_abstract.CollisionType.Collision
|
2671
2512
|
};
|
2672
2513
|
}
|
2673
2514
|
return null;
|
@@ -2709,7 +2550,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2709
2550
|
|
2710
2551
|
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2711
2552
|
init_react_import();
|
2712
|
-
var
|
2553
|
+
var import_geometry = require("@dnd-kit/geometry");
|
2713
2554
|
var INTERVAL_SENSITIVITY = 10;
|
2714
2555
|
var intervalCache = {
|
2715
2556
|
current: { x: 0, y: 0 },
|
@@ -2725,13 +2566,15 @@ var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
|
2725
2566
|
};
|
2726
2567
|
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
2727
2568
|
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
2728
|
-
intervalCache.previous =
|
2569
|
+
intervalCache.previous = import_geometry.Point.from(point);
|
2729
2570
|
}
|
2730
2571
|
return intervalCache;
|
2731
2572
|
};
|
2732
2573
|
|
2733
2574
|
// ../../node_modules/@dnd-kit/collision/dist/index.js
|
2734
2575
|
init_react_import();
|
2576
|
+
var import_abstract2 = require("@dnd-kit/abstract");
|
2577
|
+
var import_geometry2 = require("@dnd-kit/geometry");
|
2735
2578
|
var import_abstract3 = require("@dnd-kit/abstract");
|
2736
2579
|
var import_geometry3 = require("@dnd-kit/geometry");
|
2737
2580
|
var import_abstract4 = require("@dnd-kit/abstract");
|
@@ -2742,8 +2585,6 @@ var import_abstract6 = require("@dnd-kit/abstract");
|
|
2742
2585
|
var import_geometry6 = require("@dnd-kit/geometry");
|
2743
2586
|
var import_abstract7 = require("@dnd-kit/abstract");
|
2744
2587
|
var import_geometry7 = require("@dnd-kit/geometry");
|
2745
|
-
var import_abstract8 = require("@dnd-kit/abstract");
|
2746
|
-
var import_geometry8 = require("@dnd-kit/geometry");
|
2747
2588
|
var pointerIntersection = ({
|
2748
2589
|
dragOperation,
|
2749
2590
|
droppable
|
@@ -2757,12 +2598,12 @@ var pointerIntersection = ({
|
|
2757
2598
|
return null;
|
2758
2599
|
}
|
2759
2600
|
if (droppable.shape.containsPoint(pointerCoordinates)) {
|
2760
|
-
const distance =
|
2601
|
+
const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
|
2761
2602
|
return {
|
2762
2603
|
id,
|
2763
2604
|
value: 1 / distance,
|
2764
|
-
type:
|
2765
|
-
priority:
|
2605
|
+
type: import_abstract2.CollisionType.PointerIntersection,
|
2606
|
+
priority: import_abstract2.CollisionPriority.High
|
2766
2607
|
};
|
2767
2608
|
}
|
2768
2609
|
return null;
|
@@ -2773,31 +2614,15 @@ var closestCorners = (input) => {
|
|
2773
2614
|
if (!droppable.shape) {
|
2774
2615
|
return null;
|
2775
2616
|
}
|
2776
|
-
const
|
2777
|
-
const
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
},
|
2782
|
-
{
|
2783
|
-
x: right,
|
2784
|
-
y: top
|
2785
|
-
},
|
2786
|
-
{
|
2787
|
-
x: left,
|
2788
|
-
y: bottom
|
2789
|
-
},
|
2790
|
-
{
|
2791
|
-
x: right,
|
2792
|
-
y: bottom
|
2793
|
-
}
|
2794
|
-
];
|
2795
|
-
const distance = corners.reduce(
|
2796
|
-
(acc, corner) => {
|
2617
|
+
const shapeCorners = shape ? import_geometry4.Rectangle.from(shape.current.boundingRectangle).corners : void 0;
|
2618
|
+
const distance = import_geometry4.Rectangle.from(
|
2619
|
+
droppable.shape.boundingRectangle
|
2620
|
+
).corners.reduce(
|
2621
|
+
(acc, corner, index) => {
|
2797
2622
|
var _a;
|
2798
|
-
return acc +
|
2799
|
-
|
2800
|
-
(_a =
|
2623
|
+
return acc + import_geometry4.Point.distance(
|
2624
|
+
import_geometry4.Point.from(corner),
|
2625
|
+
(_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
|
2801
2626
|
);
|
2802
2627
|
},
|
2803
2628
|
0
|
@@ -2806,8 +2631,8 @@ var closestCorners = (input) => {
|
|
2806
2631
|
return {
|
2807
2632
|
id: droppable.id,
|
2808
2633
|
value: 1 / value,
|
2809
|
-
type:
|
2810
|
-
priority:
|
2634
|
+
type: import_abstract4.CollisionType.Collision,
|
2635
|
+
priority: import_abstract4.CollisionPriority.Normal
|
2811
2636
|
};
|
2812
2637
|
};
|
2813
2638
|
|
@@ -2832,12 +2657,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2832
2657
|
const { center: dragCenter } = dragShape;
|
2833
2658
|
const { fallbackEnabled } = collisionStore.getState();
|
2834
2659
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2835
|
-
|
2836
|
-
direction: interval.direction
|
2837
|
-
});
|
2838
|
-
const collisionMap = dragOperation.data.collisionMap || {};
|
2839
|
-
dragOperation.data.collisionMap = collisionMap;
|
2840
|
-
collisionMap[droppable.id] = {
|
2660
|
+
const data = {
|
2841
2661
|
direction: interval.direction
|
2842
2662
|
};
|
2843
2663
|
const { center: dropCenter } = dropShape;
|
@@ -2852,7 +2672,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2852
2672
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
2853
2673
|
if (collision) {
|
2854
2674
|
return __spreadProps(__spreadValues({}, collision), {
|
2855
|
-
priority:
|
2675
|
+
priority: import_abstract8.CollisionPriority.Highest,
|
2676
|
+
data
|
2856
2677
|
});
|
2857
2678
|
}
|
2858
2679
|
}
|
@@ -2869,12 +2690,12 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2869
2690
|
const collision = {
|
2870
2691
|
id: droppable.id,
|
2871
2692
|
value: intersectionRatio,
|
2872
|
-
priority:
|
2873
|
-
type:
|
2693
|
+
priority: import_abstract8.CollisionPriority.High,
|
2694
|
+
type: import_abstract8.CollisionType.Collision
|
2874
2695
|
};
|
2875
2696
|
const shouldFlushId = flushNext === droppable.id;
|
2876
2697
|
flushNext = "";
|
2877
|
-
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2698
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
|
2878
2699
|
}
|
2879
2700
|
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2880
2701
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
@@ -2886,9 +2707,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2886
2707
|
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
2887
2708
|
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
2888
2709
|
});
|
2889
|
-
|
2890
|
-
direction
|
2891
|
-
};
|
2710
|
+
data.direction = direction;
|
2892
2711
|
if (intersectionArea) {
|
2893
2712
|
collisionDebug(
|
2894
2713
|
dragCenter,
|
@@ -2899,7 +2718,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2899
2718
|
);
|
2900
2719
|
flushNext = droppable.id;
|
2901
2720
|
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2902
|
-
priority:
|
2721
|
+
priority: import_abstract8.CollisionPriority.Low,
|
2722
|
+
data
|
2903
2723
|
});
|
2904
2724
|
}
|
2905
2725
|
collisionDebug(
|
@@ -2909,16 +2729,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2909
2729
|
"orange",
|
2910
2730
|
direction || ""
|
2911
2731
|
);
|
2912
|
-
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2732
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2733
|
+
priority: import_abstract8.CollisionPriority.Lowest,
|
2734
|
+
data
|
2735
|
+
});
|
2913
2736
|
}
|
2914
2737
|
}
|
2915
2738
|
}
|
2916
2739
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
2917
|
-
delete collisionMap[droppable.id];
|
2918
2740
|
return null;
|
2919
2741
|
};
|
2920
2742
|
|
2921
2743
|
// components/Sortable/index.tsx
|
2744
|
+
var import_sortable = require("@dnd-kit/react/sortable");
|
2922
2745
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
2923
2746
|
var SortableProvider = ({
|
2924
2747
|
children,
|
@@ -2938,16 +2761,16 @@ var SortableProvider = ({
|
|
2938
2761
|
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
2939
2762
|
},
|
2940
2763
|
onDragOver: (event, manager) => {
|
2941
|
-
var _a
|
2764
|
+
var _a;
|
2942
2765
|
event.preventDefault();
|
2943
2766
|
const { operation } = event;
|
2944
2767
|
const { source, target } = operation;
|
2945
2768
|
if (!source || !target) return;
|
2946
2769
|
let sourceIndex = source.data.index;
|
2947
2770
|
let targetIndex = target.data.index;
|
2948
|
-
const collisionData = (
|
2771
|
+
const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
|
2949
2772
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
2950
|
-
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2773
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
|
2951
2774
|
if (targetIndex >= sourceIndex) {
|
2952
2775
|
targetIndex = targetIndex - 1;
|
2953
2776
|
}
|
@@ -2978,9 +2801,10 @@ var Sortable = ({
|
|
2978
2801
|
}) => {
|
2979
2802
|
const {
|
2980
2803
|
ref: sortableRef,
|
2981
|
-
|
2804
|
+
isDragging,
|
2805
|
+
isDropping,
|
2982
2806
|
handleRef
|
2983
|
-
} =
|
2807
|
+
} = (0, import_sortable.useSortable)({
|
2984
2808
|
id,
|
2985
2809
|
type,
|
2986
2810
|
index,
|
@@ -2988,7 +2812,7 @@ var Sortable = ({
|
|
2988
2812
|
data: { index },
|
2989
2813
|
collisionDetector: createDynamicCollisionDetector("y")
|
2990
2814
|
});
|
2991
|
-
return children({
|
2815
|
+
return children({ isDragging, isDropping, ref: sortableRef, handleRef });
|
2992
2816
|
};
|
2993
2817
|
|
2994
2818
|
// components/AutoField/context.tsx
|
@@ -3113,7 +2937,7 @@ var ArrayField = ({
|
|
3113
2937
|
}
|
3114
2938
|
}, []);
|
3115
2939
|
const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
|
3116
|
-
const
|
2940
|
+
const isDraggingAny = !!draggedItem;
|
3117
2941
|
const canEdit = useAppStore(
|
3118
2942
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
3119
2943
|
);
|
@@ -3178,13 +3002,13 @@ var ArrayField = ({
|
|
3178
3002
|
id: _arrayId,
|
3179
3003
|
index: i,
|
3180
3004
|
disabled: readOnly,
|
3181
|
-
children: ({
|
3005
|
+
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3182
3006
|
"div",
|
3183
3007
|
{
|
3184
3008
|
ref,
|
3185
3009
|
className: getClassNameItem({
|
3186
3010
|
isExpanded: arrayState.openId === _arrayId,
|
3187
|
-
isDragging
|
3011
|
+
isDragging,
|
3188
3012
|
readOnly
|
3189
3013
|
}),
|
3190
3014
|
children: [
|
@@ -3325,7 +3149,7 @@ var ArrayField = ({
|
|
3325
3149
|
type: "button",
|
3326
3150
|
className: getClassName5("addButton"),
|
3327
3151
|
onClick: () => {
|
3328
|
-
if (
|
3152
|
+
if (isDraggingAny) return;
|
3329
3153
|
const existingValue = value || [];
|
3330
3154
|
const newValue = [
|
3331
3155
|
...existingValue,
|
@@ -4308,15 +4132,15 @@ init_react_import();
|
|
4308
4132
|
|
4309
4133
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
4310
4134
|
init_react_import();
|
4311
|
-
var styles_module_default10 = { "Drawer": "
|
4135
|
+
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
4312
4136
|
|
4313
4137
|
// components/Drawer/index.tsx
|
4314
|
-
var
|
4138
|
+
var import_react38 = require("react");
|
4315
4139
|
|
4316
4140
|
// components/DragDropContext/index.tsx
|
4317
4141
|
init_react_import();
|
4318
|
-
var
|
4319
|
-
var
|
4142
|
+
var import_react36 = require("@dnd-kit/react");
|
4143
|
+
var import_react37 = require("react");
|
4320
4144
|
var import_dom = require("@dnd-kit/dom");
|
4321
4145
|
|
4322
4146
|
// components/DropZone/index.tsx
|
@@ -4329,7 +4153,7 @@ var import_react25 = require("react");
|
|
4329
4153
|
|
4330
4154
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
4331
4155
|
init_react_import();
|
4332
|
-
var styles_module_default11 = { "DraggableComponent": "
|
4156
|
+
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" };
|
4333
4157
|
|
4334
4158
|
// components/DraggableComponent/index.tsx
|
4335
4159
|
var import_react_dom2 = require("react-dom");
|
@@ -4380,7 +4204,6 @@ var DropZoneProvider = ({
|
|
4380
4204
|
value
|
4381
4205
|
}) => {
|
4382
4206
|
const [hoveringComponent, setHoveringComponent] = (0, import_react23.useState)();
|
4383
|
-
const [activeZones, setActiveZones] = (0, import_react23.useState)({});
|
4384
4207
|
const dispatch = useAppStore((s) => s.dispatch);
|
4385
4208
|
const registerZone = (0, import_react23.useCallback)(
|
4386
4209
|
(zoneCompound) => {
|
@@ -4389,7 +4212,7 @@ var DropZoneProvider = ({
|
|
4389
4212
|
zone: zoneCompound
|
4390
4213
|
});
|
4391
4214
|
},
|
4392
|
-
[
|
4215
|
+
[dispatch]
|
4393
4216
|
);
|
4394
4217
|
const unregisterZone = (0, import_react23.useCallback)(
|
4395
4218
|
(zoneCompound) => {
|
@@ -4398,17 +4221,16 @@ var DropZoneProvider = ({
|
|
4398
4221
|
zone: zoneCompound
|
4399
4222
|
});
|
4400
4223
|
},
|
4401
|
-
[
|
4224
|
+
[dispatch]
|
4402
4225
|
);
|
4403
4226
|
const memoValue = (0, import_react23.useMemo)(
|
4404
4227
|
() => __spreadValues({
|
4405
4228
|
hoveringComponent,
|
4406
4229
|
setHoveringComponent,
|
4407
4230
|
registerZone,
|
4408
|
-
unregisterZone
|
4409
|
-
activeZones
|
4231
|
+
unregisterZone
|
4410
4232
|
}, value),
|
4411
|
-
[value, hoveringComponent
|
4233
|
+
[value, hoveringComponent]
|
4412
4234
|
);
|
4413
4235
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
4414
4236
|
};
|
@@ -4428,6 +4250,7 @@ function useContextStore(context, selector) {
|
|
4428
4250
|
|
4429
4251
|
// components/DraggableComponent/index.tsx
|
4430
4252
|
var import_shallow2 = require("zustand/react/shallow");
|
4253
|
+
var import_sortable2 = require("@dnd-kit/react/sortable");
|
4431
4254
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
4432
4255
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
4433
4256
|
var DEBUG2 = false;
|
@@ -4501,8 +4324,10 @@ var DraggableComponent = ({
|
|
4501
4324
|
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
4502
4325
|
}));
|
4503
4326
|
const permissions = useAppStore(
|
4504
|
-
(0, import_shallow2.useShallow)((s) =>
|
4505
|
-
|
4327
|
+
(0, import_shallow2.useShallow)((s) => {
|
4328
|
+
const item = getItem({ index, zone: zoneCompound }, s.state);
|
4329
|
+
return s.permissions.getPermissions({ item });
|
4330
|
+
})
|
4506
4331
|
);
|
4507
4332
|
const userIsDragging = useContextStore(
|
4508
4333
|
ZoneStoreContext,
|
@@ -4511,7 +4336,7 @@ var DraggableComponent = ({
|
|
4511
4336
|
const canCollide = permissions.drag || userIsDragging;
|
4512
4337
|
const disabled = !isEnabled || !canCollide;
|
4513
4338
|
const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
|
4514
|
-
const { ref: sortableRef,
|
4339
|
+
const { ref: sortableRef, isDragging: thisIsDragging } = (0, import_sortable2.useSortable)({
|
4515
4340
|
id,
|
4516
4341
|
index,
|
4517
4342
|
group: zoneCompound,
|
@@ -4533,9 +4358,9 @@ var DraggableComponent = ({
|
|
4533
4358
|
transition: {
|
4534
4359
|
duration: 200,
|
4535
4360
|
easing: "cubic-bezier(0.2, 0, 0, 1)"
|
4536
|
-
}
|
4361
|
+
},
|
4362
|
+
feedback: "clone"
|
4537
4363
|
});
|
4538
|
-
const thisIsDragging = status === "dragging";
|
4539
4364
|
const ref = (0, import_react25.useRef)(null);
|
4540
4365
|
const refSetter = (0, import_react25.useCallback)(
|
4541
4366
|
(el) => {
|
@@ -4675,18 +4500,12 @@ var DraggableComponent = ({
|
|
4675
4500
|
el.addEventListener("click", onClick);
|
4676
4501
|
el.addEventListener("mouseover", _onMouseOver);
|
4677
4502
|
el.addEventListener("mouseout", _onMouseOut);
|
4678
|
-
if (thisIsDragging) {
|
4679
|
-
el.setAttribute("data-puck-dragging", "");
|
4680
|
-
} else {
|
4681
|
-
el.removeAttribute("data-puck-dragging");
|
4682
|
-
}
|
4683
4503
|
return () => {
|
4684
4504
|
el.removeAttribute("data-puck-component");
|
4685
4505
|
el.removeAttribute("data-puck-dnd");
|
4686
4506
|
el.removeEventListener("click", onClick);
|
4687
4507
|
el.removeEventListener("mouseover", _onMouseOver);
|
4688
4508
|
el.removeEventListener("mouseout", _onMouseOut);
|
4689
|
-
el.removeAttribute("data-puck-dragging");
|
4690
4509
|
};
|
4691
4510
|
}, [
|
4692
4511
|
ref,
|
@@ -4756,82 +4575,91 @@ var DraggableComponent = ({
|
|
4756
4575
|
setDragAxis(autoDragAxis);
|
4757
4576
|
}, [ref, userDragAxis, autoDragAxis]);
|
4758
4577
|
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 }) });
|
4759
|
-
|
4760
|
-
|
4761
|
-
|
4762
|
-
|
4763
|
-
|
4764
|
-
|
4765
|
-
|
4766
|
-
|
4767
|
-
|
4768
|
-
|
4769
|
-
|
4770
|
-
|
4771
|
-
|
4772
|
-
|
4773
|
-
|
4774
|
-
|
4775
|
-
|
4776
|
-
|
4777
|
-
|
4778
|
-
|
4779
|
-
|
4780
|
-
|
4781
|
-
|
4782
|
-
|
4783
|
-
|
4784
|
-
|
4785
|
-
|
4578
|
+
const nextContextValue = (0, import_react25.useMemo)(
|
4579
|
+
() => __spreadProps(__spreadValues({}, ctx), {
|
4580
|
+
areaId: id,
|
4581
|
+
zoneCompound,
|
4582
|
+
index,
|
4583
|
+
depth: depth + 1,
|
4584
|
+
registerLocalZone,
|
4585
|
+
unregisterLocalZone
|
4586
|
+
}),
|
4587
|
+
[
|
4588
|
+
ctx,
|
4589
|
+
id,
|
4590
|
+
zoneCompound,
|
4591
|
+
index,
|
4592
|
+
depth,
|
4593
|
+
registerLocalZone,
|
4594
|
+
unregisterLocalZone
|
4595
|
+
]
|
4596
|
+
);
|
4597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
|
4598
|
+
isVisible && (0, import_react_dom2.createPortal)(
|
4599
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
4600
|
+
"div",
|
4601
|
+
{
|
4602
|
+
className: getClassName16({
|
4603
|
+
isSelected,
|
4604
|
+
isDragging: thisIsDragging,
|
4605
|
+
hover: hover || indicativeHover
|
4606
|
+
}),
|
4607
|
+
style: __spreadValues({}, style),
|
4608
|
+
"data-puck-overlay": true,
|
4609
|
+
children: [
|
4610
|
+
debug,
|
4611
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
|
4612
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4613
|
+
"div",
|
4614
|
+
{
|
4615
|
+
className: getClassName16("actionsOverlay"),
|
4616
|
+
style: {
|
4617
|
+
top: actionsOverlayTop / zoom
|
4618
|
+
},
|
4619
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4786
4620
|
"div",
|
4787
4621
|
{
|
4788
|
-
className: getClassName16("
|
4622
|
+
className: getClassName16("actions"),
|
4789
4623
|
style: {
|
4790
|
-
|
4624
|
+
transform: `scale(${1 / zoom}`,
|
4625
|
+
top: actionsTop / zoom,
|
4626
|
+
right: 0,
|
4627
|
+
paddingLeft: actionsSide,
|
4628
|
+
paddingRight: actionsSide
|
4791
4629
|
},
|
4792
|
-
|
4793
|
-
|
4630
|
+
ref: syncActionsPosition,
|
4631
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
4632
|
+
CustomActionBar,
|
4794
4633
|
{
|
4795
|
-
|
4796
|
-
|
4797
|
-
|
4798
|
-
|
4799
|
-
|
4800
|
-
|
4801
|
-
paddingRight: actionsSide
|
4802
|
-
},
|
4803
|
-
ref: syncActionsPosition,
|
4804
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
4805
|
-
CustomActionBar,
|
4806
|
-
{
|
4807
|
-
parentAction,
|
4808
|
-
label: DEBUG2 ? id : label,
|
4809
|
-
children: [
|
4810
|
-
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
|
4811
|
-
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
|
4812
|
-
]
|
4813
|
-
}
|
4814
|
-
)
|
4634
|
+
parentAction,
|
4635
|
+
label: DEBUG2 ? id : label,
|
4636
|
+
children: [
|
4637
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
|
4638
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
|
4639
|
+
]
|
4815
4640
|
}
|
4816
4641
|
)
|
4817
4642
|
}
|
4818
|
-
)
|
4819
|
-
|
4820
|
-
|
4821
|
-
}
|
4822
|
-
|
4823
|
-
|
4824
|
-
|
4825
|
-
|
4826
|
-
|
4827
|
-
|
4828
|
-
);
|
4643
|
+
)
|
4644
|
+
}
|
4645
|
+
),
|
4646
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
4647
|
+
]
|
4648
|
+
}
|
4649
|
+
),
|
4650
|
+
portalEl || document.body
|
4651
|
+
),
|
4652
|
+
children(refSetter)
|
4653
|
+
] });
|
4829
4654
|
};
|
4830
4655
|
|
4831
4656
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
|
4832
4657
|
init_react_import();
|
4833
4658
|
var styles_module_default12 = { "DropZone": "_DropZone_3dmev_1", "DropZone--hasChildren": "_DropZone--hasChildren_3dmev_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_3dmev_19", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_3dmev_23", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_3dmev_24", "DropZone--isRootZone": "_DropZone--isRootZone_3dmev_24", "DropZone--isDestination": "_DropZone--isDestination_3dmev_34", "DropZone-item": "_DropZone-item_3dmev_46", "DropZone-hitbox": "_DropZone-hitbox_3dmev_50", "DropZone--isEnabled": "_DropZone--isEnabled_3dmev_58", "DropZone--isAnimating": "_DropZone--isAnimating_3dmev_67" };
|
4834
4659
|
|
4660
|
+
// components/DropZone/index.tsx
|
4661
|
+
var import_react35 = require("@dnd-kit/react");
|
4662
|
+
|
4835
4663
|
// components/DropZone/lib/use-min-empty-height.ts
|
4836
4664
|
init_react_import();
|
4837
4665
|
var import_react26 = require("react");
|
@@ -5011,26 +4839,33 @@ var import_shallow3 = require("zustand/react/shallow");
|
|
5011
4839
|
// components/Render/index.tsx
|
5012
4840
|
init_react_import();
|
5013
4841
|
|
5014
|
-
// lib/use-slots.
|
4842
|
+
// lib/use-slots.tsx
|
5015
4843
|
init_react_import();
|
5016
4844
|
var import_react31 = require("react");
|
5017
|
-
function useSlots(config, props,
|
5018
|
-
|
4845
|
+
function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
4846
|
+
const slotProps = (0, import_react31.useMemo)(() => {
|
5019
4847
|
if (!(config == null ? void 0 : config.fields)) return props;
|
5020
|
-
const
|
4848
|
+
const slotProps2 = {};
|
5021
4849
|
const fieldKeys = Object.keys(config.fields);
|
5022
4850
|
for (let i = 0; i < fieldKeys.length; i++) {
|
5023
4851
|
const fieldKey = fieldKeys[i];
|
5024
4852
|
const field = config.fields[fieldKey];
|
5025
4853
|
if ((field == null ? void 0 : field.type) === "slot") {
|
5026
|
-
|
4854
|
+
const content = props[fieldKey] || [];
|
4855
|
+
const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
|
4856
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
4857
|
+
allow: field.allow,
|
4858
|
+
disallow: field.disallow
|
4859
|
+
}, dzProps), {
|
5027
4860
|
zone: fieldKey,
|
5028
|
-
content
|
4861
|
+
content
|
5029
4862
|
}));
|
4863
|
+
slotProps2[fieldKey] = Slot;
|
5030
4864
|
}
|
5031
4865
|
}
|
5032
|
-
return
|
5033
|
-
}, [config,
|
4866
|
+
return slotProps2;
|
4867
|
+
}, [config, readOnly, forceReadOnly]);
|
4868
|
+
return __spreadValues(__spreadValues({}, props), slotProps);
|
5034
4869
|
}
|
5035
4870
|
|
5036
4871
|
// components/Render/index.tsx
|
@@ -5038,39 +4873,121 @@ var import_react33 = __toESM(require("react"));
|
|
5038
4873
|
|
5039
4874
|
// components/SlotRender/index.tsx
|
5040
4875
|
init_react_import();
|
4876
|
+
|
4877
|
+
// components/SlotRender/server.tsx
|
4878
|
+
init_react_import();
|
5041
4879
|
var import_react32 = require("react");
|
4880
|
+
|
4881
|
+
// components/ServerRender/index.tsx
|
4882
|
+
init_react_import();
|
5042
4883
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
5043
|
-
|
4884
|
+
function DropZoneRender({
|
4885
|
+
zone,
|
4886
|
+
data,
|
4887
|
+
areaId = "root",
|
4888
|
+
config,
|
4889
|
+
metadata = {}
|
4890
|
+
}) {
|
4891
|
+
let zoneCompound = rootDroppableId;
|
4892
|
+
let content = (data == null ? void 0 : data.content) || [];
|
4893
|
+
if (!data || !config) {
|
4894
|
+
return null;
|
4895
|
+
}
|
4896
|
+
if (areaId !== rootAreaId && zone !== rootZone) {
|
4897
|
+
zoneCompound = `${areaId}:${zone}`;
|
4898
|
+
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
4899
|
+
}
|
4900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
|
4901
|
+
const Component = config.components[item.type];
|
4902
|
+
const props = __spreadProps(__spreadValues({}, item.props), {
|
4903
|
+
puck: {
|
4904
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4905
|
+
DropZoneRender,
|
4906
|
+
{
|
4907
|
+
zone: zone2,
|
4908
|
+
data,
|
4909
|
+
areaId: item.props.id,
|
4910
|
+
config,
|
4911
|
+
metadata
|
4912
|
+
}
|
4913
|
+
),
|
4914
|
+
metadata
|
4915
|
+
}
|
4916
|
+
});
|
4917
|
+
const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
4918
|
+
if (Component) {
|
4919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
|
4920
|
+
}
|
4921
|
+
return null;
|
4922
|
+
}) });
|
4923
|
+
}
|
4924
|
+
|
4925
|
+
// components/SlotRender/server.tsx
|
4926
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
4927
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
|
4928
|
+
var Item = ({
|
4929
|
+
config,
|
4930
|
+
item,
|
4931
|
+
metadata
|
4932
|
+
}) => {
|
4933
|
+
const Component = config.components[item.type];
|
4934
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
4935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4936
|
+
Component.render,
|
4937
|
+
__spreadProps(__spreadValues({}, props), {
|
4938
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
4939
|
+
renderDropZone: DropZoneRender,
|
4940
|
+
metadata: metadata || {}
|
4941
|
+
})
|
4942
|
+
})
|
4943
|
+
);
|
4944
|
+
};
|
5044
4945
|
var SlotRender = (0, import_react32.forwardRef)(
|
5045
4946
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
5046
|
-
return /* @__PURE__ */ (0,
|
5047
|
-
|
5048
|
-
|
5049
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5050
|
-
SlotRenderPure,
|
5051
|
-
__spreadProps(__spreadValues({}, slotProps), {
|
5052
|
-
config,
|
5053
|
-
metadata
|
5054
|
-
})
|
5055
|
-
));
|
5056
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5057
|
-
Component.render,
|
5058
|
-
__spreadProps(__spreadValues({}, props), {
|
5059
|
-
puck: {
|
5060
|
-
renderDropZone: DropZoneRenderPure,
|
5061
|
-
metadata: metadata || {}
|
5062
|
-
}
|
5063
|
-
}),
|
5064
|
-
props.id
|
5065
|
-
);
|
4947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
4948
|
+
if (!config.components[item.type]) {
|
4949
|
+
return null;
|
5066
4950
|
}
|
5067
|
-
return
|
4951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4952
|
+
Item,
|
4953
|
+
{
|
4954
|
+
config,
|
4955
|
+
item,
|
4956
|
+
metadata
|
4957
|
+
},
|
4958
|
+
item.props.id
|
4959
|
+
);
|
5068
4960
|
}) });
|
5069
4961
|
}
|
5070
4962
|
);
|
5071
4963
|
|
4964
|
+
// components/SlotRender/index.tsx
|
4965
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
4966
|
+
var ContextSlotRender = ({
|
4967
|
+
componentId,
|
4968
|
+
zone
|
4969
|
+
}) => {
|
4970
|
+
const config = useAppStore((s) => s.config);
|
4971
|
+
const metadata = useAppStore((s) => s.metadata);
|
4972
|
+
const slotContent = useAppStore(
|
4973
|
+
(s) => {
|
4974
|
+
var _a, _b;
|
4975
|
+
return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
|
4976
|
+
}
|
4977
|
+
);
|
4978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4979
|
+
SlotRenderPure,
|
4980
|
+
{
|
4981
|
+
content: slotContent,
|
4982
|
+
zone,
|
4983
|
+
config,
|
4984
|
+
metadata
|
4985
|
+
}
|
4986
|
+
);
|
4987
|
+
};
|
4988
|
+
|
5072
4989
|
// components/Render/index.tsx
|
5073
|
-
var
|
4990
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
5074
4991
|
var renderContext = import_react33.default.createContext({
|
5075
4992
|
config: { components: {} },
|
5076
4993
|
data: { root: {}, content: [] },
|
@@ -5099,37 +5016,26 @@ function Render({
|
|
5099
5016
|
editMode: false,
|
5100
5017
|
id: "puck-root"
|
5101
5018
|
});
|
5102
|
-
const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0,
|
5019
|
+
const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
|
5020
|
+
const nextContextValue = (0, import_react33.useMemo)(
|
5021
|
+
() => ({
|
5022
|
+
mode: "render",
|
5023
|
+
depth: 0
|
5024
|
+
}),
|
5025
|
+
[]
|
5026
|
+
);
|
5103
5027
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5104
|
-
return /* @__PURE__ */ (0,
|
5105
|
-
DropZoneProvider,
|
5106
|
-
{
|
5107
|
-
value: {
|
5108
|
-
mode: "render",
|
5109
|
-
depth: 0
|
5110
|
-
},
|
5111
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone }) }))
|
5112
|
-
}
|
5113
|
-
) });
|
5028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneRenderPure, { zone: rootZone }) })) }) });
|
5114
5029
|
}
|
5115
|
-
return /* @__PURE__ */ (0,
|
5116
|
-
DropZoneProvider,
|
5117
|
-
{
|
5118
|
-
value: {
|
5119
|
-
mode: "render",
|
5120
|
-
depth: 0
|
5121
|
-
},
|
5122
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRenderPure, { zone: rootZone })
|
5123
|
-
}
|
5124
|
-
) });
|
5030
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneRenderPure, { zone: rootZone }) }) });
|
5125
5031
|
}
|
5126
5032
|
|
5127
5033
|
// components/DropZone/index.tsx
|
5128
|
-
var
|
5034
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
5129
5035
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
5130
5036
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
5131
5037
|
var RENDER_DEBUG = false;
|
5132
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */ (0,
|
5038
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadValues({}, props));
|
5133
5039
|
var DropZoneChild = ({
|
5134
5040
|
zoneCompound,
|
5135
5041
|
componentId,
|
@@ -5142,14 +5048,8 @@ var DropZoneChild = ({
|
|
5142
5048
|
}) => {
|
5143
5049
|
var _a, _b;
|
5144
5050
|
const metadata = useAppStore((s) => s.metadata);
|
5145
|
-
const puckProps = {
|
5146
|
-
renderDropZone: DropZoneEditPure,
|
5147
|
-
isEditing: true,
|
5148
|
-
dragRef: null,
|
5149
|
-
metadata
|
5150
|
-
};
|
5151
5051
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
5152
|
-
const { depth } = ctx;
|
5052
|
+
const { depth = 1 } = ctx != null ? ctx : {};
|
5153
5053
|
const nodeProps = useAppStore(
|
5154
5054
|
(0, import_shallow3.useShallow)((s) => {
|
5155
5055
|
var _a2;
|
@@ -5162,11 +5062,23 @@ var DropZoneChild = ({
|
|
5162
5062
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
|
5163
5063
|
}
|
5164
5064
|
);
|
5065
|
+
const nodeReadOnly = useAppStore(
|
5066
|
+
(0, import_shallow3.useShallow)((s) => {
|
5067
|
+
var _a2;
|
5068
|
+
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
5069
|
+
})
|
5070
|
+
);
|
5165
5071
|
const node = { type: nodeType, props: nodeProps };
|
5166
5072
|
const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
|
5167
5073
|
const componentConfig = useAppStore(
|
5168
5074
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
5169
5075
|
);
|
5076
|
+
const puckProps = {
|
5077
|
+
renderDropZone: DropZoneEditPure,
|
5078
|
+
isEditing: true,
|
5079
|
+
dragRef: null,
|
5080
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
|
5081
|
+
};
|
5170
5082
|
const overrides = useAppStore((s) => s.overrides);
|
5171
5083
|
const isLoading = useAppStore(
|
5172
5084
|
(s) => {
|
@@ -5183,7 +5095,7 @@ var DropZoneChild = ({
|
|
5183
5095
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
5184
5096
|
const renderPreview = (0, import_react34.useMemo)(
|
5185
5097
|
() => function Preview4() {
|
5186
|
-
return /* @__PURE__ */ (0,
|
5098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
5187
5099
|
},
|
5188
5100
|
[componentId, label, overrides]
|
5189
5101
|
);
|
@@ -5198,10 +5110,13 @@ var DropZoneChild = ({
|
|
5198
5110
|
const defaultedPropsWithSlots = useSlots(
|
5199
5111
|
componentConfig,
|
5200
5112
|
defaultsProps,
|
5201
|
-
DropZoneEditPure
|
5113
|
+
DropZoneEditPure,
|
5114
|
+
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
5115
|
+
nodeReadOnly,
|
5116
|
+
isLoading
|
5202
5117
|
);
|
5203
5118
|
if (!item) return;
|
5204
|
-
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0,
|
5119
|
+
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
5205
5120
|
"No configuration for ",
|
5206
5121
|
item.type
|
5207
5122
|
] });
|
@@ -5210,7 +5125,7 @@ var DropZoneChild = ({
|
|
5210
5125
|
if (isPreview) {
|
5211
5126
|
Render2 = renderPreview;
|
5212
5127
|
}
|
5213
|
-
return /* @__PURE__ */ (0,
|
5128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5214
5129
|
DraggableComponent,
|
5215
5130
|
{
|
5216
5131
|
id: componentId,
|
@@ -5225,17 +5140,18 @@ var DropZoneChild = ({
|
|
5225
5140
|
autoDragAxis: dragAxis,
|
5226
5141
|
userDragAxis: collisionAxis,
|
5227
5142
|
inDroppableZone,
|
5228
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0,
|
5143
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5229
5144
|
Render2,
|
5230
5145
|
__spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
|
5231
5146
|
puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
|
5232
5147
|
dragRef
|
5233
5148
|
})
|
5234
5149
|
})
|
5235
|
-
) }) : /* @__PURE__ */ (0,
|
5150
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
|
5236
5151
|
}
|
5237
5152
|
);
|
5238
5153
|
};
|
5154
|
+
var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
|
5239
5155
|
var DropZoneEdit = (0, import_react34.forwardRef)(
|
5240
5156
|
function DropZoneEditInternal({
|
5241
5157
|
zone,
|
@@ -5250,10 +5166,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5250
5166
|
const {
|
5251
5167
|
// These all need setting via context
|
5252
5168
|
areaId,
|
5253
|
-
depth,
|
5169
|
+
depth = 0,
|
5254
5170
|
registerLocalZone,
|
5255
5171
|
unregisterLocalZone
|
5256
|
-
} = ctx;
|
5172
|
+
} = ctx != null ? ctx : {};
|
5257
5173
|
const path = useAppStore(
|
5258
5174
|
(0, import_shallow3.useShallow)((s) => {
|
5259
5175
|
var _a;
|
@@ -5305,6 +5221,15 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5305
5221
|
};
|
5306
5222
|
}
|
5307
5223
|
}, [zoneType]);
|
5224
|
+
(0, import_react34.useEffect)(() => {
|
5225
|
+
if (zoneType === "dropzone") {
|
5226
|
+
if (zoneCompound !== rootDroppableId) {
|
5227
|
+
console.warn(
|
5228
|
+
"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"
|
5229
|
+
);
|
5230
|
+
}
|
5231
|
+
}
|
5232
|
+
}, [zoneType]);
|
5308
5233
|
const contentIds = (0, import_react34.useMemo)(() => {
|
5309
5234
|
return zoneContentIds || [];
|
5310
5235
|
}, [zoneContentIds]);
|
@@ -5367,7 +5292,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5367
5292
|
path: path || []
|
5368
5293
|
}
|
5369
5294
|
};
|
5370
|
-
const { ref: dropRef } =
|
5295
|
+
const { ref: dropRef } = (0, import_react35.useDroppable)(droppableConfig);
|
5371
5296
|
const isAreaSelected = useAppStore(
|
5372
5297
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
5373
5298
|
);
|
@@ -5377,7 +5302,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5377
5302
|
userMinEmptyHeight,
|
5378
5303
|
ref
|
5379
5304
|
});
|
5380
|
-
return /* @__PURE__ */ (0,
|
5305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5381
5306
|
"div",
|
5382
5307
|
{
|
5383
5308
|
className: `${getClassName17({
|
@@ -5399,8 +5324,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5399
5324
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
5400
5325
|
}),
|
5401
5326
|
children: contentIdsWithPreview.map((componentId, i) => {
|
5402
|
-
return /* @__PURE__ */ (0,
|
5403
|
-
|
5327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5328
|
+
DropZoneChildMemo,
|
5404
5329
|
{
|
5405
5330
|
zoneCompound,
|
5406
5331
|
componentId,
|
@@ -5418,8 +5343,32 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5418
5343
|
);
|
5419
5344
|
}
|
5420
5345
|
);
|
5421
|
-
var
|
5422
|
-
|
5346
|
+
var DropZoneRenderItem = ({
|
5347
|
+
config,
|
5348
|
+
item,
|
5349
|
+
metadata
|
5350
|
+
}) => {
|
5351
|
+
const Component = config.components[item.type];
|
5352
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5353
|
+
const nextContextValue = (0, import_react34.useMemo)(
|
5354
|
+
() => ({
|
5355
|
+
areaId: props.id,
|
5356
|
+
depth: 1
|
5357
|
+
}),
|
5358
|
+
[props]
|
5359
|
+
);
|
5360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5361
|
+
Component.render,
|
5362
|
+
__spreadProps(__spreadValues({}, props), {
|
5363
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
5364
|
+
renderDropZone: DropZoneRenderPure,
|
5365
|
+
metadata: __spreadValues(__spreadValues({}, metadata), Component.metadata)
|
5366
|
+
})
|
5367
|
+
})
|
5368
|
+
) }, props.id);
|
5369
|
+
};
|
5370
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
|
5371
|
+
var DropZoneRender2 = (0, import_react34.forwardRef)(
|
5423
5372
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
5424
5373
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
5425
5374
|
const { areaId = "root" } = ctx || {};
|
@@ -5445,55 +5394,37 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5445
5394
|
zoneCompound = `${areaId}:${zone}`;
|
5446
5395
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
5447
5396
|
}
|
5448
|
-
return /* @__PURE__ */ (0,
|
5397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className, style, ref, children: content.map((item) => {
|
5449
5398
|
const Component = config.components[item.type];
|
5450
5399
|
if (Component) {
|
5451
|
-
|
5452
|
-
|
5453
|
-
|
5400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5401
|
+
DropZoneRenderItem,
|
5402
|
+
{
|
5454
5403
|
config,
|
5404
|
+
item,
|
5455
5405
|
metadata
|
5456
|
-
})
|
5457
|
-
));
|
5458
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5459
|
-
DropZoneProvider,
|
5460
|
-
{
|
5461
|
-
value: {
|
5462
|
-
areaId: props.id,
|
5463
|
-
depth: 1
|
5464
|
-
},
|
5465
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5466
|
-
Component.render,
|
5467
|
-
__spreadProps(__spreadValues({}, props), {
|
5468
|
-
puck: {
|
5469
|
-
renderDropZone: DropZoneRenderPure,
|
5470
|
-
metadata: metadata || {}
|
5471
|
-
}
|
5472
|
-
})
|
5473
|
-
)
|
5474
5406
|
},
|
5475
|
-
props.id
|
5407
|
+
item.props.id
|
5476
5408
|
);
|
5477
5409
|
}
|
5478
5410
|
return null;
|
5479
5411
|
}) });
|
5480
5412
|
}
|
5481
5413
|
);
|
5482
|
-
var DropZonePure = (props) => /* @__PURE__ */ (0,
|
5414
|
+
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
|
5483
5415
|
var DropZone = (0, import_react34.forwardRef)(
|
5484
5416
|
function DropZone2(props, ref) {
|
5485
5417
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
5486
5418
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
5487
|
-
return /* @__PURE__ */ (0,
|
5419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
5488
5420
|
}
|
5489
|
-
return /* @__PURE__ */ (0,
|
5421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadProps(__spreadValues({}, props), { ref })) });
|
5490
5422
|
}
|
5491
5423
|
);
|
5492
5424
|
|
5493
5425
|
// lib/dnd/NestedDroppablePlugin.ts
|
5494
5426
|
init_react_import();
|
5495
|
-
var
|
5496
|
-
var import_state2 = require("@dnd-kit/state");
|
5427
|
+
var import_abstract9 = require("@dnd-kit/abstract");
|
5497
5428
|
|
5498
5429
|
// lib/throttle.ts
|
5499
5430
|
init_react_import();
|
@@ -5542,7 +5473,7 @@ var GlobalPosition = class {
|
|
5542
5473
|
var _a;
|
5543
5474
|
this.target = target;
|
5544
5475
|
this.original = original;
|
5545
|
-
this.frameEl = document.querySelector("iframe");
|
5476
|
+
this.frameEl = document.querySelector("iframe#preview-frame");
|
5546
5477
|
if (this.frameEl) {
|
5547
5478
|
this.frameRect = this.frameEl.getBoundingClientRect();
|
5548
5479
|
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
@@ -5622,6 +5553,7 @@ var getZoneId2 = (candidate) => {
|
|
5622
5553
|
}
|
5623
5554
|
return id;
|
5624
5555
|
};
|
5556
|
+
var BUFFER = 6;
|
5625
5557
|
var getPointerCollisions = (position, manager) => {
|
5626
5558
|
const candidates = [];
|
5627
5559
|
let elements = position.target.ownerDocument.elementsFromPoint(
|
@@ -5645,13 +5577,26 @@ var getPointerCollisions = (position, manager) => {
|
|
5645
5577
|
for (let i = 0; i < elements.length; i++) {
|
5646
5578
|
const element = elements[i];
|
5647
5579
|
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
5580
|
+
const id = element.getAttribute("data-puck-dnd");
|
5581
|
+
const isVoid = element.hasAttribute("data-puck-dnd-void");
|
5582
|
+
if (BUFFER && (dropzoneId || id) && !isVoid) {
|
5583
|
+
const box = element.getBoundingClientRect();
|
5584
|
+
const contractedBox = {
|
5585
|
+
left: box.left + BUFFER,
|
5586
|
+
right: box.right - BUFFER,
|
5587
|
+
top: box.top + BUFFER,
|
5588
|
+
bottom: box.bottom - BUFFER
|
5589
|
+
};
|
5590
|
+
if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
|
5591
|
+
continue;
|
5592
|
+
}
|
5593
|
+
}
|
5648
5594
|
if (dropzoneId) {
|
5649
5595
|
const droppable = manager.registry.droppables.get(dropzoneId);
|
5650
5596
|
if (droppable) {
|
5651
5597
|
candidates.push(droppable);
|
5652
5598
|
}
|
5653
5599
|
}
|
5654
|
-
const id = element.getAttribute("data-puck-dnd");
|
5655
5600
|
if (id) {
|
5656
5601
|
const droppable = manager.registry.droppables.get(id);
|
5657
5602
|
if (droppable) {
|
@@ -5705,17 +5650,17 @@ var findDeepestCandidate = (position, manager) => {
|
|
5705
5650
|
return { zone, area };
|
5706
5651
|
}
|
5707
5652
|
return {
|
5708
|
-
zone:
|
5709
|
-
area:
|
5653
|
+
zone: rootDroppableId,
|
5654
|
+
area: rootAreaId
|
5710
5655
|
};
|
5711
5656
|
};
|
5712
|
-
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends
|
5657
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
5713
5658
|
constructor(manager, options) {
|
5714
5659
|
super(manager);
|
5715
5660
|
if (typeof window === "undefined") {
|
5716
5661
|
return;
|
5717
5662
|
}
|
5718
|
-
|
5663
|
+
this.registerEffect(() => {
|
5719
5664
|
const handleMove = (event) => {
|
5720
5665
|
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
5721
5666
|
const position = new GlobalPosition(target, {
|
@@ -5739,12 +5684,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
5739
5684
|
capture: true
|
5740
5685
|
// dndkit's PointerSensor prevents propagation during drag
|
5741
5686
|
});
|
5742
|
-
|
5687
|
+
const cleanup = () => {
|
5743
5688
|
document.body.removeEventListener("pointermove", handlePointerMove, {
|
5744
5689
|
capture: true
|
5745
5690
|
});
|
5746
|
-
cleanupEffect();
|
5747
5691
|
};
|
5692
|
+
return cleanup;
|
5748
5693
|
});
|
5749
5694
|
}
|
5750
5695
|
};
|
@@ -5760,8 +5705,8 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
|
|
5760
5705
|
destinationZone: zone,
|
5761
5706
|
id
|
5762
5707
|
};
|
5763
|
-
const { state,
|
5764
|
-
const insertedState = insertAction(state, insertActionData,
|
5708
|
+
const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
|
5709
|
+
const insertedState = insertAction(state, insertActionData, appStore);
|
5765
5710
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
5766
5711
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
5767
5712
|
// We must always record history here so the insert is added to user history
|
@@ -5804,14 +5749,14 @@ function getDeepDir(el) {
|
|
5804
5749
|
}
|
5805
5750
|
|
5806
5751
|
// components/DragDropContext/index.tsx
|
5807
|
-
var
|
5752
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
5808
5753
|
var DEBUG3 = false;
|
5809
|
-
var dragListenerContext = (0,
|
5754
|
+
var dragListenerContext = (0, import_react37.createContext)({
|
5810
5755
|
dragListeners: {}
|
5811
5756
|
});
|
5812
5757
|
function useDragListener(type, fn, deps = []) {
|
5813
|
-
const { setDragListeners } = (0,
|
5814
|
-
(0,
|
5758
|
+
const { setDragListeners } = (0, import_react37.useContext)(dragListenerContext);
|
5759
|
+
(0, import_react37.useEffect)(() => {
|
5815
5760
|
if (setDragListeners) {
|
5816
5761
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5817
5762
|
[type]: [...old[type] || [], fn]
|
@@ -5821,8 +5766,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5821
5766
|
}
|
5822
5767
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5823
5768
|
var useTempDisableFallback = (timeout3) => {
|
5824
|
-
const lastFallbackDisable = (0,
|
5825
|
-
return (0,
|
5769
|
+
const lastFallbackDisable = (0, import_react37.useRef)(null);
|
5770
|
+
return (0, import_react37.useCallback)((manager) => {
|
5826
5771
|
collisionStore.setState({ fallbackEnabled: false });
|
5827
5772
|
const fallbackId = generateId();
|
5828
5773
|
lastFallbackDisable.current = fallbackId;
|
@@ -5841,9 +5786,9 @@ var DragDropContextClient = ({
|
|
5841
5786
|
const dispatch = useAppStore((s) => s.dispatch);
|
5842
5787
|
const appStore = useAppStoreApi();
|
5843
5788
|
const id = useSafeId();
|
5844
|
-
const debouncedParamsRef = (0,
|
5789
|
+
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
5845
5790
|
const tempDisableFallback = useTempDisableFallback(100);
|
5846
|
-
const [zoneStore] = (0,
|
5791
|
+
const [zoneStore] = (0, import_react37.useState)(
|
5847
5792
|
() => (0, import_zustand5.createStore)(() => ({
|
5848
5793
|
zoneDepthIndex: {},
|
5849
5794
|
nextZoneDepthIndex: {},
|
@@ -5853,7 +5798,7 @@ var DragDropContextClient = ({
|
|
5853
5798
|
previewIndex: {}
|
5854
5799
|
}))
|
5855
5800
|
);
|
5856
|
-
const getChanged2 = (0,
|
5801
|
+
const getChanged2 = (0, import_react37.useCallback)(
|
5857
5802
|
(params, id2) => {
|
5858
5803
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5859
5804
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5874,7 +5819,7 @@ var DragDropContextClient = ({
|
|
5874
5819
|
},
|
5875
5820
|
[zoneStore]
|
5876
5821
|
);
|
5877
|
-
const setDeepestAndCollide = (0,
|
5822
|
+
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
5878
5823
|
(params, manager) => {
|
5879
5824
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5880
5825
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5898,7 +5843,7 @@ var DragDropContextClient = ({
|
|
5898
5843
|
setDeepestDb.cancel();
|
5899
5844
|
debouncedParamsRef.current = null;
|
5900
5845
|
};
|
5901
|
-
(0,
|
5846
|
+
(0, import_react37.useEffect)(() => {
|
5902
5847
|
if (DEBUG3) {
|
5903
5848
|
zoneStore.subscribe(
|
5904
5849
|
(s) => {
|
@@ -5912,7 +5857,7 @@ var DragDropContextClient = ({
|
|
5912
5857
|
);
|
5913
5858
|
}
|
5914
5859
|
}, []);
|
5915
|
-
const [plugins] = (0,
|
5860
|
+
const [plugins] = (0, import_react37.useState)(() => [
|
5916
5861
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5917
5862
|
createNestedDroppablePlugin(
|
5918
5863
|
{
|
@@ -5960,18 +5905,26 @@ var DragDropContextClient = ({
|
|
5960
5905
|
)
|
5961
5906
|
]);
|
5962
5907
|
const sensors = useSensors();
|
5963
|
-
const [dragListeners, setDragListeners] = (0,
|
5964
|
-
const dragMode = (0,
|
5965
|
-
const initialSelector = (0,
|
5966
|
-
|
5908
|
+
const [dragListeners, setDragListeners] = (0, import_react37.useState)({});
|
5909
|
+
const dragMode = (0, import_react37.useRef)(null);
|
5910
|
+
const initialSelector = (0, import_react37.useRef)(void 0);
|
5911
|
+
const nextContextValue = (0, import_react37.useMemo)(
|
5912
|
+
() => ({
|
5913
|
+
mode: "edit",
|
5914
|
+
areaId: "root",
|
5915
|
+
depth: 0
|
5916
|
+
}),
|
5917
|
+
[]
|
5918
|
+
);
|
5919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
5967
5920
|
dragListenerContext.Provider,
|
5968
5921
|
{
|
5969
5922
|
value: {
|
5970
5923
|
dragListeners,
|
5971
5924
|
setDragListeners
|
5972
5925
|
},
|
5973
|
-
children: /* @__PURE__ */ (0,
|
5974
|
-
|
5926
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
5927
|
+
import_react36.DragDropProvider,
|
5975
5928
|
{
|
5976
5929
|
plugins,
|
5977
5930
|
sensors,
|
@@ -6004,7 +5957,6 @@ var DragDropContextClient = ({
|
|
6004
5957
|
}
|
6005
5958
|
if (thisPreview) {
|
6006
5959
|
zoneStore.setState({ previewIndex: {} });
|
6007
|
-
const state = appStore.getState().state;
|
6008
5960
|
if (thisPreview.type === "insert") {
|
6009
5961
|
insertComponent(
|
6010
5962
|
thisPreview.componentType,
|
@@ -6039,7 +5991,7 @@ var DragDropContextClient = ({
|
|
6039
5991
|
}, 250);
|
6040
5992
|
},
|
6041
5993
|
onDragOver: (event, manager) => {
|
6042
|
-
var _a, _b, _c, _d
|
5994
|
+
var _a, _b, _c, _d;
|
6043
5995
|
event.preventDefault();
|
6044
5996
|
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
6045
5997
|
if (!draggedItem) return;
|
@@ -6057,7 +6009,7 @@ var DragDropContextClient = ({
|
|
6057
6009
|
const targetData = target.data;
|
6058
6010
|
targetZone = targetData.zone;
|
6059
6011
|
targetIndex = targetData.index;
|
6060
|
-
const collisionData = (
|
6012
|
+
const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
|
6061
6013
|
const dir = getDeepDir(target.element);
|
6062
6014
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
|
6063
6015
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
@@ -6070,7 +6022,7 @@ var DragDropContextClient = ({
|
|
6070
6022
|
targetZone = target.id.toString();
|
6071
6023
|
targetIndex = 0;
|
6072
6024
|
}
|
6073
|
-
const path = ((
|
6025
|
+
const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
|
6074
6026
|
if (targetId === sourceId || path.find((path2) => {
|
6075
6027
|
const [pathId] = path2.split(":");
|
6076
6028
|
return pathId === sourceId;
|
@@ -6116,16 +6068,12 @@ var DragDropContextClient = ({
|
|
6116
6068
|
});
|
6117
6069
|
}
|
6118
6070
|
}
|
6119
|
-
(
|
6071
|
+
(_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
|
6120
6072
|
fn(event, manager);
|
6121
6073
|
});
|
6122
6074
|
},
|
6123
6075
|
onDragStart: (event, manager) => {
|
6124
6076
|
var _a;
|
6125
|
-
dispatch({
|
6126
|
-
type: "setUi",
|
6127
|
-
ui: { itemSelector: null, isDragging: true }
|
6128
|
-
});
|
6129
6077
|
const { source } = event.operation;
|
6130
6078
|
if (source && source.type !== "void") {
|
6131
6079
|
const sourceData = source.data;
|
@@ -6156,22 +6104,12 @@ var DragDropContextClient = ({
|
|
6156
6104
|
},
|
6157
6105
|
onBeforeDragStart: (event) => {
|
6158
6106
|
var _a;
|
6159
|
-
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.
|
6107
|
+
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
|
6160
6108
|
dragMode.current = isNewComponent ? "new" : "existing";
|
6161
6109
|
initialSelector.current = void 0;
|
6162
6110
|
zoneStore.setState({ draggedItem: event.operation.source });
|
6163
6111
|
},
|
6164
|
-
children: /* @__PURE__ */ (0,
|
6165
|
-
DropZoneProvider,
|
6166
|
-
{
|
6167
|
-
value: {
|
6168
|
-
mode: "edit",
|
6169
|
-
areaId: "root",
|
6170
|
-
depth: 0
|
6171
|
-
},
|
6172
|
-
children
|
6173
|
-
}
|
6174
|
-
) })
|
6112
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
|
6175
6113
|
}
|
6176
6114
|
)
|
6177
6115
|
}
|
@@ -6185,11 +6123,12 @@ var DragDropContext = ({
|
|
6185
6123
|
if (status === "LOADING") {
|
6186
6124
|
return children;
|
6187
6125
|
}
|
6188
|
-
return /* @__PURE__ */ (0,
|
6126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
6189
6127
|
};
|
6190
6128
|
|
6191
6129
|
// components/Drawer/index.tsx
|
6192
|
-
var
|
6130
|
+
var import_react39 = require("@dnd-kit/react");
|
6131
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
6193
6132
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
6194
6133
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
6195
6134
|
var DrawerItemInner = ({
|
@@ -6199,11 +6138,11 @@ var DrawerItemInner = ({
|
|
6199
6138
|
dragRef,
|
6200
6139
|
isDragDisabled
|
6201
6140
|
}) => {
|
6202
|
-
const CustomInner = (0,
|
6203
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
6141
|
+
const CustomInner = (0, import_react38.useMemo)(
|
6142
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
6204
6143
|
[children]
|
6205
6144
|
);
|
6206
|
-
return /* @__PURE__ */ (0,
|
6145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6207
6146
|
"div",
|
6208
6147
|
{
|
6209
6148
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -6211,9 +6150,9 @@ var DrawerItemInner = ({
|
|
6211
6150
|
onMouseDown: (e) => e.preventDefault(),
|
6212
6151
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
6213
6152
|
"data-puck-drawer-item": true,
|
6214
|
-
children: /* @__PURE__ */ (0,
|
6215
|
-
/* @__PURE__ */ (0,
|
6216
|
-
/* @__PURE__ */ (0,
|
6153
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
|
6154
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
6155
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DragIcon, {}) })
|
6217
6156
|
] }) }) })
|
6218
6157
|
}
|
6219
6158
|
);
|
@@ -6225,14 +6164,15 @@ var DrawerItemDraggable = ({
|
|
6225
6164
|
id,
|
6226
6165
|
isDragDisabled
|
6227
6166
|
}) => {
|
6228
|
-
const { ref } =
|
6167
|
+
const { ref } = (0, import_react39.useDraggable)({
|
6229
6168
|
id,
|
6230
|
-
data: {
|
6231
|
-
disabled: isDragDisabled
|
6169
|
+
data: { componentType: name },
|
6170
|
+
disabled: isDragDisabled,
|
6171
|
+
type: "drawer"
|
6232
6172
|
});
|
6233
|
-
return /* @__PURE__ */ (0,
|
6234
|
-
/* @__PURE__ */ (0,
|
6235
|
-
/* @__PURE__ */ (0,
|
6173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
|
6174
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
|
6175
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6236
6176
|
DrawerItemInner,
|
6237
6177
|
{
|
6238
6178
|
name,
|
@@ -6253,7 +6193,7 @@ var DrawerItem = ({
|
|
6253
6193
|
isDragDisabled
|
6254
6194
|
}) => {
|
6255
6195
|
const resolvedId = id || name;
|
6256
|
-
const [dynamicId, setDynamicId] = (0,
|
6196
|
+
const [dynamicId, setDynamicId] = (0, import_react38.useState)(generateId(resolvedId));
|
6257
6197
|
if (typeof index !== "undefined") {
|
6258
6198
|
console.error(
|
6259
6199
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -6266,7 +6206,7 @@ var DrawerItem = ({
|
|
6266
6206
|
},
|
6267
6207
|
[resolvedId]
|
6268
6208
|
);
|
6269
|
-
return /* @__PURE__ */ (0,
|
6209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6270
6210
|
DrawerItemDraggable,
|
6271
6211
|
{
|
6272
6212
|
name,
|
@@ -6293,19 +6233,20 @@ var Drawer = ({
|
|
6293
6233
|
);
|
6294
6234
|
}
|
6295
6235
|
const id = useSafeId();
|
6296
|
-
const { ref } =
|
6236
|
+
const { ref } = (0, import_react39.useDroppable)({
|
6297
6237
|
id,
|
6298
6238
|
type: "void",
|
6299
6239
|
collisionPriority: 0
|
6300
6240
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
6301
6241
|
});
|
6302
|
-
return /* @__PURE__ */ (0,
|
6242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6303
6243
|
"div",
|
6304
6244
|
{
|
6305
6245
|
className: getClassName18(),
|
6306
6246
|
ref,
|
6307
6247
|
"data-puck-dnd": id,
|
6308
6248
|
"data-puck-drawer": true,
|
6249
|
+
"data-puck-dnd-void": true,
|
6309
6250
|
children
|
6310
6251
|
}
|
6311
6252
|
);
|
@@ -6314,7 +6255,7 @@ Drawer.Item = DrawerItem;
|
|
6314
6255
|
|
6315
6256
|
// components/Puck/index.tsx
|
6316
6257
|
init_react_import();
|
6317
|
-
var
|
6258
|
+
var import_react54 = require("react");
|
6318
6259
|
|
6319
6260
|
// components/SidebarSection/index.tsx
|
6320
6261
|
init_react_import();
|
@@ -6325,7 +6266,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
6325
6266
|
|
6326
6267
|
// lib/use-breadcrumbs.ts
|
6327
6268
|
init_react_import();
|
6328
|
-
var
|
6269
|
+
var import_react40 = require("react");
|
6329
6270
|
var useBreadcrumbs = (renderCount) => {
|
6330
6271
|
const selectedId = useAppStore((s) => {
|
6331
6272
|
var _a;
|
@@ -6337,7 +6278,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6337
6278
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
6338
6279
|
});
|
6339
6280
|
const appStore = useAppStoreApi();
|
6340
|
-
return (0,
|
6281
|
+
return (0, import_react40.useMemo)(() => {
|
6341
6282
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
6342
6283
|
var _a, _b, _c;
|
6343
6284
|
const [componentId] = zoneCompound.split(":");
|
@@ -6368,7 +6309,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6368
6309
|
};
|
6369
6310
|
|
6370
6311
|
// components/SidebarSection/index.tsx
|
6371
|
-
var
|
6312
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
6372
6313
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
6373
6314
|
var SidebarSection = ({
|
6374
6315
|
children,
|
@@ -6381,15 +6322,15 @@ var SidebarSection = ({
|
|
6381
6322
|
}) => {
|
6382
6323
|
const setUi = useAppStore((s) => s.setUi);
|
6383
6324
|
const breadcrumbs = useBreadcrumbs(1);
|
6384
|
-
return /* @__PURE__ */ (0,
|
6325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
6385
6326
|
"div",
|
6386
6327
|
{
|
6387
6328
|
className: getClassName19({ noBorderTop, noPadding }),
|
6388
6329
|
style: { background },
|
6389
6330
|
children: [
|
6390
|
-
/* @__PURE__ */ (0,
|
6391
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
6392
|
-
/* @__PURE__ */ (0,
|
6331
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
6332
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
6333
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6393
6334
|
"button",
|
6394
6335
|
{
|
6395
6336
|
type: "button",
|
@@ -6398,12 +6339,12 @@ var SidebarSection = ({
|
|
6398
6339
|
children: breadcrumb.label
|
6399
6340
|
}
|
6400
6341
|
),
|
6401
|
-
/* @__PURE__ */ (0,
|
6342
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronRight, { size: 16 })
|
6402
6343
|
] }, i)) : null,
|
6403
|
-
/* @__PURE__ */ (0,
|
6344
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
6404
6345
|
] }) }),
|
6405
|
-
/* @__PURE__ */ (0,
|
6406
|
-
isLoading && /* @__PURE__ */ (0,
|
6346
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("content"), children }),
|
6347
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 32 }) })
|
6407
6348
|
]
|
6408
6349
|
}
|
6409
6350
|
);
|
@@ -6417,7 +6358,7 @@ init_react_import();
|
|
6417
6358
|
var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
6418
6359
|
|
6419
6360
|
// components/MenuBar/index.tsx
|
6420
|
-
var
|
6361
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6421
6362
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
6422
6363
|
function MenuBar({
|
6423
6364
|
menuOpen = false,
|
@@ -6428,7 +6369,7 @@ function MenuBar({
|
|
6428
6369
|
const forward = useAppStore((s) => s.history.forward);
|
6429
6370
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
6430
6371
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
6431
|
-
return /* @__PURE__ */ (0,
|
6372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
6432
6373
|
"div",
|
6433
6374
|
{
|
6434
6375
|
className: getClassName20({ menuOpen }),
|
@@ -6442,12 +6383,12 @@ function MenuBar({
|
|
6442
6383
|
setMenuOpen(false);
|
6443
6384
|
}
|
6444
6385
|
},
|
6445
|
-
children: /* @__PURE__ */ (0,
|
6446
|
-
/* @__PURE__ */ (0,
|
6447
|
-
/* @__PURE__ */ (0,
|
6448
|
-
/* @__PURE__ */ (0,
|
6386
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("inner"), children: [
|
6387
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("history"), children: [
|
6388
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Undo2, { size: 21 }) }),
|
6389
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Redo2, { size: 21 }) })
|
6449
6390
|
] }),
|
6450
|
-
/* @__PURE__ */ (0,
|
6391
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
6451
6392
|
] })
|
6452
6393
|
}
|
6453
6394
|
);
|
@@ -6465,14 +6406,14 @@ init_react_import();
|
|
6465
6406
|
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
6466
6407
|
|
6467
6408
|
// components/Puck/components/Fields/index.tsx
|
6468
|
-
var
|
6409
|
+
var import_react41 = require("react");
|
6469
6410
|
var import_shallow4 = require("zustand/react/shallow");
|
6470
|
-
var
|
6411
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6471
6412
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
6472
6413
|
var DefaultFields = ({
|
6473
6414
|
children
|
6474
6415
|
}) => {
|
6475
|
-
return /* @__PURE__ */ (0,
|
6416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
|
6476
6417
|
};
|
6477
6418
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
6478
6419
|
let currentProps;
|
@@ -6538,12 +6479,12 @@ var FieldsChild = ({ fieldName }) => {
|
|
6538
6479
|
})
|
6539
6480
|
);
|
6540
6481
|
const appStore = useAppStoreApi();
|
6541
|
-
const onChange = (0,
|
6482
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
6542
6483
|
fieldName
|
6543
6484
|
]);
|
6544
6485
|
if (!field || !id) return null;
|
6545
6486
|
if (field.type === "slot") return null;
|
6546
|
-
return /* @__PURE__ */ (0,
|
6487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
6547
6488
|
AutoFieldPrivate,
|
6548
6489
|
{
|
6549
6490
|
field,
|
@@ -6571,11 +6512,16 @@ var Fields = ({ wrapFields = true }) => {
|
|
6571
6512
|
useRegisterFieldsSlice(appStore, id);
|
6572
6513
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
6573
6514
|
const fieldNames = useAppStore(
|
6574
|
-
(0, import_shallow4.useShallow)((s) =>
|
6515
|
+
(0, import_shallow4.useShallow)((s) => {
|
6516
|
+
if (s.fields.id === id) {
|
6517
|
+
return Object.keys(s.fields.fields);
|
6518
|
+
}
|
6519
|
+
return [];
|
6520
|
+
})
|
6575
6521
|
);
|
6576
6522
|
const isLoading = fieldsLoading || componentResolving;
|
6577
|
-
const Wrapper = (0,
|
6578
|
-
return /* @__PURE__ */ (0,
|
6523
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
6524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
6579
6525
|
"form",
|
6580
6526
|
{
|
6581
6527
|
className: getClassName21({ wrapFields }),
|
@@ -6583,8 +6529,8 @@ var Fields = ({ wrapFields = true }) => {
|
|
6583
6529
|
e.preventDefault();
|
6584
6530
|
},
|
6585
6531
|
children: [
|
6586
|
-
/* @__PURE__ */ (0,
|
6587
|
-
isLoading && /* @__PURE__ */ (0,
|
6532
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChild, { fieldName }, fieldName)) }),
|
6533
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 16 }) }) })
|
6588
6534
|
]
|
6589
6535
|
}
|
6590
6536
|
);
|
@@ -6595,7 +6541,7 @@ init_react_import();
|
|
6595
6541
|
|
6596
6542
|
// lib/use-component-list.tsx
|
6597
6543
|
init_react_import();
|
6598
|
-
var
|
6544
|
+
var import_react42 = require("react");
|
6599
6545
|
|
6600
6546
|
// components/ComponentList/index.tsx
|
6601
6547
|
init_react_import();
|
@@ -6605,7 +6551,7 @@ init_react_import();
|
|
6605
6551
|
var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
6606
6552
|
|
6607
6553
|
// components/ComponentList/index.tsx
|
6608
|
-
var
|
6554
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
6609
6555
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
6610
6556
|
var ComponentListItem = ({
|
6611
6557
|
name,
|
@@ -6617,7 +6563,7 @@ var ComponentListItem = ({
|
|
6617
6563
|
type: name
|
6618
6564
|
}).insert
|
6619
6565
|
);
|
6620
|
-
return /* @__PURE__ */ (0,
|
6566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
6621
6567
|
};
|
6622
6568
|
var ComponentList = ({
|
6623
6569
|
children,
|
@@ -6628,8 +6574,8 @@ var ComponentList = ({
|
|
6628
6574
|
const setUi = useAppStore((s) => s.setUi);
|
6629
6575
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
6630
6576
|
const { expanded = true } = componentList[id] || {};
|
6631
|
-
return /* @__PURE__ */ (0,
|
6632
|
-
title && /* @__PURE__ */ (0,
|
6577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
6578
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
6633
6579
|
"button",
|
6634
6580
|
{
|
6635
6581
|
type: "button",
|
@@ -6643,14 +6589,14 @@ var ComponentList = ({
|
|
6643
6589
|
}),
|
6644
6590
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
6645
6591
|
children: [
|
6646
|
-
/* @__PURE__ */ (0,
|
6647
|
-
/* @__PURE__ */ (0,
|
6592
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
|
6593
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: 12 }) })
|
6648
6594
|
]
|
6649
6595
|
}
|
6650
6596
|
),
|
6651
|
-
/* @__PURE__ */ (0,
|
6597
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
6652
6598
|
var _a;
|
6653
|
-
return /* @__PURE__ */ (0,
|
6599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
6654
6600
|
ComponentListItem,
|
6655
6601
|
{
|
6656
6602
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -6664,12 +6610,12 @@ var ComponentList = ({
|
|
6664
6610
|
ComponentList.Item = ComponentListItem;
|
6665
6611
|
|
6666
6612
|
// lib/use-component-list.tsx
|
6667
|
-
var
|
6613
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
6668
6614
|
var useComponentList = () => {
|
6669
|
-
const [componentList, setComponentList] = (0,
|
6615
|
+
const [componentList, setComponentList] = (0, import_react42.useState)();
|
6670
6616
|
const config = useAppStore((s) => s.config);
|
6671
6617
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6672
|
-
(0,
|
6618
|
+
(0, import_react42.useEffect)(() => {
|
6673
6619
|
var _a, _b, _c;
|
6674
6620
|
if (Object.keys(uiComponentList).length > 0) {
|
6675
6621
|
const matchedComponents = [];
|
@@ -6679,7 +6625,7 @@ var useComponentList = () => {
|
|
6679
6625
|
if (category.visible === false || !category.components) {
|
6680
6626
|
return null;
|
6681
6627
|
}
|
6682
|
-
return /* @__PURE__ */ (0,
|
6628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6683
6629
|
ComponentList,
|
6684
6630
|
{
|
6685
6631
|
id: categoryKey,
|
@@ -6688,7 +6634,7 @@ var useComponentList = () => {
|
|
6688
6634
|
var _a2;
|
6689
6635
|
matchedComponents.push(componentName);
|
6690
6636
|
const componentConf = config.components[componentName] || {};
|
6691
|
-
return /* @__PURE__ */ (0,
|
6637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6692
6638
|
ComponentList.Item,
|
6693
6639
|
{
|
6694
6640
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -6708,7 +6654,7 @@ var useComponentList = () => {
|
|
6708
6654
|
);
|
6709
6655
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
6710
6656
|
_componentList.push(
|
6711
|
-
/* @__PURE__ */ (0,
|
6657
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6712
6658
|
ComponentList,
|
6713
6659
|
{
|
6714
6660
|
id: "other",
|
@@ -6716,7 +6662,7 @@ var useComponentList = () => {
|
|
6716
6662
|
children: remainingComponents.map((componentName, i) => {
|
6717
6663
|
var _a2;
|
6718
6664
|
const componentConf = config.components[componentName] || {};
|
6719
|
-
return /* @__PURE__ */ (0,
|
6665
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6720
6666
|
ComponentList.Item,
|
6721
6667
|
{
|
6722
6668
|
name: componentName,
|
@@ -6738,25 +6684,25 @@ var useComponentList = () => {
|
|
6738
6684
|
};
|
6739
6685
|
|
6740
6686
|
// components/Puck/components/Components/index.tsx
|
6741
|
-
var
|
6742
|
-
var
|
6687
|
+
var import_react43 = require("react");
|
6688
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
6743
6689
|
var Components = () => {
|
6744
6690
|
const overrides = useAppStore((s) => s.overrides);
|
6745
6691
|
const componentList = useComponentList();
|
6746
|
-
const Wrapper = (0,
|
6747
|
-
return /* @__PURE__ */ (0,
|
6692
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.components || "div", [overrides]);
|
6693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
|
6748
6694
|
};
|
6749
6695
|
|
6750
6696
|
// components/Puck/components/Preview/index.tsx
|
6751
6697
|
init_react_import();
|
6752
|
-
var
|
6698
|
+
var import_react45 = require("react");
|
6753
6699
|
|
6754
6700
|
// components/AutoFrame/index.tsx
|
6755
6701
|
init_react_import();
|
6756
|
-
var
|
6702
|
+
var import_react44 = require("react");
|
6757
6703
|
var import_object_hash = __toESM(require("object-hash"));
|
6758
6704
|
var import_react_dom3 = require("react-dom");
|
6759
|
-
var
|
6705
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6760
6706
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
6761
6707
|
var collectStyles = (doc) => {
|
6762
6708
|
const collected = [];
|
@@ -6799,7 +6745,7 @@ var CopyHostStyles = ({
|
|
6799
6745
|
onStylesLoaded = () => null
|
6800
6746
|
}) => {
|
6801
6747
|
const { document: doc, window: win } = useFrame();
|
6802
|
-
(0,
|
6748
|
+
(0, import_react44.useEffect)(() => {
|
6803
6749
|
if (!win || !doc) {
|
6804
6750
|
return () => {
|
6805
6751
|
};
|
@@ -6956,10 +6902,10 @@ var CopyHostStyles = ({
|
|
6956
6902
|
observer.disconnect();
|
6957
6903
|
};
|
6958
6904
|
}, []);
|
6959
|
-
return /* @__PURE__ */ (0,
|
6905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
|
6960
6906
|
};
|
6961
|
-
var autoFrameContext = (0,
|
6962
|
-
var useFrame = () => (0,
|
6907
|
+
var autoFrameContext = (0, import_react44.createContext)({});
|
6908
|
+
var useFrame = () => (0, import_react44.useContext)(autoFrameContext);
|
6963
6909
|
function AutoFrame(_a) {
|
6964
6910
|
var _b = _a, {
|
6965
6911
|
children,
|
@@ -6980,11 +6926,11 @@ function AutoFrame(_a) {
|
|
6980
6926
|
"onNotReady",
|
6981
6927
|
"frameRef"
|
6982
6928
|
]);
|
6983
|
-
const [loaded, setLoaded] = (0,
|
6984
|
-
const [ctx, setCtx] = (0,
|
6985
|
-
const [mountTarget, setMountTarget] = (0,
|
6986
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
6987
|
-
(0,
|
6929
|
+
const [loaded, setLoaded] = (0, import_react44.useState)(false);
|
6930
|
+
const [ctx, setCtx] = (0, import_react44.useState)({});
|
6931
|
+
const [mountTarget, setMountTarget] = (0, import_react44.useState)();
|
6932
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react44.useState)(false);
|
6933
|
+
(0, import_react44.useEffect)(() => {
|
6988
6934
|
var _a2;
|
6989
6935
|
if (frameRef.current) {
|
6990
6936
|
const doc = frameRef.current.contentDocument;
|
@@ -7003,7 +6949,7 @@ function AutoFrame(_a) {
|
|
7003
6949
|
}
|
7004
6950
|
}
|
7005
6951
|
}, [frameRef, loaded, stylesLoaded]);
|
7006
|
-
return /* @__PURE__ */ (0,
|
6952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7007
6953
|
"iframe",
|
7008
6954
|
__spreadProps(__spreadValues({}, props), {
|
7009
6955
|
className,
|
@@ -7013,7 +6959,7 @@ function AutoFrame(_a) {
|
|
7013
6959
|
onLoad: () => {
|
7014
6960
|
setLoaded(true);
|
7015
6961
|
},
|
7016
|
-
children: /* @__PURE__ */ (0,
|
6962
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7017
6963
|
CopyHostStyles,
|
7018
6964
|
{
|
7019
6965
|
debug,
|
@@ -7032,11 +6978,11 @@ init_react_import();
|
|
7032
6978
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
7033
6979
|
|
7034
6980
|
// components/Puck/components/Preview/index.tsx
|
7035
|
-
var
|
6981
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
7036
6982
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
7037
6983
|
var useBubbleIframeEvents = (ref) => {
|
7038
6984
|
const status = useAppStore((s) => s.status);
|
7039
|
-
(0,
|
6985
|
+
(0, import_react45.useEffect)(() => {
|
7040
6986
|
if (ref.current && status === "READY") {
|
7041
6987
|
const iframe = ref.current;
|
7042
6988
|
const handlePointerMove = (event) => {
|
@@ -7085,22 +7031,22 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7085
7031
|
const renderData = useAppStore(
|
7086
7032
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
7087
7033
|
);
|
7088
|
-
const Page = (0,
|
7034
|
+
const Page = (0, import_react45.useCallback)(
|
7089
7035
|
(pageProps) => {
|
7090
7036
|
var _a, _b;
|
7091
7037
|
const rootConfig = config.root;
|
7092
7038
|
const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
|
7093
7039
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
7094
7040
|
id: "puck-root"
|
7095
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
7041
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
|
7096
7042
|
},
|
7097
7043
|
[config.root]
|
7098
7044
|
);
|
7099
|
-
const Frame = (0,
|
7045
|
+
const Frame = (0, import_react45.useMemo)(() => overrides.iframe, [overrides]);
|
7100
7046
|
const rootProps = root.props || root;
|
7101
|
-
const ref = (0,
|
7047
|
+
const ref = (0, import_react45.useRef)(null);
|
7102
7048
|
useBubbleIframeEvents(ref);
|
7103
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
7049
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7104
7050
|
Page,
|
7105
7051
|
__spreadProps(__spreadValues({}, rootProps), {
|
7106
7052
|
puck: {
|
@@ -7110,15 +7056,15 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7110
7056
|
metadata
|
7111
7057
|
},
|
7112
7058
|
editMode: true,
|
7113
|
-
children: /* @__PURE__ */ (0,
|
7059
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
|
7114
7060
|
})
|
7115
|
-
) : /* @__PURE__ */ (0,
|
7116
|
-
(0,
|
7061
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
|
7062
|
+
(0, import_react45.useEffect)(() => {
|
7117
7063
|
if (!iframe.enabled) {
|
7118
7064
|
setStatus("READY");
|
7119
7065
|
}
|
7120
7066
|
}, [iframe.enabled]);
|
7121
|
-
return /* @__PURE__ */ (0,
|
7067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7122
7068
|
"div",
|
7123
7069
|
{
|
7124
7070
|
className: getClassName23(),
|
@@ -7127,7 +7073,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7127
7073
|
onClick: () => {
|
7128
7074
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
7129
7075
|
},
|
7130
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
7076
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7131
7077
|
AutoFrame_default,
|
7132
7078
|
{
|
7133
7079
|
id: "preview-frame",
|
@@ -7140,14 +7086,14 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7140
7086
|
setStatus("MOUNTED");
|
7141
7087
|
},
|
7142
7088
|
frameRef: ref,
|
7143
|
-
children: /* @__PURE__ */ (0,
|
7089
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
7144
7090
|
if (Frame) {
|
7145
|
-
return /* @__PURE__ */ (0,
|
7091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
|
7146
7092
|
}
|
7147
7093
|
return inner;
|
7148
7094
|
} })
|
7149
7095
|
}
|
7150
|
-
) : /* @__PURE__ */ (0,
|
7096
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7151
7097
|
"div",
|
7152
7098
|
{
|
7153
7099
|
id: "preview-frame",
|
@@ -7183,7 +7129,7 @@ var scrollIntoView = (el) => {
|
|
7183
7129
|
};
|
7184
7130
|
|
7185
7131
|
// components/LayerTree/index.tsx
|
7186
|
-
var
|
7132
|
+
var import_react46 = require("react");
|
7187
7133
|
|
7188
7134
|
// lib/on-scroll-end.ts
|
7189
7135
|
init_react_import();
|
@@ -7206,7 +7152,7 @@ var onScrollEnd = (frame, cb) => {
|
|
7206
7152
|
|
7207
7153
|
// components/LayerTree/index.tsx
|
7208
7154
|
var import_shallow5 = require("zustand/react/shallow");
|
7209
|
-
var
|
7155
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
7210
7156
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
7211
7157
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
7212
7158
|
var Layer = ({
|
@@ -7215,11 +7161,11 @@ var Layer = ({
|
|
7215
7161
|
zoneCompound
|
7216
7162
|
}) => {
|
7217
7163
|
var _a;
|
7218
|
-
const ctx = (0,
|
7164
|
+
const ctx = (0, import_react46.useContext)(dropZoneContext);
|
7219
7165
|
const config = useAppStore((s) => s.config);
|
7220
7166
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
7221
7167
|
const dispatch = useAppStore((s) => s.dispatch);
|
7222
|
-
const setItemSelector = (0,
|
7168
|
+
const setItemSelector = (0, import_react46.useCallback)(
|
7223
7169
|
(itemSelector2) => {
|
7224
7170
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
7225
7171
|
},
|
@@ -7252,7 +7198,7 @@ var Layer = ({
|
|
7252
7198
|
});
|
7253
7199
|
const componentConfig = config.components[nodeData.data.type];
|
7254
7200
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
7255
|
-
return /* @__PURE__ */ (0,
|
7201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
7256
7202
|
"li",
|
7257
7203
|
{
|
7258
7204
|
className: getClassNameLayer({
|
@@ -7262,7 +7208,7 @@ var Layer = ({
|
|
7262
7208
|
childIsSelected
|
7263
7209
|
}),
|
7264
7210
|
children: [
|
7265
|
-
/* @__PURE__ */ (0,
|
7211
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
7266
7212
|
"button",
|
7267
7213
|
{
|
7268
7214
|
type: "button",
|
@@ -7297,22 +7243,22 @@ var Layer = ({
|
|
7297
7243
|
setHoveringComponent(null);
|
7298
7244
|
},
|
7299
7245
|
children: [
|
7300
|
-
containsZone && /* @__PURE__ */ (0,
|
7246
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
7301
7247
|
"div",
|
7302
7248
|
{
|
7303
7249
|
className: getClassNameLayer("chevron"),
|
7304
7250
|
title: isSelected ? "Collapse" : "Expand",
|
7305
|
-
children: /* @__PURE__ */ (0,
|
7251
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
|
7306
7252
|
}
|
7307
7253
|
),
|
7308
|
-
/* @__PURE__ */ (0,
|
7309
|
-
/* @__PURE__ */ (0,
|
7310
|
-
/* @__PURE__ */ (0,
|
7254
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
7255
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayoutGrid, { size: "16" }) }),
|
7256
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
|
7311
7257
|
] })
|
7312
7258
|
]
|
7313
7259
|
}
|
7314
7260
|
) }),
|
7315
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0,
|
7261
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
|
7316
7262
|
]
|
7317
7263
|
}
|
7318
7264
|
);
|
@@ -7330,15 +7276,15 @@ var LayerTree = ({
|
|
7330
7276
|
}
|
7331
7277
|
)
|
7332
7278
|
);
|
7333
|
-
return /* @__PURE__ */ (0,
|
7334
|
-
label && /* @__PURE__ */ (0,
|
7335
|
-
/* @__PURE__ */ (0,
|
7279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
7280
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
7281
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
|
7336
7282
|
label
|
7337
7283
|
] }),
|
7338
|
-
/* @__PURE__ */ (0,
|
7339
|
-
contentIds.length === 0 && /* @__PURE__ */ (0,
|
7284
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
|
7285
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
7340
7286
|
contentIds.map((itemId, i) => {
|
7341
|
-
return /* @__PURE__ */ (0,
|
7287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
7342
7288
|
Layer,
|
7343
7289
|
{
|
7344
7290
|
index: i,
|
@@ -7353,9 +7299,9 @@ var LayerTree = ({
|
|
7353
7299
|
};
|
7354
7300
|
|
7355
7301
|
// components/Puck/components/Outline/index.tsx
|
7356
|
-
var
|
7302
|
+
var import_react47 = require("react");
|
7357
7303
|
|
7358
|
-
// lib/find-zones-for-area.ts
|
7304
|
+
// lib/data/find-zones-for-area.ts
|
7359
7305
|
init_react_import();
|
7360
7306
|
var findZonesForArea = (state, area) => {
|
7361
7307
|
return Object.keys(state.indexes.zones).filter(
|
@@ -7365,14 +7311,14 @@ var findZonesForArea = (state, area) => {
|
|
7365
7311
|
|
7366
7312
|
// components/Puck/components/Outline/index.tsx
|
7367
7313
|
var import_shallow6 = require("zustand/react/shallow");
|
7368
|
-
var
|
7314
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
7369
7315
|
var Outline = () => {
|
7370
7316
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
7371
7317
|
const rootZones = useAppStore(
|
7372
7318
|
(0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
|
7373
7319
|
);
|
7374
|
-
const Wrapper = (0,
|
7375
|
-
return /* @__PURE__ */ (0,
|
7320
|
+
const Wrapper = (0, import_react47.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
7321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7376
7322
|
LayerTree,
|
7377
7323
|
{
|
7378
7324
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
@@ -7505,22 +7451,22 @@ var getBox = function getBox2(el) {
|
|
7505
7451
|
};
|
7506
7452
|
|
7507
7453
|
// components/Puck/components/Canvas/index.tsx
|
7508
|
-
var
|
7454
|
+
var import_react49 = require("react");
|
7509
7455
|
|
7510
7456
|
// components/ViewportControls/index.tsx
|
7511
7457
|
init_react_import();
|
7512
|
-
var
|
7458
|
+
var import_react48 = require("react");
|
7513
7459
|
|
7514
7460
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7515
7461
|
init_react_import();
|
7516
7462
|
var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
|
7517
7463
|
|
7518
7464
|
// components/ViewportControls/index.tsx
|
7519
|
-
var
|
7465
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7520
7466
|
var icons = {
|
7521
|
-
Smartphone: /* @__PURE__ */ (0,
|
7522
|
-
Tablet: /* @__PURE__ */ (0,
|
7523
|
-
Monitor: /* @__PURE__ */ (0,
|
7467
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
|
7468
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
|
7469
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
|
7524
7470
|
};
|
7525
7471
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
7526
7472
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -7532,11 +7478,11 @@ var ViewportButton = ({
|
|
7532
7478
|
onClick
|
7533
7479
|
}) => {
|
7534
7480
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7535
|
-
const [isActive, setIsActive] = (0,
|
7536
|
-
(0,
|
7481
|
+
const [isActive, setIsActive] = (0, import_react48.useState)(false);
|
7482
|
+
(0, import_react48.useEffect)(() => {
|
7537
7483
|
setIsActive(width === viewports.current.width);
|
7538
7484
|
}, [width, viewports.current.width]);
|
7539
|
-
return /* @__PURE__ */ (0,
|
7485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7540
7486
|
IconButton,
|
7541
7487
|
{
|
7542
7488
|
title,
|
@@ -7545,7 +7491,7 @@ var ViewportButton = ({
|
|
7545
7491
|
e.stopPropagation();
|
7546
7492
|
onClick({ width, height });
|
7547
7493
|
},
|
7548
|
-
children: /* @__PURE__ */ (0,
|
7494
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
|
7549
7495
|
}
|
7550
7496
|
) });
|
7551
7497
|
};
|
@@ -7569,7 +7515,7 @@ var ViewportControls = ({
|
|
7569
7515
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7570
7516
|
(option) => option.value === autoZoom
|
7571
7517
|
);
|
7572
|
-
const zoomOptions = (0,
|
7518
|
+
const zoomOptions = (0, import_react48.useMemo)(
|
7573
7519
|
() => [
|
7574
7520
|
...defaultZoomOptions,
|
7575
7521
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7581,8 +7527,8 @@ var ViewportControls = ({
|
|
7581
7527
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
7582
7528
|
[autoZoom]
|
7583
7529
|
);
|
7584
|
-
return /* @__PURE__ */ (0,
|
7585
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
7530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
|
7531
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7586
7532
|
ViewportButton,
|
7587
7533
|
{
|
7588
7534
|
height: viewport.height,
|
@@ -7593,8 +7539,8 @@ var ViewportControls = ({
|
|
7593
7539
|
},
|
7594
7540
|
i
|
7595
7541
|
)),
|
7596
|
-
/* @__PURE__ */ (0,
|
7597
|
-
/* @__PURE__ */ (0,
|
7542
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
7543
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7598
7544
|
IconButton,
|
7599
7545
|
{
|
7600
7546
|
title: "Zoom viewport out",
|
@@ -7608,10 +7554,10 @@ var ViewportControls = ({
|
|
7608
7554
|
)].value
|
7609
7555
|
);
|
7610
7556
|
},
|
7611
|
-
children: /* @__PURE__ */ (0,
|
7557
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
|
7612
7558
|
}
|
7613
7559
|
),
|
7614
|
-
/* @__PURE__ */ (0,
|
7560
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7615
7561
|
IconButton,
|
7616
7562
|
{
|
7617
7563
|
title: "Zoom viewport in",
|
@@ -7625,11 +7571,11 @@ var ViewportControls = ({
|
|
7625
7571
|
)].value
|
7626
7572
|
);
|
7627
7573
|
},
|
7628
|
-
children: /* @__PURE__ */ (0,
|
7574
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
|
7629
7575
|
}
|
7630
7576
|
),
|
7631
|
-
/* @__PURE__ */ (0,
|
7632
|
-
/* @__PURE__ */ (0,
|
7577
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
7578
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7633
7579
|
"select",
|
7634
7580
|
{
|
7635
7581
|
className: getClassName25("zoomSelect"),
|
@@ -7637,7 +7583,7 @@ var ViewportControls = ({
|
|
7637
7583
|
onChange: (e) => {
|
7638
7584
|
onZoom(parseFloat(e.currentTarget.value));
|
7639
7585
|
},
|
7640
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
7586
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7641
7587
|
"option",
|
7642
7588
|
{
|
7643
7589
|
value: option.value,
|
@@ -7686,7 +7632,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
7686
7632
|
|
7687
7633
|
// components/Puck/components/Canvas/index.tsx
|
7688
7634
|
var import_shallow7 = require("zustand/react/shallow");
|
7689
|
-
var
|
7635
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
7690
7636
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
7691
7637
|
var ZOOM_ON_CHANGE = true;
|
7692
7638
|
var Canvas = () => {
|
@@ -7716,17 +7662,17 @@ var Canvas = () => {
|
|
7716
7662
|
viewports: s.state.ui.viewports
|
7717
7663
|
}))
|
7718
7664
|
);
|
7719
|
-
const frameRef = (0,
|
7720
|
-
const [showTransition, setShowTransition] = (0,
|
7721
|
-
const defaultRender = (0,
|
7722
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
7665
|
+
const frameRef = (0, import_react49.useRef)(null);
|
7666
|
+
const [showTransition, setShowTransition] = (0, import_react49.useState)(false);
|
7667
|
+
const defaultRender = (0, import_react49.useMemo)(() => {
|
7668
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
|
7723
7669
|
return PuckDefault;
|
7724
7670
|
}, []);
|
7725
|
-
const CustomPreview = (0,
|
7671
|
+
const CustomPreview = (0, import_react49.useMemo)(
|
7726
7672
|
() => overrides.preview || defaultRender,
|
7727
7673
|
[overrides]
|
7728
7674
|
);
|
7729
|
-
const getFrameDimensions = (0,
|
7675
|
+
const getFrameDimensions = (0, import_react49.useCallback)(() => {
|
7730
7676
|
if (frameRef.current) {
|
7731
7677
|
const frame = frameRef.current;
|
7732
7678
|
const box = getBox(frame);
|
@@ -7734,7 +7680,7 @@ var Canvas = () => {
|
|
7734
7680
|
}
|
7735
7681
|
return { width: 0, height: 0 };
|
7736
7682
|
}, [frameRef]);
|
7737
|
-
const resetAutoZoom = (0,
|
7683
|
+
const resetAutoZoom = (0, import_react49.useCallback)(
|
7738
7684
|
(newViewports = viewports) => {
|
7739
7685
|
if (frameRef.current) {
|
7740
7686
|
setZoomConfig(
|
@@ -7748,11 +7694,11 @@ var Canvas = () => {
|
|
7748
7694
|
},
|
7749
7695
|
[frameRef, zoomConfig, viewports]
|
7750
7696
|
);
|
7751
|
-
(0,
|
7697
|
+
(0, import_react49.useEffect)(() => {
|
7752
7698
|
setShowTransition(false);
|
7753
7699
|
resetAutoZoom(viewports);
|
7754
7700
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7755
|
-
(0,
|
7701
|
+
(0, import_react49.useEffect)(() => {
|
7756
7702
|
const { height: frameHeight } = getFrameDimensions();
|
7757
7703
|
if (viewports.current.height === "auto") {
|
7758
7704
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7760,13 +7706,13 @@ var Canvas = () => {
|
|
7760
7706
|
}));
|
7761
7707
|
}
|
7762
7708
|
}, [zoomConfig.zoom]);
|
7763
|
-
(0,
|
7709
|
+
(0, import_react49.useEffect)(() => {
|
7764
7710
|
if (ZOOM_ON_CHANGE) {
|
7765
7711
|
setShowTransition(true);
|
7766
7712
|
resetAutoZoom(viewports);
|
7767
7713
|
}
|
7768
7714
|
}, [viewports.current.width]);
|
7769
|
-
(0,
|
7715
|
+
(0, import_react49.useEffect)(() => {
|
7770
7716
|
const cb = () => {
|
7771
7717
|
setShowTransition(false);
|
7772
7718
|
resetAutoZoom();
|
@@ -7776,13 +7722,13 @@ var Canvas = () => {
|
|
7776
7722
|
window.removeEventListener("resize", cb);
|
7777
7723
|
};
|
7778
7724
|
}, []);
|
7779
|
-
const [showLoader, setShowLoader] = (0,
|
7780
|
-
(0,
|
7725
|
+
const [showLoader, setShowLoader] = (0, import_react49.useState)(false);
|
7726
|
+
(0, import_react49.useEffect)(() => {
|
7781
7727
|
setTimeout(() => {
|
7782
7728
|
setShowLoader(true);
|
7783
7729
|
}, 500);
|
7784
7730
|
}, []);
|
7785
|
-
return /* @__PURE__ */ (0,
|
7731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
7786
7732
|
"div",
|
7787
7733
|
{
|
7788
7734
|
className: getClassName26({
|
@@ -7795,7 +7741,7 @@ var Canvas = () => {
|
|
7795
7741
|
recordHistory: true
|
7796
7742
|
}),
|
7797
7743
|
children: [
|
7798
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
7744
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7799
7745
|
ViewportControls,
|
7800
7746
|
{
|
7801
7747
|
autoZoom: zoomConfig.autoZoom,
|
@@ -7821,8 +7767,8 @@ var Canvas = () => {
|
|
7821
7767
|
}
|
7822
7768
|
}
|
7823
7769
|
) }),
|
7824
|
-
/* @__PURE__ */ (0,
|
7825
|
-
/* @__PURE__ */ (0,
|
7770
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7771
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7826
7772
|
"div",
|
7827
7773
|
{
|
7828
7774
|
className: getClassName26("root"),
|
@@ -7843,10 +7789,10 @@ var Canvas = () => {
|
|
7843
7789
|
})
|
7844
7790
|
);
|
7845
7791
|
},
|
7846
|
-
children: /* @__PURE__ */ (0,
|
7792
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview3, {}) })
|
7847
7793
|
}
|
7848
7794
|
),
|
7849
|
-
/* @__PURE__ */ (0,
|
7795
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
|
7850
7796
|
] })
|
7851
7797
|
]
|
7852
7798
|
}
|
@@ -7855,7 +7801,7 @@ var Canvas = () => {
|
|
7855
7801
|
|
7856
7802
|
// lib/use-loaded-overrides.ts
|
7857
7803
|
init_react_import();
|
7858
|
-
var
|
7804
|
+
var import_react50 = require("react");
|
7859
7805
|
|
7860
7806
|
// lib/load-overrides.ts
|
7861
7807
|
init_react_import();
|
@@ -7894,26 +7840,26 @@ var useLoadedOverrides = ({
|
|
7894
7840
|
overrides,
|
7895
7841
|
plugins
|
7896
7842
|
}) => {
|
7897
|
-
return (0,
|
7843
|
+
return (0, import_react50.useMemo)(() => {
|
7898
7844
|
return loadOverrides({ overrides, plugins });
|
7899
7845
|
}, [plugins, overrides]);
|
7900
7846
|
};
|
7901
7847
|
|
7902
7848
|
// components/DefaultOverride/index.tsx
|
7903
7849
|
init_react_import();
|
7904
|
-
var
|
7905
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
7850
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
7851
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
|
7906
7852
|
|
7907
7853
|
// lib/use-inject-css.ts
|
7908
7854
|
init_react_import();
|
7909
|
-
var
|
7855
|
+
var import_react51 = require("react");
|
7910
7856
|
var styles = ``;
|
7911
7857
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7912
|
-
const [el, setEl] = (0,
|
7913
|
-
(0,
|
7858
|
+
const [el, setEl] = (0, import_react51.useState)();
|
7859
|
+
(0, import_react51.useEffect)(() => {
|
7914
7860
|
setEl(document.createElement("style"));
|
7915
7861
|
}, []);
|
7916
|
-
(0,
|
7862
|
+
(0, import_react51.useEffect)(() => {
|
7917
7863
|
var _a;
|
7918
7864
|
if (!el || typeof window === "undefined") {
|
7919
7865
|
return;
|
@@ -7933,10 +7879,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7933
7879
|
|
7934
7880
|
// lib/use-preview-mode-hotkeys.ts
|
7935
7881
|
init_react_import();
|
7936
|
-
var
|
7882
|
+
var import_react52 = require("react");
|
7937
7883
|
var usePreviewModeHotkeys = () => {
|
7938
7884
|
const appStore = useAppStoreApi();
|
7939
|
-
const toggleInteractive = (0,
|
7885
|
+
const toggleInteractive = (0, import_react52.useCallback)(() => {
|
7940
7886
|
const dispatch = appStore.getState().dispatch;
|
7941
7887
|
dispatch({
|
7942
7888
|
type: "setUi",
|
@@ -7951,7 +7897,7 @@ var usePreviewModeHotkeys = () => {
|
|
7951
7897
|
|
7952
7898
|
// lib/use-puck.ts
|
7953
7899
|
init_react_import();
|
7954
|
-
var
|
7900
|
+
var import_react53 = require("react");
|
7955
7901
|
var import_zustand6 = require("zustand");
|
7956
7902
|
var generateUsePuck = (store) => {
|
7957
7903
|
const history = {
|
@@ -7965,37 +7911,48 @@ var generateUsePuck = (store) => {
|
|
7965
7911
|
index: store.history.index
|
7966
7912
|
};
|
7967
7913
|
const storeData = {
|
7968
|
-
appState: store.state,
|
7914
|
+
appState: makeStatePublic(store.state),
|
7969
7915
|
config: store.config,
|
7970
7916
|
dispatch: store.dispatch,
|
7971
7917
|
getPermissions: store.permissions.getPermissions,
|
7972
7918
|
refreshPermissions: store.permissions.refreshPermissions,
|
7973
7919
|
history,
|
7974
|
-
selectedItem: store.selectedItem || null
|
7920
|
+
selectedItem: store.selectedItem || null,
|
7921
|
+
getItemBySelector: (selector) => getItem(selector, store.state),
|
7922
|
+
getItemById: (id) => store.state.indexes.nodes[id].data,
|
7923
|
+
getSelectorForId: (id) => {
|
7924
|
+
const node = store.state.indexes.nodes[id];
|
7925
|
+
if (!node) return;
|
7926
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
7927
|
+
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
7928
|
+
return { zone: zoneCompound, index };
|
7929
|
+
}
|
7975
7930
|
};
|
7976
7931
|
const get = () => storeData;
|
7977
7932
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
7978
7933
|
};
|
7979
|
-
var UsePuckStoreContext = (0,
|
7934
|
+
var UsePuckStoreContext = (0, import_react53.createContext)(
|
7980
7935
|
null
|
7981
7936
|
);
|
7937
|
+
var convertToPickedStore = (store) => {
|
7938
|
+
return {
|
7939
|
+
state: store.state,
|
7940
|
+
config: store.config,
|
7941
|
+
dispatch: store.dispatch,
|
7942
|
+
permissions: store.permissions,
|
7943
|
+
history: store.history,
|
7944
|
+
selectedItem: store.selectedItem
|
7945
|
+
};
|
7946
|
+
};
|
7982
7947
|
var useRegisterUsePuckStore = (appStore) => {
|
7983
|
-
const [usePuckStore] = (0,
|
7984
|
-
() => (0, import_zustand6.createStore)(
|
7948
|
+
const [usePuckStore] = (0, import_react53.useState)(
|
7949
|
+
() => (0, import_zustand6.createStore)(
|
7950
|
+
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
7951
|
+
)
|
7985
7952
|
);
|
7986
|
-
(0,
|
7953
|
+
(0, import_react53.useEffect)(() => {
|
7987
7954
|
return appStore.subscribe(
|
7988
|
-
(store) =>
|
7989
|
-
const pickedStore = {
|
7990
|
-
state: store.state,
|
7991
|
-
config: store.config,
|
7992
|
-
dispatch: store.dispatch,
|
7993
|
-
permissions: store.permissions,
|
7994
|
-
history: store.history,
|
7995
|
-
selectedItem: store.selectedItem
|
7996
|
-
};
|
7997
|
-
return pickedStore;
|
7998
|
-
},
|
7955
|
+
(store) => convertToPickedStore(store),
|
7999
7956
|
(pickedStore) => {
|
8000
7957
|
usePuckStore.setState(generateUsePuck(pickedStore));
|
8001
7958
|
}
|
@@ -8005,7 +7962,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
8005
7962
|
};
|
8006
7963
|
function createUsePuck() {
|
8007
7964
|
return function usePuck2(selector) {
|
8008
|
-
const usePuckApi = (0,
|
7965
|
+
const usePuckApi = (0, import_react53.useContext)(UsePuckStoreContext);
|
8009
7966
|
if (!usePuckApi) {
|
8010
7967
|
throw new Error("usePuck must be used inside <Puck>.");
|
8011
7968
|
}
|
@@ -8017,7 +7974,7 @@ function createUsePuck() {
|
|
8017
7974
|
};
|
8018
7975
|
}
|
8019
7976
|
function usePuck() {
|
8020
|
-
(0,
|
7977
|
+
(0, import_react53.useEffect)(() => {
|
8021
7978
|
console.warn(
|
8022
7979
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
8023
7980
|
);
|
@@ -8026,7 +7983,8 @@ function usePuck() {
|
|
8026
7983
|
}
|
8027
7984
|
|
8028
7985
|
// components/Puck/index.tsx
|
8029
|
-
var
|
7986
|
+
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
7987
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
8030
7988
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
8031
7989
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
8032
7990
|
var FieldSideBar = () => {
|
@@ -8036,31 +7994,13 @@ var FieldSideBar = () => {
|
|
8036
7994
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
8037
7995
|
}
|
8038
7996
|
);
|
8039
|
-
return /* @__PURE__ */ (0,
|
7997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
|
8040
7998
|
};
|
8041
|
-
var
|
8042
|
-
var propsContext = (0, import_react52.createContext)({});
|
7999
|
+
var propsContext = (0, import_react54.createContext)({});
|
8043
8000
|
function PropsProvider(props) {
|
8044
|
-
return /* @__PURE__ */ (0,
|
8001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
|
8045
8002
|
}
|
8046
|
-
var usePropsContext = () => (0,
|
8047
|
-
var debugPlugin = {
|
8048
|
-
overrides: {
|
8049
|
-
fields: ({ children }) => {
|
8050
|
-
const state = useAppStore((s) => s.state);
|
8051
|
-
const selectedItem = useAppStore((s) => s.selectedItem);
|
8052
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
8053
|
-
children,
|
8054
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Debug: Data", children: JSON.stringify(state.data) }),
|
8055
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SidebarSection, { title: "Debug: UI", children: JSON.stringify(state.ui) }),
|
8056
|
-
/* @__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: [
|
8057
|
-
"Selected Item: ",
|
8058
|
-
JSON.stringify(selectedItem)
|
8059
|
-
] }) }) })
|
8060
|
-
] });
|
8061
|
-
}
|
8062
|
-
}
|
8063
|
-
};
|
8003
|
+
var usePropsContext = () => (0, import_react54.useContext)(propsContext);
|
8064
8004
|
function PuckProvider({ children }) {
|
8065
8005
|
const {
|
8066
8006
|
config,
|
@@ -8068,7 +8008,7 @@ function PuckProvider({ children }) {
|
|
8068
8008
|
ui: initialUi,
|
8069
8009
|
onChange,
|
8070
8010
|
permissions = {},
|
8071
|
-
plugins
|
8011
|
+
plugins,
|
8072
8012
|
overrides,
|
8073
8013
|
viewports = defaultViewports,
|
8074
8014
|
iframe: _iframe,
|
@@ -8080,7 +8020,7 @@ function PuckProvider({ children }) {
|
|
8080
8020
|
enabled: true,
|
8081
8021
|
waitForStyles: true
|
8082
8022
|
}, _iframe);
|
8083
|
-
const [generatedAppState] = (0,
|
8023
|
+
const [generatedAppState] = (0, import_react54.useState)(() => {
|
8084
8024
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
8085
8025
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
8086
8026
|
let clientUiState = {};
|
@@ -8137,81 +8077,88 @@ function PuckProvider({ children }) {
|
|
8137
8077
|
) : {}
|
8138
8078
|
})
|
8139
8079
|
});
|
8140
|
-
return
|
8080
|
+
return walkAppState(newAppState, config);
|
8141
8081
|
});
|
8142
8082
|
const { appendData = true } = _initialHistory || {};
|
8143
|
-
const blendedHistories =
|
8144
|
-
|
8145
|
-
|
8146
|
-
|
8147
|
-
|
8148
|
-
|
8149
|
-
|
8083
|
+
const [blendedHistories] = (0, import_react54.useState)(
|
8084
|
+
[
|
8085
|
+
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
8086
|
+
...appendData ? [{ state: generatedAppState }] : []
|
8087
|
+
].map((history) => {
|
8088
|
+
let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
|
8089
|
+
if (!history.state.indexes) {
|
8090
|
+
newState = walkAppState(newState, config);
|
8091
|
+
}
|
8092
|
+
return __spreadProps(__spreadValues({}, history), {
|
8093
|
+
state: newState
|
8094
|
+
});
|
8095
|
+
})
|
8096
|
+
);
|
8150
8097
|
const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
|
8151
8098
|
const initialAppState = blendedHistories[initialHistoryIndex].state;
|
8152
|
-
const plugins = (0, import_react52.useMemo)(
|
8153
|
-
() => DEBUG4 ? [..._plugins || [], debugPlugin] : _plugins,
|
8154
|
-
[_plugins]
|
8155
|
-
);
|
8156
8099
|
const loadedOverrides = useLoadedOverrides({
|
8157
8100
|
overrides,
|
8158
8101
|
plugins
|
8159
8102
|
});
|
8160
|
-
const generateAppStore = (0,
|
8161
|
-
|
8162
|
-
|
8103
|
+
const generateAppStore = (0, import_react54.useCallback)(
|
8104
|
+
(state) => {
|
8105
|
+
return {
|
8106
|
+
state,
|
8107
|
+
config,
|
8108
|
+
plugins: plugins || [],
|
8109
|
+
overrides: loadedOverrides,
|
8110
|
+
viewports,
|
8111
|
+
iframe,
|
8112
|
+
onAction,
|
8113
|
+
metadata
|
8114
|
+
};
|
8115
|
+
},
|
8116
|
+
[
|
8117
|
+
initialAppState,
|
8163
8118
|
config,
|
8164
|
-
plugins
|
8165
|
-
|
8119
|
+
plugins,
|
8120
|
+
loadedOverrides,
|
8166
8121
|
viewports,
|
8167
8122
|
iframe,
|
8168
8123
|
onAction,
|
8169
8124
|
metadata
|
8170
|
-
|
8171
|
-
|
8172
|
-
|
8173
|
-
|
8174
|
-
|
8175
|
-
|
8176
|
-
|
8177
|
-
|
8178
|
-
|
8179
|
-
metadata
|
8180
|
-
]);
|
8181
|
-
const [appStore] = (0, import_react52.useState)(() => createAppStore(generateAppStore()));
|
8182
|
-
(0, import_react52.useEffect)(() => {
|
8183
|
-
appStore.setState(__spreadValues({}, generateAppStore()));
|
8184
|
-
}, [
|
8185
|
-
initialAppState,
|
8186
|
-
config,
|
8187
|
-
plugins,
|
8188
|
-
loadedOverrides,
|
8189
|
-
viewports,
|
8190
|
-
iframe,
|
8191
|
-
onAction,
|
8192
|
-
metadata
|
8193
|
-
]);
|
8125
|
+
]
|
8126
|
+
);
|
8127
|
+
const [appStore] = (0, import_react54.useState)(
|
8128
|
+
() => createAppStore(generateAppStore(initialAppState))
|
8129
|
+
);
|
8130
|
+
(0, import_react54.useEffect)(() => {
|
8131
|
+
const state = appStore.getState().state;
|
8132
|
+
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
8133
|
+
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
8194
8134
|
useRegisterHistorySlice(appStore, {
|
8195
8135
|
histories: blendedHistories,
|
8196
8136
|
index: initialHistoryIndex,
|
8197
8137
|
initialAppState
|
8198
8138
|
});
|
8199
|
-
(0,
|
8200
|
-
|
8201
|
-
|
8202
|
-
|
8139
|
+
const previousData = (0, import_react54.useRef)(null);
|
8140
|
+
(0, import_react54.useEffect)(() => {
|
8141
|
+
appStore.subscribe(
|
8142
|
+
(s) => s.state.data,
|
8143
|
+
(data) => {
|
8144
|
+
if (onChange) {
|
8145
|
+
if ((0, import_fast_deep_equal2.default)(data, previousData.current)) return;
|
8146
|
+
onChange(data);
|
8147
|
+
previousData.current = data;
|
8148
|
+
}
|
8149
|
+
}
|
8150
|
+
);
|
8203
8151
|
}, []);
|
8204
8152
|
useRegisterPermissionsSlice(appStore, permissions);
|
8205
8153
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
8206
|
-
(0,
|
8154
|
+
(0, import_react54.useEffect)(() => {
|
8207
8155
|
const { resolveAndCommitData } = appStore.getState();
|
8208
8156
|
resolveAndCommitData();
|
8209
8157
|
}, []);
|
8210
|
-
return /* @__PURE__ */ (0,
|
8158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
8211
8159
|
}
|
8212
8160
|
function PuckLayout({ children }) {
|
8213
8161
|
const {
|
8214
|
-
onChange,
|
8215
8162
|
onPublish,
|
8216
8163
|
renderHeader,
|
8217
8164
|
renderHeaderActions,
|
@@ -8230,18 +8177,13 @@ function PuckLayout({ children }) {
|
|
8230
8177
|
const rightSideBarVisible = useAppStore(
|
8231
8178
|
(s) => s.state.ui.rightSideBarVisible
|
8232
8179
|
);
|
8233
|
-
const [menuOpen, setMenuOpen] = (0,
|
8180
|
+
const [menuOpen, setMenuOpen] = (0, import_react54.useState)(false);
|
8234
8181
|
const appStore = useAppStoreApi();
|
8235
|
-
(0, import_react52.useEffect)(() => {
|
8236
|
-
return appStore.subscribe((s) => {
|
8237
|
-
if (onChange) onChange(s.state.data);
|
8238
|
-
});
|
8239
|
-
}, [appStore]);
|
8240
8182
|
const rootProps = useAppStore(
|
8241
8183
|
(s) => s.state.data.root.props || s.state.data.root.props
|
8242
8184
|
);
|
8243
8185
|
const dispatch = useAppStore((s) => s.dispatch);
|
8244
|
-
const toggleSidebars = (0,
|
8186
|
+
const toggleSidebars = (0, import_react54.useCallback)(
|
8245
8187
|
(sidebar) => {
|
8246
8188
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
8247
8189
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -8255,7 +8197,7 @@ function PuckLayout({ children }) {
|
|
8255
8197
|
},
|
8256
8198
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
8257
8199
|
);
|
8258
|
-
(0,
|
8200
|
+
(0, import_react54.useEffect)(() => {
|
8259
8201
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8260
8202
|
dispatch({
|
8261
8203
|
type: "setUi",
|
@@ -8278,7 +8220,7 @@ function PuckLayout({ children }) {
|
|
8278
8220
|
window.removeEventListener("resize", handleResize);
|
8279
8221
|
};
|
8280
8222
|
}, []);
|
8281
|
-
const defaultHeaderRender = (0,
|
8223
|
+
const defaultHeaderRender = (0, import_react54.useMemo)(() => {
|
8282
8224
|
if (renderHeader) {
|
8283
8225
|
console.warn(
|
8284
8226
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -8287,13 +8229,13 @@ function PuckLayout({ children }) {
|
|
8287
8229
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
8288
8230
|
const Comp = renderHeader;
|
8289
8231
|
const appState = useAppStore((s) => s.state);
|
8290
|
-
return /* @__PURE__ */ (0,
|
8232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
8291
8233
|
};
|
8292
8234
|
return RenderHeader;
|
8293
8235
|
}
|
8294
8236
|
return DefaultOverride;
|
8295
8237
|
}, [renderHeader]);
|
8296
|
-
const defaultHeaderActionsRender = (0,
|
8238
|
+
const defaultHeaderActionsRender = (0, import_react54.useMemo)(() => {
|
8297
8239
|
if (renderHeaderActions) {
|
8298
8240
|
console.warn(
|
8299
8241
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -8301,32 +8243,32 @@ function PuckLayout({ children }) {
|
|
8301
8243
|
const RenderHeader = (props) => {
|
8302
8244
|
const Comp = renderHeaderActions;
|
8303
8245
|
const appState = useAppStore((s) => s.state);
|
8304
|
-
return /* @__PURE__ */ (0,
|
8246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
8305
8247
|
};
|
8306
8248
|
return RenderHeader;
|
8307
8249
|
}
|
8308
8250
|
return DefaultOverride;
|
8309
8251
|
}, [renderHeader]);
|
8310
8252
|
const overrides = useAppStore((s) => s.overrides);
|
8311
|
-
const CustomPuck = (0,
|
8253
|
+
const CustomPuck = (0, import_react54.useMemo)(
|
8312
8254
|
() => overrides.puck || DefaultOverride,
|
8313
8255
|
[overrides]
|
8314
8256
|
);
|
8315
|
-
const CustomHeader = (0,
|
8257
|
+
const CustomHeader = (0, import_react54.useMemo)(
|
8316
8258
|
() => overrides.header || defaultHeaderRender,
|
8317
8259
|
[overrides]
|
8318
8260
|
);
|
8319
|
-
const CustomHeaderActions = (0,
|
8261
|
+
const CustomHeaderActions = (0, import_react54.useMemo)(
|
8320
8262
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
8321
8263
|
[overrides]
|
8322
8264
|
);
|
8323
|
-
const [mounted, setMounted] = (0,
|
8324
|
-
(0,
|
8265
|
+
const [mounted, setMounted] = (0, import_react54.useState)(false);
|
8266
|
+
(0, import_react54.useEffect)(() => {
|
8325
8267
|
setMounted(true);
|
8326
8268
|
}, []);
|
8327
8269
|
const ready = useAppStore((s) => s.status === "READY");
|
8328
8270
|
useMonitorHotkeys();
|
8329
|
-
(0,
|
8271
|
+
(0, import_react54.useEffect)(() => {
|
8330
8272
|
if (ready && iframe.enabled) {
|
8331
8273
|
const frameDoc = getFrame();
|
8332
8274
|
if (frameDoc) {
|
@@ -8335,8 +8277,8 @@ function PuckLayout({ children }) {
|
|
8335
8277
|
}
|
8336
8278
|
}, [ready, iframe.enabled]);
|
8337
8279
|
usePreviewModeHotkeys();
|
8338
|
-
return /* @__PURE__ */ (0,
|
8339
|
-
/* @__PURE__ */ (0,
|
8280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
8281
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8340
8282
|
"div",
|
8341
8283
|
{
|
8342
8284
|
className: getLayoutClassName({
|
@@ -8345,61 +8287,61 @@ function PuckLayout({ children }) {
|
|
8345
8287
|
mounted,
|
8346
8288
|
rightSideBarVisible
|
8347
8289
|
}),
|
8348
|
-
children: /* @__PURE__ */ (0,
|
8349
|
-
/* @__PURE__ */ (0,
|
8290
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
8291
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8350
8292
|
CustomHeader,
|
8351
8293
|
{
|
8352
|
-
actions: /* @__PURE__ */ (0,
|
8294
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8353
8295
|
Button,
|
8354
8296
|
{
|
8355
8297
|
onClick: () => {
|
8356
8298
|
const data = appStore.getState().state.data;
|
8357
8299
|
onPublish && onPublish(data);
|
8358
8300
|
},
|
8359
|
-
icon: /* @__PURE__ */ (0,
|
8301
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
|
8360
8302
|
children: "Publish"
|
8361
8303
|
}
|
8362
8304
|
) }) }),
|
8363
|
-
children: /* @__PURE__ */ (0,
|
8364
|
-
/* @__PURE__ */ (0,
|
8365
|
-
/* @__PURE__ */ (0,
|
8305
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
8306
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
|
8307
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8366
8308
|
"div",
|
8367
8309
|
{
|
8368
8310
|
className: getLayoutClassName("leftSideBarToggle"),
|
8369
|
-
children: /* @__PURE__ */ (0,
|
8311
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8370
8312
|
IconButton,
|
8371
8313
|
{
|
8372
8314
|
onClick: () => {
|
8373
8315
|
toggleSidebars("left");
|
8374
8316
|
},
|
8375
8317
|
title: "Toggle left sidebar",
|
8376
|
-
children: /* @__PURE__ */ (0,
|
8318
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
|
8377
8319
|
}
|
8378
8320
|
)
|
8379
8321
|
}
|
8380
8322
|
),
|
8381
|
-
/* @__PURE__ */ (0,
|
8323
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8382
8324
|
"div",
|
8383
8325
|
{
|
8384
8326
|
className: getLayoutClassName("rightSideBarToggle"),
|
8385
|
-
children: /* @__PURE__ */ (0,
|
8327
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8386
8328
|
IconButton,
|
8387
8329
|
{
|
8388
8330
|
onClick: () => {
|
8389
8331
|
toggleSidebars("right");
|
8390
8332
|
},
|
8391
8333
|
title: "Toggle right sidebar",
|
8392
|
-
children: /* @__PURE__ */ (0,
|
8334
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
|
8393
8335
|
}
|
8394
8336
|
)
|
8395
8337
|
}
|
8396
8338
|
)
|
8397
8339
|
] }),
|
8398
|
-
/* @__PURE__ */ (0,
|
8340
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
8399
8341
|
headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
|
8400
|
-
headerPath && /* @__PURE__ */ (0,
|
8342
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
8401
8343
|
" ",
|
8402
|
-
/* @__PURE__ */ (0,
|
8344
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8403
8345
|
"code",
|
8404
8346
|
{
|
8405
8347
|
className: getLayoutClassName("headerPath"),
|
@@ -8408,31 +8350,31 @@ function PuckLayout({ children }) {
|
|
8408
8350
|
)
|
8409
8351
|
] })
|
8410
8352
|
] }) }),
|
8411
|
-
/* @__PURE__ */ (0,
|
8412
|
-
/* @__PURE__ */ (0,
|
8353
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
|
8354
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8413
8355
|
IconButton,
|
8414
8356
|
{
|
8415
8357
|
onClick: () => {
|
8416
8358
|
return setMenuOpen(!menuOpen);
|
8417
8359
|
},
|
8418
8360
|
title: "Toggle menu bar",
|
8419
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
8361
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
|
8420
8362
|
}
|
8421
8363
|
) }),
|
8422
|
-
/* @__PURE__ */ (0,
|
8364
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8423
8365
|
MenuBar,
|
8424
8366
|
{
|
8425
8367
|
dispatch,
|
8426
8368
|
onPublish,
|
8427
8369
|
menuOpen,
|
8428
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
8370
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8429
8371
|
Button,
|
8430
8372
|
{
|
8431
8373
|
onClick: () => {
|
8432
8374
|
const data = appStore.getState().state.data;
|
8433
8375
|
onPublish && onPublish(data);
|
8434
8376
|
},
|
8435
|
-
icon: /* @__PURE__ */ (0,
|
8377
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
|
8436
8378
|
children: "Publish"
|
8437
8379
|
}
|
8438
8380
|
) }),
|
@@ -8443,20 +8385,20 @@ function PuckLayout({ children }) {
|
|
8443
8385
|
] }) })
|
8444
8386
|
}
|
8445
8387
|
),
|
8446
|
-
/* @__PURE__ */ (0,
|
8447
|
-
/* @__PURE__ */ (0,
|
8448
|
-
/* @__PURE__ */ (0,
|
8388
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
8389
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Components, {}) }),
|
8390
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Outline, {}) })
|
8449
8391
|
] }),
|
8450
|
-
/* @__PURE__ */ (0,
|
8451
|
-
/* @__PURE__ */ (0,
|
8392
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Canvas, {}),
|
8393
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FieldSideBar, {}) })
|
8452
8394
|
] })
|
8453
8395
|
}
|
8454
8396
|
) }) }),
|
8455
|
-
/* @__PURE__ */ (0,
|
8397
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
8456
8398
|
] });
|
8457
8399
|
}
|
8458
8400
|
function Puck(props) {
|
8459
|
-
return /* @__PURE__ */ (0,
|
8401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
|
8460
8402
|
}
|
8461
8403
|
Puck.Components = Components;
|
8462
8404
|
Puck.Fields = Fields;
|
@@ -8480,16 +8422,73 @@ var migrations = [
|
|
8480
8422
|
});
|
8481
8423
|
}
|
8482
8424
|
return data;
|
8425
|
+
},
|
8426
|
+
// Migrate zones to slots
|
8427
|
+
(data, config) => {
|
8428
|
+
var _a;
|
8429
|
+
if (!config) return data;
|
8430
|
+
console.log("Migrating DropZones to slots...");
|
8431
|
+
const updatedItems = {};
|
8432
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8433
|
+
const { indexes } = walkAppState(appState, config);
|
8434
|
+
const deletedCompounds = [];
|
8435
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
8436
|
+
var _a2, _b;
|
8437
|
+
if (zoneType === "dropzone") {
|
8438
|
+
const [id, slotName] = zoneCompound.split(":");
|
8439
|
+
const nodeData = indexes.nodes[id].data;
|
8440
|
+
const componentType = nodeData.type;
|
8441
|
+
const configForComponent = config.components[componentType];
|
8442
|
+
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
8443
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
8444
|
+
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
8445
|
+
[slotName]: content
|
8446
|
+
})
|
8447
|
+
});
|
8448
|
+
deletedCompounds.push(zoneCompound);
|
8449
|
+
}
|
8450
|
+
return content;
|
8451
|
+
}
|
8452
|
+
return content;
|
8453
|
+
});
|
8454
|
+
const updated = walkAppState(
|
8455
|
+
appState,
|
8456
|
+
config,
|
8457
|
+
(content) => content,
|
8458
|
+
(item) => {
|
8459
|
+
var _a2;
|
8460
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
8461
|
+
}
|
8462
|
+
);
|
8463
|
+
deletedCompounds.forEach((zoneCompound) => {
|
8464
|
+
var _a2;
|
8465
|
+
const [_, propName] = zoneCompound.split(":");
|
8466
|
+
console.log(
|
8467
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
8468
|
+
);
|
8469
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
8470
|
+
});
|
8471
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
8472
|
+
const [_, propName] = zoneCompound.split(":");
|
8473
|
+
throw new Error(
|
8474
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
8475
|
+
);
|
8476
|
+
});
|
8477
|
+
delete updated.data.zones;
|
8478
|
+
return updated.data;
|
8483
8479
|
}
|
8484
8480
|
];
|
8485
|
-
function migrate(data) {
|
8486
|
-
return migrations == null ? void 0 : migrations.reduce(
|
8481
|
+
function migrate(data, config) {
|
8482
|
+
return migrations == null ? void 0 : migrations.reduce(
|
8483
|
+
(acc, migration) => migration(acc, config),
|
8484
|
+
data
|
8485
|
+
);
|
8487
8486
|
}
|
8488
8487
|
|
8489
8488
|
// lib/transform-props.ts
|
8490
8489
|
init_react_import();
|
8491
8490
|
|
8492
|
-
// lib/default-data.ts
|
8491
|
+
// lib/data/default-data.ts
|
8493
8492
|
init_react_import();
|
8494
8493
|
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
8495
8494
|
root: data.root || {},
|
@@ -8532,7 +8531,7 @@ function transformProps(data, propTransforms) {
|
|
8532
8531
|
// lib/resolve-all-data.ts
|
8533
8532
|
init_react_import();
|
8534
8533
|
|
8535
|
-
// lib/to-component.ts
|
8534
|
+
// lib/data/to-component.ts
|
8536
8535
|
init_react_import();
|
8537
8536
|
var toComponent = (item) => {
|
8538
8537
|
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
@@ -8560,17 +8559,29 @@ function resolveAllData(_0, _1) {
|
|
8560
8559
|
"force",
|
8561
8560
|
false
|
8562
8561
|
)).node;
|
8563
|
-
const resolvedDeep = yield
|
8562
|
+
const resolvedDeep = yield mapSlotsAsync(
|
8563
|
+
resolved,
|
8564
|
+
processContent,
|
8565
|
+
false
|
8566
|
+
);
|
8564
8567
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
8565
8568
|
return resolvedDeep;
|
8566
8569
|
});
|
8567
8570
|
const processContent = (content) => __async(this, null, function* () {
|
8568
8571
|
return Promise.all(content.map(resolveNode));
|
8569
8572
|
});
|
8573
|
+
const processZones = () => __async(this, null, function* () {
|
8574
|
+
var _a2;
|
8575
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
8576
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
8577
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
8578
|
+
}));
|
8579
|
+
return zones;
|
8580
|
+
});
|
8570
8581
|
const dynamic = {
|
8571
8582
|
root: yield resolveNode(defaultedData.root),
|
8572
8583
|
content: yield processContent(defaultedData.content),
|
8573
|
-
zones:
|
8584
|
+
zones: yield processZones()
|
8574
8585
|
};
|
8575
8586
|
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
8576
8587
|
const content = defaultedData.zones[zoneKey];
|
@@ -8599,7 +8610,8 @@ function resolveAllData(_0, _1) {
|
|
8599
8610
|
renderContext,
|
8600
8611
|
resolveAllData,
|
8601
8612
|
transformProps,
|
8602
|
-
usePuck
|
8613
|
+
usePuck,
|
8614
|
+
walkTree
|
8603
8615
|
});
|
8604
8616
|
/*! Bundled license information:
|
8605
8617
|
|