@measured/puck 0.19.0-canary.a6dd529f → 0.19.0-canary.a967ca42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/chunk-GL73J54P.mjs +879 -0
- package/dist/index.css +28 -30
- package/dist/index.d.mts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +951 -1024
- package/dist/index.mjs +6038 -1635
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +566 -3780
- package/dist/rsc.mjs +7 -103
- package/dist/{resolve-all-data-BFRAghCj.d.mts → walk-tree-DOB5QZVq.d.mts} +45 -21
- package/dist/{resolve-all-data-BFRAghCj.d.ts → walk-tree-DOB5QZVq.d.ts} +45 -21
- package/package.json +4 -4
- package/dist/chunk-ZOHJNF5K.mjs +0 -5427
- package/dist/rsc.css +0 -339
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) => {
|
@@ -176,13 +169,14 @@ __export(core_exports, {
|
|
176
169
|
Puck: () => Puck,
|
177
170
|
Render: () => Render,
|
178
171
|
createUsePuck: () => createUsePuck,
|
179
|
-
mapSlots: () => mapSlotsPublic,
|
180
172
|
migrate: () => migrate,
|
181
173
|
overrideKeys: () => overrideKeys,
|
182
174
|
renderContext: () => renderContext,
|
183
175
|
resolveAllData: () => resolveAllData,
|
184
176
|
transformProps: () => transformProps,
|
185
|
-
|
177
|
+
useGetPuck: () => useGetPuck,
|
178
|
+
usePuck: () => usePuck,
|
179
|
+
walkTree: () => walkTree
|
186
180
|
});
|
187
181
|
module.exports = __toCommonJS(core_exports);
|
188
182
|
init_react_import();
|
@@ -795,7 +789,7 @@ init_react_import();
|
|
795
789
|
// reducer/actions/set.ts
|
796
790
|
init_react_import();
|
797
791
|
|
798
|
-
// lib/data/walk-
|
792
|
+
// lib/data/walk-app-state.ts
|
799
793
|
init_react_import();
|
800
794
|
|
801
795
|
// lib/data/for-each-slot.ts
|
@@ -884,8 +878,8 @@ var stripSlots = (data) => {
|
|
884
878
|
});
|
885
879
|
};
|
886
880
|
|
887
|
-
// lib/data/walk-
|
888
|
-
function
|
881
|
+
// lib/data/walk-app-state.ts
|
882
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
889
883
|
var _a;
|
890
884
|
let newZones = {};
|
891
885
|
const newZoneIndex = {};
|
@@ -1018,7 +1012,7 @@ var setAction = (state, action, appStore) => {
|
|
1018
1012
|
console.warn(
|
1019
1013
|
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1020
1014
|
);
|
1021
|
-
return
|
1015
|
+
return walkAppState(newState, appStore.config);
|
1022
1016
|
}
|
1023
1017
|
return __spreadValues(__spreadValues({}, state), action.state(state));
|
1024
1018
|
};
|
@@ -1047,18 +1041,116 @@ var getIdsForParent = (zoneCompound, state) => {
|
|
1047
1041
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
1048
1042
|
};
|
1049
1043
|
|
1044
|
+
// lib/data/populate-ids.ts
|
1045
|
+
init_react_import();
|
1046
|
+
|
1047
|
+
// lib/data/walk-tree.ts
|
1048
|
+
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
|
+
function walkTree(data, config, callbackFn) {
|
1092
|
+
var _a, _b;
|
1093
|
+
const isSlot2 = createIsSlotConfig(config);
|
1094
|
+
const walkItem = (item) => {
|
1095
|
+
return mapSlotsSync(
|
1096
|
+
item,
|
1097
|
+
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
1098
|
+
isSlot2
|
1099
|
+
);
|
1100
|
+
};
|
1101
|
+
if ("props" in data) {
|
1102
|
+
return walkItem(data);
|
1103
|
+
}
|
1104
|
+
const _data = data;
|
1105
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
1106
|
+
const mappedContent = _data.content.map(walkItem);
|
1107
|
+
return {
|
1108
|
+
root: walkItem(_data.root),
|
1109
|
+
content: (_b = callbackFn(mappedContent, {
|
1110
|
+
parentId: "root",
|
1111
|
+
propName: "default-zone"
|
1112
|
+
})) != null ? _b : mappedContent,
|
1113
|
+
zones: Object.keys(zones).reduce(
|
1114
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
1115
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
1116
|
+
}),
|
1117
|
+
{}
|
1118
|
+
)
|
1119
|
+
};
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
// lib/data/populate-ids.ts
|
1123
|
+
var populateIds = (data, config, override = false) => {
|
1124
|
+
const id = generateId(data.type);
|
1125
|
+
return walkTree(
|
1126
|
+
__spreadProps(__spreadValues({}, data), {
|
1127
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
1128
|
+
}),
|
1129
|
+
config,
|
1130
|
+
(contents) => contents.map((item) => {
|
1131
|
+
const id2 = generateId(item.type);
|
1132
|
+
return __spreadProps(__spreadValues({}, item), {
|
1133
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
1134
|
+
});
|
1135
|
+
})
|
1136
|
+
);
|
1137
|
+
};
|
1138
|
+
|
1050
1139
|
// reducer/actions/insert.ts
|
1051
1140
|
function insertAction(state, action, appStore) {
|
1052
1141
|
const id = action.id || generateId(action.componentType);
|
1053
|
-
const emptyComponentData =
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1142
|
+
const emptyComponentData = populateIds(
|
1143
|
+
{
|
1144
|
+
type: action.componentType,
|
1145
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
1146
|
+
id
|
1147
|
+
})
|
1148
|
+
},
|
1149
|
+
appStore.config
|
1150
|
+
);
|
1059
1151
|
const [parentId] = action.destinationZone.split(":");
|
1060
1152
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1061
|
-
return
|
1153
|
+
return walkAppState(
|
1062
1154
|
state,
|
1063
1155
|
appStore.config,
|
1064
1156
|
(content, zoneCompound) => {
|
@@ -1096,25 +1188,26 @@ var replaceAction = (state, action, appStore) => {
|
|
1096
1188
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1097
1189
|
);
|
1098
1190
|
}
|
1099
|
-
|
1191
|
+
const data = populateIds(action.data, appStore.config);
|
1192
|
+
return walkAppState(
|
1100
1193
|
state,
|
1101
1194
|
appStore.config,
|
1102
1195
|
(content, zoneCompound) => {
|
1103
1196
|
const newContent = [...content];
|
1104
1197
|
if (zoneCompound === action.destinationZone) {
|
1105
|
-
newContent[action.destinationIndex] =
|
1198
|
+
newContent[action.destinationIndex] = data;
|
1106
1199
|
}
|
1107
1200
|
return newContent;
|
1108
1201
|
},
|
1109
1202
|
(childItem, path) => {
|
1110
1203
|
const pathIds = path.map((p) => p.split(":")[0]);
|
1111
|
-
if (childItem.props.id ===
|
1112
|
-
return
|
1204
|
+
if (childItem.props.id === data.props.id) {
|
1205
|
+
return data;
|
1113
1206
|
} else if (childItem.props.id === parentId) {
|
1114
1207
|
return childItem;
|
1115
1208
|
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1116
1209
|
return childItem;
|
1117
|
-
} else if (pathIds.indexOf(
|
1210
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1118
1211
|
return childItem;
|
1119
1212
|
}
|
1120
1213
|
return null;
|
@@ -1125,7 +1218,7 @@ var replaceAction = (state, action, appStore) => {
|
|
1125
1218
|
// reducer/actions/replace-root.ts
|
1126
1219
|
init_react_import();
|
1127
1220
|
var replaceRootAction = (state, action, appStore) => {
|
1128
|
-
return
|
1221
|
+
return walkAppState(
|
1129
1222
|
state,
|
1130
1223
|
appStore.config,
|
1131
1224
|
(content) => content,
|
@@ -1164,7 +1257,7 @@ function duplicateAction(state, action, appStore) {
|
|
1164
1257
|
id: generateId(item.type)
|
1165
1258
|
})
|
1166
1259
|
});
|
1167
|
-
const modified =
|
1260
|
+
const modified = walkAppState(
|
1168
1261
|
state,
|
1169
1262
|
appStore.config,
|
1170
1263
|
(content, zoneCompound) => {
|
@@ -1229,7 +1322,7 @@ var moveAction = (state, action, appStore) => {
|
|
1229
1322
|
if (!item) return state;
|
1230
1323
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1231
1324
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1232
|
-
return
|
1325
|
+
return walkAppState(
|
1233
1326
|
state,
|
1234
1327
|
appStore.config,
|
1235
1328
|
(content, zoneCompound) => {
|
@@ -1287,7 +1380,7 @@ var removeAction = (state, action, appStore) => {
|
|
1287
1380
|
},
|
1288
1381
|
[item.props.id]
|
1289
1382
|
);
|
1290
|
-
const newState =
|
1383
|
+
const newState = walkAppState(
|
1291
1384
|
state,
|
1292
1385
|
appStore.config,
|
1293
1386
|
(content, zoneCompound) => {
|
@@ -1378,14 +1471,14 @@ var setDataAction = (state, action, appStore) => {
|
|
1378
1471
|
console.warn(
|
1379
1472
|
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1380
1473
|
);
|
1381
|
-
return
|
1474
|
+
return walkAppState(
|
1382
1475
|
__spreadProps(__spreadValues({}, state), {
|
1383
1476
|
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1384
1477
|
}),
|
1385
1478
|
appStore.config
|
1386
1479
|
);
|
1387
1480
|
}
|
1388
|
-
return
|
1481
|
+
return walkAppState(
|
1389
1482
|
__spreadProps(__spreadValues({}, state), {
|
1390
1483
|
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1391
1484
|
}),
|
@@ -1770,7 +1863,7 @@ var import_react7 = require("react");
|
|
1770
1863
|
init_react_import();
|
1771
1864
|
var flattenData = (state, config) => {
|
1772
1865
|
const data = [];
|
1773
|
-
|
1866
|
+
walkAppState(
|
1774
1867
|
state,
|
1775
1868
|
config,
|
1776
1869
|
(content) => content,
|
@@ -1935,7 +2028,8 @@ var createFieldsSlice = (_set, _get) => {
|
|
1935
2028
|
return {
|
1936
2029
|
fields: {},
|
1937
2030
|
loading: false,
|
1938
|
-
lastResolvedData: {}
|
2031
|
+
lastResolvedData: {},
|
2032
|
+
id: void 0
|
1939
2033
|
};
|
1940
2034
|
};
|
1941
2035
|
var useRegisterFieldsSlice = (appStore, id) => {
|
@@ -1956,7 +2050,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1956
2050
|
let lastFields = fields;
|
1957
2051
|
if (reset) {
|
1958
2052
|
appStore.setState((s) => ({
|
1959
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
2053
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1960
2054
|
}));
|
1961
2055
|
lastFields = defaultFields;
|
1962
2056
|
}
|
@@ -1984,12 +2078,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1984
2078
|
fields: {
|
1985
2079
|
fields: newFields,
|
1986
2080
|
loading: false,
|
1987
|
-
lastResolvedData: componentData
|
2081
|
+
lastResolvedData: componentData,
|
2082
|
+
id
|
1988
2083
|
}
|
1989
2084
|
});
|
1990
2085
|
} else {
|
1991
2086
|
appStore.setState((s) => ({
|
1992
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
2087
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1993
2088
|
}));
|
1994
2089
|
}
|
1995
2090
|
}),
|
@@ -2006,55 +2101,6 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
2006
2101
|
|
2007
2102
|
// lib/resolve-component-data.ts
|
2008
2103
|
init_react_import();
|
2009
|
-
|
2010
|
-
// lib/data/map-slots.ts
|
2011
|
-
init_react_import();
|
2012
|
-
function mapSlotsAsync(_0, _1) {
|
2013
|
-
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
2014
|
-
const props = __spreadValues({}, item.props);
|
2015
|
-
const propKeys = Object.keys(props);
|
2016
|
-
for (let i = 0; i < propKeys.length; i++) {
|
2017
|
-
const propKey = propKeys[i];
|
2018
|
-
const itemType = "type" in item ? item.type : "root";
|
2019
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
2020
|
-
const content = props[propKey];
|
2021
|
-
const mappedContent = recursive ? yield Promise.all(
|
2022
|
-
content.map((item2) => __async(this, null, function* () {
|
2023
|
-
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
2024
|
-
}))
|
2025
|
-
) : content;
|
2026
|
-
props[propKey] = yield map(mappedContent, propKey);
|
2027
|
-
}
|
2028
|
-
}
|
2029
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
2030
|
-
});
|
2031
|
-
}
|
2032
|
-
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
2033
|
-
const props = __spreadValues({}, item.props);
|
2034
|
-
const propKeys = Object.keys(props);
|
2035
|
-
for (let i = 0; i < propKeys.length; i++) {
|
2036
|
-
const propKey = propKeys[i];
|
2037
|
-
const itemType = "type" in item ? item.type : "root";
|
2038
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
2039
|
-
const content = props[propKey];
|
2040
|
-
const mappedContent = content.map((item2) => {
|
2041
|
-
return mapSlotsSync(item2, map, isSlot2);
|
2042
|
-
});
|
2043
|
-
props[propKey] = map(mappedContent, props.id, propKey);
|
2044
|
-
}
|
2045
|
-
}
|
2046
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
2047
|
-
}
|
2048
|
-
function mapSlotsPublic(item, config, map) {
|
2049
|
-
const isSlot2 = createIsSlotConfig(config);
|
2050
|
-
return mapSlotsSync(
|
2051
|
-
item,
|
2052
|
-
(content, parentId, propName) => map(content, { parentId, propName }),
|
2053
|
-
isSlot2
|
2054
|
-
);
|
2055
|
-
}
|
2056
|
-
|
2057
|
-
// lib/resolve-component-data.ts
|
2058
2104
|
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
2059
2105
|
var cache = { lastChange: {} };
|
2060
2106
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
@@ -2134,7 +2180,8 @@ var toRoot = (item) => {
|
|
2134
2180
|
return { props: {}, readOnly };
|
2135
2181
|
};
|
2136
2182
|
|
2137
|
-
// store/
|
2183
|
+
// store/default-app-state.ts
|
2184
|
+
init_react_import();
|
2138
2185
|
var defaultAppState = {
|
2139
2186
|
data: { content: [], root: {}, zones: {} },
|
2140
2187
|
ui: {
|
@@ -2160,6 +2207,8 @@ var defaultAppState = {
|
|
2160
2207
|
zones: {}
|
2161
2208
|
}
|
2162
2209
|
};
|
2210
|
+
|
2211
|
+
// store/index.ts
|
2163
2212
|
var defaultPageFields = {
|
2164
2213
|
title: { type: "text" }
|
2165
2214
|
};
|
@@ -2299,7 +2348,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
2299
2348
|
}),
|
2300
2349
|
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2301
2350
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2302
|
-
|
2351
|
+
walkAppState(
|
2303
2352
|
state,
|
2304
2353
|
config,
|
2305
2354
|
(content) => content,
|
@@ -2348,314 +2397,11 @@ function useAppStoreApi() {
|
|
2348
2397
|
init_react_import();
|
2349
2398
|
var import_react12 = require("@dnd-kit/react");
|
2350
2399
|
|
2351
|
-
// lib/dnd/dnd-kit/safe.ts
|
2352
|
-
init_react_import();
|
2353
|
-
var import_react10 = require("@dnd-kit/react");
|
2354
|
-
var import_sortable = require("@dnd-kit/react/sortable");
|
2355
|
-
function useDroppableSafe(input) {
|
2356
|
-
if (typeof window === "undefined") {
|
2357
|
-
return { ref: () => {
|
2358
|
-
} };
|
2359
|
-
}
|
2360
|
-
return (0, import_react10.useDroppable)(input);
|
2361
|
-
}
|
2362
|
-
function useDraggableSafe(input) {
|
2363
|
-
if (typeof window === "undefined") {
|
2364
|
-
return { ref: () => {
|
2365
|
-
} };
|
2366
|
-
}
|
2367
|
-
return (0, import_react10.useDraggable)(input);
|
2368
|
-
}
|
2369
|
-
function useSortableSafe(input) {
|
2370
|
-
if (typeof window === "undefined") {
|
2371
|
-
return { ref: () => {
|
2372
|
-
}, status: "idle", handleRef: () => {
|
2373
|
-
} };
|
2374
|
-
}
|
2375
|
-
return (0, import_sortable.useSortable)(input);
|
2376
|
-
}
|
2377
|
-
|
2378
2400
|
// lib/dnd/use-sensors.ts
|
2379
2401
|
init_react_import();
|
2380
|
-
var
|
2381
|
-
|
2382
|
-
// lib/dnd/PointerSensor.ts
|
2383
|
-
init_react_import();
|
2384
|
-
var import_state = require("@dnd-kit/state");
|
2385
|
-
var import_abstract = require("@dnd-kit/abstract");
|
2386
|
-
var import_geometry = require("@dnd-kit/geometry");
|
2402
|
+
var import_react10 = require("react");
|
2403
|
+
var import_react11 = require("@dnd-kit/react");
|
2387
2404
|
var import_utilities = require("@dnd-kit/dom/utilities");
|
2388
|
-
var _clearTimeout;
|
2389
|
-
var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
|
2390
|
-
constructor(manager, options) {
|
2391
|
-
super(manager);
|
2392
|
-
this.manager = manager;
|
2393
|
-
this.options = options;
|
2394
|
-
this.listeners = new import_utilities.Listeners();
|
2395
|
-
this.cleanup = /* @__PURE__ */ new Set();
|
2396
|
-
this.source = void 0;
|
2397
|
-
this.started = false;
|
2398
|
-
__privateAdd(this, _clearTimeout);
|
2399
|
-
this.handleCancel = this.handleCancel.bind(this);
|
2400
|
-
this.handlePointerUp = this.handlePointerUp.bind(this);
|
2401
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
2402
|
-
(0, import_state.effect)(() => {
|
2403
|
-
const unbindGlobal = this.bindGlobal(options != null ? options : {});
|
2404
|
-
return () => {
|
2405
|
-
unbindGlobal();
|
2406
|
-
};
|
2407
|
-
});
|
2408
|
-
}
|
2409
|
-
bind(source, options = this.options) {
|
2410
|
-
const unbind = (0, import_state.effect)(() => {
|
2411
|
-
var _a;
|
2412
|
-
const target = (_a = source.handle) != null ? _a : source.element;
|
2413
|
-
const listener = (event) => {
|
2414
|
-
if ((0, import_utilities.isPointerEvent)(event)) {
|
2415
|
-
this.handlePointerDown(event, source, options);
|
2416
|
-
}
|
2417
|
-
};
|
2418
|
-
if (target) {
|
2419
|
-
patchWindow(target.ownerDocument.defaultView);
|
2420
|
-
target.addEventListener("pointerdown", listener);
|
2421
|
-
return () => {
|
2422
|
-
target.removeEventListener("pointerdown", listener);
|
2423
|
-
};
|
2424
|
-
}
|
2425
|
-
});
|
2426
|
-
return unbind;
|
2427
|
-
}
|
2428
|
-
bindGlobal(options) {
|
2429
|
-
const documents = /* @__PURE__ */ new Set();
|
2430
|
-
for (const draggable of this.manager.registry.draggables.value) {
|
2431
|
-
if (draggable.element) {
|
2432
|
-
documents.add((0, import_utilities.getDocument)(draggable.element));
|
2433
|
-
}
|
2434
|
-
}
|
2435
|
-
for (const droppable of this.manager.registry.droppables.value) {
|
2436
|
-
if (droppable.element) {
|
2437
|
-
documents.add((0, import_utilities.getDocument)(droppable.element));
|
2438
|
-
}
|
2439
|
-
}
|
2440
|
-
const unbindFns = Array.from(documents).map(
|
2441
|
-
(doc) => this.listeners.bind(doc, [
|
2442
|
-
{
|
2443
|
-
type: "pointermove",
|
2444
|
-
listener: (event) => this.handlePointerMove(event, doc, options)
|
2445
|
-
},
|
2446
|
-
{
|
2447
|
-
type: "pointerup",
|
2448
|
-
listener: this.handlePointerUp,
|
2449
|
-
options: {
|
2450
|
-
capture: true
|
2451
|
-
}
|
2452
|
-
},
|
2453
|
-
{
|
2454
|
-
// Cancel activation if there is a competing Drag and Drop interaction
|
2455
|
-
type: "dragstart",
|
2456
|
-
listener: this.handleDragStart
|
2457
|
-
}
|
2458
|
-
])
|
2459
|
-
);
|
2460
|
-
return () => {
|
2461
|
-
unbindFns.forEach((unbind) => unbind());
|
2462
|
-
};
|
2463
|
-
}
|
2464
|
-
handlePointerDown(event, source, options = {}) {
|
2465
|
-
if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
|
2466
|
-
return;
|
2467
|
-
}
|
2468
|
-
const offset = (0, import_utilities.getFrameTransform)(source.element);
|
2469
|
-
this.initialCoordinates = {
|
2470
|
-
x: event.clientX * offset.scaleX + offset.x,
|
2471
|
-
y: event.clientY * offset.scaleY + offset.y
|
2472
|
-
};
|
2473
|
-
this.source = source;
|
2474
|
-
const { activationConstraints } = options;
|
2475
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
2476
|
-
event.stopImmediatePropagation();
|
2477
|
-
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
2478
|
-
this.handleStart(source, event);
|
2479
|
-
} else {
|
2480
|
-
const { delay } = constraints;
|
2481
|
-
if (delay) {
|
2482
|
-
const timeout3 = setTimeout(
|
2483
|
-
() => this.handleStart(source, event),
|
2484
|
-
delay.value
|
2485
|
-
);
|
2486
|
-
__privateSet(this, _clearTimeout, () => {
|
2487
|
-
clearTimeout(timeout3);
|
2488
|
-
__privateSet(this, _clearTimeout, void 0);
|
2489
|
-
});
|
2490
|
-
}
|
2491
|
-
}
|
2492
|
-
const cleanup = () => {
|
2493
|
-
var _a;
|
2494
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2495
|
-
this.initialCoordinates = void 0;
|
2496
|
-
this.source = void 0;
|
2497
|
-
};
|
2498
|
-
this.cleanup.add(cleanup);
|
2499
|
-
}
|
2500
|
-
handlePointerMove(event, doc, options) {
|
2501
|
-
if (!this.source) {
|
2502
|
-
return;
|
2503
|
-
}
|
2504
|
-
const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
|
2505
|
-
if (doc !== ownerDocument) {
|
2506
|
-
return;
|
2507
|
-
}
|
2508
|
-
const coordinates = {
|
2509
|
-
x: event.clientX,
|
2510
|
-
y: event.clientY
|
2511
|
-
};
|
2512
|
-
const offset = (0, import_utilities.getFrameTransform)(this.source.element);
|
2513
|
-
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
2514
|
-
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
2515
|
-
if (this.manager.dragOperation.status.dragging) {
|
2516
|
-
event.preventDefault();
|
2517
|
-
event.stopPropagation();
|
2518
|
-
this.manager.actions.move({ to: coordinates });
|
2519
|
-
return;
|
2520
|
-
}
|
2521
|
-
if (!this.initialCoordinates) {
|
2522
|
-
return;
|
2523
|
-
}
|
2524
|
-
const delta = {
|
2525
|
-
x: coordinates.x - this.initialCoordinates.x,
|
2526
|
-
y: coordinates.y - this.initialCoordinates.y
|
2527
|
-
};
|
2528
|
-
const { activationConstraints } = options;
|
2529
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
|
2530
|
-
const { distance, delay } = constraints != null ? constraints : {};
|
2531
|
-
if (distance) {
|
2532
|
-
if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
|
2533
|
-
return this.handleCancel();
|
2534
|
-
}
|
2535
|
-
if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
|
2536
|
-
return this.handleStart(this.source, event);
|
2537
|
-
}
|
2538
|
-
}
|
2539
|
-
if (delay) {
|
2540
|
-
if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
|
2541
|
-
return this.handleCancel();
|
2542
|
-
}
|
2543
|
-
}
|
2544
|
-
}
|
2545
|
-
handlePointerUp(event) {
|
2546
|
-
if (!this.source) {
|
2547
|
-
return;
|
2548
|
-
}
|
2549
|
-
event.preventDefault();
|
2550
|
-
event.stopPropagation();
|
2551
|
-
const { status } = this.manager.dragOperation;
|
2552
|
-
if (!status.idle) {
|
2553
|
-
const canceled = !status.initialized;
|
2554
|
-
this.manager.actions.stop({ canceled });
|
2555
|
-
} else if (this.started) {
|
2556
|
-
setTimeout(() => {
|
2557
|
-
if (!this.manager.dragOperation.status.idle) {
|
2558
|
-
this.manager.actions.stop({ canceled: false });
|
2559
|
-
}
|
2560
|
-
}, 10);
|
2561
|
-
}
|
2562
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2563
|
-
this.cleanup.clear();
|
2564
|
-
}
|
2565
|
-
handleKeyDown(event) {
|
2566
|
-
if (event.key === "Escape") {
|
2567
|
-
event.preventDefault();
|
2568
|
-
this.handleCancel();
|
2569
|
-
}
|
2570
|
-
}
|
2571
|
-
handleStart(source, event) {
|
2572
|
-
var _a;
|
2573
|
-
const { manager, initialCoordinates } = this;
|
2574
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2575
|
-
if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
|
2576
|
-
return;
|
2577
|
-
}
|
2578
|
-
if (event.defaultPrevented) {
|
2579
|
-
return;
|
2580
|
-
}
|
2581
|
-
this.started = true;
|
2582
|
-
event.preventDefault();
|
2583
|
-
(0, import_state.batch)(() => {
|
2584
|
-
manager.actions.setDragSource(source.id);
|
2585
|
-
manager.actions.start({ coordinates: initialCoordinates, event });
|
2586
|
-
});
|
2587
|
-
const ownerDocument = (0, import_utilities.getDocument)(event.target);
|
2588
|
-
const unbind = this.listeners.bind(ownerDocument, [
|
2589
|
-
{
|
2590
|
-
// Prevent scrolling on touch devices
|
2591
|
-
type: "touchmove",
|
2592
|
-
listener: preventDefault,
|
2593
|
-
options: {
|
2594
|
-
passive: false
|
2595
|
-
}
|
2596
|
-
},
|
2597
|
-
{
|
2598
|
-
// Prevent click events
|
2599
|
-
type: "click",
|
2600
|
-
listener: preventDefault
|
2601
|
-
},
|
2602
|
-
{
|
2603
|
-
type: "keydown",
|
2604
|
-
listener: this.handleKeyDown
|
2605
|
-
}
|
2606
|
-
]);
|
2607
|
-
ownerDocument.body.setPointerCapture(event.pointerId);
|
2608
|
-
this.cleanup.add(unbind);
|
2609
|
-
this.cleanup.add(() => {
|
2610
|
-
this.started = false;
|
2611
|
-
});
|
2612
|
-
}
|
2613
|
-
handleDragStart(event) {
|
2614
|
-
const { target } = event;
|
2615
|
-
if (!(0, import_utilities.isElement)(target)) {
|
2616
|
-
return;
|
2617
|
-
}
|
2618
|
-
const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
|
2619
|
-
if (isNativeDraggable) {
|
2620
|
-
this.handleCancel();
|
2621
|
-
} else {
|
2622
|
-
preventDefault(event);
|
2623
|
-
}
|
2624
|
-
}
|
2625
|
-
handleCancel() {
|
2626
|
-
const { dragOperation } = this.manager;
|
2627
|
-
if (dragOperation.status.initialized) {
|
2628
|
-
this.manager.actions.stop({ canceled: true });
|
2629
|
-
}
|
2630
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2631
|
-
this.cleanup.clear();
|
2632
|
-
}
|
2633
|
-
destroy() {
|
2634
|
-
this.listeners.clear();
|
2635
|
-
}
|
2636
|
-
};
|
2637
|
-
_clearTimeout = new WeakMap();
|
2638
|
-
_PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
|
2639
|
-
var PointerSensor = _PointerSensor;
|
2640
|
-
function preventDefault(event) {
|
2641
|
-
event.preventDefault();
|
2642
|
-
}
|
2643
|
-
function noop() {
|
2644
|
-
}
|
2645
|
-
var windows = /* @__PURE__ */ new WeakSet();
|
2646
|
-
function patchWindow(window2) {
|
2647
|
-
if (!window2 || windows.has(window2)) {
|
2648
|
-
return;
|
2649
|
-
}
|
2650
|
-
window2.addEventListener("touchmove", noop, {
|
2651
|
-
capture: false,
|
2652
|
-
passive: false
|
2653
|
-
});
|
2654
|
-
windows.add(window2);
|
2655
|
-
}
|
2656
|
-
|
2657
|
-
// lib/dnd/use-sensors.ts
|
2658
|
-
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
2659
2405
|
var useSensors = ({
|
2660
2406
|
other,
|
2661
2407
|
mouse,
|
@@ -2664,12 +2410,12 @@ var useSensors = ({
|
|
2664
2410
|
touch: { delay: { value: 200, tolerance: 10 } },
|
2665
2411
|
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
2666
2412
|
}) => {
|
2667
|
-
const [sensors] = (0,
|
2668
|
-
PointerSensor.configure({
|
2413
|
+
const [sensors] = (0, import_react10.useState)(() => [
|
2414
|
+
import_react11.PointerSensor.configure({
|
2669
2415
|
activationConstraints(event, source) {
|
2670
2416
|
var _a;
|
2671
2417
|
const { pointerType, target } = event;
|
2672
|
-
if (pointerType === "mouse" && (0,
|
2418
|
+
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
2673
2419
|
return mouse;
|
2674
2420
|
}
|
2675
2421
|
if (pointerType === "touch") {
|
@@ -2684,11 +2430,11 @@ var useSensors = ({
|
|
2684
2430
|
|
2685
2431
|
// lib/dnd/collision/dynamic/index.ts
|
2686
2432
|
init_react_import();
|
2687
|
-
var
|
2433
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
2688
2434
|
|
2689
2435
|
// lib/dnd/collision/directional/index.ts
|
2690
2436
|
init_react_import();
|
2691
|
-
var
|
2437
|
+
var import_abstract = require("@dnd-kit/abstract");
|
2692
2438
|
|
2693
2439
|
// lib/dnd/collision/collision-debug.ts
|
2694
2440
|
init_react_import();
|
@@ -2766,7 +2512,7 @@ var directionalCollision = (input, previous) => {
|
|
2766
2512
|
return {
|
2767
2513
|
id: droppable.id,
|
2768
2514
|
value: 1,
|
2769
|
-
type:
|
2515
|
+
type: import_abstract.CollisionType.Collision
|
2770
2516
|
};
|
2771
2517
|
}
|
2772
2518
|
return null;
|
@@ -2808,7 +2554,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2808
2554
|
|
2809
2555
|
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2810
2556
|
init_react_import();
|
2811
|
-
var
|
2557
|
+
var import_geometry = require("@dnd-kit/geometry");
|
2812
2558
|
var INTERVAL_SENSITIVITY = 10;
|
2813
2559
|
var intervalCache = {
|
2814
2560
|
current: { x: 0, y: 0 },
|
@@ -2824,13 +2570,15 @@ var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
|
2824
2570
|
};
|
2825
2571
|
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
2826
2572
|
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
2827
|
-
intervalCache.previous =
|
2573
|
+
intervalCache.previous = import_geometry.Point.from(point);
|
2828
2574
|
}
|
2829
2575
|
return intervalCache;
|
2830
2576
|
};
|
2831
2577
|
|
2832
2578
|
// ../../node_modules/@dnd-kit/collision/dist/index.js
|
2833
2579
|
init_react_import();
|
2580
|
+
var import_abstract2 = require("@dnd-kit/abstract");
|
2581
|
+
var import_geometry2 = require("@dnd-kit/geometry");
|
2834
2582
|
var import_abstract3 = require("@dnd-kit/abstract");
|
2835
2583
|
var import_geometry3 = require("@dnd-kit/geometry");
|
2836
2584
|
var import_abstract4 = require("@dnd-kit/abstract");
|
@@ -2841,8 +2589,6 @@ var import_abstract6 = require("@dnd-kit/abstract");
|
|
2841
2589
|
var import_geometry6 = require("@dnd-kit/geometry");
|
2842
2590
|
var import_abstract7 = require("@dnd-kit/abstract");
|
2843
2591
|
var import_geometry7 = require("@dnd-kit/geometry");
|
2844
|
-
var import_abstract8 = require("@dnd-kit/abstract");
|
2845
|
-
var import_geometry8 = require("@dnd-kit/geometry");
|
2846
2592
|
var pointerIntersection = ({
|
2847
2593
|
dragOperation,
|
2848
2594
|
droppable
|
@@ -2856,12 +2602,12 @@ var pointerIntersection = ({
|
|
2856
2602
|
return null;
|
2857
2603
|
}
|
2858
2604
|
if (droppable.shape.containsPoint(pointerCoordinates)) {
|
2859
|
-
const distance =
|
2605
|
+
const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
|
2860
2606
|
return {
|
2861
2607
|
id,
|
2862
2608
|
value: 1 / distance,
|
2863
|
-
type:
|
2864
|
-
priority:
|
2609
|
+
type: import_abstract2.CollisionType.PointerIntersection,
|
2610
|
+
priority: import_abstract2.CollisionPriority.High
|
2865
2611
|
};
|
2866
2612
|
}
|
2867
2613
|
return null;
|
@@ -2872,31 +2618,15 @@ var closestCorners = (input) => {
|
|
2872
2618
|
if (!droppable.shape) {
|
2873
2619
|
return null;
|
2874
2620
|
}
|
2875
|
-
const
|
2876
|
-
const
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
},
|
2881
|
-
{
|
2882
|
-
x: right,
|
2883
|
-
y: top
|
2884
|
-
},
|
2885
|
-
{
|
2886
|
-
x: left,
|
2887
|
-
y: bottom
|
2888
|
-
},
|
2889
|
-
{
|
2890
|
-
x: right,
|
2891
|
-
y: bottom
|
2892
|
-
}
|
2893
|
-
];
|
2894
|
-
const distance = corners.reduce(
|
2895
|
-
(acc, corner) => {
|
2621
|
+
const shapeCorners = shape ? import_geometry4.Rectangle.from(shape.current.boundingRectangle).corners : void 0;
|
2622
|
+
const distance = import_geometry4.Rectangle.from(
|
2623
|
+
droppable.shape.boundingRectangle
|
2624
|
+
).corners.reduce(
|
2625
|
+
(acc, corner, index) => {
|
2896
2626
|
var _a;
|
2897
|
-
return acc +
|
2898
|
-
|
2899
|
-
(_a =
|
2627
|
+
return acc + import_geometry4.Point.distance(
|
2628
|
+
import_geometry4.Point.from(corner),
|
2629
|
+
(_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
|
2900
2630
|
);
|
2901
2631
|
},
|
2902
2632
|
0
|
@@ -2905,8 +2635,8 @@ var closestCorners = (input) => {
|
|
2905
2635
|
return {
|
2906
2636
|
id: droppable.id,
|
2907
2637
|
value: 1 / value,
|
2908
|
-
type:
|
2909
|
-
priority:
|
2638
|
+
type: import_abstract4.CollisionType.Collision,
|
2639
|
+
priority: import_abstract4.CollisionPriority.Normal
|
2910
2640
|
};
|
2911
2641
|
};
|
2912
2642
|
|
@@ -2931,12 +2661,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2931
2661
|
const { center: dragCenter } = dragShape;
|
2932
2662
|
const { fallbackEnabled } = collisionStore.getState();
|
2933
2663
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2934
|
-
|
2935
|
-
direction: interval.direction
|
2936
|
-
});
|
2937
|
-
const collisionMap = dragOperation.data.collisionMap || {};
|
2938
|
-
dragOperation.data.collisionMap = collisionMap;
|
2939
|
-
collisionMap[droppable.id] = {
|
2664
|
+
const data = {
|
2940
2665
|
direction: interval.direction
|
2941
2666
|
};
|
2942
2667
|
const { center: dropCenter } = dropShape;
|
@@ -2951,7 +2676,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2951
2676
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
2952
2677
|
if (collision) {
|
2953
2678
|
return __spreadProps(__spreadValues({}, collision), {
|
2954
|
-
priority:
|
2679
|
+
priority: import_abstract8.CollisionPriority.Highest,
|
2680
|
+
data
|
2955
2681
|
});
|
2956
2682
|
}
|
2957
2683
|
}
|
@@ -2968,12 +2694,12 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2968
2694
|
const collision = {
|
2969
2695
|
id: droppable.id,
|
2970
2696
|
value: intersectionRatio,
|
2971
|
-
priority:
|
2972
|
-
type:
|
2697
|
+
priority: import_abstract8.CollisionPriority.High,
|
2698
|
+
type: import_abstract8.CollisionType.Collision
|
2973
2699
|
};
|
2974
2700
|
const shouldFlushId = flushNext === droppable.id;
|
2975
2701
|
flushNext = "";
|
2976
|
-
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2702
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
|
2977
2703
|
}
|
2978
2704
|
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2979
2705
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
@@ -2985,9 +2711,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2985
2711
|
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
2986
2712
|
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
2987
2713
|
});
|
2988
|
-
|
2989
|
-
direction
|
2990
|
-
};
|
2714
|
+
data.direction = direction;
|
2991
2715
|
if (intersectionArea) {
|
2992
2716
|
collisionDebug(
|
2993
2717
|
dragCenter,
|
@@ -2998,7 +2722,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2998
2722
|
);
|
2999
2723
|
flushNext = droppable.id;
|
3000
2724
|
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
3001
|
-
priority:
|
2725
|
+
priority: import_abstract8.CollisionPriority.Low,
|
2726
|
+
data
|
3002
2727
|
});
|
3003
2728
|
}
|
3004
2729
|
collisionDebug(
|
@@ -3008,16 +2733,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
3008
2733
|
"orange",
|
3009
2734
|
direction || ""
|
3010
2735
|
);
|
3011
|
-
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2736
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2737
|
+
priority: import_abstract8.CollisionPriority.Lowest,
|
2738
|
+
data
|
2739
|
+
});
|
3012
2740
|
}
|
3013
2741
|
}
|
3014
2742
|
}
|
3015
2743
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
3016
|
-
delete collisionMap[droppable.id];
|
3017
2744
|
return null;
|
3018
2745
|
};
|
3019
2746
|
|
3020
2747
|
// components/Sortable/index.tsx
|
2748
|
+
var import_sortable = require("@dnd-kit/react/sortable");
|
3021
2749
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
3022
2750
|
var SortableProvider = ({
|
3023
2751
|
children,
|
@@ -3037,16 +2765,16 @@ var SortableProvider = ({
|
|
3037
2765
|
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
3038
2766
|
},
|
3039
2767
|
onDragOver: (event, manager) => {
|
3040
|
-
var _a
|
2768
|
+
var _a;
|
3041
2769
|
event.preventDefault();
|
3042
2770
|
const { operation } = event;
|
3043
2771
|
const { source, target } = operation;
|
3044
2772
|
if (!source || !target) return;
|
3045
2773
|
let sourceIndex = source.data.index;
|
3046
2774
|
let targetIndex = target.data.index;
|
3047
|
-
const collisionData = (
|
2775
|
+
const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
|
3048
2776
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
3049
|
-
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2777
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
|
3050
2778
|
if (targetIndex >= sourceIndex) {
|
3051
2779
|
targetIndex = targetIndex - 1;
|
3052
2780
|
}
|
@@ -3077,9 +2805,10 @@ var Sortable = ({
|
|
3077
2805
|
}) => {
|
3078
2806
|
const {
|
3079
2807
|
ref: sortableRef,
|
3080
|
-
|
2808
|
+
isDragging,
|
2809
|
+
isDropping,
|
3081
2810
|
handleRef
|
3082
|
-
} =
|
2811
|
+
} = (0, import_sortable.useSortable)({
|
3083
2812
|
id,
|
3084
2813
|
type,
|
3085
2814
|
index,
|
@@ -3087,7 +2816,7 @@ var Sortable = ({
|
|
3087
2816
|
data: { index },
|
3088
2817
|
collisionDetector: createDynamicCollisionDetector("y")
|
3089
2818
|
});
|
3090
|
-
return children({
|
2819
|
+
return children({ isDragging, isDropping, ref: sortableRef, handleRef });
|
3091
2820
|
};
|
3092
2821
|
|
3093
2822
|
// components/AutoField/context.tsx
|
@@ -3212,7 +2941,7 @@ var ArrayField = ({
|
|
3212
2941
|
}
|
3213
2942
|
}, []);
|
3214
2943
|
const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
|
3215
|
-
const
|
2944
|
+
const isDraggingAny = !!draggedItem;
|
3216
2945
|
const canEdit = useAppStore(
|
3217
2946
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
3218
2947
|
);
|
@@ -3277,13 +3006,13 @@ var ArrayField = ({
|
|
3277
3006
|
id: _arrayId,
|
3278
3007
|
index: i,
|
3279
3008
|
disabled: readOnly,
|
3280
|
-
children: ({
|
3009
|
+
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3281
3010
|
"div",
|
3282
3011
|
{
|
3283
3012
|
ref,
|
3284
3013
|
className: getClassNameItem({
|
3285
3014
|
isExpanded: arrayState.openId === _arrayId,
|
3286
|
-
isDragging
|
3015
|
+
isDragging,
|
3287
3016
|
readOnly
|
3288
3017
|
}),
|
3289
3018
|
children: [
|
@@ -3424,7 +3153,7 @@ var ArrayField = ({
|
|
3424
3153
|
type: "button",
|
3425
3154
|
className: getClassName5("addButton"),
|
3426
3155
|
onClick: () => {
|
3427
|
-
if (
|
3156
|
+
if (isDraggingAny) return;
|
3428
3157
|
const existingValue = value || [];
|
3429
3158
|
const newValue = [
|
3430
3159
|
...existingValue,
|
@@ -4407,24 +4136,24 @@ init_react_import();
|
|
4407
4136
|
|
4408
4137
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
4409
4138
|
init_react_import();
|
4410
|
-
var styles_module_default10 = { "Drawer": "
|
4139
|
+
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" };
|
4411
4140
|
|
4412
4141
|
// components/Drawer/index.tsx
|
4413
|
-
var
|
4142
|
+
var import_react39 = require("react");
|
4414
4143
|
|
4415
4144
|
// components/DragDropContext/index.tsx
|
4416
4145
|
init_react_import();
|
4417
|
-
var
|
4418
|
-
var
|
4146
|
+
var import_react37 = require("@dnd-kit/react");
|
4147
|
+
var import_react38 = require("react");
|
4419
4148
|
var import_dom = require("@dnd-kit/dom");
|
4420
4149
|
|
4421
4150
|
// components/DropZone/index.tsx
|
4422
4151
|
init_react_import();
|
4423
|
-
var
|
4152
|
+
var import_react35 = require("react");
|
4424
4153
|
|
4425
4154
|
// components/DraggableComponent/index.tsx
|
4426
4155
|
init_react_import();
|
4427
|
-
var
|
4156
|
+
var import_react26 = require("react");
|
4428
4157
|
|
4429
4158
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
4430
4159
|
init_react_import();
|
@@ -4465,7 +4194,9 @@ var ZoneStoreContext = (0, import_react23.createContext)(
|
|
4465
4194
|
areaDepthIndex: {},
|
4466
4195
|
nextAreaDepthIndex: {},
|
4467
4196
|
draggedItem: null,
|
4468
|
-
previewIndex: {}
|
4197
|
+
previewIndex: {},
|
4198
|
+
enabledIndex: {},
|
4199
|
+
hoveringComponent: null
|
4469
4200
|
}))
|
4470
4201
|
);
|
4471
4202
|
var ZoneStoreProvider = ({
|
@@ -4478,7 +4209,6 @@ var DropZoneProvider = ({
|
|
4478
4209
|
children,
|
4479
4210
|
value
|
4480
4211
|
}) => {
|
4481
|
-
const [hoveringComponent, setHoveringComponent] = (0, import_react23.useState)();
|
4482
4212
|
const dispatch = useAppStore((s) => s.dispatch);
|
4483
4213
|
const registerZone = (0, import_react23.useCallback)(
|
4484
4214
|
(zoneCompound) => {
|
@@ -4500,16 +4230,18 @@ var DropZoneProvider = ({
|
|
4500
4230
|
);
|
4501
4231
|
const memoValue = (0, import_react23.useMemo)(
|
4502
4232
|
() => __spreadValues({
|
4503
|
-
hoveringComponent,
|
4504
|
-
setHoveringComponent,
|
4505
4233
|
registerZone,
|
4506
4234
|
unregisterZone
|
4507
4235
|
}, value),
|
4508
|
-
[value
|
4236
|
+
[value]
|
4509
4237
|
);
|
4510
4238
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
4511
4239
|
};
|
4512
4240
|
|
4241
|
+
// components/DraggableComponent/index.tsx
|
4242
|
+
var import_shallow2 = require("zustand/react/shallow");
|
4243
|
+
var import_sortable2 = require("@dnd-kit/react/sortable");
|
4244
|
+
|
4513
4245
|
// lib/use-context-store.ts
|
4514
4246
|
init_react_import();
|
4515
4247
|
var import_react24 = require("react");
|
@@ -4523,8 +4255,37 @@ function useContextStore(context, selector) {
|
|
4523
4255
|
return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
|
4524
4256
|
}
|
4525
4257
|
|
4258
|
+
// lib/dnd/use-on-drag-finished.ts
|
4259
|
+
init_react_import();
|
4260
|
+
var import_react25 = require("react");
|
4261
|
+
var useOnDragFinished = (cb, deps = []) => {
|
4262
|
+
const appStore = useAppStoreApi();
|
4263
|
+
return (0, import_react25.useCallback)(() => {
|
4264
|
+
let dispose = () => {
|
4265
|
+
};
|
4266
|
+
const processDragging = (isDragging2) => {
|
4267
|
+
if (isDragging2) {
|
4268
|
+
cb(false);
|
4269
|
+
} else {
|
4270
|
+
cb(true);
|
4271
|
+
if (dispose) dispose();
|
4272
|
+
}
|
4273
|
+
};
|
4274
|
+
const isDragging = appStore.getState().state.ui.isDragging;
|
4275
|
+
processDragging(isDragging);
|
4276
|
+
if (isDragging) {
|
4277
|
+
dispose = appStore.subscribe(
|
4278
|
+
(s) => s.state.ui.isDragging,
|
4279
|
+
(isDragging2) => {
|
4280
|
+
processDragging(isDragging2);
|
4281
|
+
}
|
4282
|
+
);
|
4283
|
+
}
|
4284
|
+
return dispose;
|
4285
|
+
}, [appStore, ...deps]);
|
4286
|
+
};
|
4287
|
+
|
4526
4288
|
// components/DraggableComponent/index.tsx
|
4527
|
-
var import_shallow2 = require("zustand/react/shallow");
|
4528
4289
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
4529
4290
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
4530
4291
|
var DEBUG2 = false;
|
@@ -4554,7 +4315,6 @@ var DraggableComponent = ({
|
|
4554
4315
|
isSelected = false,
|
4555
4316
|
debug,
|
4556
4317
|
label,
|
4557
|
-
isEnabled,
|
4558
4318
|
autoDragAxis,
|
4559
4319
|
userDragAxis,
|
4560
4320
|
inDroppableZone = true
|
@@ -4568,9 +4328,9 @@ var DraggableComponent = ({
|
|
4568
4328
|
const overrides = useAppStore((s) => s.overrides);
|
4569
4329
|
const dispatch = useAppStore((s) => s.dispatch);
|
4570
4330
|
const iframe = useAppStore((s) => s.iframe);
|
4571
|
-
const ctx = (0,
|
4572
|
-
const [localZones, setLocalZones] = (0,
|
4573
|
-
const registerLocalZone = (0,
|
4331
|
+
const ctx = (0, import_react26.useContext)(dropZoneContext);
|
4332
|
+
const [localZones, setLocalZones] = (0, import_react26.useState)({});
|
4333
|
+
const registerLocalZone = (0, import_react26.useCallback)(
|
4574
4334
|
(zoneCompound2, active) => {
|
4575
4335
|
var _a;
|
4576
4336
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -4580,7 +4340,7 @@ var DraggableComponent = ({
|
|
4580
4340
|
},
|
4581
4341
|
[setLocalZones]
|
4582
4342
|
);
|
4583
|
-
const unregisterLocalZone = (0,
|
4343
|
+
const unregisterLocalZone = (0, import_react26.useCallback)(
|
4584
4344
|
(zoneCompound2) => {
|
4585
4345
|
var _a;
|
4586
4346
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -4603,14 +4363,17 @@ var DraggableComponent = ({
|
|
4603
4363
|
return s.permissions.getPermissions({ item });
|
4604
4364
|
})
|
4605
4365
|
);
|
4606
|
-
const
|
4607
|
-
|
4608
|
-
|
4366
|
+
const zoneStore = (0, import_react26.useContext)(ZoneStoreContext);
|
4367
|
+
const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
|
4368
|
+
const dynamicCollisionDetector = (0, import_react26.useMemo)(
|
4369
|
+
() => createDynamicCollisionDetector(dragAxis),
|
4370
|
+
[dragAxis]
|
4609
4371
|
);
|
4610
|
-
const
|
4611
|
-
|
4612
|
-
|
4613
|
-
|
4372
|
+
const {
|
4373
|
+
ref: sortableRef,
|
4374
|
+
isDragging: thisIsDragging,
|
4375
|
+
sortable
|
4376
|
+
} = (0, import_sortable2.useSortable)({
|
4614
4377
|
id,
|
4615
4378
|
index,
|
4616
4379
|
group: zoneCompound,
|
@@ -4625,18 +4388,34 @@ var DraggableComponent = ({
|
|
4625
4388
|
path: path || [],
|
4626
4389
|
inDroppableZone
|
4627
4390
|
},
|
4628
|
-
collisionPriority:
|
4629
|
-
collisionDetector:
|
4630
|
-
disabled,
|
4391
|
+
collisionPriority: depth,
|
4392
|
+
collisionDetector: dynamicCollisionDetector,
|
4631
4393
|
// "Out of the way" transition from react-beautiful-dnd
|
4632
4394
|
transition: {
|
4633
4395
|
duration: 200,
|
4634
4396
|
easing: "cubic-bezier(0.2, 0, 0, 1)"
|
4635
|
-
}
|
4397
|
+
},
|
4398
|
+
feedback: "clone"
|
4636
4399
|
});
|
4637
|
-
|
4638
|
-
|
4639
|
-
|
4400
|
+
(0, import_react26.useEffect)(() => {
|
4401
|
+
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
4402
|
+
sortable.droppable.disabled = !isEnabled;
|
4403
|
+
sortable.draggable.disabled = !permissions.drag;
|
4404
|
+
const cleanup = zoneStore.subscribe((s) => {
|
4405
|
+
sortable.droppable.disabled = !s.enabledIndex[zoneCompound];
|
4406
|
+
});
|
4407
|
+
if (ref.current && !permissions.drag) {
|
4408
|
+
ref.current.setAttribute("data-puck-disabled", "");
|
4409
|
+
return () => {
|
4410
|
+
var _a;
|
4411
|
+
(_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
|
4412
|
+
cleanup();
|
4413
|
+
};
|
4414
|
+
}
|
4415
|
+
return cleanup;
|
4416
|
+
}, [permissions.drag, zoneCompound]);
|
4417
|
+
const ref = (0, import_react26.useRef)(null);
|
4418
|
+
const refSetter = (0, import_react26.useCallback)(
|
4640
4419
|
(el) => {
|
4641
4420
|
sortableRef(el);
|
4642
4421
|
if (el) {
|
@@ -4645,14 +4424,14 @@ var DraggableComponent = ({
|
|
4645
4424
|
},
|
4646
4425
|
[sortableRef]
|
4647
4426
|
);
|
4648
|
-
const [portalEl, setPortalEl] = (0,
|
4649
|
-
(0,
|
4427
|
+
const [portalEl, setPortalEl] = (0, import_react26.useState)();
|
4428
|
+
(0, import_react26.useEffect)(() => {
|
4650
4429
|
var _a, _b, _c;
|
4651
4430
|
setPortalEl(
|
4652
4431
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
4653
4432
|
);
|
4654
4433
|
}, [iframe.enabled, ref.current]);
|
4655
|
-
const getStyle = (0,
|
4434
|
+
const getStyle = (0, import_react26.useCallback)(() => {
|
4656
4435
|
var _a, _b, _c;
|
4657
4436
|
if (!ref.current) return;
|
4658
4437
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4672,11 +4451,12 @@ var DraggableComponent = ({
|
|
4672
4451
|
};
|
4673
4452
|
return style2;
|
4674
4453
|
}, [ref.current]);
|
4675
|
-
const [style, setStyle] = (0,
|
4676
|
-
const sync = (0,
|
4454
|
+
const [style, setStyle] = (0, import_react26.useState)();
|
4455
|
+
const sync = (0, import_react26.useCallback)(() => {
|
4677
4456
|
setStyle(getStyle());
|
4678
4457
|
}, [ref.current, iframe]);
|
4679
|
-
(0,
|
4458
|
+
(0, import_react26.useEffect)(() => {
|
4459
|
+
const userIsDragging = !!zoneStore.getState().draggedItem;
|
4680
4460
|
if (ref.current && !userIsDragging) {
|
4681
4461
|
const observer = new ResizeObserver(sync);
|
4682
4462
|
observer.observe(ref.current);
|
@@ -4684,20 +4464,20 @@ var DraggableComponent = ({
|
|
4684
4464
|
observer.disconnect();
|
4685
4465
|
};
|
4686
4466
|
}
|
4687
|
-
}, [ref.current
|
4467
|
+
}, [ref.current]);
|
4688
4468
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
4689
|
-
(0,
|
4469
|
+
(0, import_react26.useEffect)(() => {
|
4690
4470
|
var _a;
|
4691
4471
|
registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
|
4692
4472
|
return () => {
|
4693
4473
|
registerNode(id, { methods: { sync: () => null }, element: null });
|
4694
4474
|
};
|
4695
4475
|
}, [id, zoneCompound, index, componentType, sync]);
|
4696
|
-
const CustomActionBar = (0,
|
4476
|
+
const CustomActionBar = (0, import_react26.useMemo)(
|
4697
4477
|
() => overrides.actionBar || DefaultActionBar,
|
4698
4478
|
[overrides.actionBar]
|
4699
4479
|
);
|
4700
|
-
const onClick = (0,
|
4480
|
+
const onClick = (0, import_react26.useCallback)(
|
4701
4481
|
(e) => {
|
4702
4482
|
e.stopPropagation();
|
4703
4483
|
dispatch({
|
@@ -4710,7 +4490,7 @@ var DraggableComponent = ({
|
|
4710
4490
|
[index, zoneCompound, id]
|
4711
4491
|
);
|
4712
4492
|
const appStore = useAppStoreApi();
|
4713
|
-
const onSelectParent = (0,
|
4493
|
+
const onSelectParent = (0, import_react26.useCallback)(() => {
|
4714
4494
|
const { nodes, zones } = appStore.getState().state.indexes;
|
4715
4495
|
const node = nodes[id];
|
4716
4496
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
@@ -4731,28 +4511,32 @@ var DraggableComponent = ({
|
|
4731
4511
|
}
|
4732
4512
|
});
|
4733
4513
|
}, [ctx, path]);
|
4734
|
-
const onDuplicate = (0,
|
4514
|
+
const onDuplicate = (0, import_react26.useCallback)(() => {
|
4735
4515
|
dispatch({
|
4736
4516
|
type: "duplicate",
|
4737
4517
|
sourceIndex: index,
|
4738
4518
|
sourceZone: zoneCompound
|
4739
4519
|
});
|
4740
4520
|
}, [index, zoneCompound]);
|
4741
|
-
const onDelete = (0,
|
4521
|
+
const onDelete = (0, import_react26.useCallback)(() => {
|
4742
4522
|
dispatch({
|
4743
4523
|
type: "remove",
|
4744
4524
|
index,
|
4745
4525
|
zone: zoneCompound
|
4746
4526
|
});
|
4747
4527
|
}, [index, zoneCompound]);
|
4748
|
-
const [hover, setHover] = (0,
|
4749
|
-
const indicativeHover = (
|
4750
|
-
|
4528
|
+
const [hover, setHover] = (0, import_react26.useState)(false);
|
4529
|
+
const indicativeHover = useContextStore(
|
4530
|
+
ZoneStoreContext,
|
4531
|
+
(s) => s.hoveringComponent === id
|
4532
|
+
);
|
4533
|
+
(0, import_react26.useEffect)(() => {
|
4751
4534
|
if (!ref.current) {
|
4752
4535
|
return;
|
4753
4536
|
}
|
4754
4537
|
const el = ref.current;
|
4755
4538
|
const _onMouseOver = (e) => {
|
4539
|
+
const userIsDragging = !!zoneStore.getState().draggedItem;
|
4756
4540
|
if (userIsDragging) {
|
4757
4541
|
if (thisIsDragging) {
|
4758
4542
|
setHover(true);
|
@@ -4774,18 +4558,12 @@ var DraggableComponent = ({
|
|
4774
4558
|
el.addEventListener("click", onClick);
|
4775
4559
|
el.addEventListener("mouseover", _onMouseOver);
|
4776
4560
|
el.addEventListener("mouseout", _onMouseOut);
|
4777
|
-
if (thisIsDragging) {
|
4778
|
-
el.setAttribute("data-puck-dragging", "");
|
4779
|
-
} else {
|
4780
|
-
el.removeAttribute("data-puck-dragging");
|
4781
|
-
}
|
4782
4561
|
return () => {
|
4783
4562
|
el.removeAttribute("data-puck-component");
|
4784
4563
|
el.removeAttribute("data-puck-dnd");
|
4785
4564
|
el.removeEventListener("click", onClick);
|
4786
4565
|
el.removeEventListener("mouseover", _onMouseOver);
|
4787
4566
|
el.removeEventListener("mouseout", _onMouseOut);
|
4788
|
-
el.removeAttribute("data-puck-dragging");
|
4789
4567
|
};
|
4790
4568
|
}, [
|
4791
4569
|
ref,
|
@@ -4793,29 +4571,43 @@ var DraggableComponent = ({
|
|
4793
4571
|
containsActiveZone,
|
4794
4572
|
zoneCompound,
|
4795
4573
|
id,
|
4796
|
-
userIsDragging,
|
4797
4574
|
thisIsDragging,
|
4798
4575
|
inDroppableZone
|
4799
4576
|
]);
|
4800
|
-
(0,
|
4801
|
-
|
4802
|
-
|
4803
|
-
|
4804
|
-
|
4805
|
-
|
4806
|
-
|
4807
|
-
|
4808
|
-
|
4809
|
-
|
4810
|
-
|
4811
|
-
|
4812
|
-
|
4813
|
-
|
4577
|
+
const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
|
4578
|
+
const [dragFinished, setDragFinished] = (0, import_react26.useState)(true);
|
4579
|
+
const [_, startTransition] = (0, import_react26.useTransition)();
|
4580
|
+
(0, import_react26.useEffect)(() => {
|
4581
|
+
startTransition(() => {
|
4582
|
+
if (hover || indicativeHover || isSelected) {
|
4583
|
+
sync();
|
4584
|
+
setIsVisible(true);
|
4585
|
+
setThisWasDragging(false);
|
4586
|
+
} else {
|
4587
|
+
setIsVisible(false);
|
4588
|
+
}
|
4589
|
+
});
|
4590
|
+
}, [hover, indicativeHover, isSelected, iframe]);
|
4591
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react26.useState)(false);
|
4592
|
+
const onDragFinished = useOnDragFinished((finished) => {
|
4593
|
+
if (finished) {
|
4594
|
+
startTransition(() => {
|
4595
|
+
sync();
|
4596
|
+
setDragFinished(true);
|
4597
|
+
});
|
4814
4598
|
} else {
|
4815
|
-
|
4599
|
+
setDragFinished(false);
|
4816
4600
|
}
|
4817
|
-
}
|
4818
|
-
|
4601
|
+
});
|
4602
|
+
(0, import_react26.useEffect)(() => {
|
4603
|
+
if (thisIsDragging) {
|
4604
|
+
setThisWasDragging(true);
|
4605
|
+
}
|
4606
|
+
}, [thisIsDragging]);
|
4607
|
+
(0, import_react26.useEffect)(() => {
|
4608
|
+
if (thisWasDragging) return onDragFinished();
|
4609
|
+
}, [thisWasDragging, onDragFinished]);
|
4610
|
+
const syncActionsPosition = (0, import_react26.useCallback)(
|
4819
4611
|
(el) => {
|
4820
4612
|
if (el) {
|
4821
4613
|
const view = el.ownerDocument.defaultView;
|
@@ -4840,7 +4632,7 @@ var DraggableComponent = ({
|
|
4840
4632
|
},
|
4841
4633
|
[zoom]
|
4842
4634
|
);
|
4843
|
-
(0,
|
4635
|
+
(0, import_react26.useEffect)(() => {
|
4844
4636
|
if (userDragAxis) {
|
4845
4637
|
setDragAxis(userDragAxis);
|
4846
4638
|
return;
|
@@ -4854,8 +4646,11 @@ var DraggableComponent = ({
|
|
4854
4646
|
}
|
4855
4647
|
setDragAxis(autoDragAxis);
|
4856
4648
|
}, [ref, userDragAxis, autoDragAxis]);
|
4857
|
-
const parentAction = (
|
4858
|
-
|
4649
|
+
const parentAction = (0, import_react26.useMemo)(
|
4650
|
+
() => (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 }) }),
|
4651
|
+
[ctx == null ? void 0 : ctx.areaId]
|
4652
|
+
);
|
4653
|
+
const nextContextValue = (0, import_react26.useMemo)(
|
4859
4654
|
() => __spreadProps(__spreadValues({}, ctx), {
|
4860
4655
|
areaId: id,
|
4861
4656
|
zoneCompound,
|
@@ -4875,7 +4670,7 @@ var DraggableComponent = ({
|
|
4875
4670
|
]
|
4876
4671
|
);
|
4877
4672
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
|
4878
|
-
isVisible && (0, import_react_dom2.createPortal)(
|
4673
|
+
dragFinished && isVisible && (0, import_react_dom2.createPortal)(
|
4879
4674
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
4880
4675
|
"div",
|
4881
4676
|
{
|
@@ -4935,19 +4730,22 @@ var DraggableComponent = ({
|
|
4935
4730
|
|
4936
4731
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
|
4937
4732
|
init_react_import();
|
4938
|
-
var styles_module_default12 = { "DropZone": "
|
4733
|
+
var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
|
4734
|
+
|
4735
|
+
// components/DropZone/index.tsx
|
4736
|
+
var import_react36 = require("@dnd-kit/react");
|
4939
4737
|
|
4940
4738
|
// components/DropZone/lib/use-min-empty-height.ts
|
4941
4739
|
init_react_import();
|
4942
|
-
var
|
4740
|
+
var import_react27 = require("react");
|
4943
4741
|
var useMinEmptyHeight = ({
|
4944
4742
|
zoneCompound,
|
4945
4743
|
userMinEmptyHeight,
|
4946
4744
|
ref
|
4947
4745
|
}) => {
|
4948
4746
|
const appStore = useAppStoreApi();
|
4949
|
-
const [prevHeight, setPrevHeight] = (0,
|
4950
|
-
const [isAnimating, setIsAnimating] = (0,
|
4747
|
+
const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
|
4748
|
+
const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
|
4951
4749
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
4952
4750
|
var _a, _b;
|
4953
4751
|
return {
|
@@ -4955,7 +4753,7 @@ var useMinEmptyHeight = ({
|
|
4955
4753
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
4956
4754
|
};
|
4957
4755
|
});
|
4958
|
-
(0,
|
4756
|
+
(0, import_react27.useEffect)(() => {
|
4959
4757
|
if (draggedItem && ref.current) {
|
4960
4758
|
if (isZone) {
|
4961
4759
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4964,19 +4762,22 @@ var useMinEmptyHeight = ({
|
|
4964
4762
|
return;
|
4965
4763
|
}
|
4966
4764
|
}
|
4765
|
+
const _prevHeight = prevHeight;
|
4967
4766
|
setPrevHeight(0);
|
4968
4767
|
setTimeout(() => {
|
4969
|
-
var _a, _b;
|
4768
|
+
var _a, _b, _c;
|
4769
|
+
const newHeight = (_a = ref.current) == null ? void 0 : _a.getBoundingClientRect().height;
|
4770
|
+
if (newHeight === _prevHeight) return;
|
4970
4771
|
const zones = appStore.getState().state.indexes.zones;
|
4971
4772
|
const nodes = appStore.getState().nodes;
|
4972
4773
|
const selectedItem = appStore.getState().selectedItem;
|
4973
|
-
const contentIds = ((
|
4774
|
+
const contentIds = ((_b = zones[zoneCompound]) == null ? void 0 : _b.contentIds) || [];
|
4974
4775
|
contentIds.forEach((contentId) => {
|
4975
4776
|
const node = nodes.nodes[contentId];
|
4976
4777
|
node == null ? void 0 : node.methods.sync();
|
4977
4778
|
});
|
4978
4779
|
if (selectedItem) {
|
4979
|
-
(
|
4780
|
+
(_c = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _c.methods.sync();
|
4980
4781
|
}
|
4981
4782
|
setIsAnimating(false);
|
4982
4783
|
}, 400);
|
@@ -5001,15 +4802,15 @@ function assignRefs(refs, node) {
|
|
5001
4802
|
|
5002
4803
|
// components/DropZone/lib/use-content-with-preview.ts
|
5003
4804
|
init_react_import();
|
5004
|
-
var
|
4805
|
+
var import_react30 = require("react");
|
5005
4806
|
|
5006
4807
|
// lib/dnd/use-rendered-callback.ts
|
5007
4808
|
init_react_import();
|
5008
|
-
var
|
5009
|
-
var
|
4809
|
+
var import_react28 = require("@dnd-kit/react");
|
4810
|
+
var import_react29 = require("react");
|
5010
4811
|
function useRenderedCallback(callback, deps) {
|
5011
|
-
const manager = (0,
|
5012
|
-
return (0,
|
4812
|
+
const manager = (0, import_react28.useDragDropManager)();
|
4813
|
+
return (0, import_react29.useCallback)(
|
5013
4814
|
(...args) => __async(this, null, function* () {
|
5014
4815
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
5015
4816
|
return callback(...args);
|
@@ -5020,27 +4821,21 @@ function useRenderedCallback(callback, deps) {
|
|
5020
4821
|
|
5021
4822
|
// components/DropZone/lib/use-content-with-preview.ts
|
5022
4823
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
5023
|
-
const
|
4824
|
+
const zoneStore = (0, import_react30.useContext)(ZoneStoreContext);
|
4825
|
+
const preview = useContextStore(
|
5024
4826
|
ZoneStoreContext,
|
5025
|
-
(s) =>
|
5026
|
-
var _a;
|
5027
|
-
return {
|
5028
|
-
draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
|
5029
|
-
preview: s.previewIndex[zoneCompound],
|
5030
|
-
previewExists: Object.keys(s.previewIndex || {}).length > 0
|
5031
|
-
};
|
5032
|
-
}
|
4827
|
+
(s) => s.previewIndex[zoneCompound]
|
5033
4828
|
);
|
5034
4829
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
5035
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
5036
|
-
const [localPreview, setLocalPreview] = (0,
|
4830
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
|
4831
|
+
const [localPreview, setLocalPreview] = (0, import_react30.useState)(
|
5037
4832
|
preview
|
5038
4833
|
);
|
5039
4834
|
const updateContent = useRenderedCallback(
|
5040
|
-
(contentIds2, preview2
|
5041
|
-
|
5042
|
-
|
5043
|
-
|
4835
|
+
(contentIds2, preview2) => {
|
4836
|
+
var _a;
|
4837
|
+
const s = zoneStore.getState();
|
4838
|
+
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
5044
4839
|
if (preview2) {
|
5045
4840
|
if (preview2.type === "insert") {
|
5046
4841
|
setContentIdsWithPreview(
|
@@ -5061,14 +4856,14 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5061
4856
|
}
|
5062
4857
|
} else {
|
5063
4858
|
setContentIdsWithPreview(
|
5064
|
-
|
4859
|
+
contentIds2.filter((id) => id !== draggedItemId)
|
5065
4860
|
);
|
5066
4861
|
}
|
5067
4862
|
setLocalPreview(preview2);
|
5068
4863
|
},
|
5069
|
-
[
|
4864
|
+
[]
|
5070
4865
|
);
|
5071
|
-
(0,
|
4866
|
+
(0, import_react30.useEffect)(() => {
|
5072
4867
|
updateContent(contentIds, preview, isDragging);
|
5073
4868
|
}, [contentIds, preview, isDragging]);
|
5074
4869
|
return [contentIdsWithPreview, localPreview];
|
@@ -5076,16 +4871,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5076
4871
|
|
5077
4872
|
// components/DropZone/lib/use-drag-axis.ts
|
5078
4873
|
init_react_import();
|
5079
|
-
var
|
4874
|
+
var import_react31 = require("react");
|
5080
4875
|
var GRID_DRAG_AXIS = "dynamic";
|
5081
4876
|
var FLEX_ROW_DRAG_AXIS = "x";
|
5082
4877
|
var DEFAULT_DRAG_AXIS = "y";
|
5083
4878
|
var useDragAxis = (ref, collisionAxis) => {
|
5084
4879
|
const status = useAppStore((s) => s.status);
|
5085
|
-
const [dragAxis, setDragAxis] = (0,
|
4880
|
+
const [dragAxis, setDragAxis] = (0, import_react31.useState)(
|
5086
4881
|
collisionAxis || DEFAULT_DRAG_AXIS
|
5087
4882
|
);
|
5088
|
-
const calculateDragAxis = (0,
|
4883
|
+
const calculateDragAxis = (0, import_react31.useCallback)(() => {
|
5089
4884
|
if (ref.current) {
|
5090
4885
|
const computedStyle = window.getComputedStyle(ref.current);
|
5091
4886
|
if (computedStyle.display === "grid") {
|
@@ -5097,7 +4892,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
5097
4892
|
}
|
5098
4893
|
}
|
5099
4894
|
}, [ref.current]);
|
5100
|
-
(0,
|
4895
|
+
(0, import_react31.useEffect)(() => {
|
5101
4896
|
const onViewportChange = () => {
|
5102
4897
|
calculateDragAxis();
|
5103
4898
|
};
|
@@ -5106,7 +4901,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
5106
4901
|
window.removeEventListener("viewportchange", onViewportChange);
|
5107
4902
|
};
|
5108
4903
|
}, []);
|
5109
|
-
(0,
|
4904
|
+
(0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
5110
4905
|
return [dragAxis, calculateDragAxis];
|
5111
4906
|
};
|
5112
4907
|
|
@@ -5118,9 +4913,9 @@ init_react_import();
|
|
5118
4913
|
|
5119
4914
|
// lib/use-slots.tsx
|
5120
4915
|
init_react_import();
|
5121
|
-
var
|
4916
|
+
var import_react32 = require("react");
|
5122
4917
|
function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
5123
|
-
const slotProps = (0,
|
4918
|
+
const slotProps = (0, import_react32.useMemo)(() => {
|
5124
4919
|
if (!(config == null ? void 0 : config.fields)) return props;
|
5125
4920
|
const slotProps2 = {};
|
5126
4921
|
const fieldKeys = Object.keys(config.fields);
|
@@ -5142,63 +4937,94 @@ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEd
|
|
5142
4937
|
}
|
5143
4938
|
return slotProps2;
|
5144
4939
|
}, [config, readOnly, forceReadOnly]);
|
5145
|
-
|
4940
|
+
const mergedProps = (0, import_react32.useMemo)(
|
4941
|
+
() => __spreadValues(__spreadValues({}, props), slotProps),
|
4942
|
+
[props, slotProps]
|
4943
|
+
);
|
4944
|
+
return mergedProps;
|
5146
4945
|
}
|
5147
4946
|
|
5148
4947
|
// components/Render/index.tsx
|
5149
|
-
var
|
4948
|
+
var import_react34 = __toESM(require("react"));
|
5150
4949
|
|
5151
4950
|
// components/SlotRender/index.tsx
|
5152
4951
|
init_react_import();
|
5153
|
-
|
4952
|
+
|
4953
|
+
// components/SlotRender/server.tsx
|
4954
|
+
init_react_import();
|
4955
|
+
var import_react33 = require("react");
|
4956
|
+
|
4957
|
+
// components/ServerRender/index.tsx
|
4958
|
+
init_react_import();
|
5154
4959
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
5155
|
-
|
5156
|
-
|
5157
|
-
|
5158
|
-
|
5159
|
-
|
5160
|
-
|
5161
|
-
|
5162
|
-
|
5163
|
-
|
5164
|
-
|
5165
|
-
|
5166
|
-
|
5167
|
-
)
|
5168
|
-
|
5169
|
-
|
5170
|
-
|
5171
|
-
|
5172
|
-
|
5173
|
-
|
5174
|
-
|
4960
|
+
function DropZoneRender({
|
4961
|
+
zone,
|
4962
|
+
data,
|
4963
|
+
areaId = "root",
|
4964
|
+
config,
|
4965
|
+
metadata = {}
|
4966
|
+
}) {
|
4967
|
+
let zoneCompound = rootDroppableId;
|
4968
|
+
let content = (data == null ? void 0 : data.content) || [];
|
4969
|
+
if (!data || !config) {
|
4970
|
+
return null;
|
4971
|
+
}
|
4972
|
+
if (areaId !== rootAreaId && zone !== rootZone) {
|
4973
|
+
zoneCompound = `${areaId}:${zone}`;
|
4974
|
+
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
4975
|
+
}
|
4976
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
|
4977
|
+
const Component = config.components[item.type];
|
4978
|
+
const props = __spreadProps(__spreadValues({}, item.props), {
|
4979
|
+
puck: {
|
4980
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4981
|
+
DropZoneRender,
|
4982
|
+
{
|
4983
|
+
zone: zone2,
|
4984
|
+
data,
|
4985
|
+
areaId: item.props.id,
|
4986
|
+
config,
|
4987
|
+
metadata
|
4988
|
+
}
|
4989
|
+
),
|
4990
|
+
metadata
|
4991
|
+
}
|
4992
|
+
});
|
4993
|
+
const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
4994
|
+
if (Component) {
|
4995
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
|
5175
4996
|
}
|
5176
|
-
|
5177
|
-
};
|
4997
|
+
return null;
|
4998
|
+
}) });
|
4999
|
+
}
|
5000
|
+
|
5001
|
+
// components/SlotRender/server.tsx
|
5002
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
5003
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
|
5178
5004
|
var Item = ({
|
5179
5005
|
config,
|
5180
5006
|
item,
|
5181
5007
|
metadata
|
5182
5008
|
}) => {
|
5183
5009
|
const Component = config.components[item.type];
|
5184
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0,
|
5185
|
-
return /* @__PURE__ */ (0,
|
5010
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5186
5012
|
Component.render,
|
5187
5013
|
__spreadProps(__spreadValues({}, props), {
|
5188
5014
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
5189
|
-
renderDropZone:
|
5015
|
+
renderDropZone: DropZoneRender,
|
5190
5016
|
metadata: metadata || {}
|
5191
5017
|
})
|
5192
5018
|
})
|
5193
5019
|
);
|
5194
5020
|
};
|
5195
|
-
var SlotRender = (0,
|
5021
|
+
var SlotRender = (0, import_react33.forwardRef)(
|
5196
5022
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
5197
|
-
return /* @__PURE__ */ (0,
|
5023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
5198
5024
|
if (!config.components[item.type]) {
|
5199
5025
|
return null;
|
5200
5026
|
}
|
5201
|
-
return /* @__PURE__ */ (0,
|
5027
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5202
5028
|
Item,
|
5203
5029
|
{
|
5204
5030
|
config,
|
@@ -5211,9 +5037,34 @@ var SlotRender = (0, import_react32.forwardRef)(
|
|
5211
5037
|
}
|
5212
5038
|
);
|
5213
5039
|
|
5040
|
+
// components/SlotRender/index.tsx
|
5041
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5042
|
+
var ContextSlotRender = ({
|
5043
|
+
componentId,
|
5044
|
+
zone
|
5045
|
+
}) => {
|
5046
|
+
const config = useAppStore((s) => s.config);
|
5047
|
+
const metadata = useAppStore((s) => s.metadata);
|
5048
|
+
const slotContent = useAppStore(
|
5049
|
+
(s) => {
|
5050
|
+
var _a, _b;
|
5051
|
+
return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
|
5052
|
+
}
|
5053
|
+
);
|
5054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5055
|
+
SlotRenderPure,
|
5056
|
+
{
|
5057
|
+
content: slotContent,
|
5058
|
+
zone,
|
5059
|
+
config,
|
5060
|
+
metadata
|
5061
|
+
}
|
5062
|
+
);
|
5063
|
+
};
|
5064
|
+
|
5214
5065
|
// components/Render/index.tsx
|
5215
|
-
var
|
5216
|
-
var renderContext =
|
5066
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
5067
|
+
var renderContext = import_react34.default.createContext({
|
5217
5068
|
config: { components: {} },
|
5218
5069
|
data: { root: {}, content: [] },
|
5219
5070
|
metadata: {}
|
@@ -5241,8 +5092,8 @@ function Render({
|
|
5241
5092
|
editMode: false,
|
5242
5093
|
id: "puck-root"
|
5243
5094
|
});
|
5244
|
-
const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0,
|
5245
|
-
const nextContextValue = (0,
|
5095
|
+
const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
|
5096
|
+
const nextContextValue = (0, import_react34.useMemo)(
|
5246
5097
|
() => ({
|
5247
5098
|
mode: "render",
|
5248
5099
|
depth: 0
|
@@ -5250,31 +5101,30 @@ function Render({
|
|
5250
5101
|
[]
|
5251
5102
|
);
|
5252
5103
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5253
|
-
return /* @__PURE__ */ (0,
|
5104
|
+
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 }) })) }) });
|
5254
5105
|
}
|
5255
|
-
return /* @__PURE__ */ (0,
|
5106
|
+
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 }) }) });
|
5256
5107
|
}
|
5257
5108
|
|
5258
5109
|
// components/DropZone/index.tsx
|
5259
|
-
var
|
5110
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
5260
5111
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
5261
5112
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
5262
5113
|
var RENDER_DEBUG = false;
|
5263
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */ (0,
|
5114
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadValues({}, props));
|
5264
5115
|
var DropZoneChild = ({
|
5265
5116
|
zoneCompound,
|
5266
5117
|
componentId,
|
5267
|
-
preview,
|
5268
5118
|
index,
|
5269
|
-
isEnabled,
|
5270
5119
|
dragAxis,
|
5271
5120
|
collisionAxis,
|
5272
5121
|
inDroppableZone
|
5273
5122
|
}) => {
|
5274
5123
|
var _a, _b;
|
5275
5124
|
const metadata = useAppStore((s) => s.metadata);
|
5276
|
-
const ctx = (0,
|
5125
|
+
const ctx = (0, import_react35.useContext)(dropZoneContext);
|
5277
5126
|
const { depth = 1 } = ctx != null ? ctx : {};
|
5127
|
+
const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
|
5278
5128
|
const nodeProps = useAppStore(
|
5279
5129
|
(0, import_shallow3.useShallow)((s) => {
|
5280
5130
|
var _a2;
|
@@ -5293,17 +5143,32 @@ var DropZoneChild = ({
|
|
5293
5143
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
5294
5144
|
})
|
5295
5145
|
);
|
5296
|
-
const
|
5297
|
-
|
5146
|
+
const item = (0, import_react35.useMemo)(() => {
|
5147
|
+
if (nodeProps) {
|
5148
|
+
return { type: nodeType, props: nodeProps };
|
5149
|
+
}
|
5150
|
+
const preview = zoneStore.getState().previewIndex[zoneCompound];
|
5151
|
+
if (componentId === (preview == null ? void 0 : preview.props.id)) {
|
5152
|
+
return {
|
5153
|
+
type: preview.componentType,
|
5154
|
+
props: preview.props,
|
5155
|
+
previewType: preview.type
|
5156
|
+
};
|
5157
|
+
}
|
5158
|
+
return null;
|
5159
|
+
}, [componentId, zoneCompound, nodeType, nodeProps]);
|
5298
5160
|
const componentConfig = useAppStore(
|
5299
5161
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
5300
5162
|
);
|
5301
|
-
const puckProps =
|
5302
|
-
|
5303
|
-
|
5304
|
-
|
5305
|
-
|
5306
|
-
|
5163
|
+
const puckProps = (0, import_react35.useMemo)(
|
5164
|
+
() => ({
|
5165
|
+
renderDropZone: DropZoneEditPure,
|
5166
|
+
isEditing: true,
|
5167
|
+
dragRef: null,
|
5168
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
|
5169
|
+
}),
|
5170
|
+
[metadata, componentConfig == null ? void 0 : componentConfig.metadata]
|
5171
|
+
);
|
5307
5172
|
const overrides = useAppStore((s) => s.overrides);
|
5308
5173
|
const isLoading = useAppStore(
|
5309
5174
|
(s) => {
|
@@ -5318,13 +5183,13 @@ var DropZoneChild = ({
|
|
5318
5183
|
}
|
5319
5184
|
);
|
5320
5185
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
5321
|
-
const renderPreview = (0,
|
5322
|
-
() => function
|
5323
|
-
return /* @__PURE__ */ (0,
|
5186
|
+
const renderPreview = (0, import_react35.useMemo)(
|
5187
|
+
() => function Preview3() {
|
5188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
5324
5189
|
},
|
5325
5190
|
[componentId, label, overrides]
|
5326
5191
|
);
|
5327
|
-
const defaultsProps = (0,
|
5192
|
+
const defaultsProps = (0, import_react35.useMemo)(
|
5328
5193
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
5329
5194
|
puck: puckProps,
|
5330
5195
|
editMode: true
|
@@ -5336,21 +5201,21 @@ var DropZoneChild = ({
|
|
5336
5201
|
componentConfig,
|
5337
5202
|
defaultsProps,
|
5338
5203
|
DropZoneEditPure,
|
5339
|
-
(slotProps) => /* @__PURE__ */ (0,
|
5204
|
+
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
5340
5205
|
nodeReadOnly,
|
5341
5206
|
isLoading
|
5342
5207
|
);
|
5343
5208
|
if (!item) return;
|
5344
|
-
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0,
|
5209
|
+
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
5345
5210
|
"No configuration for ",
|
5346
5211
|
item.type
|
5347
5212
|
] });
|
5348
5213
|
let componentType = item.type;
|
5349
|
-
const
|
5350
|
-
if (
|
5214
|
+
const isInserting = item.previewType === "insert";
|
5215
|
+
if (isInserting) {
|
5351
5216
|
Render2 = renderPreview;
|
5352
5217
|
}
|
5353
|
-
return /* @__PURE__ */ (0,
|
5218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5354
5219
|
DraggableComponent,
|
5355
5220
|
{
|
5356
5221
|
id: componentId,
|
@@ -5361,23 +5226,22 @@ var DropZoneChild = ({
|
|
5361
5226
|
isLoading,
|
5362
5227
|
isSelected,
|
5363
5228
|
label,
|
5364
|
-
isEnabled,
|
5365
5229
|
autoDragAxis: dragAxis,
|
5366
5230
|
userDragAxis: collisionAxis,
|
5367
5231
|
inDroppableZone,
|
5368
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !
|
5232
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5369
5233
|
Render2,
|
5370
5234
|
__spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
|
5371
5235
|
puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
|
5372
5236
|
dragRef
|
5373
5237
|
})
|
5374
5238
|
})
|
5375
|
-
) }) : /* @__PURE__ */ (0,
|
5239
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
|
5376
5240
|
}
|
5377
5241
|
);
|
5378
5242
|
};
|
5379
|
-
var DropZoneChildMemo = (0,
|
5380
|
-
var DropZoneEdit = (0,
|
5243
|
+
var DropZoneChildMemo = (0, import_react35.memo)(DropZoneChild);
|
5244
|
+
var DropZoneEdit = (0, import_react35.forwardRef)(
|
5381
5245
|
function DropZoneEditInternal({
|
5382
5246
|
zone,
|
5383
5247
|
allow,
|
@@ -5387,7 +5251,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5387
5251
|
minEmptyHeight: userMinEmptyHeight = 128,
|
5388
5252
|
collisionAxis
|
5389
5253
|
}, userRef) {
|
5390
|
-
const ctx = (0,
|
5254
|
+
const ctx = (0, import_react35.useContext)(dropZoneContext);
|
5391
5255
|
const {
|
5392
5256
|
// These all need setting via context
|
5393
5257
|
areaId,
|
@@ -5408,20 +5272,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5408
5272
|
}
|
5409
5273
|
}
|
5410
5274
|
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
5411
|
-
const
|
5412
|
-
|
5413
|
-
|
5414
|
-
|
5415
|
-
userIsDragging
|
5416
|
-
} = useContextStore(ZoneStoreContext, (s) => {
|
5417
|
-
var _a, _b;
|
5418
|
-
return {
|
5419
|
-
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
5420
|
-
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
5421
|
-
draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
|
5422
|
-
userIsDragging: !!s.draggedItem
|
5423
|
-
};
|
5424
|
-
});
|
5275
|
+
const inNextDeepestArea = useContextStore(
|
5276
|
+
ZoneStoreContext,
|
5277
|
+
(s) => s.nextAreaDepthIndex[areaId || ""]
|
5278
|
+
);
|
5425
5279
|
const zoneContentIds = useAppStore(
|
5426
5280
|
(0, import_shallow3.useShallow)((s) => {
|
5427
5281
|
var _a;
|
@@ -5434,13 +5288,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5434
5288
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
5435
5289
|
})
|
5436
5290
|
);
|
5437
|
-
(0,
|
5291
|
+
(0, import_react35.useEffect)(() => {
|
5438
5292
|
if (!zoneType || zoneType === "dropzone") {
|
5439
|
-
if (zoneCompound !== rootDroppableId) {
|
5440
|
-
console.warn(
|
5441
|
-
"DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
|
5442
|
-
);
|
5443
|
-
}
|
5444
5293
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5445
5294
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5446
5295
|
}
|
@@ -5451,11 +5300,20 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5451
5300
|
};
|
5452
5301
|
}
|
5453
5302
|
}, [zoneType]);
|
5454
|
-
|
5303
|
+
(0, import_react35.useEffect)(() => {
|
5304
|
+
if (zoneType === "dropzone") {
|
5305
|
+
if (zoneCompound !== rootDroppableId) {
|
5306
|
+
console.warn(
|
5307
|
+
"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"
|
5308
|
+
);
|
5309
|
+
}
|
5310
|
+
}
|
5311
|
+
}, [zoneType]);
|
5312
|
+
const contentIds = (0, import_react35.useMemo)(() => {
|
5455
5313
|
return zoneContentIds || [];
|
5456
5314
|
}, [zoneContentIds]);
|
5457
|
-
const ref = (0,
|
5458
|
-
const acceptsTarget = (0,
|
5315
|
+
const ref = (0, import_react35.useRef)(null);
|
5316
|
+
const acceptsTarget = (0, import_react35.useCallback)(
|
5459
5317
|
(componentType) => {
|
5460
5318
|
if (!componentType) {
|
5461
5319
|
return true;
|
@@ -5477,29 +5335,44 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5477
5335
|
},
|
5478
5336
|
[allow, disallow]
|
5479
5337
|
);
|
5480
|
-
(
|
5338
|
+
const targetAccepted = useContextStore(ZoneStoreContext, (s) => {
|
5339
|
+
var _a;
|
5340
|
+
const draggedComponentType = (_a = s.draggedItem) == null ? void 0 : _a.data.componentType;
|
5341
|
+
return acceptsTarget(draggedComponentType);
|
5342
|
+
});
|
5343
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
5344
|
+
const isEnabled = useContextStore(ZoneStoreContext, (s) => {
|
5345
|
+
var _a;
|
5346
|
+
let _isEnabled = true;
|
5347
|
+
const isDeepestZone = (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false;
|
5348
|
+
_isEnabled = isDeepestZone;
|
5349
|
+
if (_isEnabled) {
|
5350
|
+
_isEnabled = targetAccepted;
|
5351
|
+
}
|
5352
|
+
return _isEnabled;
|
5353
|
+
});
|
5354
|
+
(0, import_react35.useEffect)(() => {
|
5481
5355
|
if (registerLocalZone) {
|
5482
|
-
registerLocalZone(zoneCompound,
|
5356
|
+
registerLocalZone(zoneCompound, isEnabled);
|
5483
5357
|
}
|
5484
5358
|
return () => {
|
5485
5359
|
if (unregisterLocalZone) {
|
5486
5360
|
unregisterLocalZone(zoneCompound);
|
5487
5361
|
}
|
5488
5362
|
};
|
5489
|
-
}, [
|
5490
|
-
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
5491
|
-
let isEnabled = true;
|
5492
|
-
if (userIsDragging) {
|
5493
|
-
isEnabled = isDeepestZone;
|
5494
|
-
}
|
5495
|
-
if (isEnabled) {
|
5496
|
-
isEnabled = acceptsTarget(draggedComponentType);
|
5497
|
-
}
|
5363
|
+
}, [isEnabled, zoneCompound]);
|
5498
5364
|
const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
|
5499
5365
|
contentIds,
|
5500
5366
|
zoneCompound
|
5501
5367
|
);
|
5502
5368
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
5369
|
+
const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
|
5370
|
+
(0, import_react35.useEffect)(() => {
|
5371
|
+
const { enabledIndex } = zoneStore.getState();
|
5372
|
+
zoneStore.setState({
|
5373
|
+
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
5374
|
+
});
|
5375
|
+
}, [isEnabled, zoneStore, zoneCompound]);
|
5503
5376
|
const droppableConfig = {
|
5504
5377
|
id: zoneCompound,
|
5505
5378
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -5509,11 +5382,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5509
5382
|
data: {
|
5510
5383
|
areaId,
|
5511
5384
|
depth,
|
5512
|
-
isDroppableTarget:
|
5385
|
+
isDroppableTarget: targetAccepted,
|
5513
5386
|
path: path || []
|
5514
5387
|
}
|
5515
5388
|
};
|
5516
|
-
const { ref: dropRef } =
|
5389
|
+
const { ref: dropRef } = (0, import_react36.useDroppable)(droppableConfig);
|
5517
5390
|
const isAreaSelected = useAppStore(
|
5518
5391
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
5519
5392
|
);
|
@@ -5523,12 +5396,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5523
5396
|
userMinEmptyHeight,
|
5524
5397
|
ref
|
5525
5398
|
});
|
5526
|
-
return /* @__PURE__ */ (0,
|
5399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5527
5400
|
"div",
|
5528
5401
|
{
|
5529
5402
|
className: `${getClassName17({
|
5530
5403
|
isRootZone,
|
5531
|
-
userIsDragging,
|
5532
5404
|
hoveringOverArea,
|
5533
5405
|
isEnabled,
|
5534
5406
|
isAreaSelected,
|
@@ -5545,17 +5417,15 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5545
5417
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
5546
5418
|
}),
|
5547
5419
|
children: contentIdsWithPreview.map((componentId, i) => {
|
5548
|
-
return /* @__PURE__ */ (0,
|
5420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5549
5421
|
DropZoneChildMemo,
|
5550
5422
|
{
|
5551
5423
|
zoneCompound,
|
5552
5424
|
componentId,
|
5553
|
-
preview,
|
5554
5425
|
dragAxis,
|
5555
|
-
isEnabled,
|
5556
5426
|
index: i,
|
5557
5427
|
collisionAxis,
|
5558
|
-
inDroppableZone:
|
5428
|
+
inDroppableZone: targetAccepted
|
5559
5429
|
},
|
5560
5430
|
componentId
|
5561
5431
|
);
|
@@ -5570,15 +5440,15 @@ var DropZoneRenderItem = ({
|
|
5570
5440
|
metadata
|
5571
5441
|
}) => {
|
5572
5442
|
const Component = config.components[item.type];
|
5573
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0,
|
5574
|
-
const nextContextValue = (0,
|
5443
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5444
|
+
const nextContextValue = (0, import_react35.useMemo)(
|
5575
5445
|
() => ({
|
5576
5446
|
areaId: props.id,
|
5577
5447
|
depth: 1
|
5578
5448
|
}),
|
5579
5449
|
[props]
|
5580
5450
|
);
|
5581
|
-
return /* @__PURE__ */ (0,
|
5451
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5582
5452
|
Component.render,
|
5583
5453
|
__spreadProps(__spreadValues({}, props), {
|
5584
5454
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
@@ -5588,15 +5458,15 @@ var DropZoneRenderItem = ({
|
|
5588
5458
|
})
|
5589
5459
|
) }, props.id);
|
5590
5460
|
};
|
5591
|
-
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0,
|
5592
|
-
var
|
5461
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
|
5462
|
+
var DropZoneRender2 = (0, import_react35.forwardRef)(
|
5593
5463
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
5594
|
-
const ctx = (0,
|
5464
|
+
const ctx = (0, import_react35.useContext)(dropZoneContext);
|
5595
5465
|
const { areaId = "root" } = ctx || {};
|
5596
|
-
const { config, data, metadata } = (0,
|
5466
|
+
const { config, data, metadata } = (0, import_react35.useContext)(renderContext);
|
5597
5467
|
let zoneCompound = rootDroppableId;
|
5598
5468
|
let content = (data == null ? void 0 : data.content) || [];
|
5599
|
-
(0,
|
5469
|
+
(0, import_react35.useEffect)(() => {
|
5600
5470
|
if (!content) {
|
5601
5471
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5602
5472
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
@@ -5615,10 +5485,10 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5615
5485
|
zoneCompound = `${areaId}:${zone}`;
|
5616
5486
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
5617
5487
|
}
|
5618
|
-
return /* @__PURE__ */ (0,
|
5488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className, style, ref, children: content.map((item) => {
|
5619
5489
|
const Component = config.components[item.type];
|
5620
5490
|
if (Component) {
|
5621
|
-
return /* @__PURE__ */ (0,
|
5491
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5622
5492
|
DropZoneRenderItem,
|
5623
5493
|
{
|
5624
5494
|
config,
|
@@ -5632,21 +5502,20 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5632
5502
|
}) });
|
5633
5503
|
}
|
5634
5504
|
);
|
5635
|
-
var DropZonePure = (props) => /* @__PURE__ */ (0,
|
5636
|
-
var DropZone = (0,
|
5505
|
+
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
|
5506
|
+
var DropZone = (0, import_react35.forwardRef)(
|
5637
5507
|
function DropZone2(props, ref) {
|
5638
|
-
const ctx = (0,
|
5508
|
+
const ctx = (0, import_react35.useContext)(dropZoneContext);
|
5639
5509
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
5640
|
-
return /* @__PURE__ */ (0,
|
5510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
5641
5511
|
}
|
5642
|
-
return /* @__PURE__ */ (0,
|
5512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadProps(__spreadValues({}, props), { ref })) });
|
5643
5513
|
}
|
5644
5514
|
);
|
5645
5515
|
|
5646
5516
|
// lib/dnd/NestedDroppablePlugin.ts
|
5647
5517
|
init_react_import();
|
5648
|
-
var
|
5649
|
-
var import_state2 = require("@dnd-kit/state");
|
5518
|
+
var import_abstract9 = require("@dnd-kit/abstract");
|
5650
5519
|
|
5651
5520
|
// lib/throttle.ts
|
5652
5521
|
init_react_import();
|
@@ -5695,7 +5564,7 @@ var GlobalPosition = class {
|
|
5695
5564
|
var _a;
|
5696
5565
|
this.target = target;
|
5697
5566
|
this.original = original;
|
5698
|
-
this.frameEl = document.querySelector("iframe");
|
5567
|
+
this.frameEl = document.querySelector("iframe#preview-frame");
|
5699
5568
|
if (this.frameEl) {
|
5700
5569
|
this.frameRect = this.frameEl.getBoundingClientRect();
|
5701
5570
|
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
@@ -5775,6 +5644,7 @@ var getZoneId2 = (candidate) => {
|
|
5775
5644
|
}
|
5776
5645
|
return id;
|
5777
5646
|
};
|
5647
|
+
var BUFFER = 6;
|
5778
5648
|
var getPointerCollisions = (position, manager) => {
|
5779
5649
|
const candidates = [];
|
5780
5650
|
let elements = position.target.ownerDocument.elementsFromPoint(
|
@@ -5798,13 +5668,26 @@ var getPointerCollisions = (position, manager) => {
|
|
5798
5668
|
for (let i = 0; i < elements.length; i++) {
|
5799
5669
|
const element = elements[i];
|
5800
5670
|
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
5671
|
+
const id = element.getAttribute("data-puck-dnd");
|
5672
|
+
const isVoid = element.hasAttribute("data-puck-dnd-void");
|
5673
|
+
if (BUFFER && (dropzoneId || id) && !isVoid) {
|
5674
|
+
const box = element.getBoundingClientRect();
|
5675
|
+
const contractedBox = {
|
5676
|
+
left: box.left + BUFFER,
|
5677
|
+
right: box.right - BUFFER,
|
5678
|
+
top: box.top + BUFFER,
|
5679
|
+
bottom: box.bottom - BUFFER
|
5680
|
+
};
|
5681
|
+
if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
|
5682
|
+
continue;
|
5683
|
+
}
|
5684
|
+
}
|
5801
5685
|
if (dropzoneId) {
|
5802
5686
|
const droppable = manager.registry.droppables.get(dropzoneId);
|
5803
5687
|
if (droppable) {
|
5804
5688
|
candidates.push(droppable);
|
5805
5689
|
}
|
5806
5690
|
}
|
5807
|
-
const id = element.getAttribute("data-puck-dnd");
|
5808
5691
|
if (id) {
|
5809
5692
|
const droppable = manager.registry.droppables.get(id);
|
5810
5693
|
if (droppable) {
|
@@ -5858,17 +5741,17 @@ var findDeepestCandidate = (position, manager) => {
|
|
5858
5741
|
return { zone, area };
|
5859
5742
|
}
|
5860
5743
|
return {
|
5861
|
-
zone:
|
5862
|
-
area:
|
5744
|
+
zone: rootDroppableId,
|
5745
|
+
area: rootAreaId
|
5863
5746
|
};
|
5864
5747
|
};
|
5865
|
-
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends
|
5748
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
5866
5749
|
constructor(manager, options) {
|
5867
5750
|
super(manager);
|
5868
5751
|
if (typeof window === "undefined") {
|
5869
5752
|
return;
|
5870
5753
|
}
|
5871
|
-
|
5754
|
+
this.registerEffect(() => {
|
5872
5755
|
const handleMove = (event) => {
|
5873
5756
|
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
5874
5757
|
const position = new GlobalPosition(target, {
|
@@ -5892,12 +5775,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
5892
5775
|
capture: true
|
5893
5776
|
// dndkit's PointerSensor prevents propagation during drag
|
5894
5777
|
});
|
5895
|
-
|
5778
|
+
const cleanup = () => {
|
5896
5779
|
document.body.removeEventListener("pointermove", handlePointerMove, {
|
5897
5780
|
capture: true
|
5898
5781
|
});
|
5899
|
-
cleanupEffect();
|
5900
5782
|
};
|
5783
|
+
return cleanup;
|
5901
5784
|
});
|
5902
5785
|
}
|
5903
5786
|
};
|
@@ -5957,14 +5840,15 @@ function getDeepDir(el) {
|
|
5957
5840
|
}
|
5958
5841
|
|
5959
5842
|
// components/DragDropContext/index.tsx
|
5960
|
-
var
|
5843
|
+
var import_state = require("@dnd-kit/state");
|
5844
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
5961
5845
|
var DEBUG3 = false;
|
5962
|
-
var dragListenerContext = (0,
|
5846
|
+
var dragListenerContext = (0, import_react38.createContext)({
|
5963
5847
|
dragListeners: {}
|
5964
5848
|
});
|
5965
5849
|
function useDragListener(type, fn, deps = []) {
|
5966
|
-
const { setDragListeners } = (0,
|
5967
|
-
(0,
|
5850
|
+
const { setDragListeners } = (0, import_react38.useContext)(dragListenerContext);
|
5851
|
+
(0, import_react38.useEffect)(() => {
|
5968
5852
|
if (setDragListeners) {
|
5969
5853
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5970
5854
|
[type]: [...old[type] || [], fn]
|
@@ -5974,8 +5858,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5974
5858
|
}
|
5975
5859
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5976
5860
|
var useTempDisableFallback = (timeout3) => {
|
5977
|
-
const lastFallbackDisable = (0,
|
5978
|
-
return (0,
|
5861
|
+
const lastFallbackDisable = (0, import_react38.useRef)(null);
|
5862
|
+
return (0, import_react38.useCallback)((manager) => {
|
5979
5863
|
collisionStore.setState({ fallbackEnabled: false });
|
5980
5864
|
const fallbackId = generateId();
|
5981
5865
|
lastFallbackDisable.current = fallbackId;
|
@@ -5994,19 +5878,21 @@ var DragDropContextClient = ({
|
|
5994
5878
|
const dispatch = useAppStore((s) => s.dispatch);
|
5995
5879
|
const appStore = useAppStoreApi();
|
5996
5880
|
const id = useSafeId();
|
5997
|
-
const debouncedParamsRef = (0,
|
5881
|
+
const debouncedParamsRef = (0, import_react38.useRef)(null);
|
5998
5882
|
const tempDisableFallback = useTempDisableFallback(100);
|
5999
|
-
const [zoneStore] = (0,
|
5883
|
+
const [zoneStore] = (0, import_react38.useState)(
|
6000
5884
|
() => (0, import_zustand5.createStore)(() => ({
|
6001
5885
|
zoneDepthIndex: {},
|
6002
5886
|
nextZoneDepthIndex: {},
|
6003
5887
|
areaDepthIndex: {},
|
6004
5888
|
nextAreaDepthIndex: {},
|
6005
5889
|
draggedItem: null,
|
6006
|
-
previewIndex: {}
|
5890
|
+
previewIndex: {},
|
5891
|
+
enabledIndex: {},
|
5892
|
+
hoveringComponent: null
|
6007
5893
|
}))
|
6008
5894
|
);
|
6009
|
-
const getChanged2 = (0,
|
5895
|
+
const getChanged2 = (0, import_react38.useCallback)(
|
6010
5896
|
(params, id2) => {
|
6011
5897
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
6012
5898
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -6027,7 +5913,7 @@ var DragDropContextClient = ({
|
|
6027
5913
|
},
|
6028
5914
|
[zoneStore]
|
6029
5915
|
);
|
6030
|
-
const setDeepestAndCollide = (0,
|
5916
|
+
const setDeepestAndCollide = (0, import_react38.useCallback)(
|
6031
5917
|
(params, manager) => {
|
6032
5918
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
6033
5919
|
if (!zoneChanged && !areaChanged) return;
|
@@ -6051,7 +5937,7 @@ var DragDropContextClient = ({
|
|
6051
5937
|
setDeepestDb.cancel();
|
6052
5938
|
debouncedParamsRef.current = null;
|
6053
5939
|
};
|
6054
|
-
(0,
|
5940
|
+
(0, import_react38.useEffect)(() => {
|
6055
5941
|
if (DEBUG3) {
|
6056
5942
|
zoneStore.subscribe(
|
6057
5943
|
(s) => {
|
@@ -6065,7 +5951,7 @@ var DragDropContextClient = ({
|
|
6065
5951
|
);
|
6066
5952
|
}
|
6067
5953
|
}, []);
|
6068
|
-
const [plugins] = (0,
|
5954
|
+
const [plugins] = (0, import_react38.useState)(() => [
|
6069
5955
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
6070
5956
|
createNestedDroppablePlugin(
|
6071
5957
|
{
|
@@ -6113,10 +5999,10 @@ var DragDropContextClient = ({
|
|
6113
5999
|
)
|
6114
6000
|
]);
|
6115
6001
|
const sensors = useSensors();
|
6116
|
-
const [dragListeners, setDragListeners] = (0,
|
6117
|
-
const dragMode = (0,
|
6118
|
-
const initialSelector = (0,
|
6119
|
-
const nextContextValue = (0,
|
6002
|
+
const [dragListeners, setDragListeners] = (0, import_react38.useState)({});
|
6003
|
+
const dragMode = (0, import_react38.useRef)(null);
|
6004
|
+
const initialSelector = (0, import_react38.useRef)(void 0);
|
6005
|
+
const nextContextValue = (0, import_react38.useMemo)(
|
6120
6006
|
() => ({
|
6121
6007
|
mode: "edit",
|
6122
6008
|
areaId: "root",
|
@@ -6124,20 +6010,22 @@ var DragDropContextClient = ({
|
|
6124
6010
|
}),
|
6125
6011
|
[]
|
6126
6012
|
);
|
6127
|
-
return /* @__PURE__ */ (0,
|
6013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
6128
6014
|
dragListenerContext.Provider,
|
6129
6015
|
{
|
6130
6016
|
value: {
|
6131
6017
|
dragListeners,
|
6132
6018
|
setDragListeners
|
6133
6019
|
},
|
6134
|
-
children: /* @__PURE__ */ (0,
|
6135
|
-
|
6020
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
6021
|
+
import_react37.DragDropProvider,
|
6136
6022
|
{
|
6137
6023
|
plugins,
|
6138
6024
|
sensors,
|
6139
6025
|
onDragEnd: (event, manager) => {
|
6140
|
-
var _a;
|
6026
|
+
var _a, _b;
|
6027
|
+
const entryEl = (_a = getFrame()) == null ? void 0 : _a.querySelector("[data-puck-entry]");
|
6028
|
+
entryEl == null ? void 0 : entryEl.removeAttribute("data-puck-dragging");
|
6141
6029
|
const { source, target } = event.operation;
|
6142
6030
|
if (!source) {
|
6143
6031
|
zoneStore.setState({ draggedItem: null });
|
@@ -6145,9 +6033,9 @@ var DragDropContextClient = ({
|
|
6145
6033
|
}
|
6146
6034
|
const { zone, index } = source.data;
|
6147
6035
|
const { previewIndex = {} } = zoneStore.getState() || {};
|
6148
|
-
const thisPreview = ((
|
6149
|
-
|
6150
|
-
var _a2,
|
6036
|
+
const thisPreview = ((_b = previewIndex[zone]) == null ? void 0 : _b.props.id) === source.id ? previewIndex[zone] : null;
|
6037
|
+
const onAnimationEnd = () => {
|
6038
|
+
var _a2, _b2;
|
6151
6039
|
zoneStore.setState({ draggedItem: null });
|
6152
6040
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
6153
6041
|
zoneStore.setState({ previewIndex: {} });
|
@@ -6183,23 +6071,28 @@ var DragDropContextClient = ({
|
|
6183
6071
|
});
|
6184
6072
|
}
|
6185
6073
|
}
|
6186
|
-
|
6187
|
-
|
6188
|
-
|
6189
|
-
|
6190
|
-
|
6191
|
-
|
6192
|
-
|
6193
|
-
|
6194
|
-
|
6195
|
-
}, 50);
|
6196
|
-
(_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
|
6074
|
+
dispatch({
|
6075
|
+
type: "setUi",
|
6076
|
+
ui: {
|
6077
|
+
itemSelector: { index, zone },
|
6078
|
+
isDragging: false
|
6079
|
+
},
|
6080
|
+
recordHistory: true
|
6081
|
+
});
|
6082
|
+
(_b2 = dragListeners.dragend) == null ? void 0 : _b2.forEach((fn) => {
|
6197
6083
|
fn(event, manager);
|
6198
6084
|
});
|
6199
|
-
}
|
6085
|
+
};
|
6086
|
+
let dispose;
|
6087
|
+
dispose = (0, import_state.effect)(() => {
|
6088
|
+
if (source.status === "idle") {
|
6089
|
+
onAnimationEnd();
|
6090
|
+
dispose == null ? void 0 : dispose();
|
6091
|
+
}
|
6092
|
+
});
|
6200
6093
|
},
|
6201
6094
|
onDragOver: (event, manager) => {
|
6202
|
-
var _a, _b, _c, _d
|
6095
|
+
var _a, _b, _c, _d;
|
6203
6096
|
event.preventDefault();
|
6204
6097
|
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
6205
6098
|
if (!draggedItem) return;
|
@@ -6217,7 +6110,7 @@ var DragDropContextClient = ({
|
|
6217
6110
|
const targetData = target.data;
|
6218
6111
|
targetZone = targetData.zone;
|
6219
6112
|
targetIndex = targetData.index;
|
6220
|
-
const collisionData = (
|
6113
|
+
const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
|
6221
6114
|
const dir = getDeepDir(target.element);
|
6222
6115
|
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";
|
6223
6116
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
@@ -6230,7 +6123,7 @@ var DragDropContextClient = ({
|
|
6230
6123
|
targetZone = target.id.toString();
|
6231
6124
|
targetIndex = 0;
|
6232
6125
|
}
|
6233
|
-
const path = ((
|
6126
|
+
const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
|
6234
6127
|
if (targetId === sourceId || path.find((path2) => {
|
6235
6128
|
const [pathId] = path2.split(":");
|
6236
6129
|
return pathId === sourceId;
|
@@ -6276,16 +6169,12 @@ var DragDropContextClient = ({
|
|
6276
6169
|
});
|
6277
6170
|
}
|
6278
6171
|
}
|
6279
|
-
(
|
6172
|
+
(_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
|
6280
6173
|
fn(event, manager);
|
6281
6174
|
});
|
6282
6175
|
},
|
6283
6176
|
onDragStart: (event, manager) => {
|
6284
6177
|
var _a;
|
6285
|
-
dispatch({
|
6286
|
-
type: "setUi",
|
6287
|
-
ui: { itemSelector: null, isDragging: true }
|
6288
|
-
});
|
6289
6178
|
const { source } = event.operation;
|
6290
6179
|
if (source && source.type !== "void") {
|
6291
6180
|
const sourceData = source.data;
|
@@ -6315,13 +6204,33 @@ var DragDropContextClient = ({
|
|
6315
6204
|
});
|
6316
6205
|
},
|
6317
6206
|
onBeforeDragStart: (event) => {
|
6318
|
-
var _a;
|
6319
|
-
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.
|
6207
|
+
var _a, _b, _c, _d;
|
6208
|
+
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
|
6320
6209
|
dragMode.current = isNewComponent ? "new" : "existing";
|
6321
6210
|
initialSelector.current = void 0;
|
6322
6211
|
zoneStore.setState({ draggedItem: event.operation.source });
|
6212
|
+
if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== ((_c = event.operation.source) == null ? void 0 : _c.id)) {
|
6213
|
+
dispatch({
|
6214
|
+
type: "setUi",
|
6215
|
+
ui: {
|
6216
|
+
itemSelector: null,
|
6217
|
+
isDragging: true
|
6218
|
+
},
|
6219
|
+
recordHistory: false
|
6220
|
+
});
|
6221
|
+
} else {
|
6222
|
+
dispatch({
|
6223
|
+
type: "setUi",
|
6224
|
+
ui: {
|
6225
|
+
isDragging: true
|
6226
|
+
},
|
6227
|
+
recordHistory: false
|
6228
|
+
});
|
6229
|
+
}
|
6230
|
+
const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
|
6231
|
+
entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
|
6323
6232
|
},
|
6324
|
-
children: /* @__PURE__ */ (0,
|
6233
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
|
6325
6234
|
}
|
6326
6235
|
)
|
6327
6236
|
}
|
@@ -6335,11 +6244,12 @@ var DragDropContext = ({
|
|
6335
6244
|
if (status === "LOADING") {
|
6336
6245
|
return children;
|
6337
6246
|
}
|
6338
|
-
return /* @__PURE__ */ (0,
|
6247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
6339
6248
|
};
|
6340
6249
|
|
6341
6250
|
// components/Drawer/index.tsx
|
6342
|
-
var
|
6251
|
+
var import_react40 = require("@dnd-kit/react");
|
6252
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
6343
6253
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
6344
6254
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
6345
6255
|
var DrawerItemInner = ({
|
@@ -6349,11 +6259,11 @@ var DrawerItemInner = ({
|
|
6349
6259
|
dragRef,
|
6350
6260
|
isDragDisabled
|
6351
6261
|
}) => {
|
6352
|
-
const CustomInner = (0,
|
6353
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
6262
|
+
const CustomInner = (0, import_react39.useMemo)(
|
6263
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
6354
6264
|
[children]
|
6355
6265
|
);
|
6356
|
-
return /* @__PURE__ */ (0,
|
6266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6357
6267
|
"div",
|
6358
6268
|
{
|
6359
6269
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -6361,9 +6271,9 @@ var DrawerItemInner = ({
|
|
6361
6271
|
onMouseDown: (e) => e.preventDefault(),
|
6362
6272
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
6363
6273
|
"data-puck-drawer-item": true,
|
6364
|
-
children: /* @__PURE__ */ (0,
|
6365
|
-
/* @__PURE__ */ (0,
|
6366
|
-
/* @__PURE__ */ (0,
|
6274
|
+
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: [
|
6275
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
6276
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DragIcon, {}) })
|
6367
6277
|
] }) }) })
|
6368
6278
|
}
|
6369
6279
|
);
|
@@ -6375,14 +6285,15 @@ var DrawerItemDraggable = ({
|
|
6375
6285
|
id,
|
6376
6286
|
isDragDisabled
|
6377
6287
|
}) => {
|
6378
|
-
const { ref } =
|
6288
|
+
const { ref } = (0, import_react40.useDraggable)({
|
6379
6289
|
id,
|
6380
|
-
data: {
|
6381
|
-
disabled: isDragDisabled
|
6290
|
+
data: { componentType: name },
|
6291
|
+
disabled: isDragDisabled,
|
6292
|
+
type: "drawer"
|
6382
6293
|
});
|
6383
|
-
return /* @__PURE__ */ (0,
|
6384
|
-
/* @__PURE__ */ (0,
|
6385
|
-
/* @__PURE__ */ (0,
|
6294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
|
6295
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
|
6296
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6386
6297
|
DrawerItemInner,
|
6387
6298
|
{
|
6388
6299
|
name,
|
@@ -6403,7 +6314,7 @@ var DrawerItem = ({
|
|
6403
6314
|
isDragDisabled
|
6404
6315
|
}) => {
|
6405
6316
|
const resolvedId = id || name;
|
6406
|
-
const [dynamicId, setDynamicId] = (0,
|
6317
|
+
const [dynamicId, setDynamicId] = (0, import_react39.useState)(generateId(resolvedId));
|
6407
6318
|
if (typeof index !== "undefined") {
|
6408
6319
|
console.error(
|
6409
6320
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -6416,7 +6327,7 @@ var DrawerItem = ({
|
|
6416
6327
|
},
|
6417
6328
|
[resolvedId]
|
6418
6329
|
);
|
6419
|
-
return /* @__PURE__ */ (0,
|
6330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6420
6331
|
DrawerItemDraggable,
|
6421
6332
|
{
|
6422
6333
|
name,
|
@@ -6443,19 +6354,20 @@ var Drawer = ({
|
|
6443
6354
|
);
|
6444
6355
|
}
|
6445
6356
|
const id = useSafeId();
|
6446
|
-
const { ref } =
|
6357
|
+
const { ref } = (0, import_react40.useDroppable)({
|
6447
6358
|
id,
|
6448
6359
|
type: "void",
|
6449
6360
|
collisionPriority: 0
|
6450
6361
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
6451
6362
|
});
|
6452
|
-
return /* @__PURE__ */ (0,
|
6363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6453
6364
|
"div",
|
6454
6365
|
{
|
6455
6366
|
className: getClassName18(),
|
6456
6367
|
ref,
|
6457
6368
|
"data-puck-dnd": id,
|
6458
6369
|
"data-puck-drawer": true,
|
6370
|
+
"data-puck-dnd-void": true,
|
6459
6371
|
children
|
6460
6372
|
}
|
6461
6373
|
);
|
@@ -6464,7 +6376,7 @@ Drawer.Item = DrawerItem;
|
|
6464
6376
|
|
6465
6377
|
// components/Puck/index.tsx
|
6466
6378
|
init_react_import();
|
6467
|
-
var
|
6379
|
+
var import_react55 = require("react");
|
6468
6380
|
|
6469
6381
|
// components/SidebarSection/index.tsx
|
6470
6382
|
init_react_import();
|
@@ -6475,7 +6387,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
6475
6387
|
|
6476
6388
|
// lib/use-breadcrumbs.ts
|
6477
6389
|
init_react_import();
|
6478
|
-
var
|
6390
|
+
var import_react41 = require("react");
|
6479
6391
|
var useBreadcrumbs = (renderCount) => {
|
6480
6392
|
const selectedId = useAppStore((s) => {
|
6481
6393
|
var _a;
|
@@ -6487,7 +6399,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6487
6399
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
6488
6400
|
});
|
6489
6401
|
const appStore = useAppStoreApi();
|
6490
|
-
return (0,
|
6402
|
+
return (0, import_react41.useMemo)(() => {
|
6491
6403
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
6492
6404
|
var _a, _b, _c;
|
6493
6405
|
const [componentId] = zoneCompound.split(":");
|
@@ -6518,7 +6430,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6518
6430
|
};
|
6519
6431
|
|
6520
6432
|
// components/SidebarSection/index.tsx
|
6521
|
-
var
|
6433
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
6522
6434
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
6523
6435
|
var SidebarSection = ({
|
6524
6436
|
children,
|
@@ -6531,15 +6443,15 @@ var SidebarSection = ({
|
|
6531
6443
|
}) => {
|
6532
6444
|
const setUi = useAppStore((s) => s.setUi);
|
6533
6445
|
const breadcrumbs = useBreadcrumbs(1);
|
6534
|
-
return /* @__PURE__ */ (0,
|
6446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
6535
6447
|
"div",
|
6536
6448
|
{
|
6537
6449
|
className: getClassName19({ noBorderTop, noPadding }),
|
6538
6450
|
style: { background },
|
6539
6451
|
children: [
|
6540
|
-
/* @__PURE__ */ (0,
|
6541
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
6542
|
-
/* @__PURE__ */ (0,
|
6452
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
6453
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
6454
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6543
6455
|
"button",
|
6544
6456
|
{
|
6545
6457
|
type: "button",
|
@@ -6548,12 +6460,12 @@ var SidebarSection = ({
|
|
6548
6460
|
children: breadcrumb.label
|
6549
6461
|
}
|
6550
6462
|
),
|
6551
|
-
/* @__PURE__ */ (0,
|
6463
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronRight, { size: 16 })
|
6552
6464
|
] }, i)) : null,
|
6553
|
-
/* @__PURE__ */ (0,
|
6465
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
6554
6466
|
] }) }),
|
6555
|
-
/* @__PURE__ */ (0,
|
6556
|
-
isLoading && /* @__PURE__ */ (0,
|
6467
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("content"), children }),
|
6468
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 32 }) })
|
6557
6469
|
]
|
6558
6470
|
}
|
6559
6471
|
);
|
@@ -6567,7 +6479,7 @@ init_react_import();
|
|
6567
6479
|
var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
6568
6480
|
|
6569
6481
|
// components/MenuBar/index.tsx
|
6570
|
-
var
|
6482
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6571
6483
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
6572
6484
|
function MenuBar({
|
6573
6485
|
menuOpen = false,
|
@@ -6578,7 +6490,7 @@ function MenuBar({
|
|
6578
6490
|
const forward = useAppStore((s) => s.history.forward);
|
6579
6491
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
6580
6492
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
6581
|
-
return /* @__PURE__ */ (0,
|
6493
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
6582
6494
|
"div",
|
6583
6495
|
{
|
6584
6496
|
className: getClassName20({ menuOpen }),
|
@@ -6592,12 +6504,12 @@ function MenuBar({
|
|
6592
6504
|
setMenuOpen(false);
|
6593
6505
|
}
|
6594
6506
|
},
|
6595
|
-
children: /* @__PURE__ */ (0,
|
6596
|
-
/* @__PURE__ */ (0,
|
6597
|
-
/* @__PURE__ */ (0,
|
6598
|
-
/* @__PURE__ */ (0,
|
6507
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("inner"), children: [
|
6508
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("history"), children: [
|
6509
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Undo2, { size: 21 }) }),
|
6510
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Redo2, { size: 21 }) })
|
6599
6511
|
] }),
|
6600
|
-
/* @__PURE__ */ (0,
|
6512
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
6601
6513
|
] })
|
6602
6514
|
}
|
6603
6515
|
);
|
@@ -6615,14 +6527,14 @@ init_react_import();
|
|
6615
6527
|
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
6616
6528
|
|
6617
6529
|
// components/Puck/components/Fields/index.tsx
|
6618
|
-
var
|
6530
|
+
var import_react42 = require("react");
|
6619
6531
|
var import_shallow4 = require("zustand/react/shallow");
|
6620
|
-
var
|
6532
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6621
6533
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
6622
6534
|
var DefaultFields = ({
|
6623
6535
|
children
|
6624
6536
|
}) => {
|
6625
|
-
return /* @__PURE__ */ (0,
|
6537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
|
6626
6538
|
};
|
6627
6539
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
6628
6540
|
let currentProps;
|
@@ -6688,12 +6600,12 @@ var FieldsChild = ({ fieldName }) => {
|
|
6688
6600
|
})
|
6689
6601
|
);
|
6690
6602
|
const appStore = useAppStoreApi();
|
6691
|
-
const onChange = (0,
|
6603
|
+
const onChange = (0, import_react42.useCallback)(createOnChange(fieldName, appStore), [
|
6692
6604
|
fieldName
|
6693
6605
|
]);
|
6694
6606
|
if (!field || !id) return null;
|
6695
6607
|
if (field.type === "slot") return null;
|
6696
|
-
return /* @__PURE__ */ (0,
|
6608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
6697
6609
|
AutoFieldPrivate,
|
6698
6610
|
{
|
6699
6611
|
field,
|
@@ -6721,11 +6633,16 @@ var Fields = ({ wrapFields = true }) => {
|
|
6721
6633
|
useRegisterFieldsSlice(appStore, id);
|
6722
6634
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
6723
6635
|
const fieldNames = useAppStore(
|
6724
|
-
(0, import_shallow4.useShallow)((s) =>
|
6636
|
+
(0, import_shallow4.useShallow)((s) => {
|
6637
|
+
if (s.fields.id === id) {
|
6638
|
+
return Object.keys(s.fields.fields);
|
6639
|
+
}
|
6640
|
+
return [];
|
6641
|
+
})
|
6725
6642
|
);
|
6726
6643
|
const isLoading = fieldsLoading || componentResolving;
|
6727
|
-
const Wrapper = (0,
|
6728
|
-
return /* @__PURE__ */ (0,
|
6644
|
+
const Wrapper = (0, import_react42.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
6645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
6729
6646
|
"form",
|
6730
6647
|
{
|
6731
6648
|
className: getClassName21({ wrapFields }),
|
@@ -6733,8 +6650,8 @@ var Fields = ({ wrapFields = true }) => {
|
|
6733
6650
|
e.preventDefault();
|
6734
6651
|
},
|
6735
6652
|
children: [
|
6736
|
-
/* @__PURE__ */ (0,
|
6737
|
-
isLoading && /* @__PURE__ */ (0,
|
6653
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChild, { fieldName }, fieldName)) }),
|
6654
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 16 }) }) })
|
6738
6655
|
]
|
6739
6656
|
}
|
6740
6657
|
);
|
@@ -6745,7 +6662,7 @@ init_react_import();
|
|
6745
6662
|
|
6746
6663
|
// lib/use-component-list.tsx
|
6747
6664
|
init_react_import();
|
6748
|
-
var
|
6665
|
+
var import_react43 = require("react");
|
6749
6666
|
|
6750
6667
|
// components/ComponentList/index.tsx
|
6751
6668
|
init_react_import();
|
@@ -6755,7 +6672,7 @@ init_react_import();
|
|
6755
6672
|
var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
6756
6673
|
|
6757
6674
|
// components/ComponentList/index.tsx
|
6758
|
-
var
|
6675
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
6759
6676
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
6760
6677
|
var ComponentListItem = ({
|
6761
6678
|
name,
|
@@ -6767,7 +6684,7 @@ var ComponentListItem = ({
|
|
6767
6684
|
type: name
|
6768
6685
|
}).insert
|
6769
6686
|
);
|
6770
|
-
return /* @__PURE__ */ (0,
|
6687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
6771
6688
|
};
|
6772
6689
|
var ComponentList = ({
|
6773
6690
|
children,
|
@@ -6778,8 +6695,8 @@ var ComponentList = ({
|
|
6778
6695
|
const setUi = useAppStore((s) => s.setUi);
|
6779
6696
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
6780
6697
|
const { expanded = true } = componentList[id] || {};
|
6781
|
-
return /* @__PURE__ */ (0,
|
6782
|
-
title && /* @__PURE__ */ (0,
|
6698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
6699
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
6783
6700
|
"button",
|
6784
6701
|
{
|
6785
6702
|
type: "button",
|
@@ -6793,14 +6710,14 @@ var ComponentList = ({
|
|
6793
6710
|
}),
|
6794
6711
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
6795
6712
|
children: [
|
6796
|
-
/* @__PURE__ */ (0,
|
6797
|
-
/* @__PURE__ */ (0,
|
6713
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
|
6714
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: 12 }) })
|
6798
6715
|
]
|
6799
6716
|
}
|
6800
6717
|
),
|
6801
|
-
/* @__PURE__ */ (0,
|
6718
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
6802
6719
|
var _a;
|
6803
|
-
return /* @__PURE__ */ (0,
|
6720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
6804
6721
|
ComponentListItem,
|
6805
6722
|
{
|
6806
6723
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -6814,12 +6731,12 @@ var ComponentList = ({
|
|
6814
6731
|
ComponentList.Item = ComponentListItem;
|
6815
6732
|
|
6816
6733
|
// lib/use-component-list.tsx
|
6817
|
-
var
|
6734
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
6818
6735
|
var useComponentList = () => {
|
6819
|
-
const [componentList, setComponentList] = (0,
|
6736
|
+
const [componentList, setComponentList] = (0, import_react43.useState)();
|
6820
6737
|
const config = useAppStore((s) => s.config);
|
6821
6738
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6822
|
-
(0,
|
6739
|
+
(0, import_react43.useEffect)(() => {
|
6823
6740
|
var _a, _b, _c;
|
6824
6741
|
if (Object.keys(uiComponentList).length > 0) {
|
6825
6742
|
const matchedComponents = [];
|
@@ -6829,7 +6746,7 @@ var useComponentList = () => {
|
|
6829
6746
|
if (category.visible === false || !category.components) {
|
6830
6747
|
return null;
|
6831
6748
|
}
|
6832
|
-
return /* @__PURE__ */ (0,
|
6749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6833
6750
|
ComponentList,
|
6834
6751
|
{
|
6835
6752
|
id: categoryKey,
|
@@ -6838,7 +6755,7 @@ var useComponentList = () => {
|
|
6838
6755
|
var _a2;
|
6839
6756
|
matchedComponents.push(componentName);
|
6840
6757
|
const componentConf = config.components[componentName] || {};
|
6841
|
-
return /* @__PURE__ */ (0,
|
6758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6842
6759
|
ComponentList.Item,
|
6843
6760
|
{
|
6844
6761
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -6858,7 +6775,7 @@ var useComponentList = () => {
|
|
6858
6775
|
);
|
6859
6776
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
6860
6777
|
_componentList.push(
|
6861
|
-
/* @__PURE__ */ (0,
|
6778
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6862
6779
|
ComponentList,
|
6863
6780
|
{
|
6864
6781
|
id: "other",
|
@@ -6866,7 +6783,7 @@ var useComponentList = () => {
|
|
6866
6783
|
children: remainingComponents.map((componentName, i) => {
|
6867
6784
|
var _a2;
|
6868
6785
|
const componentConf = config.components[componentName] || {};
|
6869
|
-
return /* @__PURE__ */ (0,
|
6786
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6870
6787
|
ComponentList.Item,
|
6871
6788
|
{
|
6872
6789
|
name: componentName,
|
@@ -6888,25 +6805,25 @@ var useComponentList = () => {
|
|
6888
6805
|
};
|
6889
6806
|
|
6890
6807
|
// components/Puck/components/Components/index.tsx
|
6891
|
-
var
|
6892
|
-
var
|
6808
|
+
var import_react44 = require("react");
|
6809
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
6893
6810
|
var Components = () => {
|
6894
6811
|
const overrides = useAppStore((s) => s.overrides);
|
6895
6812
|
const componentList = useComponentList();
|
6896
|
-
const Wrapper = (0,
|
6897
|
-
return /* @__PURE__ */ (0,
|
6813
|
+
const Wrapper = (0, import_react44.useMemo)(() => overrides.components || "div", [overrides]);
|
6814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
|
6898
6815
|
};
|
6899
6816
|
|
6900
6817
|
// components/Puck/components/Preview/index.tsx
|
6901
6818
|
init_react_import();
|
6902
|
-
var
|
6819
|
+
var import_react46 = require("react");
|
6903
6820
|
|
6904
6821
|
// components/AutoFrame/index.tsx
|
6905
6822
|
init_react_import();
|
6906
|
-
var
|
6823
|
+
var import_react45 = require("react");
|
6907
6824
|
var import_object_hash = __toESM(require("object-hash"));
|
6908
6825
|
var import_react_dom3 = require("react-dom");
|
6909
|
-
var
|
6826
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6910
6827
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
6911
6828
|
var collectStyles = (doc) => {
|
6912
6829
|
const collected = [];
|
@@ -6949,7 +6866,7 @@ var CopyHostStyles = ({
|
|
6949
6866
|
onStylesLoaded = () => null
|
6950
6867
|
}) => {
|
6951
6868
|
const { document: doc, window: win } = useFrame();
|
6952
|
-
(0,
|
6869
|
+
(0, import_react45.useEffect)(() => {
|
6953
6870
|
if (!win || !doc) {
|
6954
6871
|
return () => {
|
6955
6872
|
};
|
@@ -7106,10 +7023,10 @@ var CopyHostStyles = ({
|
|
7106
7023
|
observer.disconnect();
|
7107
7024
|
};
|
7108
7025
|
}, []);
|
7109
|
-
return /* @__PURE__ */ (0,
|
7026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
|
7110
7027
|
};
|
7111
|
-
var autoFrameContext = (0,
|
7112
|
-
var useFrame = () => (0,
|
7028
|
+
var autoFrameContext = (0, import_react45.createContext)({});
|
7029
|
+
var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
|
7113
7030
|
function AutoFrame(_a) {
|
7114
7031
|
var _b = _a, {
|
7115
7032
|
children,
|
@@ -7130,11 +7047,11 @@ function AutoFrame(_a) {
|
|
7130
7047
|
"onNotReady",
|
7131
7048
|
"frameRef"
|
7132
7049
|
]);
|
7133
|
-
const [loaded, setLoaded] = (0,
|
7134
|
-
const [ctx, setCtx] = (0,
|
7135
|
-
const [mountTarget, setMountTarget] = (0,
|
7136
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
7137
|
-
(0,
|
7050
|
+
const [loaded, setLoaded] = (0, import_react45.useState)(false);
|
7051
|
+
const [ctx, setCtx] = (0, import_react45.useState)({});
|
7052
|
+
const [mountTarget, setMountTarget] = (0, import_react45.useState)();
|
7053
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
|
7054
|
+
(0, import_react45.useEffect)(() => {
|
7138
7055
|
var _a2;
|
7139
7056
|
if (frameRef.current) {
|
7140
7057
|
const doc = frameRef.current.contentDocument;
|
@@ -7153,7 +7070,7 @@ function AutoFrame(_a) {
|
|
7153
7070
|
}
|
7154
7071
|
}
|
7155
7072
|
}, [frameRef, loaded, stylesLoaded]);
|
7156
|
-
return /* @__PURE__ */ (0,
|
7073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7157
7074
|
"iframe",
|
7158
7075
|
__spreadProps(__spreadValues({}, props), {
|
7159
7076
|
className,
|
@@ -7163,7 +7080,7 @@ function AutoFrame(_a) {
|
|
7163
7080
|
onLoad: () => {
|
7164
7081
|
setLoaded(true);
|
7165
7082
|
},
|
7166
|
-
children: /* @__PURE__ */ (0,
|
7083
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7167
7084
|
CopyHostStyles,
|
7168
7085
|
{
|
7169
7086
|
debug,
|
@@ -7182,11 +7099,11 @@ init_react_import();
|
|
7182
7099
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
7183
7100
|
|
7184
7101
|
// components/Puck/components/Preview/index.tsx
|
7185
|
-
var
|
7102
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
7186
7103
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
7187
7104
|
var useBubbleIframeEvents = (ref) => {
|
7188
7105
|
const status = useAppStore((s) => s.status);
|
7189
|
-
(0,
|
7106
|
+
(0, import_react46.useEffect)(() => {
|
7190
7107
|
if (ref.current && status === "READY") {
|
7191
7108
|
const iframe = ref.current;
|
7192
7109
|
const handlePointerMove = (event) => {
|
@@ -7224,7 +7141,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
7224
7141
|
}
|
7225
7142
|
}, [status]);
|
7226
7143
|
};
|
7227
|
-
var
|
7144
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
7228
7145
|
const dispatch = useAppStore((s) => s.dispatch);
|
7229
7146
|
const root = useAppStore((s) => s.state.data.root);
|
7230
7147
|
const config = useAppStore((s) => s.config);
|
@@ -7235,22 +7152,22 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7235
7152
|
const renderData = useAppStore(
|
7236
7153
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
7237
7154
|
);
|
7238
|
-
const Page = (0,
|
7155
|
+
const Page = (0, import_react46.useCallback)(
|
7239
7156
|
(pageProps) => {
|
7240
7157
|
var _a, _b;
|
7241
7158
|
const rootConfig = config.root;
|
7242
7159
|
const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
|
7243
7160
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
7244
7161
|
id: "puck-root"
|
7245
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
7162
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
|
7246
7163
|
},
|
7247
7164
|
[config.root]
|
7248
7165
|
);
|
7249
|
-
const Frame = (0,
|
7166
|
+
const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
|
7250
7167
|
const rootProps = root.props || root;
|
7251
|
-
const ref = (0,
|
7168
|
+
const ref = (0, import_react46.useRef)(null);
|
7252
7169
|
useBubbleIframeEvents(ref);
|
7253
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
7170
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7254
7171
|
Page,
|
7255
7172
|
__spreadProps(__spreadValues({}, rootProps), {
|
7256
7173
|
puck: {
|
@@ -7260,15 +7177,15 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7260
7177
|
metadata
|
7261
7178
|
},
|
7262
7179
|
editMode: true,
|
7263
|
-
children: /* @__PURE__ */ (0,
|
7180
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
|
7264
7181
|
})
|
7265
|
-
) : /* @__PURE__ */ (0,
|
7266
|
-
(0,
|
7182
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
|
7183
|
+
(0, import_react46.useEffect)(() => {
|
7267
7184
|
if (!iframe.enabled) {
|
7268
7185
|
setStatus("READY");
|
7269
7186
|
}
|
7270
7187
|
}, [iframe.enabled]);
|
7271
|
-
return /* @__PURE__ */ (0,
|
7188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7272
7189
|
"div",
|
7273
7190
|
{
|
7274
7191
|
className: getClassName23(),
|
@@ -7277,7 +7194,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7277
7194
|
onClick: () => {
|
7278
7195
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
7279
7196
|
},
|
7280
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
7197
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7281
7198
|
AutoFrame_default,
|
7282
7199
|
{
|
7283
7200
|
id: "preview-frame",
|
@@ -7290,14 +7207,14 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7290
7207
|
setStatus("MOUNTED");
|
7291
7208
|
},
|
7292
7209
|
frameRef: ref,
|
7293
|
-
children: /* @__PURE__ */ (0,
|
7210
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
7294
7211
|
if (Frame) {
|
7295
|
-
return /* @__PURE__ */ (0,
|
7212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
|
7296
7213
|
}
|
7297
7214
|
return inner;
|
7298
7215
|
} })
|
7299
7216
|
}
|
7300
|
-
) : /* @__PURE__ */ (0,
|
7217
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7301
7218
|
"div",
|
7302
7219
|
{
|
7303
7220
|
id: "preview-frame",
|
@@ -7333,7 +7250,7 @@ var scrollIntoView = (el) => {
|
|
7333
7250
|
};
|
7334
7251
|
|
7335
7252
|
// components/LayerTree/index.tsx
|
7336
|
-
var
|
7253
|
+
var import_react47 = require("react");
|
7337
7254
|
|
7338
7255
|
// lib/on-scroll-end.ts
|
7339
7256
|
init_react_import();
|
@@ -7356,7 +7273,7 @@ var onScrollEnd = (frame, cb) => {
|
|
7356
7273
|
|
7357
7274
|
// components/LayerTree/index.tsx
|
7358
7275
|
var import_shallow5 = require("zustand/react/shallow");
|
7359
|
-
var
|
7276
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
7360
7277
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
7361
7278
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
7362
7279
|
var Layer = ({
|
@@ -7365,11 +7282,11 @@ var Layer = ({
|
|
7365
7282
|
zoneCompound
|
7366
7283
|
}) => {
|
7367
7284
|
var _a;
|
7368
|
-
const ctx = (0,
|
7285
|
+
const ctx = (0, import_react47.useContext)(dropZoneContext);
|
7369
7286
|
const config = useAppStore((s) => s.config);
|
7370
7287
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
7371
7288
|
const dispatch = useAppStore((s) => s.dispatch);
|
7372
|
-
const setItemSelector = (0,
|
7289
|
+
const setItemSelector = (0, import_react47.useCallback)(
|
7373
7290
|
(itemSelector2) => {
|
7374
7291
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
7375
7292
|
},
|
@@ -7389,9 +7306,11 @@ var Layer = ({
|
|
7389
7306
|
)
|
7390
7307
|
);
|
7391
7308
|
const containsZone = zonesForItem.length > 0;
|
7392
|
-
const
|
7393
|
-
|
7394
|
-
|
7309
|
+
const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
|
7310
|
+
const isHovering = useContextStore(
|
7311
|
+
ZoneStoreContext,
|
7312
|
+
(s) => s.hoveringComponent === itemId
|
7313
|
+
);
|
7395
7314
|
const childIsSelected = useAppStore((s) => {
|
7396
7315
|
var _a2, _b;
|
7397
7316
|
const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
|
@@ -7402,7 +7321,7 @@ var Layer = ({
|
|
7402
7321
|
});
|
7403
7322
|
const componentConfig = config.components[nodeData.data.type];
|
7404
7323
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
7405
|
-
return /* @__PURE__ */ (0,
|
7324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
7406
7325
|
"li",
|
7407
7326
|
{
|
7408
7327
|
className: getClassNameLayer({
|
@@ -7412,7 +7331,7 @@ var Layer = ({
|
|
7412
7331
|
childIsSelected
|
7413
7332
|
}),
|
7414
7333
|
children: [
|
7415
|
-
/* @__PURE__ */ (0,
|
7334
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
7416
7335
|
"button",
|
7417
7336
|
{
|
7418
7337
|
type: "button",
|
@@ -7438,31 +7357,31 @@ var Layer = ({
|
|
7438
7357
|
});
|
7439
7358
|
});
|
7440
7359
|
},
|
7441
|
-
|
7360
|
+
onMouseEnter: (e) => {
|
7442
7361
|
e.stopPropagation();
|
7443
|
-
|
7362
|
+
zoneStore.setState({ hoveringComponent: itemId });
|
7444
7363
|
},
|
7445
|
-
|
7364
|
+
onMouseLeave: (e) => {
|
7446
7365
|
e.stopPropagation();
|
7447
|
-
|
7366
|
+
zoneStore.setState({ hoveringComponent: null });
|
7448
7367
|
},
|
7449
7368
|
children: [
|
7450
|
-
containsZone && /* @__PURE__ */ (0,
|
7369
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
7451
7370
|
"div",
|
7452
7371
|
{
|
7453
7372
|
className: getClassNameLayer("chevron"),
|
7454
7373
|
title: isSelected ? "Collapse" : "Expand",
|
7455
|
-
children: /* @__PURE__ */ (0,
|
7374
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
|
7456
7375
|
}
|
7457
7376
|
),
|
7458
|
-
/* @__PURE__ */ (0,
|
7459
|
-
/* @__PURE__ */ (0,
|
7460
|
-
/* @__PURE__ */ (0,
|
7377
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
7378
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayoutGrid, { size: "16" }) }),
|
7379
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
|
7461
7380
|
] })
|
7462
7381
|
]
|
7463
7382
|
}
|
7464
7383
|
) }),
|
7465
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0,
|
7384
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
|
7466
7385
|
]
|
7467
7386
|
}
|
7468
7387
|
);
|
@@ -7480,15 +7399,15 @@ var LayerTree = ({
|
|
7480
7399
|
}
|
7481
7400
|
)
|
7482
7401
|
);
|
7483
|
-
return /* @__PURE__ */ (0,
|
7484
|
-
label && /* @__PURE__ */ (0,
|
7485
|
-
/* @__PURE__ */ (0,
|
7402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
7403
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
7404
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
|
7486
7405
|
label
|
7487
7406
|
] }),
|
7488
|
-
/* @__PURE__ */ (0,
|
7489
|
-
contentIds.length === 0 && /* @__PURE__ */ (0,
|
7407
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
|
7408
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
7490
7409
|
contentIds.map((itemId, i) => {
|
7491
|
-
return /* @__PURE__ */ (0,
|
7410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
7492
7411
|
Layer,
|
7493
7412
|
{
|
7494
7413
|
index: i,
|
@@ -7503,7 +7422,7 @@ var LayerTree = ({
|
|
7503
7422
|
};
|
7504
7423
|
|
7505
7424
|
// components/Puck/components/Outline/index.tsx
|
7506
|
-
var
|
7425
|
+
var import_react48 = require("react");
|
7507
7426
|
|
7508
7427
|
// lib/data/find-zones-for-area.ts
|
7509
7428
|
init_react_import();
|
@@ -7515,14 +7434,14 @@ var findZonesForArea = (state, area) => {
|
|
7515
7434
|
|
7516
7435
|
// components/Puck/components/Outline/index.tsx
|
7517
7436
|
var import_shallow6 = require("zustand/react/shallow");
|
7518
|
-
var
|
7437
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
7519
7438
|
var Outline = () => {
|
7520
7439
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
7521
7440
|
const rootZones = useAppStore(
|
7522
7441
|
(0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
|
7523
7442
|
);
|
7524
|
-
const Wrapper = (0,
|
7525
|
-
return /* @__PURE__ */ (0,
|
7443
|
+
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
7444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7526
7445
|
LayerTree,
|
7527
7446
|
{
|
7528
7447
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
@@ -7655,22 +7574,22 @@ var getBox = function getBox2(el) {
|
|
7655
7574
|
};
|
7656
7575
|
|
7657
7576
|
// components/Puck/components/Canvas/index.tsx
|
7658
|
-
var
|
7577
|
+
var import_react50 = require("react");
|
7659
7578
|
|
7660
7579
|
// components/ViewportControls/index.tsx
|
7661
7580
|
init_react_import();
|
7662
|
-
var
|
7581
|
+
var import_react49 = require("react");
|
7663
7582
|
|
7664
7583
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7665
7584
|
init_react_import();
|
7666
7585
|
var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
|
7667
7586
|
|
7668
7587
|
// components/ViewportControls/index.tsx
|
7669
|
-
var
|
7588
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7670
7589
|
var icons = {
|
7671
|
-
Smartphone: /* @__PURE__ */ (0,
|
7672
|
-
Tablet: /* @__PURE__ */ (0,
|
7673
|
-
Monitor: /* @__PURE__ */ (0,
|
7590
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
|
7591
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
|
7592
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
|
7674
7593
|
};
|
7675
7594
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
7676
7595
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -7682,11 +7601,11 @@ var ViewportButton = ({
|
|
7682
7601
|
onClick
|
7683
7602
|
}) => {
|
7684
7603
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7685
|
-
const [isActive, setIsActive] = (0,
|
7686
|
-
(0,
|
7604
|
+
const [isActive, setIsActive] = (0, import_react49.useState)(false);
|
7605
|
+
(0, import_react49.useEffect)(() => {
|
7687
7606
|
setIsActive(width === viewports.current.width);
|
7688
7607
|
}, [width, viewports.current.width]);
|
7689
|
-
return /* @__PURE__ */ (0,
|
7608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7690
7609
|
IconButton,
|
7691
7610
|
{
|
7692
7611
|
title,
|
@@ -7695,7 +7614,7 @@ var ViewportButton = ({
|
|
7695
7614
|
e.stopPropagation();
|
7696
7615
|
onClick({ width, height });
|
7697
7616
|
},
|
7698
|
-
children: /* @__PURE__ */ (0,
|
7617
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
|
7699
7618
|
}
|
7700
7619
|
) });
|
7701
7620
|
};
|
@@ -7719,7 +7638,7 @@ var ViewportControls = ({
|
|
7719
7638
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7720
7639
|
(option) => option.value === autoZoom
|
7721
7640
|
);
|
7722
|
-
const zoomOptions = (0,
|
7641
|
+
const zoomOptions = (0, import_react49.useMemo)(
|
7723
7642
|
() => [
|
7724
7643
|
...defaultZoomOptions,
|
7725
7644
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7731,8 +7650,8 @@ var ViewportControls = ({
|
|
7731
7650
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
7732
7651
|
[autoZoom]
|
7733
7652
|
);
|
7734
|
-
return /* @__PURE__ */ (0,
|
7735
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
7653
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
|
7654
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7736
7655
|
ViewportButton,
|
7737
7656
|
{
|
7738
7657
|
height: viewport.height,
|
@@ -7743,8 +7662,8 @@ var ViewportControls = ({
|
|
7743
7662
|
},
|
7744
7663
|
i
|
7745
7664
|
)),
|
7746
|
-
/* @__PURE__ */ (0,
|
7747
|
-
/* @__PURE__ */ (0,
|
7665
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
7666
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7748
7667
|
IconButton,
|
7749
7668
|
{
|
7750
7669
|
title: "Zoom viewport out",
|
@@ -7758,10 +7677,10 @@ var ViewportControls = ({
|
|
7758
7677
|
)].value
|
7759
7678
|
);
|
7760
7679
|
},
|
7761
|
-
children: /* @__PURE__ */ (0,
|
7680
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
|
7762
7681
|
}
|
7763
7682
|
),
|
7764
|
-
/* @__PURE__ */ (0,
|
7683
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7765
7684
|
IconButton,
|
7766
7685
|
{
|
7767
7686
|
title: "Zoom viewport in",
|
@@ -7775,11 +7694,11 @@ var ViewportControls = ({
|
|
7775
7694
|
)].value
|
7776
7695
|
);
|
7777
7696
|
},
|
7778
|
-
children: /* @__PURE__ */ (0,
|
7697
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
|
7779
7698
|
}
|
7780
7699
|
),
|
7781
|
-
/* @__PURE__ */ (0,
|
7782
|
-
/* @__PURE__ */ (0,
|
7700
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
7701
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7783
7702
|
"select",
|
7784
7703
|
{
|
7785
7704
|
className: getClassName25("zoomSelect"),
|
@@ -7787,7 +7706,7 @@ var ViewportControls = ({
|
|
7787
7706
|
onChange: (e) => {
|
7788
7707
|
onZoom(parseFloat(e.currentTarget.value));
|
7789
7708
|
},
|
7790
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
7709
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7791
7710
|
"option",
|
7792
7711
|
{
|
7793
7712
|
value: option.value,
|
@@ -7836,7 +7755,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
7836
7755
|
|
7837
7756
|
// components/Puck/components/Canvas/index.tsx
|
7838
7757
|
var import_shallow7 = require("zustand/react/shallow");
|
7839
|
-
var
|
7758
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
7840
7759
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
7841
7760
|
var ZOOM_ON_CHANGE = true;
|
7842
7761
|
var Canvas = () => {
|
@@ -7866,17 +7785,17 @@ var Canvas = () => {
|
|
7866
7785
|
viewports: s.state.ui.viewports
|
7867
7786
|
}))
|
7868
7787
|
);
|
7869
|
-
const frameRef = (0,
|
7870
|
-
const [showTransition, setShowTransition] = (0,
|
7871
|
-
const defaultRender = (0,
|
7872
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
7788
|
+
const frameRef = (0, import_react50.useRef)(null);
|
7789
|
+
const [showTransition, setShowTransition] = (0, import_react50.useState)(false);
|
7790
|
+
const defaultRender = (0, import_react50.useMemo)(() => {
|
7791
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
|
7873
7792
|
return PuckDefault;
|
7874
7793
|
}, []);
|
7875
|
-
const CustomPreview = (0,
|
7794
|
+
const CustomPreview = (0, import_react50.useMemo)(
|
7876
7795
|
() => overrides.preview || defaultRender,
|
7877
7796
|
[overrides]
|
7878
7797
|
);
|
7879
|
-
const getFrameDimensions = (0,
|
7798
|
+
const getFrameDimensions = (0, import_react50.useCallback)(() => {
|
7880
7799
|
if (frameRef.current) {
|
7881
7800
|
const frame = frameRef.current;
|
7882
7801
|
const box = getBox(frame);
|
@@ -7884,7 +7803,7 @@ var Canvas = () => {
|
|
7884
7803
|
}
|
7885
7804
|
return { width: 0, height: 0 };
|
7886
7805
|
}, [frameRef]);
|
7887
|
-
const resetAutoZoom = (0,
|
7806
|
+
const resetAutoZoom = (0, import_react50.useCallback)(
|
7888
7807
|
(newViewports = viewports) => {
|
7889
7808
|
if (frameRef.current) {
|
7890
7809
|
setZoomConfig(
|
@@ -7898,11 +7817,11 @@ var Canvas = () => {
|
|
7898
7817
|
},
|
7899
7818
|
[frameRef, zoomConfig, viewports]
|
7900
7819
|
);
|
7901
|
-
(0,
|
7820
|
+
(0, import_react50.useEffect)(() => {
|
7902
7821
|
setShowTransition(false);
|
7903
7822
|
resetAutoZoom(viewports);
|
7904
7823
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7905
|
-
(0,
|
7824
|
+
(0, import_react50.useEffect)(() => {
|
7906
7825
|
const { height: frameHeight } = getFrameDimensions();
|
7907
7826
|
if (viewports.current.height === "auto") {
|
7908
7827
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7910,13 +7829,13 @@ var Canvas = () => {
|
|
7910
7829
|
}));
|
7911
7830
|
}
|
7912
7831
|
}, [zoomConfig.zoom]);
|
7913
|
-
(0,
|
7832
|
+
(0, import_react50.useEffect)(() => {
|
7914
7833
|
if (ZOOM_ON_CHANGE) {
|
7915
7834
|
setShowTransition(true);
|
7916
7835
|
resetAutoZoom(viewports);
|
7917
7836
|
}
|
7918
7837
|
}, [viewports.current.width]);
|
7919
|
-
(0,
|
7838
|
+
(0, import_react50.useEffect)(() => {
|
7920
7839
|
const cb = () => {
|
7921
7840
|
setShowTransition(false);
|
7922
7841
|
resetAutoZoom();
|
@@ -7926,13 +7845,13 @@ var Canvas = () => {
|
|
7926
7845
|
window.removeEventListener("resize", cb);
|
7927
7846
|
};
|
7928
7847
|
}, []);
|
7929
|
-
const [showLoader, setShowLoader] = (0,
|
7930
|
-
(0,
|
7848
|
+
const [showLoader, setShowLoader] = (0, import_react50.useState)(false);
|
7849
|
+
(0, import_react50.useEffect)(() => {
|
7931
7850
|
setTimeout(() => {
|
7932
7851
|
setShowLoader(true);
|
7933
7852
|
}, 500);
|
7934
7853
|
}, []);
|
7935
|
-
return /* @__PURE__ */ (0,
|
7854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
7936
7855
|
"div",
|
7937
7856
|
{
|
7938
7857
|
className: getClassName26({
|
@@ -7945,7 +7864,7 @@ var Canvas = () => {
|
|
7945
7864
|
recordHistory: true
|
7946
7865
|
}),
|
7947
7866
|
children: [
|
7948
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
7867
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7949
7868
|
ViewportControls,
|
7950
7869
|
{
|
7951
7870
|
autoZoom: zoomConfig.autoZoom,
|
@@ -7971,8 +7890,8 @@ var Canvas = () => {
|
|
7971
7890
|
}
|
7972
7891
|
}
|
7973
7892
|
) }),
|
7974
|
-
/* @__PURE__ */ (0,
|
7975
|
-
/* @__PURE__ */ (0,
|
7893
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7894
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7976
7895
|
"div",
|
7977
7896
|
{
|
7978
7897
|
className: getClassName26("root"),
|
@@ -7993,10 +7912,10 @@ var Canvas = () => {
|
|
7993
7912
|
})
|
7994
7913
|
);
|
7995
7914
|
},
|
7996
|
-
children: /* @__PURE__ */ (0,
|
7915
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview2, {}) })
|
7997
7916
|
}
|
7998
7917
|
),
|
7999
|
-
/* @__PURE__ */ (0,
|
7918
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
|
8000
7919
|
] })
|
8001
7920
|
]
|
8002
7921
|
}
|
@@ -8005,7 +7924,7 @@ var Canvas = () => {
|
|
8005
7924
|
|
8006
7925
|
// lib/use-loaded-overrides.ts
|
8007
7926
|
init_react_import();
|
8008
|
-
var
|
7927
|
+
var import_react51 = require("react");
|
8009
7928
|
|
8010
7929
|
// lib/load-overrides.ts
|
8011
7930
|
init_react_import();
|
@@ -8044,26 +7963,26 @@ var useLoadedOverrides = ({
|
|
8044
7963
|
overrides,
|
8045
7964
|
plugins
|
8046
7965
|
}) => {
|
8047
|
-
return (0,
|
7966
|
+
return (0, import_react51.useMemo)(() => {
|
8048
7967
|
return loadOverrides({ overrides, plugins });
|
8049
7968
|
}, [plugins, overrides]);
|
8050
7969
|
};
|
8051
7970
|
|
8052
7971
|
// components/DefaultOverride/index.tsx
|
8053
7972
|
init_react_import();
|
8054
|
-
var
|
8055
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
7973
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
7974
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
|
8056
7975
|
|
8057
7976
|
// lib/use-inject-css.ts
|
8058
7977
|
init_react_import();
|
8059
|
-
var
|
7978
|
+
var import_react52 = require("react");
|
8060
7979
|
var styles = ``;
|
8061
7980
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
8062
|
-
const [el, setEl] = (0,
|
8063
|
-
(0,
|
7981
|
+
const [el, setEl] = (0, import_react52.useState)();
|
7982
|
+
(0, import_react52.useEffect)(() => {
|
8064
7983
|
setEl(document.createElement("style"));
|
8065
7984
|
}, []);
|
8066
|
-
(0,
|
7985
|
+
(0, import_react52.useEffect)(() => {
|
8067
7986
|
var _a;
|
8068
7987
|
if (!el || typeof window === "undefined") {
|
8069
7988
|
return;
|
@@ -8083,10 +8002,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
8083
8002
|
|
8084
8003
|
// lib/use-preview-mode-hotkeys.ts
|
8085
8004
|
init_react_import();
|
8086
|
-
var
|
8005
|
+
var import_react53 = require("react");
|
8087
8006
|
var usePreviewModeHotkeys = () => {
|
8088
8007
|
const appStore = useAppStoreApi();
|
8089
|
-
const toggleInteractive = (0,
|
8008
|
+
const toggleInteractive = (0, import_react53.useCallback)(() => {
|
8090
8009
|
const dispatch = appStore.getState().dispatch;
|
8091
8010
|
dispatch({
|
8092
8011
|
type: "setUi",
|
@@ -8101,7 +8020,7 @@ var usePreviewModeHotkeys = () => {
|
|
8101
8020
|
|
8102
8021
|
// lib/use-puck.ts
|
8103
8022
|
init_react_import();
|
8104
|
-
var
|
8023
|
+
var import_react54 = require("react");
|
8105
8024
|
var import_zustand6 = require("zustand");
|
8106
8025
|
var generateUsePuck = (store) => {
|
8107
8026
|
const history = {
|
@@ -8135,7 +8054,7 @@ var generateUsePuck = (store) => {
|
|
8135
8054
|
const get = () => storeData;
|
8136
8055
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
8137
8056
|
};
|
8138
|
-
var UsePuckStoreContext = (0,
|
8057
|
+
var UsePuckStoreContext = (0, import_react54.createContext)(
|
8139
8058
|
null
|
8140
8059
|
);
|
8141
8060
|
var convertToPickedStore = (store) => {
|
@@ -8149,12 +8068,12 @@ var convertToPickedStore = (store) => {
|
|
8149
8068
|
};
|
8150
8069
|
};
|
8151
8070
|
var useRegisterUsePuckStore = (appStore) => {
|
8152
|
-
const [usePuckStore] = (0,
|
8071
|
+
const [usePuckStore] = (0, import_react54.useState)(
|
8153
8072
|
() => (0, import_zustand6.createStore)(
|
8154
8073
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
8155
8074
|
)
|
8156
8075
|
);
|
8157
|
-
(0,
|
8076
|
+
(0, import_react54.useEffect)(() => {
|
8158
8077
|
return appStore.subscribe(
|
8159
8078
|
(store) => convertToPickedStore(store),
|
8160
8079
|
(pickedStore) => {
|
@@ -8166,7 +8085,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
8166
8085
|
};
|
8167
8086
|
function createUsePuck() {
|
8168
8087
|
return function usePuck2(selector) {
|
8169
|
-
const usePuckApi = (0,
|
8088
|
+
const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
|
8170
8089
|
if (!usePuckApi) {
|
8171
8090
|
throw new Error("usePuck must be used inside <Puck>.");
|
8172
8091
|
}
|
@@ -8178,16 +8097,24 @@ function createUsePuck() {
|
|
8178
8097
|
};
|
8179
8098
|
}
|
8180
8099
|
function usePuck() {
|
8181
|
-
(0,
|
8100
|
+
(0, import_react54.useEffect)(() => {
|
8182
8101
|
console.warn(
|
8183
8102
|
"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."
|
8184
8103
|
);
|
8185
8104
|
}, []);
|
8186
8105
|
return createUsePuck()((s) => s);
|
8187
8106
|
}
|
8107
|
+
function useGetPuck() {
|
8108
|
+
const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
|
8109
|
+
if (!usePuckApi) {
|
8110
|
+
throw new Error("usePuckGet must be used inside <Puck>.");
|
8111
|
+
}
|
8112
|
+
return usePuckApi.getState;
|
8113
|
+
}
|
8188
8114
|
|
8189
8115
|
// components/Puck/index.tsx
|
8190
|
-
var
|
8116
|
+
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
8117
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
8191
8118
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
8192
8119
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
8193
8120
|
var FieldSideBar = () => {
|
@@ -8197,13 +8124,13 @@ var FieldSideBar = () => {
|
|
8197
8124
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
8198
8125
|
}
|
8199
8126
|
);
|
8200
|
-
return /* @__PURE__ */ (0,
|
8127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
|
8201
8128
|
};
|
8202
|
-
var propsContext = (0,
|
8129
|
+
var propsContext = (0, import_react55.createContext)({});
|
8203
8130
|
function PropsProvider(props) {
|
8204
|
-
return /* @__PURE__ */ (0,
|
8131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
|
8205
8132
|
}
|
8206
|
-
var usePropsContext = () => (0,
|
8133
|
+
var usePropsContext = () => (0, import_react55.useContext)(propsContext);
|
8207
8134
|
function PuckProvider({ children }) {
|
8208
8135
|
const {
|
8209
8136
|
config,
|
@@ -8223,7 +8150,7 @@ function PuckProvider({ children }) {
|
|
8223
8150
|
enabled: true,
|
8224
8151
|
waitForStyles: true
|
8225
8152
|
}, _iframe);
|
8226
|
-
const [generatedAppState] = (0,
|
8153
|
+
const [generatedAppState] = (0, import_react55.useState)(() => {
|
8227
8154
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
8228
8155
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
8229
8156
|
let clientUiState = {};
|
@@ -8280,17 +8207,17 @@ function PuckProvider({ children }) {
|
|
8280
8207
|
) : {}
|
8281
8208
|
})
|
8282
8209
|
});
|
8283
|
-
return
|
8210
|
+
return walkAppState(newAppState, config);
|
8284
8211
|
});
|
8285
8212
|
const { appendData = true } = _initialHistory || {};
|
8286
|
-
const [blendedHistories] = (0,
|
8213
|
+
const [blendedHistories] = (0, import_react55.useState)(
|
8287
8214
|
[
|
8288
8215
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
8289
8216
|
...appendData ? [{ state: generatedAppState }] : []
|
8290
8217
|
].map((history) => {
|
8291
8218
|
let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
|
8292
8219
|
if (!history.state.indexes) {
|
8293
|
-
newState =
|
8220
|
+
newState = walkAppState(newState, config);
|
8294
8221
|
}
|
8295
8222
|
return __spreadProps(__spreadValues({}, history), {
|
8296
8223
|
state: newState
|
@@ -8303,7 +8230,7 @@ function PuckProvider({ children }) {
|
|
8303
8230
|
overrides,
|
8304
8231
|
plugins
|
8305
8232
|
});
|
8306
|
-
const generateAppStore = (0,
|
8233
|
+
const generateAppStore = (0, import_react55.useCallback)(
|
8307
8234
|
(state) => {
|
8308
8235
|
return {
|
8309
8236
|
state,
|
@@ -8327,10 +8254,10 @@ function PuckProvider({ children }) {
|
|
8327
8254
|
metadata
|
8328
8255
|
]
|
8329
8256
|
);
|
8330
|
-
const [appStore] = (0,
|
8257
|
+
const [appStore] = (0, import_react55.useState)(
|
8331
8258
|
() => createAppStore(generateAppStore(initialAppState))
|
8332
8259
|
);
|
8333
|
-
(0,
|
8260
|
+
(0, import_react55.useEffect)(() => {
|
8334
8261
|
const state = appStore.getState().state;
|
8335
8262
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
8336
8263
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
@@ -8339,22 +8266,29 @@ function PuckProvider({ children }) {
|
|
8339
8266
|
index: initialHistoryIndex,
|
8340
8267
|
initialAppState
|
8341
8268
|
});
|
8342
|
-
(0,
|
8343
|
-
|
8344
|
-
|
8345
|
-
|
8269
|
+
const previousData = (0, import_react55.useRef)(null);
|
8270
|
+
(0, import_react55.useEffect)(() => {
|
8271
|
+
appStore.subscribe(
|
8272
|
+
(s) => s.state.data,
|
8273
|
+
(data) => {
|
8274
|
+
if (onChange) {
|
8275
|
+
if ((0, import_fast_deep_equal2.default)(data, previousData.current)) return;
|
8276
|
+
onChange(data);
|
8277
|
+
previousData.current = data;
|
8278
|
+
}
|
8279
|
+
}
|
8280
|
+
);
|
8346
8281
|
}, []);
|
8347
8282
|
useRegisterPermissionsSlice(appStore, permissions);
|
8348
8283
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
8349
|
-
(0,
|
8284
|
+
(0, import_react55.useEffect)(() => {
|
8350
8285
|
const { resolveAndCommitData } = appStore.getState();
|
8351
8286
|
resolveAndCommitData();
|
8352
8287
|
}, []);
|
8353
|
-
return /* @__PURE__ */ (0,
|
8288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
8354
8289
|
}
|
8355
8290
|
function PuckLayout({ children }) {
|
8356
8291
|
const {
|
8357
|
-
onChange,
|
8358
8292
|
onPublish,
|
8359
8293
|
renderHeader,
|
8360
8294
|
renderHeaderActions,
|
@@ -8373,18 +8307,13 @@ function PuckLayout({ children }) {
|
|
8373
8307
|
const rightSideBarVisible = useAppStore(
|
8374
8308
|
(s) => s.state.ui.rightSideBarVisible
|
8375
8309
|
);
|
8376
|
-
const [menuOpen, setMenuOpen] = (0,
|
8310
|
+
const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
|
8377
8311
|
const appStore = useAppStoreApi();
|
8378
|
-
(0, import_react52.useEffect)(() => {
|
8379
|
-
return appStore.subscribe((s) => {
|
8380
|
-
if (onChange) onChange(s.state.data);
|
8381
|
-
});
|
8382
|
-
}, [appStore]);
|
8383
8312
|
const rootProps = useAppStore(
|
8384
8313
|
(s) => s.state.data.root.props || s.state.data.root.props
|
8385
8314
|
);
|
8386
8315
|
const dispatch = useAppStore((s) => s.dispatch);
|
8387
|
-
const toggleSidebars = (0,
|
8316
|
+
const toggleSidebars = (0, import_react55.useCallback)(
|
8388
8317
|
(sidebar) => {
|
8389
8318
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
8390
8319
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -8398,7 +8327,7 @@ function PuckLayout({ children }) {
|
|
8398
8327
|
},
|
8399
8328
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
8400
8329
|
);
|
8401
|
-
(0,
|
8330
|
+
(0, import_react55.useEffect)(() => {
|
8402
8331
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8403
8332
|
dispatch({
|
8404
8333
|
type: "setUi",
|
@@ -8421,7 +8350,7 @@ function PuckLayout({ children }) {
|
|
8421
8350
|
window.removeEventListener("resize", handleResize);
|
8422
8351
|
};
|
8423
8352
|
}, []);
|
8424
|
-
const defaultHeaderRender = (0,
|
8353
|
+
const defaultHeaderRender = (0, import_react55.useMemo)(() => {
|
8425
8354
|
if (renderHeader) {
|
8426
8355
|
console.warn(
|
8427
8356
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -8430,13 +8359,13 @@ function PuckLayout({ children }) {
|
|
8430
8359
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
8431
8360
|
const Comp = renderHeader;
|
8432
8361
|
const appState = useAppStore((s) => s.state);
|
8433
|
-
return /* @__PURE__ */ (0,
|
8362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
8434
8363
|
};
|
8435
8364
|
return RenderHeader;
|
8436
8365
|
}
|
8437
8366
|
return DefaultOverride;
|
8438
8367
|
}, [renderHeader]);
|
8439
|
-
const defaultHeaderActionsRender = (0,
|
8368
|
+
const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
|
8440
8369
|
if (renderHeaderActions) {
|
8441
8370
|
console.warn(
|
8442
8371
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -8444,32 +8373,32 @@ function PuckLayout({ children }) {
|
|
8444
8373
|
const RenderHeader = (props) => {
|
8445
8374
|
const Comp = renderHeaderActions;
|
8446
8375
|
const appState = useAppStore((s) => s.state);
|
8447
|
-
return /* @__PURE__ */ (0,
|
8376
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
8448
8377
|
};
|
8449
8378
|
return RenderHeader;
|
8450
8379
|
}
|
8451
8380
|
return DefaultOverride;
|
8452
8381
|
}, [renderHeader]);
|
8453
8382
|
const overrides = useAppStore((s) => s.overrides);
|
8454
|
-
const CustomPuck = (0,
|
8383
|
+
const CustomPuck = (0, import_react55.useMemo)(
|
8455
8384
|
() => overrides.puck || DefaultOverride,
|
8456
8385
|
[overrides]
|
8457
8386
|
);
|
8458
|
-
const CustomHeader = (0,
|
8387
|
+
const CustomHeader = (0, import_react55.useMemo)(
|
8459
8388
|
() => overrides.header || defaultHeaderRender,
|
8460
8389
|
[overrides]
|
8461
8390
|
);
|
8462
|
-
const CustomHeaderActions = (0,
|
8391
|
+
const CustomHeaderActions = (0, import_react55.useMemo)(
|
8463
8392
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
8464
8393
|
[overrides]
|
8465
8394
|
);
|
8466
|
-
const [mounted, setMounted] = (0,
|
8467
|
-
(0,
|
8395
|
+
const [mounted, setMounted] = (0, import_react55.useState)(false);
|
8396
|
+
(0, import_react55.useEffect)(() => {
|
8468
8397
|
setMounted(true);
|
8469
8398
|
}, []);
|
8470
8399
|
const ready = useAppStore((s) => s.status === "READY");
|
8471
8400
|
useMonitorHotkeys();
|
8472
|
-
(0,
|
8401
|
+
(0, import_react55.useEffect)(() => {
|
8473
8402
|
if (ready && iframe.enabled) {
|
8474
8403
|
const frameDoc = getFrame();
|
8475
8404
|
if (frameDoc) {
|
@@ -8478,8 +8407,8 @@ function PuckLayout({ children }) {
|
|
8478
8407
|
}
|
8479
8408
|
}, [ready, iframe.enabled]);
|
8480
8409
|
usePreviewModeHotkeys();
|
8481
|
-
return /* @__PURE__ */ (0,
|
8482
|
-
/* @__PURE__ */ (0,
|
8410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
8411
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8483
8412
|
"div",
|
8484
8413
|
{
|
8485
8414
|
className: getLayoutClassName({
|
@@ -8488,61 +8417,61 @@ function PuckLayout({ children }) {
|
|
8488
8417
|
mounted,
|
8489
8418
|
rightSideBarVisible
|
8490
8419
|
}),
|
8491
|
-
children: /* @__PURE__ */ (0,
|
8492
|
-
/* @__PURE__ */ (0,
|
8420
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
8421
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8493
8422
|
CustomHeader,
|
8494
8423
|
{
|
8495
|
-
actions: /* @__PURE__ */ (0,
|
8424
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8496
8425
|
Button,
|
8497
8426
|
{
|
8498
8427
|
onClick: () => {
|
8499
8428
|
const data = appStore.getState().state.data;
|
8500
8429
|
onPublish && onPublish(data);
|
8501
8430
|
},
|
8502
|
-
icon: /* @__PURE__ */ (0,
|
8431
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
|
8503
8432
|
children: "Publish"
|
8504
8433
|
}
|
8505
8434
|
) }) }),
|
8506
|
-
children: /* @__PURE__ */ (0,
|
8507
|
-
/* @__PURE__ */ (0,
|
8508
|
-
/* @__PURE__ */ (0,
|
8435
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
8436
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
|
8437
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8509
8438
|
"div",
|
8510
8439
|
{
|
8511
8440
|
className: getLayoutClassName("leftSideBarToggle"),
|
8512
|
-
children: /* @__PURE__ */ (0,
|
8441
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8513
8442
|
IconButton,
|
8514
8443
|
{
|
8515
8444
|
onClick: () => {
|
8516
8445
|
toggleSidebars("left");
|
8517
8446
|
},
|
8518
8447
|
title: "Toggle left sidebar",
|
8519
|
-
children: /* @__PURE__ */ (0,
|
8448
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
|
8520
8449
|
}
|
8521
8450
|
)
|
8522
8451
|
}
|
8523
8452
|
),
|
8524
|
-
/* @__PURE__ */ (0,
|
8453
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8525
8454
|
"div",
|
8526
8455
|
{
|
8527
8456
|
className: getLayoutClassName("rightSideBarToggle"),
|
8528
|
-
children: /* @__PURE__ */ (0,
|
8457
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8529
8458
|
IconButton,
|
8530
8459
|
{
|
8531
8460
|
onClick: () => {
|
8532
8461
|
toggleSidebars("right");
|
8533
8462
|
},
|
8534
8463
|
title: "Toggle right sidebar",
|
8535
|
-
children: /* @__PURE__ */ (0,
|
8464
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
|
8536
8465
|
}
|
8537
8466
|
)
|
8538
8467
|
}
|
8539
8468
|
)
|
8540
8469
|
] }),
|
8541
|
-
/* @__PURE__ */ (0,
|
8470
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
8542
8471
|
headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
|
8543
|
-
headerPath && /* @__PURE__ */ (0,
|
8472
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
8544
8473
|
" ",
|
8545
|
-
/* @__PURE__ */ (0,
|
8474
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8546
8475
|
"code",
|
8547
8476
|
{
|
8548
8477
|
className: getLayoutClassName("headerPath"),
|
@@ -8551,31 +8480,31 @@ function PuckLayout({ children }) {
|
|
8551
8480
|
)
|
8552
8481
|
] })
|
8553
8482
|
] }) }),
|
8554
|
-
/* @__PURE__ */ (0,
|
8555
|
-
/* @__PURE__ */ (0,
|
8483
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
|
8484
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8556
8485
|
IconButton,
|
8557
8486
|
{
|
8558
8487
|
onClick: () => {
|
8559
8488
|
return setMenuOpen(!menuOpen);
|
8560
8489
|
},
|
8561
8490
|
title: "Toggle menu bar",
|
8562
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
8491
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
|
8563
8492
|
}
|
8564
8493
|
) }),
|
8565
|
-
/* @__PURE__ */ (0,
|
8494
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8566
8495
|
MenuBar,
|
8567
8496
|
{
|
8568
8497
|
dispatch,
|
8569
8498
|
onPublish,
|
8570
8499
|
menuOpen,
|
8571
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
8500
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8572
8501
|
Button,
|
8573
8502
|
{
|
8574
8503
|
onClick: () => {
|
8575
8504
|
const data = appStore.getState().state.data;
|
8576
8505
|
onPublish && onPublish(data);
|
8577
8506
|
},
|
8578
|
-
icon: /* @__PURE__ */ (0,
|
8507
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
|
8579
8508
|
children: "Publish"
|
8580
8509
|
}
|
8581
8510
|
) }),
|
@@ -8586,25 +8515,25 @@ function PuckLayout({ children }) {
|
|
8586
8515
|
] }) })
|
8587
8516
|
}
|
8588
8517
|
),
|
8589
|
-
/* @__PURE__ */ (0,
|
8590
|
-
/* @__PURE__ */ (0,
|
8591
|
-
/* @__PURE__ */ (0,
|
8518
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
8519
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Components, {}) }),
|
8520
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Outline, {}) })
|
8592
8521
|
] }),
|
8593
|
-
/* @__PURE__ */ (0,
|
8594
|
-
/* @__PURE__ */ (0,
|
8522
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Canvas, {}),
|
8523
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FieldSideBar, {}) })
|
8595
8524
|
] })
|
8596
8525
|
}
|
8597
8526
|
) }) }),
|
8598
|
-
/* @__PURE__ */ (0,
|
8527
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
8599
8528
|
] });
|
8600
8529
|
}
|
8601
8530
|
function Puck(props) {
|
8602
|
-
return /* @__PURE__ */ (0,
|
8531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
|
8603
8532
|
}
|
8604
8533
|
Puck.Components = Components;
|
8605
8534
|
Puck.Fields = Fields;
|
8606
8535
|
Puck.Outline = Outline;
|
8607
|
-
Puck.Preview =
|
8536
|
+
Puck.Preview = Preview2;
|
8608
8537
|
|
8609
8538
|
// lib/migrate.ts
|
8610
8539
|
init_react_import();
|
@@ -8631,15 +8560,15 @@ var migrations = [
|
|
8631
8560
|
console.log("Migrating DropZones to slots...");
|
8632
8561
|
const updatedItems = {};
|
8633
8562
|
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8634
|
-
const { indexes } =
|
8563
|
+
const { indexes } = walkAppState(appState, config);
|
8635
8564
|
const deletedCompounds = [];
|
8636
|
-
|
8565
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
8637
8566
|
var _a2, _b;
|
8638
8567
|
if (zoneType === "dropzone") {
|
8639
8568
|
const [id, slotName] = zoneCompound.split(":");
|
8640
8569
|
const nodeData = indexes.nodes[id].data;
|
8641
8570
|
const componentType = nodeData.type;
|
8642
|
-
const configForComponent = config.components[componentType];
|
8571
|
+
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
8643
8572
|
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
8644
8573
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
8645
8574
|
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
@@ -8652,7 +8581,7 @@ var migrations = [
|
|
8652
8581
|
}
|
8653
8582
|
return content;
|
8654
8583
|
});
|
8655
|
-
const updated =
|
8584
|
+
const updated = walkAppState(
|
8656
8585
|
appState,
|
8657
8586
|
config,
|
8658
8587
|
(content) => content,
|
@@ -8697,11 +8626,13 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
8697
8626
|
});
|
8698
8627
|
|
8699
8628
|
// lib/transform-props.ts
|
8700
|
-
function transformProps(data, propTransforms) {
|
8629
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
8701
8630
|
const mapItem = (item) => {
|
8702
8631
|
if (propTransforms[item.type]) {
|
8703
8632
|
return __spreadProps(__spreadValues({}, item), {
|
8704
|
-
props:
|
8633
|
+
props: __spreadValues({
|
8634
|
+
id: item.props.id
|
8635
|
+
}, propTransforms[item.type](item.props))
|
8705
8636
|
});
|
8706
8637
|
}
|
8707
8638
|
return item;
|
@@ -8710,23 +8641,18 @@ function transformProps(data, propTransforms) {
|
|
8710
8641
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
8711
8642
|
let newRoot = __spreadValues({}, defaultedData.root);
|
8712
8643
|
if (propTransforms["root"]) {
|
8713
|
-
|
8714
|
-
newRoot.props = propTransforms["root"](rootProps);
|
8715
|
-
} else {
|
8716
|
-
newRoot = propTransforms["root"](rootProps);
|
8717
|
-
}
|
8644
|
+
newRoot.props = propTransforms["root"](rootProps);
|
8718
8645
|
}
|
8719
|
-
const
|
8720
|
-
|
8721
|
-
|
8722
|
-
|
8723
|
-
|
8724
|
-
|
8725
|
-
|
8726
|
-
|
8727
|
-
|
8728
|
-
|
8729
|
-
return afterPropTransforms;
|
8646
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
8647
|
+
const updatedData = walkTree(
|
8648
|
+
dataWithUpdatedRoot,
|
8649
|
+
config,
|
8650
|
+
(content) => content.map(mapItem)
|
8651
|
+
);
|
8652
|
+
if (!defaultedData.root.props) {
|
8653
|
+
updatedData.root = updatedData.root.props;
|
8654
|
+
}
|
8655
|
+
return updatedData;
|
8730
8656
|
}
|
8731
8657
|
|
8732
8658
|
// lib/resolve-all-data.ts
|
@@ -8806,13 +8732,14 @@ function resolveAllData(_0, _1) {
|
|
8806
8732
|
Puck,
|
8807
8733
|
Render,
|
8808
8734
|
createUsePuck,
|
8809
|
-
mapSlots,
|
8810
8735
|
migrate,
|
8811
8736
|
overrideKeys,
|
8812
8737
|
renderContext,
|
8813
8738
|
resolveAllData,
|
8814
8739
|
transformProps,
|
8815
|
-
|
8740
|
+
useGetPuck,
|
8741
|
+
usePuck,
|
8742
|
+
walkTree
|
8816
8743
|
});
|
8817
8744
|
/*! Bundled license information:
|
8818
8745
|
|