@measured/puck 0.19.0-canary.91cb9cee → 0.19.0-canary.a60c81eb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-GL73J54P.mjs → chunk-HGAPIQP5.mjs} +231 -161
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +352 -226
- package/dist/index.mjs +117 -53
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +232 -167
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-DOB5QZVq.d.mts → walk-tree-DBd3aQ_5.d.mts} +26 -21
- package/dist/{walk-tree-DOB5QZVq.d.ts → walk-tree-DBd3aQ_5.d.ts} +26 -21
- package/package.json +12 -7
package/dist/index.js
CHANGED
@@ -792,43 +792,6 @@ init_react_import();
|
|
792
792
|
// lib/data/walk-app-state.ts
|
793
793
|
init_react_import();
|
794
794
|
|
795
|
-
// lib/data/for-each-slot.ts
|
796
|
-
init_react_import();
|
797
|
-
|
798
|
-
// lib/data/is-slot.ts
|
799
|
-
init_react_import();
|
800
|
-
var isSlot = (prop) => {
|
801
|
-
var _a, _b;
|
802
|
-
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
803
|
-
};
|
804
|
-
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
805
|
-
var _a, _b;
|
806
|
-
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
807
|
-
if (!configForComponent) return isSlot(propValue);
|
808
|
-
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
809
|
-
};
|
810
|
-
|
811
|
-
// lib/data/for-each-slot.ts
|
812
|
-
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
813
|
-
const props = item.props || {};
|
814
|
-
const propKeys = Object.keys(props);
|
815
|
-
for (let i = 0; i < propKeys.length; i++) {
|
816
|
-
const propKey = propKeys[i];
|
817
|
-
const itemType = "type" in item ? item.type : "root";
|
818
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
819
|
-
const content = props[propKey];
|
820
|
-
cb(props.id, propKey, content);
|
821
|
-
if (recursive) {
|
822
|
-
content.forEach(
|
823
|
-
(childItem) => __async(void 0, null, function* () {
|
824
|
-
return forEachSlot(childItem, cb, true, isSlot2);
|
825
|
-
})
|
826
|
-
);
|
827
|
-
}
|
828
|
-
}
|
829
|
-
}
|
830
|
-
};
|
831
|
-
|
832
795
|
// lib/data/for-related-zones.ts
|
833
796
|
init_react_import();
|
834
797
|
|
@@ -862,19 +825,160 @@ function forRelatedZones(item, data, cb, path = []) {
|
|
862
825
|
});
|
863
826
|
}
|
864
827
|
|
828
|
+
// lib/data/map-slots.ts
|
829
|
+
init_react_import();
|
830
|
+
var isPromise = (v) => !!v && typeof v.then === "function";
|
831
|
+
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
832
|
+
var containsPromise = (arr) => arr.some(isPromise);
|
833
|
+
var walkField = ({
|
834
|
+
value,
|
835
|
+
fields,
|
836
|
+
map,
|
837
|
+
propKey = "",
|
838
|
+
propPath = "",
|
839
|
+
id = "",
|
840
|
+
config,
|
841
|
+
recurseSlots = false
|
842
|
+
}) => {
|
843
|
+
var _a, _b, _c;
|
844
|
+
if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
|
845
|
+
const content = value || [];
|
846
|
+
const mappedContent = recurseSlots ? content.map((el) => {
|
847
|
+
var _a2;
|
848
|
+
const componentConfig = config.components[el.type];
|
849
|
+
if (!componentConfig) {
|
850
|
+
throw new Error(`Could not find component config for ${el.type}`);
|
851
|
+
}
|
852
|
+
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
|
853
|
+
return walkField({
|
854
|
+
value: el,
|
855
|
+
fields: fields2,
|
856
|
+
map,
|
857
|
+
id: el.props.id,
|
858
|
+
config,
|
859
|
+
recurseSlots
|
860
|
+
});
|
861
|
+
}) : content;
|
862
|
+
if (containsPromise(mappedContent)) {
|
863
|
+
return Promise.all(mappedContent);
|
864
|
+
}
|
865
|
+
return map(mappedContent, id, propPath, fields[propKey], propPath);
|
866
|
+
}
|
867
|
+
if (value && typeof value === "object") {
|
868
|
+
if (Array.isArray(value)) {
|
869
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
870
|
+
if (!arrayFields) return value;
|
871
|
+
const newValue = value.map(
|
872
|
+
(el, idx) => walkField({
|
873
|
+
value: el,
|
874
|
+
fields: arrayFields,
|
875
|
+
map,
|
876
|
+
propKey,
|
877
|
+
propPath: `${propPath}[${idx}]`,
|
878
|
+
id,
|
879
|
+
config,
|
880
|
+
recurseSlots
|
881
|
+
})
|
882
|
+
);
|
883
|
+
if (containsPromise(newValue)) {
|
884
|
+
return Promise.all(newValue);
|
885
|
+
}
|
886
|
+
return newValue;
|
887
|
+
} else if ("$$typeof" in value) {
|
888
|
+
return value;
|
889
|
+
} else {
|
890
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
891
|
+
return walkObject({
|
892
|
+
value,
|
893
|
+
fields: objectFields,
|
894
|
+
map,
|
895
|
+
id,
|
896
|
+
getPropPath: (k) => `${propPath}.${k}`,
|
897
|
+
config,
|
898
|
+
recurseSlots
|
899
|
+
});
|
900
|
+
}
|
901
|
+
}
|
902
|
+
return value;
|
903
|
+
};
|
904
|
+
var walkObject = ({
|
905
|
+
value,
|
906
|
+
fields,
|
907
|
+
map,
|
908
|
+
id,
|
909
|
+
getPropPath,
|
910
|
+
config,
|
911
|
+
recurseSlots
|
912
|
+
}) => {
|
913
|
+
const newProps = Object.entries(value).map(([k, v]) => {
|
914
|
+
const opts = {
|
915
|
+
value: v,
|
916
|
+
fields,
|
917
|
+
map,
|
918
|
+
propKey: k,
|
919
|
+
propPath: getPropPath(k),
|
920
|
+
id,
|
921
|
+
config,
|
922
|
+
recurseSlots
|
923
|
+
};
|
924
|
+
const newValue = walkField(opts);
|
925
|
+
if (isPromise(newValue)) {
|
926
|
+
return newValue.then((resolvedValue) => ({
|
927
|
+
[k]: resolvedValue
|
928
|
+
}));
|
929
|
+
}
|
930
|
+
return {
|
931
|
+
[k]: newValue
|
932
|
+
};
|
933
|
+
}, {});
|
934
|
+
if (containsPromise(newProps)) {
|
935
|
+
return Promise.all(newProps).then(flatten);
|
936
|
+
}
|
937
|
+
return flatten(newProps);
|
938
|
+
};
|
939
|
+
function mapSlots(item, map, config, recurseSlots = false) {
|
940
|
+
var _a, _b, _c, _d;
|
941
|
+
const itemType = "type" in item ? item.type : "root";
|
942
|
+
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
943
|
+
const newProps = walkObject({
|
944
|
+
value: (_b = item.props) != null ? _b : {},
|
945
|
+
fields: (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {},
|
946
|
+
map,
|
947
|
+
id: item.props ? (_d = item.props.id) != null ? _d : "root" : "root",
|
948
|
+
getPropPath: (k) => k,
|
949
|
+
config,
|
950
|
+
recurseSlots
|
951
|
+
});
|
952
|
+
if (isPromise(newProps)) {
|
953
|
+
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
954
|
+
props: resolvedProps
|
955
|
+
}));
|
956
|
+
}
|
957
|
+
return __spreadProps(__spreadValues({}, item), {
|
958
|
+
props: newProps
|
959
|
+
});
|
960
|
+
}
|
961
|
+
|
962
|
+
// lib/data/flatten-node.ts
|
963
|
+
init_react_import();
|
964
|
+
var import_flat = require("flat");
|
965
|
+
|
865
966
|
// lib/data/strip-slots.ts
|
866
967
|
init_react_import();
|
867
|
-
var stripSlots = (data) => {
|
868
|
-
return
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
968
|
+
var stripSlots = (data, config) => {
|
969
|
+
return mapSlots(data, () => null, config);
|
970
|
+
};
|
971
|
+
|
972
|
+
// lib/data/flatten-node.ts
|
973
|
+
var flattenNode = (node, config) => {
|
974
|
+
return __spreadProps(__spreadValues({}, node), {
|
975
|
+
props: (0, import_flat.flatten)(stripSlots(node, config).props)
|
976
|
+
});
|
977
|
+
};
|
978
|
+
var expandNode = (node) => {
|
979
|
+
const props = (0, import_flat.unflatten)(node.props);
|
980
|
+
return __spreadProps(__spreadValues({}, node), {
|
981
|
+
props
|
878
982
|
});
|
879
983
|
};
|
880
984
|
|
@@ -920,10 +1024,9 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
920
1024
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
921
1025
|
if (!mappedItem) return item;
|
922
1026
|
const id = mappedItem.props.id;
|
923
|
-
const newProps = __spreadValues({},
|
924
|
-
forEachSlot(
|
1027
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlots(
|
925
1028
|
mappedItem,
|
926
|
-
(parentId2, slotId
|
1029
|
+
(content, parentId2, slotId) => {
|
927
1030
|
const zoneCompound = `${parentId2}:${slotId}`;
|
928
1031
|
const [_2, newContent2] = processContent(
|
929
1032
|
path,
|
@@ -932,18 +1035,19 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
932
1035
|
"slot",
|
933
1036
|
parentId2
|
934
1037
|
);
|
935
|
-
|
1038
|
+
return newContent2;
|
936
1039
|
},
|
937
|
-
|
938
|
-
|
939
|
-
|
1040
|
+
config
|
1041
|
+
).props), {
|
1042
|
+
id
|
1043
|
+
});
|
940
1044
|
processRelatedZones(item, id, path);
|
941
1045
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
942
1046
|
const thisZoneCompound = path[path.length - 1];
|
943
1047
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
944
1048
|
newNodeIndex[id] = {
|
945
1049
|
data: newItem,
|
946
|
-
flatData:
|
1050
|
+
flatData: flattenNode(newItem, config),
|
947
1051
|
path,
|
948
1052
|
parentId,
|
949
1053
|
zone
|
@@ -1046,56 +1150,17 @@ init_react_import();
|
|
1046
1150
|
|
1047
1151
|
// lib/data/walk-tree.ts
|
1048
1152
|
init_react_import();
|
1049
|
-
|
1050
|
-
// lib/data/map-slots.ts
|
1051
|
-
init_react_import();
|
1052
|
-
function mapSlotsAsync(_0, _1) {
|
1053
|
-
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1054
|
-
const props = __spreadValues({}, item.props);
|
1055
|
-
const propKeys = Object.keys(props);
|
1056
|
-
for (let i = 0; i < propKeys.length; i++) {
|
1057
|
-
const propKey = propKeys[i];
|
1058
|
-
const itemType = "type" in item ? item.type : "root";
|
1059
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
1060
|
-
const content = props[propKey];
|
1061
|
-
const mappedContent = recursive ? yield Promise.all(
|
1062
|
-
content.map((item2) => __async(this, null, function* () {
|
1063
|
-
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1064
|
-
}))
|
1065
|
-
) : content;
|
1066
|
-
props[propKey] = yield map(mappedContent, propKey);
|
1067
|
-
}
|
1068
|
-
}
|
1069
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1070
|
-
});
|
1071
|
-
}
|
1072
|
-
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
1073
|
-
var _a, _b;
|
1074
|
-
const props = __spreadValues({}, item.props);
|
1075
|
-
const propKeys = Object.keys(props);
|
1076
|
-
for (let i = 0; i < propKeys.length; i++) {
|
1077
|
-
const propKey = propKeys[i];
|
1078
|
-
const itemType = "type" in item ? item.type : "root";
|
1079
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
1080
|
-
const content = props[propKey];
|
1081
|
-
const mappedContent = content.map((item2) => {
|
1082
|
-
return mapSlotsSync(item2, map, isSlot2);
|
1083
|
-
});
|
1084
|
-
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
1085
|
-
}
|
1086
|
-
}
|
1087
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1088
|
-
}
|
1089
|
-
|
1090
|
-
// lib/data/walk-tree.ts
|
1091
1153
|
function walkTree(data, config, callbackFn) {
|
1092
1154
|
var _a, _b;
|
1093
|
-
const isSlot2 = createIsSlotConfig(config);
|
1094
1155
|
const walkItem = (item) => {
|
1095
|
-
return
|
1156
|
+
return mapSlots(
|
1096
1157
|
item,
|
1097
|
-
(content, parentId, propName) =>
|
1098
|
-
|
1158
|
+
(content, parentId, propName) => {
|
1159
|
+
var _a2;
|
1160
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
1161
|
+
},
|
1162
|
+
config,
|
1163
|
+
true
|
1099
1164
|
);
|
1100
1165
|
};
|
1101
1166
|
if ("props" in data) {
|
@@ -1124,7 +1189,7 @@ var populateIds = (data, config, override = false) => {
|
|
1124
1189
|
const id = generateId(data.type);
|
1125
1190
|
return walkTree(
|
1126
1191
|
__spreadProps(__spreadValues({}, data), {
|
1127
|
-
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({
|
1192
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
1128
1193
|
}),
|
1129
1194
|
config,
|
1130
1195
|
(contents) => contents.map((item) => {
|
@@ -1881,12 +1946,13 @@ var flattenData = (state, config) => {
|
|
1881
1946
|
|
1882
1947
|
// lib/get-changed.ts
|
1883
1948
|
init_react_import();
|
1949
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
1884
1950
|
var getChanged = (newItem, oldItem) => {
|
1885
1951
|
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1886
1952
|
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1887
1953
|
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1888
1954
|
return __spreadProps(__spreadValues({}, acc), {
|
1889
|
-
[item]: oldItemProps[item]
|
1955
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1890
1956
|
});
|
1891
1957
|
}, {}) : {};
|
1892
1958
|
};
|
@@ -2105,14 +2171,16 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
2105
2171
|
|
2106
2172
|
// lib/resolve-component-data.ts
|
2107
2173
|
init_react_import();
|
2108
|
-
var
|
2174
|
+
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
2109
2175
|
var cache = { lastChange: {} };
|
2110
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace"
|
2176
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
2111
2177
|
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
2112
|
-
|
2113
|
-
|
2178
|
+
const resolvedItem = __spreadValues({}, item);
|
2179
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
2180
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2181
|
+
if (shouldRunResolver) {
|
2114
2182
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
2115
|
-
if (item && (0,
|
2183
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
2116
2184
|
return { node: resolved, didChange: false };
|
2117
2185
|
}
|
2118
2186
|
const changed = getChanged(item, oldItem);
|
@@ -2125,46 +2193,42 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
2125
2193
|
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
2126
2194
|
trigger
|
2127
2195
|
});
|
2128
|
-
|
2129
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
2130
|
-
});
|
2131
|
-
if (recursive) {
|
2132
|
-
resolvedItem = yield mapSlotsAsync(
|
2133
|
-
resolvedItem,
|
2134
|
-
(content) => __async(void 0, null, function* () {
|
2135
|
-
return Promise.all(
|
2136
|
-
content.map(
|
2137
|
-
(childItem) => __async(void 0, null, function* () {
|
2138
|
-
return (yield resolveComponentData(
|
2139
|
-
childItem,
|
2140
|
-
config,
|
2141
|
-
metadata,
|
2142
|
-
onResolveStart,
|
2143
|
-
onResolveEnd,
|
2144
|
-
trigger,
|
2145
|
-
false
|
2146
|
-
)).node;
|
2147
|
-
})
|
2148
|
-
)
|
2149
|
-
);
|
2150
|
-
}),
|
2151
|
-
false,
|
2152
|
-
createIsSlotConfig(config)
|
2153
|
-
);
|
2154
|
-
}
|
2196
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
2155
2197
|
if (Object.keys(readOnly).length) {
|
2156
2198
|
resolvedItem.readOnly = readOnly;
|
2157
2199
|
}
|
2158
|
-
cache.lastChange[id] = {
|
2159
|
-
item,
|
2160
|
-
resolved: resolvedItem
|
2161
|
-
};
|
2162
|
-
if (onResolveEnd) {
|
2163
|
-
onResolveEnd(resolvedItem);
|
2164
|
-
}
|
2165
|
-
return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
|
2166
2200
|
}
|
2167
|
-
|
2201
|
+
let itemWithResolvedChildren = yield mapSlots(
|
2202
|
+
resolvedItem,
|
2203
|
+
(content) => __async(void 0, null, function* () {
|
2204
|
+
return yield Promise.all(
|
2205
|
+
content.map(
|
2206
|
+
(childItem) => __async(void 0, null, function* () {
|
2207
|
+
return (yield resolveComponentData(
|
2208
|
+
childItem,
|
2209
|
+
config,
|
2210
|
+
metadata,
|
2211
|
+
onResolveStart,
|
2212
|
+
onResolveEnd,
|
2213
|
+
trigger
|
2214
|
+
)).node;
|
2215
|
+
})
|
2216
|
+
)
|
2217
|
+
);
|
2218
|
+
}),
|
2219
|
+
config
|
2220
|
+
);
|
2221
|
+
if (shouldRunResolver && onResolveEnd) {
|
2222
|
+
onResolveEnd(resolvedItem);
|
2223
|
+
}
|
2224
|
+
cache.lastChange[id] = {
|
2225
|
+
item,
|
2226
|
+
resolved: itemWithResolvedChildren
|
2227
|
+
};
|
2228
|
+
return {
|
2229
|
+
node: itemWithResolvedChildren,
|
2230
|
+
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
2231
|
+
};
|
2168
2232
|
});
|
2169
2233
|
|
2170
2234
|
// lib/data/to-root.ts
|
@@ -2406,13 +2470,18 @@ init_react_import();
|
|
2406
2470
|
var import_react10 = require("react");
|
2407
2471
|
var import_react11 = require("@dnd-kit/react");
|
2408
2472
|
var import_utilities = require("@dnd-kit/dom/utilities");
|
2473
|
+
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
2474
|
+
var otherDefault = {
|
2475
|
+
delay: { value: 200, tolerance: 10 },
|
2476
|
+
distance: { value: 5 }
|
2477
|
+
};
|
2409
2478
|
var useSensors = ({
|
2410
|
-
other,
|
2479
|
+
other = otherDefault,
|
2411
2480
|
mouse,
|
2412
|
-
touch
|
2481
|
+
touch = touchDefault
|
2413
2482
|
} = {
|
2414
|
-
touch:
|
2415
|
-
other:
|
2483
|
+
touch: touchDefault,
|
2484
|
+
other: otherDefault
|
2416
2485
|
}) => {
|
2417
2486
|
const [sensors] = (0, import_react10.useState)(() => [
|
2418
2487
|
import_react11.PointerSensor.configure({
|
@@ -2951,6 +3020,19 @@ var ArrayField = ({
|
|
2951
3020
|
);
|
2952
3021
|
const forceReadOnly = !canEdit;
|
2953
3022
|
const valueRef = (0, import_react14.useRef)(value);
|
3023
|
+
const uniqifyItem = (0, import_react14.useCallback)(
|
3024
|
+
(val) => {
|
3025
|
+
if (field.type !== "array" || !field.arrayFields) return;
|
3026
|
+
const config = appStore.getState().config;
|
3027
|
+
return walkField({
|
3028
|
+
value: val,
|
3029
|
+
fields: field.arrayFields,
|
3030
|
+
map: (content) => content.map((item) => populateIds(item, config, true)),
|
3031
|
+
config
|
3032
|
+
});
|
3033
|
+
},
|
3034
|
+
[appStore, field]
|
3035
|
+
);
|
2954
3036
|
if (field.type !== "array" || !field.arrayFields) {
|
2955
3037
|
return null;
|
2956
3038
|
}
|
@@ -3055,11 +3137,10 @@ var ArrayField = ({
|
|
3055
3137
|
onClick: (e) => {
|
3056
3138
|
e.stopPropagation();
|
3057
3139
|
const existingValue = [...value || []];
|
3058
|
-
|
3059
|
-
i,
|
3060
|
-
0,
|
3140
|
+
const newItem = uniqifyItem(
|
3061
3141
|
existingValue[i]
|
3062
3142
|
);
|
3143
|
+
existingValue.splice(i, 0, newItem);
|
3063
3144
|
const newUi = mapArrayStateToUi(
|
3064
3145
|
regenerateArrayState(existingValue)
|
3065
3146
|
);
|
@@ -3157,12 +3238,11 @@ var ArrayField = ({
|
|
3157
3238
|
type: "button",
|
3158
3239
|
className: getClassName5("addButton"),
|
3159
3240
|
onClick: () => {
|
3241
|
+
var _a;
|
3160
3242
|
if (isDraggingAny) return;
|
3161
3243
|
const existingValue = value || [];
|
3162
|
-
const
|
3163
|
-
|
3164
|
-
field.defaultItemProps || {}
|
3165
|
-
];
|
3244
|
+
const newItem = uniqifyItem((_a = field.defaultItemProps) != null ? _a : {});
|
3245
|
+
const newValue = [...existingValue, newItem];
|
3166
3246
|
const newArrayState = regenerateArrayState(newValue);
|
3167
3247
|
setUi(mapArrayStateToUi(newArrayState), false);
|
3168
3248
|
onChange(newValue);
|
@@ -4056,6 +4136,10 @@ function AutoFieldInternal(props) {
|
|
4056
4136
|
});
|
4057
4137
|
}
|
4058
4138
|
}, []);
|
4139
|
+
const { visible = true } = props.field;
|
4140
|
+
if (!visible) {
|
4141
|
+
return null;
|
4142
|
+
}
|
4059
4143
|
if (field.type === "slot") {
|
4060
4144
|
return null;
|
4061
4145
|
}
|
@@ -4891,10 +4975,10 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4891
4975
|
preview
|
4892
4976
|
);
|
4893
4977
|
const updateContent = useRenderedCallback(
|
4894
|
-
(contentIds2, preview2) => {
|
4895
|
-
|
4896
|
-
|
4897
|
-
|
4978
|
+
(contentIds2, preview2, isDragging2, draggedItemId, previewExists) => {
|
4979
|
+
if (isDragging2 && !previewExists) {
|
4980
|
+
return;
|
4981
|
+
}
|
4898
4982
|
if (preview2) {
|
4899
4983
|
if (preview2.type === "insert") {
|
4900
4984
|
setContentIdsWithPreview(
|
@@ -4915,7 +4999,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4915
4999
|
}
|
4916
5000
|
} else {
|
4917
5001
|
setContentIdsWithPreview(
|
4918
|
-
contentIds2.filter((id) => id !== draggedItemId)
|
5002
|
+
previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
|
4919
5003
|
);
|
4920
5004
|
}
|
4921
5005
|
setLocalPreview(preview2);
|
@@ -4923,7 +5007,17 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4923
5007
|
[]
|
4924
5008
|
);
|
4925
5009
|
(0, import_react30.useEffect)(() => {
|
4926
|
-
|
5010
|
+
var _a;
|
5011
|
+
const s = zoneStore.getState();
|
5012
|
+
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
5013
|
+
const previewExists = Object.keys(s.previewIndex || {}).length > 0;
|
5014
|
+
updateContent(
|
5015
|
+
contentIds,
|
5016
|
+
preview,
|
5017
|
+
isDragging,
|
5018
|
+
draggedItemId,
|
5019
|
+
previewExists
|
5020
|
+
);
|
4927
5021
|
}, [contentIds, preview, isDragging]);
|
4928
5022
|
return [contentIdsWithPreview, localPreview];
|
4929
5023
|
};
|
@@ -4965,7 +5059,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4965
5059
|
};
|
4966
5060
|
|
4967
5061
|
// components/DropZone/index.tsx
|
4968
|
-
var
|
5062
|
+
var import_shallow4 = require("zustand/react/shallow");
|
4969
5063
|
|
4970
5064
|
// components/Render/index.tsx
|
4971
5065
|
init_react_import();
|
@@ -4973,32 +5067,30 @@ init_react_import();
|
|
4973
5067
|
// lib/use-slots.tsx
|
4974
5068
|
init_react_import();
|
4975
5069
|
var import_react32 = require("react");
|
4976
|
-
function useSlots(config,
|
5070
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
4977
5071
|
const slotProps = (0, import_react32.useMemo)(() => {
|
4978
|
-
|
4979
|
-
|
4980
|
-
|
4981
|
-
|
4982
|
-
|
4983
|
-
|
4984
|
-
if ((field == null ? void 0 : field.type) === "slot") {
|
4985
|
-
const content = props[fieldKey] || [];
|
4986
|
-
const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
|
5072
|
+
const mapped = mapSlots(
|
5073
|
+
item,
|
5074
|
+
(content, _parentId, propName, field, propPath) => {
|
5075
|
+
const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
|
5076
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
|
5077
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
4987
5078
|
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
4988
|
-
allow: field.allow,
|
4989
|
-
disallow: field.disallow
|
5079
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
5080
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
4990
5081
|
}, dzProps), {
|
4991
|
-
zone:
|
5082
|
+
zone: propName,
|
4992
5083
|
content
|
4993
5084
|
}));
|
4994
|
-
|
4995
|
-
}
|
4996
|
-
|
4997
|
-
|
4998
|
-
|
5085
|
+
return Slot;
|
5086
|
+
},
|
5087
|
+
config
|
5088
|
+
).props;
|
5089
|
+
return mapped;
|
5090
|
+
}, [config, item, readOnly, forceReadOnly]);
|
4999
5091
|
const mergedProps = (0, import_react32.useMemo)(
|
5000
|
-
() => __spreadValues(__spreadValues({}, props), slotProps),
|
5001
|
-
[props, slotProps]
|
5092
|
+
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
5093
|
+
[item.props, slotProps]
|
5002
5094
|
);
|
5003
5095
|
return mergedProps;
|
5004
5096
|
}
|
@@ -5008,6 +5100,7 @@ var import_react34 = __toESM(require("react"));
|
|
5008
5100
|
|
5009
5101
|
// components/SlotRender/index.tsx
|
5010
5102
|
init_react_import();
|
5103
|
+
var import_shallow3 = require("zustand/react/shallow");
|
5011
5104
|
|
5012
5105
|
// components/SlotRender/server.tsx
|
5013
5106
|
init_react_import();
|
@@ -5046,12 +5139,15 @@ function DropZoneRender({
|
|
5046
5139
|
metadata
|
5047
5140
|
}
|
5048
5141
|
),
|
5049
|
-
metadata
|
5142
|
+
metadata,
|
5143
|
+
dragRef: null,
|
5144
|
+
isEditing: false
|
5050
5145
|
}
|
5051
5146
|
});
|
5052
|
-
const
|
5147
|
+
const renderItem = __spreadProps(__spreadValues({}, item), { props });
|
5148
|
+
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
5053
5149
|
if (Component) {
|
5054
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots),
|
5150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
|
5055
5151
|
}
|
5056
5152
|
return null;
|
5057
5153
|
}) });
|
@@ -5066,7 +5162,7 @@ var Item = ({
|
|
5066
5162
|
metadata
|
5067
5163
|
}) => {
|
5068
5164
|
const Component = config.components[item.type];
|
5069
|
-
const props = useSlots(
|
5165
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5070
5166
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5071
5167
|
Component.render,
|
5072
5168
|
__spreadProps(__spreadValues({}, props), {
|
@@ -5105,10 +5201,12 @@ var ContextSlotRender = ({
|
|
5105
5201
|
const config = useAppStore((s) => s.config);
|
5106
5202
|
const metadata = useAppStore((s) => s.metadata);
|
5107
5203
|
const slotContent = useAppStore(
|
5108
|
-
(s) => {
|
5204
|
+
(0, import_shallow3.useShallow)((s) => {
|
5109
5205
|
var _a, _b;
|
5110
|
-
|
5111
|
-
|
5206
|
+
const indexes = s.state.indexes;
|
5207
|
+
const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
|
5208
|
+
return contentIds.map((contentId) => indexes.nodes[contentId].flatData);
|
5209
|
+
})
|
5112
5210
|
);
|
5113
5211
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5114
5212
|
SlotRenderPure,
|
@@ -5138,7 +5236,7 @@ function Render({
|
|
5138
5236
|
root: data.root || {},
|
5139
5237
|
content: data.content || []
|
5140
5238
|
});
|
5141
|
-
const rootProps = defaultedData.root.props
|
5239
|
+
const rootProps = "props" in defaultedData.root ? defaultedData.root.props : defaultedData.root;
|
5142
5240
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
5143
5241
|
const pageProps = __spreadProps(__spreadValues({}, rootProps), {
|
5144
5242
|
puck: {
|
@@ -5151,7 +5249,11 @@ function Render({
|
|
5151
5249
|
editMode: false,
|
5152
5250
|
id: "puck-root"
|
5153
5251
|
});
|
5154
|
-
const propsWithSlots = useSlots(
|
5252
|
+
const propsWithSlots = useSlots(
|
5253
|
+
config,
|
5254
|
+
{ type: "root", props: pageProps },
|
5255
|
+
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
5256
|
+
);
|
5155
5257
|
const nextContextValue = (0, import_react34.useMemo)(
|
5156
5258
|
() => ({
|
5157
5259
|
mode: "render",
|
@@ -5185,7 +5287,7 @@ var DropZoneChild = ({
|
|
5185
5287
|
const { depth = 1 } = ctx != null ? ctx : {};
|
5186
5288
|
const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
|
5187
5289
|
const nodeProps = useAppStore(
|
5188
|
-
(0,
|
5290
|
+
(0, import_shallow4.useShallow)((s) => {
|
5189
5291
|
var _a2;
|
5190
5292
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
|
5191
5293
|
})
|
@@ -5197,14 +5299,19 @@ var DropZoneChild = ({
|
|
5197
5299
|
}
|
5198
5300
|
);
|
5199
5301
|
const nodeReadOnly = useAppStore(
|
5200
|
-
(0,
|
5302
|
+
(0, import_shallow4.useShallow)((s) => {
|
5201
5303
|
var _a2;
|
5202
5304
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
5203
5305
|
})
|
5204
5306
|
);
|
5307
|
+
const appStore = useAppStoreApi();
|
5205
5308
|
const item = (0, import_react35.useMemo)(() => {
|
5206
5309
|
if (nodeProps) {
|
5207
|
-
|
5310
|
+
const expanded = expandNode({
|
5311
|
+
type: nodeType,
|
5312
|
+
props: nodeProps
|
5313
|
+
});
|
5314
|
+
return expanded;
|
5208
5315
|
}
|
5209
5316
|
const preview = zoneStore.getState().previewIndex[zoneCompound];
|
5210
5317
|
if (componentId === (preview == null ? void 0 : preview.props.id)) {
|
@@ -5215,7 +5322,7 @@ var DropZoneChild = ({
|
|
5215
5322
|
};
|
5216
5323
|
}
|
5217
5324
|
return null;
|
5218
|
-
}, [componentId, zoneCompound, nodeType, nodeProps]);
|
5325
|
+
}, [appStore, componentId, zoneCompound, nodeType, nodeProps]);
|
5219
5326
|
const componentConfig = useAppStore(
|
5220
5327
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
5221
5328
|
);
|
@@ -5256,9 +5363,17 @@ var DropZoneChild = ({
|
|
5256
5363
|
}),
|
5257
5364
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
5258
5365
|
);
|
5366
|
+
const defaultedNode = (0, import_react35.useMemo)(
|
5367
|
+
() => {
|
5368
|
+
var _a2;
|
5369
|
+
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
5370
|
+
},
|
5371
|
+
[item == null ? void 0 : item.type, nodeType, defaultsProps]
|
5372
|
+
);
|
5373
|
+
const config = useAppStore((s) => s.config);
|
5259
5374
|
const defaultedPropsWithSlots = useSlots(
|
5260
|
-
|
5261
|
-
|
5375
|
+
config,
|
5376
|
+
defaultedNode,
|
5262
5377
|
DropZoneEditPure,
|
5263
5378
|
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
5264
5379
|
nodeReadOnly,
|
@@ -5270,7 +5385,7 @@ var DropZoneChild = ({
|
|
5270
5385
|
item.type
|
5271
5386
|
] });
|
5272
5387
|
let componentType = item.type;
|
5273
|
-
const isInserting = item.previewType === "insert";
|
5388
|
+
const isInserting = "previewType" in item ? item.previewType === "insert" : false;
|
5274
5389
|
if (isInserting) {
|
5275
5390
|
Render2 = renderPreview;
|
5276
5391
|
}
|
@@ -5319,7 +5434,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
5319
5434
|
unregisterLocalZone
|
5320
5435
|
} = ctx != null ? ctx : {};
|
5321
5436
|
const path = useAppStore(
|
5322
|
-
(0,
|
5437
|
+
(0, import_shallow4.useShallow)((s) => {
|
5323
5438
|
var _a;
|
5324
5439
|
return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
|
5325
5440
|
})
|
@@ -5336,13 +5451,13 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
5336
5451
|
(s) => s.nextAreaDepthIndex[areaId || ""]
|
5337
5452
|
);
|
5338
5453
|
const zoneContentIds = useAppStore(
|
5339
|
-
(0,
|
5454
|
+
(0, import_shallow4.useShallow)((s) => {
|
5340
5455
|
var _a;
|
5341
5456
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
|
5342
5457
|
})
|
5343
5458
|
);
|
5344
5459
|
const zoneType = useAppStore(
|
5345
|
-
(0,
|
5460
|
+
(0, import_shallow4.useShallow)((s) => {
|
5346
5461
|
var _a;
|
5347
5462
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
5348
5463
|
})
|
@@ -5499,7 +5614,7 @@ var DropZoneRenderItem = ({
|
|
5499
5614
|
metadata
|
5500
5615
|
}) => {
|
5501
5616
|
const Component = config.components[item.type];
|
5502
|
-
const props = useSlots(
|
5617
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5503
5618
|
const nextContextValue = (0, import_react35.useMemo)(
|
5504
5619
|
() => ({
|
5505
5620
|
areaId: props.id,
|
@@ -6543,7 +6658,7 @@ var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields
|
|
6543
6658
|
|
6544
6659
|
// components/Puck/components/Fields/index.tsx
|
6545
6660
|
var import_react42 = require("react");
|
6546
|
-
var
|
6661
|
+
var import_shallow5 = require("zustand/react/shallow");
|
6547
6662
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6548
6663
|
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
|
6549
6664
|
var DefaultFields = ({
|
@@ -6609,7 +6724,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
6609
6724
|
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
6610
6725
|
});
|
6611
6726
|
const permissions = useAppStore(
|
6612
|
-
(0,
|
6727
|
+
(0, import_shallow5.useShallow)((s) => {
|
6613
6728
|
const { selectedItem, permissions: permissions2 } = s;
|
6614
6729
|
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
6615
6730
|
})
|
@@ -6618,7 +6733,8 @@ var FieldsChild = ({ fieldName }) => {
|
|
6618
6733
|
const onChange = (0, import_react42.useCallback)(createOnChange(fieldName, appStore), [
|
6619
6734
|
fieldName
|
6620
6735
|
]);
|
6621
|
-
|
6736
|
+
const { visible = true } = field != null ? field : {};
|
6737
|
+
if (!field || !id || !visible) return null;
|
6622
6738
|
if (field.type === "slot") return null;
|
6623
6739
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("field"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
6624
6740
|
AutoFieldPrivate,
|
@@ -6640,7 +6756,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
6640
6756
|
const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
|
6641
6757
|
return (loadingCount != null ? loadingCount : 0) > 0;
|
6642
6758
|
});
|
6643
|
-
const itemSelector = useAppStore((0,
|
6759
|
+
const itemSelector = useAppStore((0, import_shallow5.useShallow)((s) => s.state.ui.itemSelector));
|
6644
6760
|
const id = useAppStore((s) => {
|
6645
6761
|
var _a;
|
6646
6762
|
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
@@ -6649,7 +6765,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
6649
6765
|
useRegisterFieldsSlice(appStore, id);
|
6650
6766
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
6651
6767
|
const fieldNames = useAppStore(
|
6652
|
-
(0,
|
6768
|
+
(0, import_shallow5.useShallow)((s) => {
|
6653
6769
|
if (s.fields.id === id) {
|
6654
6770
|
return Object.keys(s.fields.fields);
|
6655
6771
|
}
|
@@ -7172,13 +7288,16 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
7172
7288
|
const Page = (0, import_react46.useCallback)(
|
7173
7289
|
(pageProps) => {
|
7174
7290
|
var _a, _b;
|
7175
|
-
const
|
7176
|
-
|
7291
|
+
const propsWithSlots = useSlots(
|
7292
|
+
config,
|
7293
|
+
{ type: "root", props: pageProps },
|
7294
|
+
DropZoneEditPure
|
7295
|
+
);
|
7177
7296
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
7178
7297
|
id: "puck-root"
|
7179
7298
|
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: propsWithSlots.children });
|
7180
7299
|
},
|
7181
|
-
[config
|
7300
|
+
[config]
|
7182
7301
|
);
|
7183
7302
|
const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
|
7184
7303
|
const rootProps = root.props || root;
|
@@ -7289,7 +7408,7 @@ var onScrollEnd = (frame, cb) => {
|
|
7289
7408
|
};
|
7290
7409
|
|
7291
7410
|
// components/LayerTree/index.tsx
|
7292
|
-
var
|
7411
|
+
var import_shallow6 = require("zustand/react/shallow");
|
7293
7412
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
7294
7413
|
var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
|
7295
7414
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
|
@@ -7316,7 +7435,7 @@ var Layer = ({
|
|
7316
7435
|
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
7317
7436
|
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
7318
7437
|
const zonesForItem = useAppStore(
|
7319
|
-
(0,
|
7438
|
+
(0, import_shallow6.useShallow)(
|
7320
7439
|
(s) => Object.keys(s.state.indexes.zones).filter(
|
7321
7440
|
(z) => z.split(":")[0] === itemId
|
7322
7441
|
)
|
@@ -7363,7 +7482,10 @@ var Layer = ({
|
|
7363
7482
|
`[data-puck-component="${itemId}"]`
|
7364
7483
|
);
|
7365
7484
|
if (!el) {
|
7366
|
-
|
7485
|
+
setItemSelector({
|
7486
|
+
index,
|
7487
|
+
zone: zoneCompound
|
7488
|
+
});
|
7367
7489
|
return;
|
7368
7490
|
}
|
7369
7491
|
scrollIntoView(el);
|
@@ -7409,7 +7531,7 @@ var LayerTree = ({
|
|
7409
7531
|
}) => {
|
7410
7532
|
const label = _label != null ? _label : zoneCompound.split(":")[1];
|
7411
7533
|
const contentIds = useAppStore(
|
7412
|
-
(0,
|
7534
|
+
(0, import_shallow6.useShallow)(
|
7413
7535
|
(s) => {
|
7414
7536
|
var _a, _b;
|
7415
7537
|
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
@@ -7450,12 +7572,12 @@ var findZonesForArea = (state, area) => {
|
|
7450
7572
|
};
|
7451
7573
|
|
7452
7574
|
// components/Puck/components/Outline/index.tsx
|
7453
|
-
var
|
7575
|
+
var import_shallow7 = require("zustand/react/shallow");
|
7454
7576
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
7455
7577
|
var Outline = () => {
|
7456
7578
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
7457
7579
|
const rootZones = useAppStore(
|
7458
|
-
(0,
|
7580
|
+
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
7459
7581
|
);
|
7460
7582
|
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
7461
7583
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -7771,7 +7893,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
7771
7893
|
};
|
7772
7894
|
|
7773
7895
|
// components/Puck/components/Canvas/index.tsx
|
7774
|
-
var
|
7896
|
+
var import_shallow8 = require("zustand/react/shallow");
|
7775
7897
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7776
7898
|
var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
|
7777
7899
|
var ZOOM_ON_CHANGE = true;
|
@@ -7785,7 +7907,7 @@ var Canvas = () => {
|
|
7785
7907
|
status,
|
7786
7908
|
iframe
|
7787
7909
|
} = useAppStore(
|
7788
|
-
(0,
|
7910
|
+
(0, import_shallow8.useShallow)((s) => ({
|
7789
7911
|
dispatch: s.dispatch,
|
7790
7912
|
overrides: s.overrides,
|
7791
7913
|
setUi: s.setUi,
|
@@ -7796,7 +7918,7 @@ var Canvas = () => {
|
|
7796
7918
|
}))
|
7797
7919
|
);
|
7798
7920
|
const { leftSideBarVisible, rightSideBarVisible, viewports } = useAppStore(
|
7799
|
-
(0,
|
7921
|
+
(0, import_shallow8.useShallow)((s) => ({
|
7800
7922
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
7801
7923
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
7802
7924
|
viewports: s.state.ui.viewports
|
@@ -8130,7 +8252,7 @@ function useGetPuck() {
|
|
8130
8252
|
}
|
8131
8253
|
|
8132
8254
|
// components/Puck/index.tsx
|
8133
|
-
var
|
8255
|
+
var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
8134
8256
|
|
8135
8257
|
// components/Puck/components/Header/index.tsx
|
8136
8258
|
init_react_import();
|
@@ -8492,6 +8614,11 @@ function PuckProvider({ children }) {
|
|
8492
8614
|
const [appStore] = (0, import_react56.useState)(
|
8493
8615
|
() => createAppStore(generateAppStore(initialAppState))
|
8494
8616
|
);
|
8617
|
+
(0, import_react56.useEffect)(() => {
|
8618
|
+
if (process.env.NODE_ENV !== "production") {
|
8619
|
+
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
8620
|
+
}
|
8621
|
+
}, [appStore]);
|
8495
8622
|
(0, import_react56.useEffect)(() => {
|
8496
8623
|
const state = appStore.getState().state;
|
8497
8624
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
@@ -8507,7 +8634,7 @@ function PuckProvider({ children }) {
|
|
8507
8634
|
(s) => s.state.data,
|
8508
8635
|
(data) => {
|
8509
8636
|
if (onChange) {
|
8510
|
-
if ((0,
|
8637
|
+
if ((0, import_fast_deep_equal3.default)(data, previousData.current)) return;
|
8511
8638
|
onChange(data);
|
8512
8639
|
previousData.current = data;
|
8513
8640
|
}
|
@@ -8763,13 +8890,12 @@ function resolveAllData(_0, _1) {
|
|
8763
8890
|
},
|
8764
8891
|
() => {
|
8765
8892
|
},
|
8766
|
-
"force"
|
8767
|
-
false
|
8893
|
+
"force"
|
8768
8894
|
)).node;
|
8769
|
-
const resolvedDeep = yield
|
8895
|
+
const resolvedDeep = yield mapSlots(
|
8770
8896
|
resolved,
|
8771
8897
|
processContent,
|
8772
|
-
|
8898
|
+
config
|
8773
8899
|
);
|
8774
8900
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
8775
8901
|
return resolvedDeep;
|